Difference between revisions of "Debugging"

From coreboot
Jump to: navigation, search
(update location of coreboot_ram.debug that changed over time)
(One intermediate revision by one user not shown)
Line 5: Line 5:
 
  [*]  Wait for a GDB connection
 
  [*]  Wait for a GDB connection
 
Then Coreboot will stop and wait for a GDB connection.
 
Then Coreboot will stop and wait for a GDB connection.
 +
 +
To connect to the remote coreboot instance  over serial do:
 +
$ gdb
 +
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
 +
Copyright (C) 2011 Free Software Foundation, Inc.
 +
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 +
This is free software: you are free to change and redistribute it.
 +
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 +
and "show warranty" for details.
 +
This GDB was configured as "x86_64-linux-gnu".
 +
For bug reporting instructions, please see:
 +
<http://bugs.launchpad.net/gdb-linaro/>.
 +
(gdb) file ./build/cbfs/fallback/coreboot_ram.debug
 +
Reading symbols from /home/gnutoo/Coreboot/coreboot/build/cbfs/fallback/coreboot_ram.debug...done.
 +
(gdb) set remotebaud 115200
 +
(gdb) target remote /dev/ttyUSB0
 +
Remote debugging using /dev/ttyUSB0
 +
_text () at src/arch/x86/lib/c_start.S:85
 +
85 call hardwaremain
 +
(gdb)
  
 
== Exceptions with GDB ==
 
== Exceptions with GDB ==

Revision as of 12:15, 23 June 2012

GDB Interface

GDB Wait

Coreboot has an easy to use interface to the GNU debugger gdb. To enable it, select the CONFIG_GDB_STUB and the CONFIG_GDB_WAIT options in the Debugging menu of coreboot's configuration:

[*] GDB debugging support
[*]   Wait for a GDB connection

Then Coreboot will stop and wait for a GDB connection.

To connect to the remote coreboot instance over serial do:

$ gdb
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>.
(gdb) file ./build/cbfs/fallback/coreboot_ram.debug
Reading symbols from /home/gnutoo/Coreboot/coreboot/build/cbfs/fallback/coreboot_ram.debug...done.
(gdb) set remotebaud 115200
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
_text () at src/arch/x86/lib/c_start.S:85
85		call	hardwaremain
(gdb) 

Exceptions with GDB

Else if you just enable CONFIG_GDB_STUB option in the Debugging menu of coreboot's configuration you will still get some benefit.

[*] GDB debugging support

For instance you will not get exceptions like this:

Unexpected Exception: 0 @ 10:0012724b - Halting
Code: 0 eflags: 00010046
eax: 00000001 ebx: 00000061 ecx: 00000004 edx: 00000000
edi: 00000000 esi: 00000061 ebp: 00163abc esp: 00163a98

But instead you will be able to connect to the machine using gdb over a serial line in case of an exception:

(gdb) file coreboot/build/cbfs/fallback/coreboot_ram.debug
Reading symbols from coreboot/build/cbfs/fallback/coreboot_ram.debug...done.
(gdb) set remotebaud 115200
(gdb) target remote /dev/ttyUSB0
Remote debugging using /dev/ttyUSB0
0x0012824b in __udivdi3 (n=17082841390, d=0) at ...
...
(gdb) bt
#0  0x0012824b in __udivdi3 (n=17082841390, d=0)
    at /usr/lib/gcc/gcc- 4.3.2/libgcc/../gcc/libgcc2.c:899 
#1  0x0011efa2 in handle_port_61h ()
#2  0x0011fbc3 in my_inb ()
#3  0x001189f5 in x86emuOp_in_byte_AL_IMM ()
#4  0x001092f1 in X86EMU_exec ()
#5  0x0010a06f in biosemu ()
#6  0x0011fcfb in run_bios ()
#7  0x0010cbcb in pci_dev_init ()
#8  0x00103d9b in dev_initialize ()
#9  0x0010f8b5 in hardwaremain ()
#10 0x00100099 in _text ()