Is it possible to convert the pointer of struct member to the struct pointer.

Bin Chen binary.chen@gmail.com
Mon Apr 2 07:48:00 GMT 2007


If there is a struct:
struct A {
    int b;
    int c;
};


void func(int *c)
{
[...trap point..]
}

main()
{
struct A a;
func(&a.c);
}

Now we are breaking in the body of func, and I want to take the value
of b. Can any command  do this?

I know I can substract 4 from c's address to obtain the address of b,
but it is not what I want. Can I use the explicitly type converting to
do this?

Thanks.
abai



More information about the Gdb mailing list