使用Eclipse CDT和GDB进行调试:无法找到源文件

11

当我尝试使用Eclipse CDT中的GDB调试我的应用程序时,会出现以下错误:

 Can't find a source file at "../mingw/main.c"
 Locate the file or edit the source lookup path to include its location.

Eclipse 正在寻找../mingw/main.c的源文件位置,但它应该在/edit/src/main.c中。如下面的截图所示,edit/src是源代码查找路径的一部分。为什么会在 ../mingw 中搜索呢?我找不到任何配置设置使它那样做。
我正在使用 Eclipse Juno、CDT 8.1 和 Windows 7 64位系统。Here is a screenshot that indicates the problem

你找出问题所在了吗? - Winter
我也需要找到这个问题的答案。 - yarun can
不,我仍然不知道解决方案是什么。 - amarillion
3个回答

7
这是你的答案: http://www.eclipse.org/forums/index.php/t/57027/ 如果你在Windows下工作,是否设置了必要的映射?可能由于缺少对项目/工作区所在(cygwin-)驱动器的映射,Eclipse找不到源。
当你启动Cygwin时,请输入“mount”并查找你拥有的映射:它们可能看起来像这样:
Admin@bs11-01xp ~
$ mount
D:\cygwin\bin on /usr/bin type system (binmode)
D:\cygwin\lib on /usr/lib type system (binmode)
D:\cygwin on / type system (binmode)
c: on /cygdrive/c type system (binmode,noumount)
d: on /cygdrive/d type system (binmode,noumount)
e: on /cygdrive/e type system (binmode,noumount)
j: on /cygdrive/j type system (binmode,noumount)
n: on /cygdrive/n type system (binmode,noumount)
u: on /cygdrive/u type system (binmode,noumount)
w: on /cygdrive/w type system (binmode,noumount)
x: on /cygdrive/x type system (binmode,noumount)
y: on /cygdrive/y type system (binmode,noumount)
z: on /cygdrive/z type system (binmode,noumount)

我的项目都在 J:\Projects 下,所以我的映射需要在 Eclipse 中呈现为:

/cygdrive/j j:/

打开Eclipse,然后点击
- Windows => Preferences... => C/C++ => Debug =>Common Source Lookup Path
- 添加一个新的路径映射:点击[Add] => Path Mapping => [OK]
- 选择新的映射 => [Edith] => 更改映射名称为"Project Source" => [Add]
- 将"Compilation path"设置为源代码路径(示例cygwin!) "/cygdrive/j"(不包括引号!)
- 将"Local file system path"设置为"J:\" (不包括引号!)

现在您已经准备好再试一次了....祝你好运!


2
不鼓励仅提供链接的答案。链接可能会被移动/删除。请编辑答案以包括实际步骤(除了链接)。 - anishsane

0

在调试器选项卡下的“调试配置”(位于调试器弹出图标下),取消勾选“停止启动时”,这样它就不会在启动时停止,但您仍然可以在那里设置断点(如果需要的话)


0

什么都不起作用。除了下面的解决方案,以上的解决方案都没有用。

我只是用msys gdb替换了gdb

例如:

当前配置

...应用程序配置..调试..调试

GDB调试器 gdb

改为

GDB调试器 msys gdb的路径(例如c:\msys\bin\gdb.exe)

Manu


为什么不将你的其他答案与问题链接起来,并更详细地解释为什么以及如何修复此问题,而不是复制/粘贴呢? - Elikill58

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接