user972276
user972276

Reputation: 3053

gdb: printing a variable not in the current scope

I am using gdb and I was wanting to print a variable not currently in the scope. I am not sure what the exact name of the variable is so I would like to be able to change scopes rather than printing a specific variable in a specific file.

Upvotes: 9

Views: 3116

Answers (1)

Neil
Neil

Reputation: 55392

You can use the frame, up and down commands to access scopes on the stack.

frame N
f N
    Select frame number N. (The current instruction is in frame 0.)

up [N]
    Move N frames up the stack (away from frame 0).

down [N]
    Move N frames down the stack (towards frame 0).

Upvotes: 14

Related Questions