当前位置: 技术问答>linux和unix
求助:gdb调试core文件,加了-g参数,还是显示no debugging symbols found
来源: 互联网 发布时间:2016-10-19
本文导语: 如题。 1、在PC机上编写了测试程序。 #include #include int main() { char *p; strcpy(p,"hello"); } 2、在PC机的linux下运行及gdb调试core正常。 [root@localhost test]# gcc -g -o test_kkk test_kkk.c [root@localhost...
如题。
1、在PC机上编写了测试程序。
#include
#include
int main()
{
char *p;
strcpy(p,"hello");
}
2、在PC机的linux下运行及gdb调试core正常。
[root@localhost test]# gcc -g -o test_kkk test_kkk.c
[root@localhost test]# ./test_kkk
段错误 (core dumped)
[root@localhost test]# gdb -c core.141
core.14188 core.14198
[root@localhost test]# gdb -c core.14198 test_kkk
GNU gdb 6.8
Copyright (C) 2008 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 "i686-pc-linux-gnu"...
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./test_kkk'.
Program terminated with signal 11, Segmentation fault.
[New process 14198]
#0 0x08048388 in main () at test_kkk.c:7
7 strcpy(p,"hello");
(gdb) bt
#0 0x08048388 in main () at test_kkk.c:7
(gdb)
3、将程序下载到硬件平台上后,gdb运行core如下。
arm-linux-gcc -g -o test_kkk test_kkk.c
./gdb -c core test_kkk
GNU gdb (GDB) 7.0
Copyright (C) 2009 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-linux".
For bug reporting instructions, please see:
...
Reading symbols from /mnt/nand/fw/test_kkk...done.
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.3
Core was generated by `./test_kkk'.
Program terminated with signal 11, Segmentation fault.
#0 0x4009920c in memcpy () from /lib/libc.so.6
(gdb) bt
#0 0x4009920c in memcpy () from /lib/libc.so.6
#1 0x00000000 in ?? ()
(gdb)
4、为什么还是出现了no debugging symbols found,导致bt命令后,不能正常的显示错在哪一行。
补充说明:
1、gdb是交叉编译到板子上的,可以使用,strip和未strip都试过,结果一样。
2、板子上运行的linux的所有库文件都是交叉编译环境相同,strip和未strip都试过,结果一样。
我该怎么做????谢谢各位。
1、在PC机上编写了测试程序。
#include
#include
int main()
{
char *p;
strcpy(p,"hello");
}
2、在PC机的linux下运行及gdb调试core正常。
[root@localhost test]# gcc -g -o test_kkk test_kkk.c
[root@localhost test]# ./test_kkk
段错误 (core dumped)
[root@localhost test]# gdb -c core.141
core.14188 core.14198
[root@localhost test]# gdb -c core.14198 test_kkk
GNU gdb 6.8
Copyright (C) 2008 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 "i686-pc-linux-gnu"...
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Core was generated by `./test_kkk'.
Program terminated with signal 11, Segmentation fault.
[New process 14198]
#0 0x08048388 in main () at test_kkk.c:7
7 strcpy(p,"hello");
(gdb) bt
#0 0x08048388 in main () at test_kkk.c:7
(gdb)
3、将程序下载到硬件平台上后,gdb运行core如下。
arm-linux-gcc -g -o test_kkk test_kkk.c
./gdb -c core test_kkk
GNU gdb (GDB) 7.0
Copyright (C) 2009 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-linux".
For bug reporting instructions, please see:
...
Reading symbols from /mnt/nand/fw/test_kkk...done.
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.3
Core was generated by `./test_kkk'.
Program terminated with signal 11, Segmentation fault.
#0 0x4009920c in memcpy () from /lib/libc.so.6
(gdb) bt
#0 0x4009920c in memcpy () from /lib/libc.so.6
#1 0x00000000 in ?? ()
(gdb)
4、为什么还是出现了no debugging symbols found,导致bt命令后,不能正常的显示错在哪一行。
补充说明:
1、gdb是交叉编译到板子上的,可以使用,strip和未strip都试过,结果一样。
2、板子上运行的linux的所有库文件都是交叉编译环境相同,strip和未strip都试过,结果一样。
我该怎么做????谢谢各位。
|
哦代码就是上面那个啊……那基本上就是栈脏掉然后memcpy最终触发了segfault。没啥好纠结的。
|
可以试试访问NULL确定一下原因
char *p;
=>
char *p = 0;
char *p;
=>
char *p = 0;
|
仔细看no debugging symbols found是在哪里的。是载入两个系统lib库的时候没有调试符号……这当然是没有的。乃自己的程序Read symbols不是正常done了么
然后,如果bt都不对的话很大的可能性是整个栈都被乃越界越得破坏掉了。只能先静态调试确定哪里出问题再说。
然后,如果bt都不对的话很大的可能性是整个栈都被乃越界越得破坏掉了。只能先静态调试确定哪里出问题再说。