You are not logged in.

#1 2023-03-22 03:48:07

Registered: 2021-08-29
Posts: 14

How to view user-defined variables in GDB?

Hi everyone,

I often forget the names of variables I set when using GDB for debugging. Is there a way to view the user-defined variables in GDB?

I tried using the

 info locals 

, but it only shows the automatic variables in the current scope. I also tried

 info variables

, but it shows all variables, including system variables and function arguments.

Is there a command or option in GDB that allows me to view only the variables I set myself? Or perhaps a way to filter the output of info variables to show only user-defined variables?

Thank you in advance for your help!


#2 2023-06-02 01:44:12

Registered: 2023-05-26
Posts: 37

Re: How to view user-defined variables in GDB?

Might be a little late, but you could try putting a prefix before your variable name to distinguish them from other variables. Something like


Then run

info variables | grep userdef

to get a list of the variables you defined.


Board footer

Powered by FluxBB