我正在尝试远程调试本地网络中服务器上的应用程序。
服务器:
$ uname -a
Linux broatyctl.localdomain 3.6.11.2-rt33.39.el6rt.x86_64 #1 SMP PREEMPT RT Thu Jul 4 06:46:48 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
$ gdbserver --version
GNU gdbserver (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 Free Software Foundation, Inc.
gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "x86_64-redhat-linux-gnu"
工作站:
$ uname -a
Linux workstation.localdomain 3.12.7-300.fc20.x86_64 #1 SMP Fri Jan 10 15:35:31 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ gdb --version
GNU gdb (GDB) Fedora 7.6.50.20130731-16.fc20
我在工作站上编译了一个“Hello World”应用程序,它在工作站和服务器上运行都没有错误。
这适用于服务器和工作站
外壳 1:
$gdbserver localhost:2345 CrossTest
外壳 2:
$ gdb CrossTest
(gdb)target extended-remote localhost:2345
(gdb)run
这行不通
服务器:
$ gdbserver workstation.ip.address:2345 CrossTest
工作站:
$ gdb CrossTest
(gdb)target extended-remote server.ip.address:2345
(gdb)cont
GDB 输出
(gdb) cont
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x00007f2a3b247d50 in ?? ()
(gdb)
gdbserver 告诉我有一个传入连接,但它没有写入我的 hello world 消息。
有什么想法吗?
附言不久前,我已经在 linuxquestions.org 上发布了这个问题。我认为那不是合适的论坛,所以我在这里试试运气。
最佳答案
使用 -ggdb 而不是 -g 进行编译,并使用 target remote 而不是 extended-remote 进行编译。
关于c++ - 远程调试问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21187522/