記一下常用的gdb指令如下。下面是我早上debug用。
hylai@APC002 /cygdrive/c/mycode/patch $ nds32le-elf-gdb.exe GNU gdb (2011-07-29) 6.8 Copyright (C) 2008 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 "--host=i686-mingw32 --target=nds32le-elf". source E:\Andestech\AndeSight200MCU\toolchains\nds32le-elf-newlib-v2\bin\.Andesg dbinit (gdb) target remote:9900 Remote debugging using :9900 0x00005b68 in ?? () core0(gdb) file mainprog.adx A program is being debugged already. Are you sure you want to change the file? (y or n) y Reading symbols from c:\mycode\patch\mainprog.adx...done. core0(gdb) lo Loading section .nds32_init, size 0x4 lma 0x500000 Loading section .init, size 0xc lma 0x500004 Loading section .text, size 0x95dc lma 0x500010 Loading section .rodata, size 0x338 lma 0x5095f0 Loading section .eh_frame, size 0x34 lma 0x509948 Loading section .ctors, size 0x4 lma 0x50997c Loading section .dtors, size 0x4 lma 0x509980 Loading section .jcr, size 0x4 lma 0x509984 Loading section .data, size 0x870 lma 0x509988 Loading section .sdata_w, size 0x2c lma 0x50a1f8 Loading section .sdata_b, size 0x3 lma 0x50a224 Loading section FUNC_TABLE, size 0xc lma 0x510000 Start address 0x500010, load size 41487 Transfer rate: 519 KB/sec, 2963 bytes/write. core0(gdb) file patch.adx A program is being debugged already. Are you sure you want to change the file? (y or n) y
Load new symbol table from "c:\mycode\patch\patch.adx"? (y or n) y Reading symbols from c:\mycode\patch\patch.adx...done. 附註...這邊load code 2次是因為我寫的code是ROM加上ROM的patch。 所以load code2次。 core0(gdb) loLoading section FUNC_TABLE, size 0xc lma 0x510000 Loading section FUNC_PATCH, size 0x28 lma 0x510020 Start address 0x500010, load size 52 Transfer rate: 416 bits in <1 sec, 26 bytes/write. core0(gdb) b main Breakpoint 1 at 0x50017c core0(gdb) disas main No function contains specified address. core0(gdb) disass main No function contains specified address. core0(gdb) c Continuing.
Breakpoint 1, 0x0050017c in ?? () core0(gdb) disass $pc No function contains specified address. core0(gdb) disass 0x0050017c No function contains specified address. core0(gdb) disass *0x0050017c No function contains specified address. core0(gdb) x/10i 0x0050017c0x50017c: sethi $r0,#1296 0x500180: ori $r0,$r0,#0x0 0x500184: lwi $r1,[$r0+#0] 0x500188: movi $r0,#30 0x50018c: jral $lp,$r1 0x500190: mov55 $r1,$r0 0x500192: sethi $r0,#1289 0x500196: ori $r0,$r0,#0x5f0 0x50019a: sethi $r15,#1280 0x50019e: ori $r15,$r15,#0x204 core0(gdb) si 0x00500180 in ?? () core0(gdb) si 0x00500184 in ?? () core0(gdb) si 0x00500188 in ?? () core0(gdb) si 0x0050018c in ?? () core0(gdb) si mul2 (x=0) at ../patchprog.c:22 22 int mul2(int x){ core0(gdb) disass $pc Dump of assembler code for function mul2: 0x00510020 <mul2+0>: smw.adm $sp,[$sp],$sp,#0x8 0x00510024 <mul2+4>: addi $fp,$sp,#0 0x00510028 <mul2+8>: addi $sp,$sp,#-12 0x0051002c <mul2+12>: swi $r0,[$fp+#-8] 0x00510030 <mul2+16>: lwi $r1,[$fp+#-8] 0x00510034 <mul2+20>: movi $r0,#200 0x00510038 <mul2+24>: mul $r0,$r1,$r0 0x0051003c <mul2+28>: addi $sp,$fp,#0 0x00510040 <mul2+32>: lmw.bim $sp,[$sp],$sp,#0x8 0x00510044 <mul2+36>: ret $lp End of assembler dump.core0(gdb) si 0x00510024 22 int mul2(int x){ core0(gdb) si 0x00510028 22 int mul2(int x){ core0(gdb) si 0x0051002c 22 int mul2(int x){ core0(gdb) si 23 return x*200; core0(gdb) si 0x00510034 23 return x*200; core0(gdb) si 0x00510038 23 return x*200; core0(gdb) si 24 } core0(gdb) si 0x00510040 24 } core0(gdb) si 0x00510044 in mul2 (x=50331644) at ../patchprog.c:24 24 } core0(gdb) si 0x00500190 in ?? () core0(gdb) x/10i 0x500190 0x500190: mov55 $r1,$r0 0x500192: sethi $r0,#1289 0x500196: ori $r0,$r0,#0x5f0 0x50019a: sethi $r15,#1280 0x50019e: ori $r15,$r15,#0x204 0x5001a2: jral5 $r15 0x5001a4: sethi $r0,#1296 0x5001a8: ori $r0,$r0,#0x0 0x5001ac: lwi $r1,[$r0+#4] 0x5001b0: movi $r0,#30 core0(gdb) si 0x00500192 in ?? () core0(gdb) si 0x00500196 in ?? () core0(gdb) si 0x0050019a in ?? () core0(gdb) si 0x0050019e in ?? () core0(gdb) si 0x005001a2 in ?? () core0(gdb) si 0x00500204 in ?? () core0(gdb) x/10i 0x500204 0x500204: smw.adm $r1,[$sp],$r5,#0x0 0x500208: smw.adm $sp,[$sp],$sp,#0x2 0x50020c: addi $sp,$sp,#-8 0x500210: sethi $r1,#1290 0x500214: lwi $r1,[$r1+#504] 0x500218: mov55 $r2,$r0 0x50021a: mov55 $r0,$r1 0x50021c: lwi $r1,[$r1+#8] 0x500220: addi $r3,$sp,#12 0x500224: swi $r3,[$sp+#4] core0(gdb) si 0x00500208 in ?? () core0(gdb) si 0x0050020c in ?? () core0(gdb) si 0x00500210 in ?? () core0(gdb) si 0x00500214 in ?? () core0(gdb) si 0x00500218 in ?? () core0(gdb) si 0x0050021a in ?? () core0(gdb) si 0x0050021c in ?? () core0(gdb) si 0x00500220 in ?? () core0(gdb) si 0x00500224 in ?? () core0(gdb) x/10i 0x500224 0x500224: swi $r3,[$sp+#4] 0x500228: sethi $r15,#1280 0x50022c: ori $r15,$r15,#0x270 0x500230: jral $lp,$r15 0x500234: addi10.sp #8 0x500236: lmw.bim $sp,[$sp],$sp,#0x2 0x50023a: addi10.sp #20 0x50023c: ret5 $lp 0x50023e: srli45 $r0,#0x0 0x500240: smw.adm $r2,[$sp],$r5,#0x0 core0(gdb) s Cannot find bounds of current function core0(gdb) si 0x00500228 in ?? () core0(gdb) si 0x0050022c in ?? () core0(gdb) si 0x00500230 in ?? () core0(gdb) b *0x500234 Breakpoint 2 at 0x500234 core0(gdb) c Continuing.
Breakpoint 2, 0x00500234 in ?? () core0(gdb) si 0x00500236 in ?? () core0(gdb) si 0x0050023a in ?? () core0(gdb) si 0x0050023c in ?? () core0(gdb) si 0x005001a4 in ?? () core0(gdb) b *0x5001b8 Breakpoint 3 at 0x5001b8 core0(gdb) b *0x5001cc Breakpoint 4 at 0x5001cc core0(gdb) b *0x5001e0 Breakpoint 5 at 0x5001e0 core0(gdb) b *0x5001f4 Breakpoint 6 at 0x5001f4 core0(gdb) c Continuing.
Breakpoint 3, 0x005001b8 in ?? () core0(gdb) c Continuing.
Breakpoint 2, 0x00500234 in ?? () core0(gdb) c Continuing.
Breakpoint 4, 0x005001cc in ?? () core0(gdb) c Continuing.
Breakpoint 5, 0x005001e0 in ?? () core0(gdb) c Continuing.
Breakpoint 2, 0x00500234 in ?? () core0(gdb) c Continuing.
Breakpoint 6, 0x005001f4 in ?? () core0(gdb)
|