Orchard gdb cheatsheet

From Studio Kousagi Wiki
Revision as of 08:31, 4 November 2015 by Bunnie (talk | contribs) (Debugging with GDB)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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
  • 'mon reset halt' will bring the CPU to reset state
  • 'set *((unsigned short *) 0xdeadbeef) = 0xf00' puts the 16-bit constant 0xf00 into location 0xdeadbeef.

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

Layouts:

  • to view assembly while single stepping "layout asm"
  • to view registers, "layout reg"