eclipse调试模式下的GDB找不到stdlib / rand.c [英] GDB on eclipse debug mode can't find stdlib/rand.c

查看:318
本文介绍了eclipse调试模式下的GDB找不到stdlib / rand.c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把gdb与ubuntu上的eclipse cdt一起运行,开始调试一些简单的程序。所以我做了必要的步骤让它运行:



1。创建一个可执行项目



2。编译



3。运行



4。创建文件.gdbinit并将其放在主项目文件夹



5. 设置一些调试器文件,看起来像这样:

 设定时间表多个

dir〜/ gcc_build / 4.7.2 / build / gcc
dir〜/ gcc_build / 4.7.2 / gcc
dir〜/ gcc_build / 4.7.2 / gcc / cp
dir〜/ gcc_build / 4.7.2 / gcc / lto
source〜/ gcc_build / 4.7.2 / build / gcc / gdbinit.in
pre>

但是,我的电脑中没有找到任何类似的东西,即使是这样做:

 #find / -name .gdbinit 

所以,我的文件.gdbinit结束用简单的内容 - 只是这样:

 
上设置新的控制台

然后点击Apply and Debug:





gdb按照预期开始工作。我按下Step over / F6按钮,调试器逐步跳过代码。直到达到命令rand(),gdb挂起消息:

 找不到源文件/build/buildd/eglibc-2.19/stdlib/rand.c
找到文件或编辑源查找路径以包含其位置。



因此,我也尝试不成功找到rand.c来更新此路径以包含其位置:

 #find / -name rand.c 
#find / -name stdlib

在GDB抱怨rand.c丢失的错误消息后,我尝试继续执行...从那时起,重启调试时,步进模式被禁用:





发生这个问题是因为我的文件.gdbinit的某些设置丢失了吗?或者一些GDB如何不能从c99的stdlib找到rand.c?当我编译并运行该程序运行良好。只有当我尝试启动调试器时,GDB崩溃。



更新:运行命令:

 #apt-get install libc6-dbg 
#apt-get source libc6

但是现在出现一个不同的错误:

 在/build/buildd/eglibc-2.19/csu/libc-start.c找不到源文件
找到文件或编辑源查找路径以包含其位置。

我还应该为gdb安装该库吗?



所有的建议都非常感谢。

解决方案

从我在你的描述中看到的...寻找第4和第5您发布的图像,您做了所有必要的步骤。



但是,在我看来,您的GDB附加到几个项目。这意味着除非您真的需要,否则我强烈建议您选择您当前未调试的所有项目,并将其从调试器模式中删除。所以,我的建议是,在您完成了迄今为止所做的所有步骤后,请继续执行:

 调试配置> C / C ++应用程序:(下拉)

...然后点击你不是的每个项目编译,使用鼠标右键选择删除 - 但不用担心,它不会删除您的项目,而只是该项目的附件到您的调试器模式。



然后重新启动eclipse。当您再次尝试在调试器模式下运行时,所有操作都将比以前更顺利。


I am trying to put the gdb to run with eclipse cdt on ubuntu to start debugging some simple programs. So I did the steps I reckon as necessary to get it running:

1. Create an executable project

2. Compile

3. Run

4. Create the file .gdbinit and place it on the main project folder

5. Set some of the debugger configuration:

5. I also tried to find a .gdbinit file that would look some like this:

set schedule-multiple

dir ~/gcc_build/4.7.2/build/gcc
dir ~/gcc_build/4.7.2/gcc
dir ~/gcc_build/4.7.2/gcc/cp
dir ~/gcc_build/4.7.2/gcc/lto
source ~/gcc_build/4.7.2/build/gcc/gdbinit.in

But I didn't find anything similar in my computer, even after doing a:

# find / -name .gdbinit

So, my file .gdbinit end up with the simple content - yes only that:

set new-console on

Then I clicked on Apply and Debug:

The gdb starts working nicely as expected. I press the button "step over / F6" and the debugger goes jumping through the code step by step. Until the point it reaches the command rand() and the gdb hangs with the message:

Can't find a source file at "/build/buildd/eglibc-2.19/stdlib/rand.c" 
Locate the file or edit the source lookup path to include its location.

Thus I also tried unsuccessfully to find the rand.c to update this path to include its location:

# find / -name rand.c
# find / -name stdlib

After the error message from GDB complaining that rand.c is missing, then I tried to keep stepping... since then the stepping mode is disable when I restart the debug:

Is this problem happening because some setting for my file .gdbinit is missing? Or some how GDB is not able to find the rand.c from stdlib from c99? When I compile and run the program it runs nicely. Only when I try to launch the debugger is when GDB crashes.

Update: I got the missing rand.c problem after running the commands:

# apt-get install libc6-dbg
# apt-get source libc6

But now a different error appears:

Can't find a source file at "/build/buildd/eglibc-2.19/csu/libc-start.c" 
Locate the file or edit the source lookup path to include its location.

Should I also install that library for gdb?

All suggestions are highly appreciated.

解决方案

From what I saw on your description... looking to the 4th and 5th image you posted, you did right all the required steps.

However, it seems to me that your GDB is attached to several projects. That means that unless you really need that, I would strongly advise you to select all project that you are not currently debugging and delete them from the debugger mode. So, my suggestion is that after you have done all the steps you did so far, then go on:

Debug Configurations > C/C++ Applications: (drop down it)

... then click on each project you are not compiling, with right button from the mouse select "delete" - but don't worry, it will not delete your project, but only the attachment of that project to your debugger mode.

Then restart the eclipse. When you again try to run in the debugger mode, everything will run much smoother than before.

这篇关于eclipse调试模式下的GDB找不到stdlib / rand.c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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