目录(?)[+]
libncurses.so放在ncurses-5.6/output/arm/lib路径下。
(1)测试程序运行时首先会有个段错误:./gdbtest &
[user0@ user0]$ [65334.020000] pgd = c3e14000
[65334.020000] [00000000] *pgd=43b87031, *pte=00000000, *ppte=00000000
用移植好的gdb来测试运行如下:
./gdb gdbtest
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 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 "arm-unknown-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/user0/gdbtest...done.
(gdb) r
Starting program: /home/user0/gdbtest
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[65352.710000] pgd = c1cbc000read_db matching inferior's thread library, thread debugging will not be available.
[65352.710000] [00000000] *pgd=41c9c031, *pte=00000000, *ppte=00000000
Program received signal SIGSEGV, Segmentation fault.
0x400ca048 in strcpy () from /lib/libc.so.6
(gdb) bt
#0 0x400ca048 in strcpy () from /lib/libc.so.6
#1 0x00008540 in f2 (str=0x0) at src/gdbtest.c:45
#2 0x0000855c in main () at src/gdbtest.c:73
(gdb)
[1]+ Segmentation fault ./gdbtest
可以看出代码段错误问题出在strcpy上。
(2)测试程序中把
Delay(10000);
test1();
Delay放到test1之前,这样程序会阻塞,阻塞的时候用gdb定位正在运行的进程非常好用:
./gdb gdbtest 1865 第一是运行gdb 第二个进程名称 第三个进程pid,顺序这样子来要
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 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 "arm-unknown-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/user0/gdbtest...done.
Attaching to program: /home/user0/gdbtest, process 1865
Reading symbols from /lib/libpthread.so.0...(no debugging symbols found)...done.
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/libdl.so.2...(no debugging symbols found)...done.
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Loaded symbols for /lib/ld-linux.so.2
0x401198dc in select () from /lib/libc.so.6
(gdb) bt
#0 0x401198dc in select () from /lib/libc.so.6
#1 0x000086e0 in Delay (uiTimeS=
#2 0x00008598 in _start ()
(gdb) q
A debugging session is active.
bt用来查看堆栈信息,发现阻塞在select函数中,和我们的代码一致。