Hemanth
Hemanth

Reputation: 5145

How to print the value of members of a structure with gdb debugger?

I'm using C. How can I print the values of a member of an instance of a structure? Is it possible? At least is it possible in case of a structure declared as global variable (not a dynamically allocated one)?

Upvotes: 1

Views: 1489

Answers (1)

Josh Matthews
Josh Matthews

Reputation: 13026

set print objects on
p structVar
p *pointerToStructVar

Or, more explicitly:

p structVar.member
p pointerToStructVar->member

Upvotes: 3

Related Questions