Copyright(C) 2008Free
SoftwareFoundation, Inc.
License GPLv3+: GNU GPL version 3or later<</SPAN>http://gnu.org/licenses/gpl.html> This isfreesoftware: you arefree tochangeand
redistributeit.
There is NO WARRANTY, to the extentpermitted by law. Type"showcopying" and"showwarranty"fordetails. This GDBwas configured as
"--host=i686-pc-linux-gnu--target=arm-none-linux-gnueabi". For bugreporting instructions, pleasesee: <</SPAN>https:
[root@Frankzfz]$gdbserver10.27.10.48:9000./test_seg_fault
Process ./test_seg_faultcreated;pid=760
Listening on port 9000
Remote debugging from host 10.27.10.48
然后在宿主机上运行
arm-linux-gdb/bin$arm-linux-gdb
GNU gdb (SourceryG++ Lite2008q3-72)
6.8.50.20080821-cvs
Copyright (C) 2008 Free SoftwareFoundation, Inc. LicenseGPLv3+: GNU GPLversion3 or later<</SPAN>http://gnu.org/licenses/gpl.html>
Thisis freesoftware: you are free tochange and redistribute it.
There isNO WARRANTY, tothe extent permittedby law.Type"showcopying"
and "showwarranty"
fordetails. This GDBwas configured
as"--host=i686-pc-linux-gnu--target=arm-none-linux-gnueabi". For bugreporting instructions, pleasesee: <</SPAN>https://support.codesourcery.com/GNUToolchain/>.
(gdb) symbol-file
test_seg_fault
Reading symbols from /home/zfz/kernel/fs/arm-linux-gdb/bin/test_seg_fault...done. (gdb)break main
Breakpoint 1 at 0x84a8:
filetest_seg_fault.c,line 7. (gdb) info main
Undefined info command:
"main".
Try"helpinfo". (gdb) info b
Num TypeDisp Enb Address What
1 breakpoint keep y 0x000084a8 in main attest_seg_fault.c:7 (gdb) c Theprogram
is not beingrun. (gdb)
[root@Frankzfz]$gdbserver10.27.10.48:9000./test_seg_fault
Process ./test_seg_faultcreated;pid=760
Listening on port 9000
Remote debugging from host 10.27.10.48 readchar: Got EOF
Remote side has terminated connection. GDBserver will reopen theconnection.
Listening on port 9000
GNU gdb(GDB) 7.1
Copyright (C) 2010Free SoftwareFoundation, Inc.
License GPLv3+: GNU GPL version 3or later<</SPAN>http://gnu.org/licenses/gpl.html>
This isfreesoftware: you arefree tochangeand
redistributeit.
There is NO WARRANTY, to the extentpermitted by law. Type"showcopying" and"showwarranty"fordetails. This GDBwas configured as
"--host=x86_64-unknown-linux-gnu--target=arm-linux". For bugreporting instructions, pleasesee: <</SPAN>http://www.gnu.org/software/gdb/bugs/>.
zfz@zfz:~/kernel/fs/arm-linux-gdb/bin$./arm-linux-gdbtest ./arm-linux-gdb:
Symbol`acs_map' has different size inshared object, consider re-linking
GNU gdb (GDB) 7.1
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistributeit.
There is NO WARRANTY, to the extent permitted by law. Type "showcopying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu--target=arm-linux".
For bug reporting instructions, please see:
< http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from/home/zfz/kernel/fs/arm-linux-gdb/bin/test...done.
(gdb) target remote 10.27.10.23:9000
Remote debugging using 10.27.10.23:9000
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x400007b0 in ?? ()
(gdb) l
Cannot access memory at address 0x0
1 #include
2 int main( void )
3 {
4 int i=2;
5 int x, y;
6
7 x=(++i);
8 printf(" %d %d\n", i,x);
9 x+=(++i);
10 printf(" %d %d\n", i,x);
(gdb) l
11 x+=(++i);
12 printf(" %d %d\n", i,x);
13 i=2;
14 y=(i++)+(i++)+(i++);
15 printf(" %d %d\n", i,y);
16
17 return 0;
18 }
19
(gdb) break 9
Breakpoint 1 at 0x83b8: file test.c, line 9.
(gdb) c
Continuing.
Error while mapping shared library sections:
`/lib/libc.so.6':
not in executableformat:Fileformatnot recognized Errorwhilemapping shared library sections: /lib/ld-linux.so.3:
No suchfileordirectory.
Breakpoint 1, main
() at
test.c:9
9 x+=(++i); (gdb) step
10 printf(" %d%d\n", i,x); (gdb) next
11 x+=(++i); (gdb) next
12 printf(" %d%d\n", i,x); (gdb) next
13 i=2; (gdb) next
14 y=(i++)+(i++)+(i++); (gdb) next
15 printf(" %d%d\n", i,y); (gdb) next
17 return 0; (gdb) next
18 } (gdb)next
在目标板上的输出:
[root@Frankzfz]$gdbserver10.27.10.48:9000./test
Process ./testcreated;pid=746
Listening on port 9000
Remote debugging from host 10.27.10.48
3 3
4 7
5 12
5 6
set solib-absolute-prefix/nfsroot/rootfs set solib-search-path/nfsroot/rootfs/lib
调试找不到源代码,如下设置:
directory xfer-1.0.0/src/
下面是调试的情况:
(gdb)setsolib-absolute-prefix/home/kernel/fs/root_nfs (gdb)setsolib-search-path/home/kernel/fs/root_nfs/lib (gdb) target remote10.27.10.23:9000
Remote debugging using 10.27.10.23:9000
Reading symbols from /home/kernel/fs/root_nfs/lib/ld-linux.so.3...(nodebugging
symbols
found)...done.
Loaded symbols for
/home/kernel/fs/root_nfs/lib/ld-linux.so.3
0x400007b0 in ??() from/home/kernel/fs/root_nfs/lib/ld-linux.so.3 (gdb) l
3 {
4 inti=2;
5 intx,y;
6
7 x=(++i);
8 printf(" %d%d\n", i,x);
9 x+=(++i);
10 printf(" %d%d\n", i,x);
11 x+=(++i);
12 printf(" %d%d\n", i,x); (gdb) l
13 i=2;
14 y=(i++)+(i++)+(i++);
15 printf(" %d%d\n", i,y);
16
17 return 0;
18 }
19 (gdb) b 8
Note:breakpoint 1 also
set at pc0x83a8.
Breakpoint 2 at 0x83a8:
filetest.c,line 8. (gdb) c
Continuing.
Breakpoint 1, main
() at
test.c:8
8 printf(" %d%d\n", i,x); (gdb) n
9 x+=(++i); (gdb) b 12
Breakpoint 3 at 0x8400:
filetest.c,line 12. (gdb) n
10 printf(" %d%d\n", i,x); (gdb) n
11 x+=(++i); (gdb) n
Breakpoint 3, main
() at
test.c:12
12 printf(" %d%d\n", i,x); (gdb) n
13 i=2; (gdb) n
14 y=(i++)+(i++)+(i++); (gdb) n
15 printf(" %d%d\n", i,y); (gdb) n
17 return 0; (gdb) n
18 } (gdb) n
0x4003b004 in __libc_start_main ()
from /home/kernel/fs/root_nfs/lib/libc.so.6 (gdb)