axe axe - 27 days ago 9
C++ Question

Eclipse CDT: how to enable project debugging

I want to enable integrated debugging with gdb for my project in Eclipse CDT. The problem is I can't run the debugger with just a simple command like

gdb myapp
, because application starts using various scripts, there are lot of environment variables to set before starts, so there is shell scripts that starts application under gdb debugger, let's say it is
located in some
. Now I'd like to configure Eclipse to start the debugger from it's interface, is there any way to do that? I'm trying to set my script as debugger, but it does nothing when I start debugger.

Answer Source

Your could handle command line parameters. Add a parameter to it, e.g. --debug, and have it invoke GDB after it has set up whatever environment variables are required, e.g. replace

export FOO=...
... other setup ...
exec /path/to/binary $ARGS


... setup ...
exec $GDB /path/to/binary $ARGS

where $GDB is empty if --debug was not on command line, or is set to gdb --args if it was.

Now set up Eclipse to invoke --debug when debugging, and you are done.