I am encountering a problem to print multiple variables (say 25
) in a function on GDB Prompt
.
Is there any convenient way to do this instead of printing every variables manually ?
can I have a script or a simpler way which can do my job ?
You can print multiple values using printf
command in gdb.
printf "%d,%d\n", a, b
To use it in future, you can either define a gdb-function or use gdb-history feature.
To define a gdb-function, create/modify file $HOME/.gdbinit
with the following conten,
define print_all
printf "%d,%d\n", a, b
end
document print_all
Prints all my variables.
end
Then you can use print_all
as a command.
For history trick, create/modify file $HOME/.gdbinit
with the following content:
set history filename ~/.gdb_history
set history save
and get it using ctrl+r
same like in bash.
Actual gdb-history answer is here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With