7

On Linux, I am trying to debug a C++ application with gdb in Eclipse CDT.

For example the application applic.exe takes some command line arguments arg1 and arg2 and it expects some data on stdin (say, taken from a file input.txt).

Normally, to run the application in the console I would do this:

cat input.txt | applic.exe arg1 arg2

Using gdb in the console I can do:

gdb applic.exe
(gdb) run applic.exe arg1 arg2 < input.txt

Is it possible to do that with gdb in Eclipse? I know how to specify the arguments (and the environment) in the Eclipse Debug Configurations, but what about stdin?

1
  • I am not sure if that can be done, in the run configuration there is an option for specifying an output file, but for input it says that it needs to have a console attached. Commented Jan 13, 2012 at 14:44

2 Answers 2

2

There is Console tab in Eclipse (at the bottom of IDE) you can put your data here.

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

4 Comments

Make sure you select the gdb console from the consoles that are available.
I think the op is asking for an automatic way of doing that, not copying and pasting every time (it might be a very large input file!)
Then what about passing file name as a parameter, and open it for read inside the program?
Yes, that can used as a workaround. But I would have preferred not to.
0

Instead of entering the redirection in the arguments tab, append it to the executable file name in the debug configuration.

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.