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

gdbserver program crashes before main on freebsd

尝试使用 gdb - gdbserver 在 freebsd 上调试应用 运行ning。不知何故,如果我进行本地调试(在 bsd 上使用 gdb)一切顺利,但是使用 gdbserver(我 运行 gdb 和 gdbserver 在同一台 bsd 机器上)似乎在 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 和描述的步骤可重现此问题。

对于那些正在寻找解决这个问题的人:

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