gdbserver程序在freebsd上的main之前崩溃了

时间:2016-04-08 15:49:54

标签: gdbserver

尝试使用gdb -gdbserver调试在freebsd上运行的应用程序。不知何故,如果我进行本地调试(在bsd上使用gdb)一切顺利但是使用gdbserver(我在同一台bsd机器上运行gdb和gdbserver)似乎在main之前的初始化过程中失败。

我的工作流程是:

echo "int main(int argc, char** argv){return 0;}">main.cpp
clang++ -ggdb main.cpp

gdbserver localhost:2222 ./a.out

相同机器或不同无关紧要:

gdb
file a.out
target remote localhost:2222
break main
continue -> here everything is crashing (not gdbserver but app).

提前谢谢你:)

The output of my console is:
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 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 "amd64-marcel-freebsd".
(gdb) file a.out
Reading symbols from a.out...done.
(gdb) target remote localhost:2222
Remote debugging using localhost:2222
0x0000000800602110 in ?? ()
(gdb) break main
Breakpoint 1 at 0x400770: file main.cpp, line 1.  
(gdb) continue 
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) 

其他一些信息:

(gdb) backtrace 
#0  0x0000000000000000 in ?? ()
#1  0x0000000200000000 in ?? ()
#2  0x0000000000400200 in ?? ()
#3  0x0000000000400510 in ?? ()
#4  0x00007fffffffeba0 in ?? ()
#5  0x00007fffffffeba8 in ?? ()
#6  0x00007fffffffebc0 in ?? ()
#7  0x000000000040023c in crt_noinit_tag ()
#8  0x000000080061e000 in ?? ()
#9  0x0000000000400248 in crt_noinit_tag ()
#10 0x00007fffffffedd8 in ?? ()
#11 0x00007fffffffebd0 in ?? ()
#12 0x0000000000000000 in ?? ()

(gdb) info sharedlibrary 
From                To                  Syms Read   Shared Object Library
0x00000008008599c0  0x00000008008b2f58  Yes         /usr/lib/libc++.so.1
0x0000000800ae4a20  0x0000000800af0a78  Yes         /lib/libcxxrt.so.1
0x0000000800cfdcf0  0x0000000800d158a8  Yes         /lib/libm.so.5
0x0000000800f5b780  0x00000008010673a8  Yes         /lib/libc.so.7
0x00000008012cc150  0x00000008012d58e8  Yes         /lib/libgcc_s.so.1
0x0000000800602110  0x0000000800615639  Yes         /libexec/ld-elf.so.1

使用FreeBSD 10.1和上述步骤可以重现此问题。

1 个答案:

答案 0 :(得分:1)

对于那些希望解决这个问题的人:

与FreeBSD中的gdb维护者进行了对话。结果是在FreeBSD中没有可以单独使用的gdbserver。相反,有一个名为ds2的远程调试服务器可以代替使用。不幸的是,ds2在FreeBSD 10.1中不可用,但它在较新版本的FreeBSD中运行良好。用gdb测试它,它正在工作!!!。