About gdb

Jtag debugger is very usefull on the first testing stage of a new hardware, for searching of some hardware problems. If the working of hardware is correct and there are no hardware problems we can begin with software debugging.

When debugging software we can use the debugger programm called GNU Debugger and jtag debugger.

As a rule GNU Debugger is a part of the cross-compiler. For example for arm platform, it can be called arm-openwrt-linux-gdb.

U-boot debug example using arm-openwrt-linux-gdb debugger and jtag peddi debugger.

Starting the debugger from the command line:

$ arm-openwrt-linux-gdb u-boot
GNU gdb (Linaro GDB) 7.5-2012.09
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
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 "--host=i686-linux-gnu --target=arm-openwrt-linux-uclibcgnueabi".
For bug reporting instructions, please see:
...
Reading symbols from /home/u-boot-1.1.4/u-boot...done.
(gdb) 

further we connect the processor using jtag peedi (192.168.1.1 - peedi address):

(gdb) target remote 192.168.1.1:2000
Remote debugging using 192.168.1.1:2000
0x00000bb0 in ?? ()

load u-boot into RAM of the processor:

(gdb) load
Loading section .text, size 0x50a18 lma 0x600000
Loading section .dummy, size 0x10 lma 0x650a18
Loading section .rodata, size 0xce9 lma 0x650a28
Loading section .rodata.str1.1, size 0xefac lma 0x651711
Loading section .reset_vector_sect, size 0x18c lma 0x670000
Loading section .data, size 0x315b lma 0x67018c
Loading section .u_boot_cmd, size 0x930 lma 0x6732e8
Start address 0x600000, load size 410324
Transfer rate: 367 KB/sec, 13677 bytes/write.

load the application:

(gdb) continue 
Continuing.

Debugger tools.

adding a breakpoint by function name:

(gdb) break mv_set_power_scheme
Breakpoint 1 at 0x602774: file /home/u-boot-1.1.4/board/mv_feroceon/mv_kw/mv_main.c, line 1175.
(gdb) continue 
Continuing.

Breakpoint 1, mv_set_power_scheme () at /home/u-boot-1.1.4/board/mv_feroceon/mv_kw/mv_main.c:1175
1175		int mppGroupType1 = mvBoardMppGroupTypeGet(MV_BOARD_MPP_GROUP_1);

adding a breakpoint by line number:

break mv_main.c:1249
Breakpoint 1 at 0x60295c: file /home/u-boot-1.1.4/board/mv_feroceon/mv_kw/mv_main.c, line 1249.
(gdb) continue 
Continuing.

Breakpoint 1, mv_set_power_scheme () at /home/u-boot-1.1.4/board/mv_feroceon/mv_kw/mv_main.c:1250
1250	}

adding a breakpoint by address:

b *0x00000090

information about breakpoints:

(gdb) info break
Num     Type           Disp Enb Address    What
1       breakpoint     keep y   0x0060295c in mv_set_power_scheme 
                                           at /home/u-boot-1.1.4/board/mv_feroceon/mv_kw/mv_main.c:1249
	breakpoint already hit 1 time

Deleting all breakpoints:

(gdb) delete 
Delete all breakpoints? (y or n) y 

program path monitoring — backtrace:

(gdb) bt
#0  mvHddPowerCtrl () at /home/u-boot-1.1.4/board/mv_feroceon/mv_kw/mv_main.c:1328
#1  misc_init_r_env () at /home/u-boot-1.1.4/board/mv_feroceon/mv_kw/mv_main.c:807
#2  0x00603c44 in misc_init_r () at /home/u-boot-1.1.4/board/mv_feroceon/mv_kw/mv_main.c:881
#3  0x00623274 in start_armboot () at board.c:450
#4  0x00600064 in reset () at cpu/arm926ejs/start.S:202
#5  0x00600064 in reset () at cpu/arm926ejs/start.S:202

location monitoring of a program counter:

(gdb) x/i $pc
=> 0x6036b8 :	cmp	r9, #31

monitoring the variable values (format is followed by a slash):

(gdb) print hddPowerBit
$3 = 35
(gdb) print /x hddPowerBit
$4 = 0x23

program stepping:

n ni s si

(gdb) n

detaching the target:

detach

quitting:

q