Debugging: Difference between revisions

From coreboot
Jump to navigation Jump to search
(d'uh... Mentioned the wrong file name)
No edit summary
Line 1: Line 1:
= GDB Interface =
= GDB Interface =


coreboot has an easy to use interface to the GNU debugger gdb. To enable it, add the following two lines to your mainboard's Options.lb:
coreboot has an easy to use interface to the GNU debugger gdb. To enable it, select the CONFIG_GDB_STUB option in the Debugging menu of coreboot's configuration:
 
  [*] GDB debugging support
uses CONFIG_GDB_STUB
...
default CONFIG_GDB_STUB=1
 
'''NOTE:''' You need to put the '''uses''' line into the uses-section of the Options.lb, and the '''default''' line into the configuration section, or the coreboot config tool will print an error.
 
Compiling coreboot with debugging symbols might help:
Index: src/config/Config.lb
  ===================================================================
--- src/config/Config.lb (revision 1578)
+++ src/config/Config.lb (working copy)
@@ -10,7 +10,7 @@
  makedefine GCC_INC_DIR := $(shell LC_ALL=C $(GCC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
 
  makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
-makedefine CFLAGS := $(CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -Os -nostdinc -nostdlib -Wall -Wundef ...
+makedefine CFLAGS := $(CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -O2 -g -nostdinc -nostdlib -Wall -Wundef ...
  if ASSEMBLER_DEBUG
  makedefine DEBUG_CFLAGS := -g -dA -fverbose-asm


Then you will not get exceptions like this:
Then you will not get exceptions like this:
Line 33: Line 13:
But instead you will be able to connect to the machine using gdb over a serial line in case of an exception:
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-v2/coreboot-builds/kontron_986lcd-m/fallback/coreboot_ram
  (gdb) file coreboot/build/coreboot_ram.debug
  Reading symbols from coreboot-v2/coreboot-builds/kontron_986lcd-m/fallback/coreboot_ram...done.
  Reading symbols from coreboot/build/coreboot_ram.debug...done.
  (gdb) set remotebaud 115200
  (gdb) set remotebaud 115200
  (gdb) target remote /dev/ttyUSB0
  (gdb) target remote /dev/ttyUSB0

Revision as of 19:56, 29 March 2012

GDB Interface

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

[*] GDB debugging support

Then 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/coreboot_ram.debug
Reading symbols from coreboot/build/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 ()