Author Topic: Watch a complex struct when debugging  (Read 5328 times)

Offline su1

  • Single posting newcomer
  • *
  • Posts: 6
Watch a complex struct when debugging
« on: February 21, 2012, 03:30:03 pm »
Hello,

in my code I define a struct like this:

Code
  
Individuals *individuals = NULL;
individuals = malloc(10*sizeof(Individuals));

When debugging, I know how to watch one individual at a time, by Right click > Adding watch > individuals[3] for example.

But I would like to be able to follow easily the values in every structure in individuals, ie individuals[0], individuals[1], etc... on the same screen (like what I've seen XCode is doing).

Is there a way to do that?

Thanks.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Watch a complex struct when debugging
« Reply #1 on: February 21, 2012, 04:05:10 pm »
Screen shot?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline su1

  • Single posting newcomer
  • *
  • Posts: 6
Re: Watch a complex struct when debugging
« Reply #2 on: February 22, 2012, 09:11:22 am »
Screenshot of what? I can't give you a screen shot of what I want and don't have...  :D

But here's a screenshot of what I have for now:



As you can see, I can easily access individuals[1], or individuals[2],... But I would like to have in the same watch:

individuals[1]  individuals[2]      ...

offer             offer                 ...
request         request             ...
strength        strength            ...


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Watch a complex struct when debugging
« Reply #3 on: February 22, 2012, 09:37:38 am »
What you tried Right click -> Properties -> Watch as array?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline su1

  • Single posting newcomer
  • *
  • Posts: 6
Re: Watch a complex struct when debugging
« Reply #4 on: February 22, 2012, 10:02:14 am »
I guess you mean Right click -> Edit watch -> Watch as array?

So yes I've tried, when I do this I obtain


Code
*individuals

[0] offer             
[1] request         
[2] strength       
...

instead of

Code
*individuals

offer             
request         
strength       
...

but still not what I want:

Code
individuals[1]  individuals[2]      ...

offer             offer                 ...
request         request             ...
strength        strength            ...

It seems like the watch *individuals only shows individuals[0]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Watch a complex struct when debugging
« Reply #5 on: February 22, 2012, 10:27:56 am »
Quote
It seems like the watch *individuals only shows individuals[0]
Which is actually correct. NOte that C -arrays are not real arrays/vectors. The name of the C-arrays decays into a pointer to the type ==> *individuals is then actually the same as :
Code
int * foo = new int();

*foo;  // <-- same thing here

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Watch a complex struct when debugging
« Reply #6 on: February 22, 2012, 10:40:55 am »
su1: Also it might be a good idea to try the debugger's branch nightly build or build a version directly from svn (wxpropgrid_debuggers).
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline su1

  • Single posting newcomer
  • *
  • Posts: 6
Re: Watch a complex struct when debugging
« Reply #7 on: February 22, 2012, 11:12:18 am »
Hey,

thanks for the tips, but it starts to be just over my competences to do that and would take me too much time that I don't have right now.

I was just checking if there was an easy solution, otherwise I'll just use seperate watches for individuals[0], individuals[1], etc..., even if it's not really user-friendly.