Oswald
Oswald

Reputation: 31685

Eclipse CDT and gdb have different opinions about where source files are

I did the following:

  1. imported a Makefile project into Eclipse CDT.
  2. compiled the program from the command line using the -ggdb option of g++.
  3. run the programm from the command line
  4. set some breakpoints in Eclipse CDT
  5. attached the Eclipse CDT debugger (gdb) to a child process that my program spawned (the child process runs a program from the same project).

At this point I get the error message in the console

No source file named /home/oswald/Eclipse/CDT/Workspace/Project/path/to/header.h.

When I resume the programm, all my breakpoints are skipped. How can I get my breakpoints working?

Some additional notes:

Upvotes: 0

Views: 1566

Answers (1)

Oswald
Oswald

Reputation: 31685

As a workaround, I have written a shell script that generates a .gdbinit file that contains the appropriate directory entries:

#!/bin/sh

PROJECT=/home/oswald/Eclipse/CDT/Workspace/Project

find $PROJECT -name "*.h*" -o -name "*.c*" \
  | sed 's:/[^/]*$::' \
  | sort \
  | uniq \
  | sed 's/^/directory /' > $PROJECT/.gdbinit

and configured the Eclipse CDT to use that .gdbinit file.

Upvotes: 1

Related Questions