B2G/gdb

From MozillaWiki
< B2G
Jump to: navigation, search

Running gdb

There are some Makefile targets to help debug with gdb:

  • attach-gdb
Attach to a running b2g process remotely. You may want to use this target if the code of interest is executed after the b2g process is started and can be triggered after user interaction (like dialing).
example:
$make attach-gdb
...
syscall () at bionic/libc/arch-arm/bionic/syscall.S:50
50          ldmfd   sp!, {r4, r5, r6, r7}
(gdb) bt
#0  syscall () at bionic/libc/arch-arm/bionic/syscall.S:50
...
(gdb)
  • run-gdb
Start a new b2g process remotely in gdb. You may want to use this target if the code of interest is executed before startup completion of the b2g process. For example, your cannot debug using attach-gdb target because you encounter a crash before the home screen is shown.
After running this target, you may start the b2g process by issueing the 'run' command in gdb. You may also 'kill' or 'restart' the process without leaving gdb.
Please note that this target will stop the b2g service to prevent it from being restarted by init. You need to use the 'restore-auto-restart' target to reenable the service after leaving gdb.
  • restore-auto-restart
Reenables the b2g service so it will get restarted automatically by init.
example:
$make run-gdb
...
Remote debugging using :22576
Remote debugging from host 127.0.0.1
(gdb) break main
(gdb) run
Starting program: ...
(gdb) kill
Kill the program being debugged? (y or n) y
(gdb) run
Starting program: ...
(gdb) quit
A debugging session is active.

        Inferior 1 [process 12355] will be killed.

Quit anyway? (y or n) y
$ make restore-auto-restart