远程gdb会话在进入main之前接收信号SIGSEGV

时间:2014-05-13 09:35:18

标签: linux gcc gdb cross-compiling gdbserver

我尝试使用gdb 7.7为嵌入式Linux平台设置远程调试,运行使用" i586-geode-linux-gnu-gcc(crosstool-NG 1.19.0)4.8编译的代码。 1"

此处使用的示例是以下程序:

#include <stdio.h>
#include <stdlib.h>

int main(char* argc, char* argv[])
{
    printf("Hello, 1!");
    printf("Hello, 2!");
    printf("Hello, 3!");

    return 0;
}

使用编译:

i586-geode-linux-gnu-gcc -g test.c -o testsc

步骤1.在目标上(通过ssh):

# gdbserver :2345 testsc
Process testsc created; pid = 23623
Listening on port 2345

步骤2.在主机PC上:

chetic@ubuntu:~/Documents/tmp/remotetest$ gdb testsc 
GNU gdb (GDB) 7.7
Copyright (C) 2014 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 "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from testsc...done.

第3步。我怀疑这是不对的:

(gdb) target remote 192.168.1.102:2345
Remote debugging using 192.168.1.102:2345
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
0x40000c80 in ?? () from /lib/ld-linux.so.2

第4步:

(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x4000f9ef in ?? () from /lib/ld-linux.so.2
(gdb) 

我尝试在main设置断点,但没有遇到。如果我在目标上使用gdb运行程序,或者使用常规gcc进行编译并在PC主机上本地运行远程会话,那么一切都可以正常进行调试。

我已经为主机上的目标和主机编译并安装了gdb 7.7和gdbserver 7.7。

谷歌搜索这个问题主要是建议改变堆栈大小,但我尝试使用&#39; ulimit -s&#39;来改变堆栈大小限制。使用不同的值(包括无限制)并在/ proc / [pid] / maps中看到堆栈受到影响,但问题仍然存在。

记忆地图(此示例使用&#39; ulimit -s unlimited&#39;):

# cat /proc/`pidof gdbserver`/maps
08048000-08090000 r-xp 00000000 03:01 60919      /usr/bin/gdbserver
08090000-08092000 rw-p 00048000 03:01 60919      /usr/bin/gdbserver
08092000-080be000 rw-p 00000000 00:00 0          [heap]
40000000-4001f000 r-xp 00000000 03:01 45729      /lib/ld-2.17.so
4001f000-40020000 r--p 0001f000 03:01 45729      /lib/ld-2.17.so
40020000-40021000 rw-p 00020000 03:01 45729      /lib/ld-2.17.so
40021000-40022000 r-xp 00000000 00:00 0          [vdso]
40022000-40024000 rw-p 00000000 00:00 0 
40025000-40028000 r-xp 00000000 03:01 45726      /lib/libdl-2.17.so
40028000-40029000 r--p 00002000 03:01 45726      /lib/libdl-2.17.so
40029000-4002a000 rw-p 00003000 03:01 45726      /lib/libdl-2.17.so
4002a000-40195000 r-xp 00000000 03:01 45711      /lib/libc-2.17.so
40195000-40196000 ---p 0016b000 03:01 45711      /lib/libc-2.17.so
40196000-40198000 r--p 0016b000 03:01 45711      /lib/libc-2.17.so
40198000-40199000 rw-p 0016d000 03:01 45711      /lib/libc-2.17.so
40199000-4069e000 rw-p 00000000 00:00 0 
bfb24000-bfb39000 rw-p 00000000 00:00 0          [stack]

0 个答案:

没有答案