注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

gmd20的个人空间

// 编程和生活

 
 
 

日志

 
 

试试在windows用Eclipse CDT IDE+ MinGW GDB远程调试Linux程序  

2013-04-26 13:03:09|  分类: 程序设计 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
参考文章
Windows 下使用Eclipse CDT 远程调试 Linux C/C++ 程序
http://blog.csdn.net/txk1452/article/details/7603272

HOWTO Install the MinGW (GCC) Compiler Suite
http://www.mingw.org/wiki/InstallationHOWTOforMinGW


1.
下载MinGW,使用它的安装程序安装,不要手工安装。
最好装一个新的,不要用 strawberry perl 和 msysGit自带的MinGW。
http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/
我下载的是 mingw-get-inst-20120426.exe 
安装 时选择安装 c, c++ 和msys组件。  其他的包可以用mingw-get i 命令安装。
或者直接到下面这个页面下载,手工安装,解压出来反倒mingw的bin目录等文件夹里面去。
http://sourceforge.net/projects/mingw/files/MinGW

2.
然后到这里下载gdb源码,编译一个针对linux target的版本。
http://sourceforge.net/projects/mingw/files/MinGW/Extension/gdb/
gdb-7.5-1-mingw32-src.tar.lzma

我是解压到D盘,通过 开始菜单的  MinGW shell进入 MinGW提示符
./configure --target=i686-pc-linux-gnu 
make

编译完成之后在 gdb目录下有 生成gdb.exe ,我把它改名为linux_gdb.exe 放到 C:\MinGW\bin目录下
试着执行一下
$ linux_gdb
GNU gdb (GDB) 7.5
Copyright (C) 2012 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 "--host=i686-pc-mingw32 --target=i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb)



3. 安装最新的Eclipse CDT IDE。
新建C/C++ 项目。 toolchain选择 MinGW GCC
配置项目属性“Debug as” -》 “C++ Remote Application”

“Main” page
              配置  “ disable auto build“  “Using GDB(DSF) Manual Remote   Debuer Launcher” 需要自己手工启动 gdbserver
试试在windows用Eclipse CDT IDE+ MinGW GDB远程调试Linux程序 - widebright - widebright的个人空间
 
“Debugger”page 
                刚刚编译gdb的位置   gdbserver的连接端口
                点debug配置页面下面 的debug开始调试。
试试在windows用Eclipse CDT IDE+ MinGW GDB远程调试Linux程序 - widebright - widebright的个人空间
 
试试在windows用Eclipse CDT IDE+ MinGW GDB远程调试Linux程序 - widebright - widebright的个人空间
 
试试在windows用Eclipse CDT IDE+ MinGW GDB远程调试Linux程序 - widebright - widebright的个人空间
 
  直接在“Console” 窗口可以手工敲入gdb命令执行。试了一下是可以的,不过之后eclipse的那些调试功能就不能再执行了。
而且文件等显示错误。在eclipse里面他还帮你加载了这些了。
-----------------
服务器端启动gdbserver 后面接要监听的端口和ip 和调试参数
[root@IN-TEST-LINUX-02 bright]# gdbserver 192.168.100.115:2345 a.out 
Process a.out created; pid = 19939
Listening on port 2345
Remote debugging from host 192.168.100.8
!!!Hello World!!!00
!!!Hello World!!!11
!!!Hello World!!!12
!!!Hello World!!!23
!!!Hello World!!!24

gdb里面用这个去连接gdbserver
target remote 192.168.100.115:2345

----------------
GDB 的xml解析需要其他几个包。
mingw-get install libexpat-dev
mingw-get install libiconv-dev
mingw-get install gettext-dev


