Issue
I have a gdb shell provided by an IDE(VSCode). The debugging experience isn't great there so I'd like to use gdb from the command line. But because of the complications of build system and the way commands are invoked, I don't know what arguments were passed to gdb.
Is it possible to print the arguments that were passed to gdb from within gdb?
Solution
Is it possible to print the arguments that were passed to gdb from within gdb?
I don't believe so.
You could attach the running GDB with another GDB, and look at its argv[]
(provided you have install debug info for GDB), but a much simpler solution is to look at /proc/${gdb_pid}/cmdline
.
This is on Linux
The following command should get you all you want:
cat -v /proc/$(pgrep gdb)/cmdline
Update:
i get
/usr/bin/gdb^@--interpreter=mi^@--tty=/dev/pts/5^@
This answers your question: GDB was invoked as:
/usr/bin/gdb --interpreter=mi --tty=/dev/pts/5
It then follows that all the other actions: loading executable, attaching to a process or starting one from the beginning, etc. were done by giving GDB commands (file /path/to/a.out
, start
, etc.)
These commands should be discoverable in the GDB console (VSCode provides access to it somewhere) and you should look for them there.
Answered By - Employed Russian Answer Checked By - Mildred Charles (WPSolving Admin)