c – 远程调试问题

我正在尝试远程调试本地网络中的服务器上的应用程序.

服务器:

$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告诉我有一个incomming连接,但它没有写我的hello world消息.

有任何想法吗?

附:我刚刚在linuxquestions.org上发布了这个问题.我认为这不是正确的论坛,所以我在这里试试运气.

最佳答案 使用-ggdb而不是-g AND使用目标远程而不是使用extended-remote进行编译.

点赞