1

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 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm not attaching to existing application. See step 3 in above. I start new process instead of attaching.
But why use "attach to application" launch configuration? This is meant to debug already running applications. Still, in Luna SR1 the dialog shown after clicking "new" (3) also includes "arguments" text-box where you can enter arguments.
I'm using Juno SR2 and there isn't possibility to pass arguments in that case. However I tried to to create dummy project and got debugging work by that solution. Thanks for the hint.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.