再重新编译一次gdb
$ ./configure --target=i686-pc-linux-gnu  --prefix=linux
checking build system type... i686-pc-mingw32
checking host system type... i686-pc-mingw32
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /bin/install -c
checking whether ln works... yes
checking whether ln -s works... no, using cp -p
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f
2
checking for objdir... .libs
checking for PWL_handle_timeout in -lpwl... no
checking for version 0.11 (revision 0 or later) of PPL... no
checking for default BUILD_CONFIG...
*** removing intl/Makefile to force reconfigure
*** removing libiberty/Makefile to force reconfigure
*** removing opcodes/Makefile to force reconfigure
*** removing bfd/Makefile to force reconfigure
*** removing readline/Makefile to force reconfigure
*** removing libdecnumber/Makefile to force reconfigure
*** removing sim/Makefile to force reconfigure
*** removing gdb/Makefile to force reconfigure
*** removing etc/Makefile to force reconfigure
checking for bison... no
checking for byacc... no
checking for yacc... no
checking for bison... no
checking for gm4... no
checking for gnum4... no
checking for m4... no
checking for flex... no
checking for lex... no
checking for flex... no
checking for makeinfo... makeinfo
checking for expect... no
checking for runtest... no
checking for ar... ar
checking for as... as
checking for dlltool... dlltool
checking for ld... (cached) c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mi
ngw32/bin/ld.exe
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... windres
checking for windmc... windmc
checking for objcopy... objcopy
checking for objdump... objdump
checking for readelf... readelf
checking for i686-pc-linux-gnu-cc... no
checking for i686-pc-linux-gnu-gcc... no
checking for i686-pc-linux-gnu-c++... no
checking for i686-pc-linux-gnu-g++... no
checking for i686-pc-linux-gnu-cxx... no
checking for i686-pc-linux-gnu-gxx... no
checking for i686-pc-linux-gnu-gcc... no
checking for i686-pc-linux-gnu-gcj... no
checking for i686-pc-linux-gnu-gfortran... no
checking for i686-pc-linux-gnu-gccgo... no
checking for i686-pc-linux-gnu-ar... no
checking for i686-pc-linux-gnu-as... no
checking for i686-pc-linux-gnu-dlltool... no
checking for i686-pc-linux-gnu-ld... no
checking for i686-pc-linux-gnu-lipo... no
checking for i686-pc-linux-gnu-nm... no
checking for i686-pc-linux-gnu-objdump... no
checking for i686-pc-linux-gnu-ranlib... no
checking for i686-pc-linux-gnu-readelf... no
checking for i686-pc-linux-gnu-strip... no
checking for i686-pc-linux-gnu-windres... no
checking for i686-pc-linux-gnu-windmc... no
checking where to find the target ar... pre-installed
checking where to find the target as... pre-installed
checking where to find the target cc... pre-installed
checking where to find the target c++... pre-installed
checking where to find the target c++ for libstdc++... pre-installed
checking where to find the target dlltool... pre-installed
checking where to find the target gcc... pre-installed
checking where to find the target gcj... pre-installed
checking where to find the target gfortran... pre-installed
checking where to find the target gccgo... pre-installed
checking where to find the target ld... pre-installed
checking where to find the target lipo... pre-installed
checking where to find the target nm... pre-installed
checking where to find the target objdump... pre-installed
checking where to find the target ranlib... pre-installed
checking where to find the target readelf... pre-installed
checking where to find the target strip... pre-installed
checking where to find the target windres... pre-installed
checking where to find the target windmc... pre-installed
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether -fkeep-inline-functions is supported... yes
configure: creating ./config.status
config.status: creating Makefile

这样重新编译之后,安装gdb还是提示不能解析 xml。

Eclipse里面即时调试是能下断点,查看变量之类的,堆栈显示也都正常。

另外如果有其他的动态链接库等也要指定吧,好像eclipse的配置里面有相关的设置,没试过效果怎么样。 


使用这样的gdb来分析core dump,bt查看 堆栈,调试符号等显示不正常。

可能编译的时候,需要配置对应target的 as gcc ld 等。这个又要自己像编译gdb一样,一个个的去编译,不知道mingw有没有弄好的安装包。

不过如果直接使用gdb命令行的话,还不如直接去Linux上面用了,不过管这么多乱七八糟的配置。

不过在带GUI的linux 上面用这样eclipse CDT 去远程调试server的东西,应该会好很多吧? 不会有这些堆栈显示解析无的问题了吧?  不习惯命令行的可以考虑一下,这个eclipse cdt做的还是很不错的。


  评论这张
 
阅读(1076)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017