Print multiple variables with one command in GDB

Solution 1:

You can simply do this

print {var1,var2,var3,var4}

This will do the job.

Solution 2:

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.).