I have a lengthy program with several variables i want to check up on periodically. rather than typing
print var1
print var2
print var2
and so on, ho can I either get output for multiple variables from one print
(I tried print var1, var2, var3
but that didn't work.)
or
How can I write my own function to do the same thing as repetitiously typing print for each available?
is there any easier way?
You were close enough
print (var1, var2, ...)
Incidentally, you can use p
as a shorthand for print
:
p (var1, var2, ...)
If you simply want to monitor those variables for changes, then you need to watch them:
watch var1
watch var2
This way, any time the value of var1
etc. changes, GDB will notify you and print old and new value.