Difference between revisions of "Dev/Debugging"

From PaparazziUAV
Jump to navigation Jump to search
m
Line 13: Line 13:
#:<pre>target remote localhost:3333</pre>
#:<pre>target remote localhost:3333</pre>
# Now we need to set some break points in the code.
# Now we need to set some break points in the code.
#: In this example we the ap target was part of the rotorcraft and main.c contains the main program. Open rotorcraft sw/airborne/firmwares/rotorcraft/main.c and find a line at which you'd like to set a break point.
#: In this example the ap target was part of the rotorcraft and main.c contains the main program. Open rotorcraft sw/airborne/firmwares/rotorcraft/main.c and find a line at which you'd like to set a break point.
#: <pre>break main.c:113</pre>
#: <pre>break main.c:113</pre>
# Stop the currently running code
# Stop the currently running code

Revision as of 23:22, 12 June 2011

Introduction

GDB can be used for debugging the code on the boards.

Procedure

  1. Start openocd in a new shell since this process needs to remain running.
    To program the Lisa/L board run the command
    openocd -f interface/lisa-l.cfg -f board/lisa-l.cfg
  2. Start GDB with an argument of the elf file created and uploaded to the board.
    If you programmed with the ap target then the command would be along the lines of
    arm-none-eabi-gdb var/<airframe>/ap/ap.elf
    Replace <airframe> with the name of the airframe that has been built.
  3. Now connect GDB to the board
    target remote localhost:3333
  4. Now we need to set some break points in the code.
    In this example the ap target was part of the rotorcraft and main.c contains the main program. Open rotorcraft sw/airborne/firmwares/rotorcraft/main.c and find a line at which you'd like to set a break point.
    break main.c:113
  5. Stop the currently running code
    monitor reset halt
  6. Reset the code back to the start
    monitor reset init
  7. We probably want to ignore the interrupt calls for the moment so we can step through the code as it's being called. Note that we don't always want to do this.
    monitor cortex_m3 maskisr on
  8. Now we can run the program which will stop at the break point we set.
    continue

Useful commands

  • A stack trace can be printed with the command
    bt