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

时间:2023-01-24 18:54:16

When I try to debug my application using GDB from eclipse CDT, I get the following error:

当我试图使用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 is looking for the source file location at ../mingw/main.c, but it should be in /edit/src/main.c. As you can see in the screenshot below, edit/src is part of the source lookup path. Why is looking in ../mingw? I can't find any configuration setting that makes it look there.

Eclipse正在../mingw/main处寻找源文件位置。c,但是应该在/edit/src/main.c中。如下面的屏幕截图所示,编辑/src是源查找路径的一部分。为什么看? /明?我找不到任何可以让它看起来的配置设置。

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

I'm using eclipse Juno, CDT 8.1, Windows 7 64bit

我使用的是eclipse Juno、CDT 8.1、Windows 7 64位

2 个解决方案

#1


5  

Here is your answer http://www.eclipse.org/forums/index.php/t/57027/

你的答案是http://www.eclipse.org/forums/index.php/t/57027/

If you're working under Windows, have you set the required mappings? Maybe Eclipse couldn't find the Source because of the missing mapping to the (cygwin-)drive where your projects/workspaces are.

如果在Windows下工作,是否设置了所需的映射?也许Eclipse找不到源,因为缺少到项目/工作区所在的(cygwin-)驱动器的映射。

When you start Cygwin, enter "mount" and look for the mapping you have: They may look like this:

当您启动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)

My Projects ara all under J:\Projects, so my mapping needs to be present in Eclipse as:

我的项目都在J:\项目之下,所以我的映射需要在Eclipse中显示为:

/cygdrive/j j:/

Open Eclipse and then click
- Windows => Preferences... => C/C++ => Debug =>Common Source Lookup Path
- Add a new Path Mapping: click [Add] => Path Mapping => [OK]
- Select the new Mapping => [Edith] => change Name of Mapping "Project Source" => [Add]
- set "Compilation path" to the Source (Sample cygwin!) "/cygdrive/j" (without the quotes!)
- set"Local file system path" tho "J:\" (without the quotes!)

打开Eclipse,然后单击- Windows =>首选项…=>C /C++ => Debug =>公共源查找路径-添加新的路径映射:点击[Add] =>路径映射=> [OK] -选择新的映射=> [Edith] =>映射“Project Source”=> [Add] -设置“编译路径”到源(Sample cygwin) !"/cygdrive/j"(没有引号!)-设置"本地文件系统路径" tho " j:\"(没有引号!)

Now you are ready ti give it another try.... good luck !

现在你准备好了ti给它另一个尝试....祝你好运!

#2


0  

in "Debug Configuration" (under debugger popup icon) in Debugger tab uncheck "stop on startup at", after this it will not stop on startup, but u can put breakpoint there if u like

在“调试配置”(调试器弹出图标下)的调试器选项卡uncheck“在启动时停止”中,在此之后它不会在启动时停止,但是如果您愿意,您可以在那里放置断点

#1


5  

Here is your answer http://www.eclipse.org/forums/index.php/t/57027/

你的答案是http://www.eclipse.org/forums/index.php/t/57027/

If you're working under Windows, have you set the required mappings? Maybe Eclipse couldn't find the Source because of the missing mapping to the (cygwin-)drive where your projects/workspaces are.

如果在Windows下工作,是否设置了所需的映射?也许Eclipse找不到源,因为缺少到项目/工作区所在的(cygwin-)驱动器的映射。

When you start Cygwin, enter "mount" and look for the mapping you have: They may look like this:

当您启动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)

My Projects ara all under J:\Projects, so my mapping needs to be present in Eclipse as:

我的项目都在J:\项目之下,所以我的映射需要在Eclipse中显示为:

/cygdrive/j j:/

Open Eclipse and then click
- Windows => Preferences... => C/C++ => Debug =>Common Source Lookup Path
- Add a new Path Mapping: click [Add] => Path Mapping => [OK]
- Select the new Mapping => [Edith] => change Name of Mapping "Project Source" => [Add]
- set "Compilation path" to the Source (Sample cygwin!) "/cygdrive/j" (without the quotes!)
- set"Local file system path" tho "J:\" (without the quotes!)

打开Eclipse,然后单击- Windows =>首选项…=>C /C++ => Debug =>公共源查找路径-添加新的路径映射:点击[Add] =>路径映射=> [OK] -选择新的映射=> [Edith] =>映射“Project Source”=> [Add] -设置“编译路径”到源(Sample cygwin) !"/cygdrive/j"(没有引号!)-设置"本地文件系统路径" tho " j:\"(没有引号!)

Now you are ready ti give it another try.... good luck !

现在你准备好了ti给它另一个尝试....祝你好运!

#2


0  

in "Debug Configuration" (under debugger popup icon) in Debugger tab uncheck "stop on startup at", after this it will not stop on startup, but u can put breakpoint there if u like

在“调试配置”(调试器弹出图标下)的调试器选项卡uncheck“在启动时停止”中,在此之后它不会在启动时停止,但是如果您愿意,您可以在那里放置断点