Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: mijewen on June 27, 2014, 01:45:38 am

Title: Watches : expansion of structures
Post by: mijewen on June 27, 2014, 01:45:38 am
It would be a great feature if structures were stated by their name under Watches with a little "+" beside them for expansion of their contents.
Does such a feature exist?  At the moment (though I'm still a very newbie) I can only see them by writing the struct member onto a new Watch line.

To explain,

main()
{ struct my_test
   { int i;
      char c;
      char s[10];
    } test;

   // do some stuff...
}

When viewing this under GDB, it would be nice if Watches showed, on one line ...

+   test           struct my_test

It already does this, (without the "+"), but if the + was clicked, it would list ...

-   test           struct my_test
     test.i         4                     int
     test.c        h                     char
     test.s        my_string          char

Today is my first on this forum, so if I should have asked this under Suggestions, please just direct me there, though I asked it here because I think it may already be possible (I hope)
Title: Re: Watches : expansion of structures
Post by: oBFusCATed on June 27, 2014, 02:11:24 am
It is implemented in all versions. But it doesn't dereference pointers automatically.
Title: Re: Watches : expansion of structures
Post by: mijewen on June 27, 2014, 02:44:29 am
I'm sorry to be thick about this, but I don't understand what you mean by "it doesn't dereference pointers"
When you say that all versions implement it, do you mean that what I wanted (expansion of structures / unions) is already implemented, so that I can see the value of ...

my_struct.member

... without specifically typing in "my_struct.member" onto a new Watches line?

Currently, if I highlight the line containing my_struct and click the button in the second column, it opens a new dialogue frame, but all it contains is..

(struct my_struct *) 0x32470

It doesn't expand the contents.

I should have mentioned that I'm running C::B under Windows XP SP3.
Title: Re: Watches : expansion of structures
Post by: oBFusCATed on June 27, 2014, 09:43:22 am
I'm sorry to be thick about this, but I don't understand what you mean by "it doesn't dereference pointers"

If you have MyStruct *ptrToStruct and add ptrToStruct in the watches it will print the value of the pointer and not the value of the struct.
You have to either add *ptrToStruct to the watches or right click on it and select "Dereference ptrToStruct" in the context menu.
Title: Re: Watches : expansion of structures
Post by: mijewen on June 27, 2014, 01:02:10 pm
OK, got it.
Thanks for your patience.