This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to fix the error "No source file named .....\main.c" when adding a breakpoint in Eclipse when debugging with gdb

When trying to setup the gcc toolchain with Eclipse Luna IDE, I ran into the problem when I can't set a break point when debugging with the GNU ARM J-Link Debugging Support plugin. When I added a breakpoint, I got "No source file named ... " in the gdb trace. I have made sure that I used -g option when compiling with gcc (make debug).

image description

I could step through the code but when I clicked resume (F8), the PC didn't seem to stop at the breakpoint I set. Nothing happened after Resume.

This issue caused debugging impossible in most cases.

  • After a while, I seemed to find the cause and solution for this. It was because Eclipse seems to used a wrong path to main.c file as shown in the picture, seems like there is an extra backslash \ (gdb trace) and GDB doesn't like this:

    image description

    I tried to fix this by adding a relative path that points to the absolute path instead. In Debug Configuration -> Source, I added Project - Path Relative to Source Folder that point to the project. And made sure it's above the Default path.

    image description(/attachment/d3489266b8d188874d910f9a9aec0268)

    After that Eclipse will set breakpoint using relative path and I was able to debug and set breakpoint, resume, etc.

    gdb traces

  • Good information, you should mark it as answered.

  • I had the same error, thanks!

Related