Difference between revisions of "Orchard gdb cheatsheet"

From Studio Kousagi Wiki
Jump to: navigation, search
(Debugging with GDB)
(Debugging with GDB)
Line 28: Line 28:
 
* 'disas' will show you the assembly code of the current code that's running
 
* 'disas' will show you the assembly code of the current code that's running
 
* 'print <expression>' will print the value of a variable in the current stack frame
 
* 'print <expression>' will print the value of a variable in the current stack frame
 +
 +
Also see http://darkdust.net/files/GDB%20Cheat%20Sheet.pdf

Revision as of 09:30, 28 May 2015

If you're not familiar with gdb, here are some commands to get you started.

Starting GDB

To start GDB with Orchard, use these commands:

pi@raspberrypi ~/orchard-src/orchard $ gdb build/orchard.elf

Note that you're starting it in the same directory where you'd type make to build the executable.

Once GDB is started, you want to first execute

target remote localhost:3333

This establishes a connection between gdb and the orchard CPU.

Debugging with GDB

  • To stop execution, hit ctrl-c. This will break you to a prompt.
  • 'c' will continue execution
  • 'mon reset' will reset the board
  • 'b <function name>' will set a breakpoint at a given symbolic function name
  • 'step' will step one source line, diving into functions
  • 'next' will step one source line, treating functions as a single source line
  • 'info reg' will give you the register dump
  • 'info threads' will give you the status of all threads running on chibiOS
  • 'bt' will give you the current backtrace
  • 'l' will list the current source line that's running
  • 'disas' will show you the assembly code of the current code that's running
  • 'print <expression>' will print the value of a variable in the current stack frame

Also see http://darkdust.net/files/GDB%20Cheat%20Sheet.pdf