Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print multiple variables with one command in GDB

Tags:

gdb

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   
like image 512
Rao Garimella Avatar asked Dec 10 '09 18:12

Rao Garimella


People also ask

What is print command in GDB?

The usual way to examine data in your program is with the print command (abbreviated p ), or its synonym inspect . It evaluates and prints the value of an expression of the language your program is written in (see section Using GDB with Different Languages).

Which command prints value of the variable?

If a standalone variable is found as a statement, bc command prints the value of the variable.

What does frame do in GDB?

The frame command allows you to move from one stack frame to another, and to print the stack frame you select. args may be either the address of the frame or the stack frame number. Without an argument, frame prints the current stack frame.

Which command in GDB is used to find the type of variable?

The ptype [ARG] command will print the type. Show activity on this post. This question may be related: vtable in polymorphic class of C++ using gdb: (gdb) help set print object Set printing of object's derived type based on vtable info.


1 Answers

You can simply do this

print {var1,var2,var3,var4} 

This will do the job.

like image 165
vikasmk Avatar answered Sep 20 '22 20:09

vikasmk