0
votes

I'm trying to debug process with GDB from Eclipse (CDT). I can start debugging, step on code and so on. So, basic setup seems to work.

However, I don't understand how to pass command line arguments to process. Executable is not built with Eclipse, I use separate make files.

Steps I have taken to debug:

  1. Run -> Debug configurations -> Select C/C++ attach to application -> New.
  2. Press Debug -> Select processes dialog is shown.
  3. Press new -> File explorer is opened and I'm able to select correct executable (once again: built outside of Eclipse)
  4. After that execution stops to the beginning of main and I'm able to start debugging. BUT without command line arguments.

So, how I pass command line arguments for attached new application in scenario above?

Thanks in advance!

2

2 Answers

1
votes

As "c++ attach to application" attaches debugger to already running application you can't expect to be able to pass command line arguments. You need to pass those whereever you start your executable.

I think you are looking for ordinary "C/C++ application" launch configuration. It does require a project (you can create a dummy one or import your actual makefile project, if you use that). With this type of launch configuration you will get additional "Arguments" tab, where you can enter "command-line" arguments.

1
votes

FYI, if someone is later fighting with same issue:
It seems to be possible to pass arguments to new attached process with gdb command file. I simply attached next line to command file:

set args arg1 arg2 argX

...and selected that file as GDB command line in debugger options. Those arguments were passed to main when process was started.