GDB question

I just now learning how to use GDB.

I wanted to look at an int that was part of a struct in global space.
The global is called header and the int is called start.

I tried many variations of
print header.start
but all it says in return is
Attempt to extract a component of a value that is not a structure.

What is the proper way to display a global value?

What does

ptype header

show?

You can always cast it

print ((struct header *)&header)->start

and for convenience you can set a user defined variable

set $header = (struct header *)&header

Bill Caroselli wrote:

I just now learning how to use GDB.

I wanted to look at an int that was part of a struct in global space.
The global is called header and the int is called start.

I tried many variations of
print header.start
but all it says in return is
Attempt to extract a component of a value that is not a structure.

What is the proper way to display a global value?


cburgess@qnx.com

Did you specify -g option when you compile the files?


Bill Caroselli wrote:

I just now learning how to use GDB.

I wanted to look at an int that was part of a struct in global space.
The global is called header and the int is called start.

I tried many variations of
print header.start
but all it says in return is
Attempt to extract a component of a value that is not a structure.

What is the proper way to display a global value?