3

Is there a way to automatically start a process under gdb on Linux? An equivalent of setting the Image File Execution Options on Windows.

I am trying to debug start-up phase of a process that is launched from another one.

2 Answers 2

7

I would normally move the real program out of the way, and replace it with a script that launches the program under GDB with the same parameters.

#!/bin/bash

exec gdb -args <realprog> "$@"

If that doesn't work due to the output being redirected to file, or something, then try this:

#!/bin/bash

exec xterm -e gdb -args <realprog> "$@"

That should give you a pop-up terminal with GDB running inside.

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

Comments

3

You don't have to go through all that registry voodoo on Linux :)

Simply:

1) Rename your program

2) Write a shell script that calls gdb with your (renamed) program and passes any arguments you want. Make sure you "chmod +rx" your script.

3) Name the shell script the original name of your program, and put it in the same directory as your program

4) Execute!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.