如何使用GDB调试大项目? [英] How to use GDB to debug a big project?

查看:1211
本文介绍了如何使用GDB调试大项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我有一个c语言项目,其中包含三个目录 / bin / inc / src
所有标题文件( .h)都包含在 / inc 中,所有的源文件( .c)存储在 / src ,ieac,bc,cc ..,最终生成的可执行文件将位于/ bin。



在makefile之后,所有的obj文件将被生成 / src / obj 像ao,bo,co,d ....!此外,在 / bin 目录中将生成一个final.exe可执行文件。



现在,如果我想使用GDB进行调试,那么我这样做?



要调试/ src / obj中的obj文件?还是有些其他?



非常感谢您的帮助!

解决方案

您可以通过启动GDB来调试应用程序

 %> gdb< your_executable> 

或通常更容易启动应用程序,然后使用PID附加调试器到进程。

 %> gdb -p< pid> 

对于命令行选项,只需键入 gdb -h 并且在gdb
内部运行的帮助总是可以通过在gdb命令行上键入help。



这是一个快速的作弊表和一个教程网站一些常见的命令。



正如Arkaitz所说,一定要编译你的代码,使它有必要的调试信息包含在可执行文件中。



如果从命令行调试有点令人生畏,有一些使用GDB的UI可用。我使用gdb在 Eclipse 中进行了很多调试。



一旦你开始使用gdb路径,我相信你会有更多的问题,我鼓励你在SO上提出更具体的问题。 >

祝你好运。


Now I have a c language project which include three directories /bin, /inc and /src. All of header files (.h) are included in /inc and all of source(.c) files are stored in /src, i.e. a.c, b.c, c.c..., the final generated executable file will locate in /bin.

after compling with makefile, all of obj files will be generated in /src/obj like a.o, b.o, c.o, d....! Moreover an final.exe executable file will be generated in the /bin directory.

Now if I want to debug it with GDB, how can I do it???

To debug those obj files in /src/obj? or somewhat else?

Many thanks for the kind help!

解决方案

You can either debug an application by starting it with GDB

%> gdb <your_executable>

or what is usually easier is to start your application and then attach the debugger to the process using the PID.

%> gdb -p <pid>

For command line options, just type gdb -h and while running inside of gdb help is always available by typing "help" on the gdb command line.

Here is a quick cheat sheet and a tutorial site on some common commands.

As Arkaitz mentioned, be sure to compile your code so that it has the necessary debug information included in the executable.

If debugging from the command line is a bit daunting, there are some UIs available that use GDB. I do a lot of my debugging in Eclipse using gdb.

Once you get started down the gdb path, I'm sure you'll have more questions and I encourage you to ask those more specific questions on SO.

Good luck.

这篇关于如何使用GDB调试大项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