Shuzheng
Shuzheng

Reputation: 13996

Is it possible to debug another program in a GDB session without first quitting?

Is it possible to debug another program in a GDB session without first quitting?

After having set up things like set disassembly-flavor intel and having debugged my first program1, I want to debug another program2 without quitting the GDB session.

The reason is, that I don't want to enter all of the commands, like the one above.

Usually, I first quit the original GDB session and debug program2 using gdb program2, but there must be something smarter?

Upvotes: 0

Views: 71

Answers (1)

Tom Tromey
Tom Tromey

Reputation: 22549

You can kill the currently running inferior, then use file to select a new program to debug, then run it.

If you find yourself typing the same commands a lot, put them in your ~/.gdbinit. You can also enable history-saving so they will be in the command history when you restart gdb.

Upvotes: 2

Related Questions