Print multiple variables with one command in GDB

Viewed 24758

I want to execute the very simple command

print var1, var2, var3, var4 

in gdb to examine the values of the vars from time to time.

I don't want to use display because it clutters up my view.

How can I do this? Right now all I can do is:

p var1  
p var2  
p var3  
p var4  
4 Answers

Use the printf command. It's a bit of a hassle, but it gives good control over the formatting. From the command line:

(gdb) help printf
printf "printf format string", arg1, arg2, arg3, ..., argn
This is useful for formatted output in user-defined commands.

The format string is like in C (%d for normal size ints, %s for null terminated strings, etc.).

Related