Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No source file named" error debugging Eclipse CDT

I've got a project with a shared library (loaded dynamically), and I'm attempting to debug it. I get the following error message:

No source file named /home/username/Code/path/to/project/MyFile.cpp.

After having searched other threads, I've ensured that I'm compiling with -g, and that the appropriate folders are on the source paths tab of debug configurations. The strange part is that it's giving the correct absolute path: the file it references does exist, so I don't understand why it doesn't think it's there.

Anyone know what to do about this?

like image 676
OrbitalDan Avatar asked Oct 19 '12 00:10

OrbitalDan


3 Answers

I just came across the same issue, although my breakpoints were in the executable itself, not in a shared library. To solve this, I had to open the "Debug configuration", select my debug configuration and adjust the following settings:

  • At the bottom, there is a link "Select other ..." to select the Create Process launcher. Click the link. Tick the "Use configuration specific settings". Select "Standard Create Process Launcher" and press "Ok".
  • Go to the "Debugger" tab, and on the top of the tab select "Debugger: gdb/mi". What may/may not make a difference: On the same tab there is also a checkbox "Use full file path to set breakpoints" - I played with this, but it does not seem to affect the issue we observe (obviously, our source paths are already full paths).

For breakpoints in shared libraries, you might need additional information (especially about deferred breakpoints) from Debugging with eclipse cdt and gdb and Why does eclipse cdt ignore breakpoints.

Note: This refers to Eclipse Kepler (4.3) and gdb 7.4.

like image 183
Andreas Fester Avatar answered Oct 21 '22 15:10

Andreas Fester


I had the same problem, but in my case it was my fault. Some of my projects were set to Release configuration and the debugger naturally could not find the source file information.

like image 24
ahmkara Avatar answered Oct 21 '22 16:10

ahmkara


I had the same problem. I couldn't set a breakpoint in a shared library file (.so), compiled in a different place than my program. To fix this:

  1. Go to the Debug Configuration, Source tab
  2. Add a compilation directory (I used the location of the main makefile that compiles all processes, not where the makefile for this process is located).
  3. also click "Subdirectories are also used for compilation" (my subprocess makefile is compiled in a subdirectory of the main location)

I haven't figured out how to make this change for all debug configurations future and past so that I don't have to add this directory every time, but I'll try to update later if I do figure that out.

like image 30
Geronimo Avatar answered Oct 21 '22 14:10

Geronimo