gpt4 book ai didi

c++ - eclipse Debug模式下的 GDB 找不到 stdlib/rand.c

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:02:06 25 4
gpt4 key购买 nike

我正在尝试让 gdb 在 ubuntu 上与 eclipse cdt 一起运行,以开始调试一些简单的程序。因此,我执行了我认为必要的步骤以使其运行:

1.创建可执行项目

2.编译

3.运行

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

5. 设置一些调试器configuration : enter image description here enter image description here

5. 我也试着找到一个 .gdbinit看起来像这样的文件:

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

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

# find / -name .gdbinit

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

set new-console on

然后我点击应用和调试:

enter image description here

gdb 开始正常工作。我按下“step over/F6”按钮,调试器一步步跳过代码。直到它到达命令 rand() 并且 gdb 挂起并显示消息:

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.

enter image description here

因此我也没有成功地找到 rand.c 来更新这个路径以包含它的位置:

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

在 GDB 发出错误消息提示 rand.c 丢失后,我尝试继续步进...从那时起,当我重新启动调试时步进模式被禁用:

enter image description here

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

更新: 我在运行 commands 后遇到了缺少 rand.c 的问题。 :

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

但是现在出现了不同的错误:

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.

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

非常感谢所有建议。

最佳答案

根据我在您的描述中看到的...查看您发布的第 4 和第 5 张图片,您已正确完成所有必需的步骤。

但是,在我看来,您的 GDB 与多个项目相关联。这意味着除非你真的需要它,否则我强烈建议你选择你当前没有调试的所有项目并将它们从调试器模式中删除。因此,我的建议是,在您完成目前为止执行的所有步骤后,继续:

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

...然后单击您未编译的每个项目,用鼠标右键选择“删除”——但别担心,它不会删除您的项目,只会删除该项目到调试器的附件模式。

然后重启eclipse。当您再次尝试在调试器模式下运行时,一切都会比以前运行得更流畅。

关于c++ - eclipse Debug模式下的 GDB 找不到 stdlib/rand.c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26964364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com