- 论坛徽章:
- 0
|
调试过程如下:
1: 代码见1楼.
2: $(CC) hello.c -g -I$(INC) -o test -lpthread
3: copy至arm目标机
4: 目标机.gdbserver host:1234 test
5: 主机.gdb test
6: 主机:target remote xx.xx.xx.xx:1234
7: l main
8: l func
9: b func
10: c
11: exit normal.
另外:
1: file gdb/gdbserver/gdbserver
gdb/gdbserver/gdbserver: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), for GNU/Linux 2.6.4, not stripped
2: file gdb/gdb
gdb/gdb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for GNU/Linux 2.4.1, not stripped
3: readelf gdb/gdb -a | grep lib
[Requesting program interpreter: /lib/ld-linux.so.2]
0x00000001 (NEEDED) Shared library: [libncurses.so.5]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libc.so.6]
4: readelf gdb/gdbserver/gdbserver -a | grep lib
[Requesting program interpreter: /lib/ld-linux.so.2]
0x00000001 (NEEDED) Shared library: [libthread_db.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.6]
0001b8d0 00008116 R_ARM_JUMP_SLOT 0000a828 __libc_start_main
52: 00010e74 4 FUNC GLOBAL DEFAULT 12 __libc_csu_fini
122: 00010e78 108 FUNC GLOBAL DEFAULT 12 __libc_csu_init
129: 0000a828 524 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.0 (2)
461: 00010e74 4 FUNC GLOBAL DEFAULT 12 __libc_csu_fini
531: 00010e78 108 FUNC GLOBAL DEFAULT 12 __libc_csu_init
538: 0000a828 524 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
000000: Version: 1 File: libthread_db.so.1 Cnt: 3
0x0040: Version: 1 File: libc.so.6 Cnt: 2
5: 比较过目标机和主机链接的pthread库,弄成一致.
set debug remote 1后主机信息如下:
gdb/gdb test
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-926ejs-linux"...
(gdb) target remote 192.168.0.199:1234
Remote debugging using 192.168.0.199:1234
0x40000880 in ?? () from /lib/ld-linux.so.2
(gdb) l func
11 #include <asm-arm/arch-mxc/pm_api.h>
12
13 #include <pthread.h>
14
15 static void *func(void *arg)
16 {
17 while (1)
18 {
19 printf("new thread\n");
20 sleep(3000);
(gdb)
21 }
22 }
23
24 /*!
25 * This the main function of the porogram.
26 *
27 * @param argc number of arguments sent to the program.
28 * @param argv array of strings containing the program arguments.
29 *
30 * @return 0 if program exited with no error. else returns -1.
(gdb)
31 *
32 */
33 int main(int argc, char *argv[])
34 {
35 pthread_t id;
36 int a= 3;
37 int ret;
38
39 printf("hello,world %d\n", a);
40 ret = pthread_create(&id, NULL, func, 0);
(gdb) b 19
Breakpoint 1 at 0x84ac: file hello.c, line 19.
(gdb) set de
debug debug-file-directory debugvarobj demangle-style
(gdb) set debug remote 1
(gdb) c
Continuing.
Sending packet: $Z0,4000c0e0,4#02...Ack
Packet received:
Packet Z0 (software-breakpoint) is NOT supported
Sending packet: $m4000c0e0,4#b9...Ack
Packet received: 8401a0e1
Sending packet: $X4000c0e0,0:#da...Ack
Packet received: OK
binary downloading suppported by target
Sending packet: $X4000c0e0,4:\001\000\237?6d...Ack
Packet received: OK
Sending packet: $m84ac,4#fd...Ack
Packet received: 0c009fe5
Sending packet: $X84ac,4:\001\000\237?b1...Ack
Packet received: OK
Sending packet: $vCont?#49...Ack
Packet received: vCont;c;C;s;S
Packet vCont (verbose-resume) is supported
Sending packet: $vCont;c#a8...Ack
Packet received: T050b:a44990be;0d:504890be;0f:e0c00040;
Sending packet: $X4000c0e0,4:\204\001犪#e4...Ack
Packet received: OK
Sending packet: $X84ac,4:\f\000\237?b2...Ack
Packet received: OK
Sending packet: $m10654,d0#2d...Ack
Packet received: 010000000100000001000000430000000c0000002c8300000d000000f48500000400000028810000050000000482000006000000648100000a0000009a0000000b00000010000000150000001037024003000000240701000200000030000000140000001100000017000000fc82000011000000f482000012000000080000001300000008000000feffff6fb4820000ffffff6f02000000f0ffff6f9e820000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Sending packet: $m40023714,4#62...Ack
Packet received: 28370240
Sending packet: $m40023728,14#98...Ack
Packet received: 0000000020770140540601004c33024000000000
Sending packet: $m4002334c,14#c1...Ack
Packet received: 00000040f4800000502f024058b6014028370240
Sending packet: $m80f4,4#cf...Ack
Packet received: 2f6c6962
Sending packet: $m80f8,4#d3...Ack
Packet received: 2f6c642d
Sending packet: $m80fc,4#fe...Ack
Packet received: 6c696e75
Sending packet: $m8100,4#96...Ack
Packet received: 782e736f
Sending packet: $m8104,4#9a...Ack
Packet received: 2e320000
Sending packet: $m4001b658,14#c8...Ack
Packet received: 0040024040b6014018bf0340d8b801404c330240
Sending packet: $m4001b640,4#8e...Ack
Packet received: 2f6c6962
Sending packet: $m4001b644,4#92...Ack
Packet received: 2f6c6962
Sending packet: $m4001b648,4#96...Ack
Packet received: 70746872
Sending packet: $m4001b64c,4#c1...Ack
Packet received: 6561642e
Sending packet: $m4001b650,4#8f...Ack
Packet received: 736f2e30
Sending packet: $m4001b654,4#93...Ack
Packet received: 00000000
Sending packet: $m4001b8d8,14#f9...Ack
Packet received: 00f00340c8b8014020ef14400000000058b60140
Sending packet: $m4001b8c8,4#c7...Ack
Packet received: 2f6c6962
Sending packet: $m4001b8cc,4#f2...Ack
Packet received: 2f6c6962
Sending packet: $m4001b8d0,4#c0...Ack
Packet received: 632e736f
Sending packet: $m4001b8d4,4#c4...Ack
Packet received: 2e360000
Sending packet: $m40023710,4#5e...Ack
Packet received: 01000000
warning: .dynamic section for "/lib/libpthread.so.0" is not at the expected address (wrong library or version mismatch?)
warning: .dynamic section for "/lib/libc.so.6" is not at the expected address (wrong library or version mismatch?)
Sending packet: $qSymbol::#5b...Ack
Packet received: qSymbol:6e70746c5f76657273696f6e
Sending packet: $qSymbol::6e70746c5f76657273696f6e#4d...Ack
Packet received: OK
Sending packet: $qSymbol::#5b...Ack
Packet received: qSymbol:6e70746c5f76657273696f6e
Sending packet: $qSymbol::6e70746c5f76657273696f6e#4d...Ack
Packet received: OK
Sending packet: $m4000c0e0,4#b9...Ack
Packet received: 8401a0e1
Sending packet: $Hg0#df...Ack
Packet received: E01
Sending packet: $p19#da...Ack
Packet received:
Sending packet: $g#67...Ack
Packet received: 040000004c33024000000000000000000300000000000000d8bf034000000000644890bef864024000300240a44990bea3760240504890beb4db0040e0c0004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000a0
Sending packet: $m4000c0e4,4#bd...Ack
Packet received: 040080e2
Sending packet: $X4000c0e4,4:\001\000\237?71...Ack
Packet received: OK
Sending packet: $vCont;c#a8...Ack
Packet received: T050b:a44990be;0d:504890be;0f:e4c00040;
Sending packet: $X4000c0e4,4:\004\000\200?48...Ack
Packet received: OK
Sending packet: $m4000c0e0,4#b9...Ack
Packet received: 8401a0e1
Sending packet: $X4000c0e0,4:\001\000\237?6d...Ack
Packet received: OK
Sending packet: $m84ac,4#fd...Ack
Packet received: 0c009fe5
Sending packet: $X84ac,4:\001\000\237?b1...Ack
Packet received: OK
Sending packet: $vCont;c#a8...Ack
Packet received: T050b:a44990be;0d:dc4790be;0f:e0c00040;
Sending packet: $X4000c0e0,4:\204\001犪#e4...Ack
Packet received: OK
Sending packet: $X84ac,4:\f\000\237?b2...Ack
Packet received: OK
Sending packet: $m40023714,4#62...Ack
Packet received: 28370240
Sending packet: $m40023728,14#98...Ack
Packet received: 0000000020770140540601004c33024000000000
Sending packet: $m4002334c,14#c1...Ack
Packet received: 00000040f4800000502f024058b6014028370240
Sending packet: $m80f4,4#cf...Ack
Packet received: 2f6c6962
Sending packet: $m80f8,4#d3...Ack
Packet received: 2f6c642d
Sending packet: $m80fc,4#fe...Ack
Packet received: 6c696e75
Sending packet: $m8100,4#96...Ack
Packet received: 782e736f
Sending packet: $m8104,4#9a...Ack
Packet received: 2e320000
Sending packet: $m4001b658,14#c8...Ack
Packet received: 0040024040b6014018bf0340d8b801404c330240
Sending packet: $m4001b640,4#8e...Ack
Packet received: 2f6c6962
Sending packet: $m4001b644,4#92...Ack
Packet received: 2f6c6962
Sending packet: $m4001b648,4#96...Ack
Packet received: 70746872
Sending packet: $m4001b64c,4#c1...Ack
Packet received: 6561642e
Sending packet: $m4001b650,4#8f...Ack
Packet received: 736f2e30
Sending packet: $m4001b654,4#93...Ack
Packet received: 00000000
Sending packet: $m4001b8d8,14#f9...Ack
Packet received: 00f00340c8b8014020ef14400000000058b60140
Sending packet: $m4001b8c8,4#c7...Ack
Packet received: 2f6c6962
Sending packet: $m4001b8cc,4#f2...Ack
Packet received: 2f6c6962
Sending packet: $m4001b8d0,4#c0...Ack
Packet received: 632e736f
Sending packet: $m4001b8d4,4#c4...Ack
Packet received: 2e360000
Sending packet: $m40023710,4#5e...Ack
Packet received: 01000000
Sending packet: $m4000c0e0,4#b9...Ack
Packet received: 8401a0e1
Sending packet: $g#67...Ack
Packet received: 000000004c33024000000000000000000200000000000000d8ef144000000000e04790bea8ab044000300240a44990be6dfd0440dc4790beb4db0040e0c0004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000a0
Sending packet: $m4000c0e4,4#bd...Ack
Packet received: 040080e2
Sending packet: $X4000c0e4,4:\001\000\237?71...Ack
Packet received: OK
Sending packet: $vCont;c#a8...Ack
Packet received: T050b:a44990be;0d:dc4790be;0f:e4c00040;
Sending packet: $X4000c0e4,4:\004\000\200?48...Ack
Packet received: OK
Sending packet: $m4000c0e0,4#b9...Ack
Packet received: 8401a0e1
Sending packet: $X4000c0e0,4:\001\000\237?6d...Ack
Packet received: OK
Sending packet: $m84ac,4#fd...Ack
Packet received: 0c009fe5
Sending packet: $X84ac,4:\001\000\237?b1...Ack
Packet received: OK
Sending packet: $vCont;c#a8...Ack
Packet received: X05
Program terminated with signal SIGTRAP, Trace/breakpoint trap.
The program no longer exists.
(gdb)
目标机:
gdbserver host:1234 test &
mx27# Process test created; pid = 1683
Listening on port 1234
Remote debugging from host 192.168.0.1
hello,world 3
ID 1083516176 ret = 0
Child terminated with signal = 5
Child terminated with signal = 0x5 (SIGTRAP)
GDBserver exiting
没能进入多线程的断点.
希望高手指点一下,谢谢!!
[ 本帖最后由 boliyun 于 2007-12-15 10:06 编辑 ] |
|