• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Can you show static struct variables in debugger?

If I have 2 constructors, one parent of the other like so:
GML:
function this_function() constructor{
    static width = 200;
    static height = 32;
}

function that_function(_val) : this_function() constructor{
    name = _val;
}
and I go
Code:
thing = new that_function("Bob");
The debugger won't display the width and height under the variable "thing" by default, just the name.
If I go and modify the width or the height like thing[$"width"] = 50, the width will appear in the debugger.
And just to be clear, I do have 100% access and functionality to the data, it's just that the variables don't show up under the "All Instances" tab where they should be
Is this expected behavior? I feel it's kind of weird to not see them in there. Is there a way to change this? I like to have my variables under tight supervision, lol.
 

gnysek

Member
Not sure if it's a bug, but this might be lack of functionality.

Also, overriding width makes local copy in that struct, so this variable is no longer shared for this one.
 
Not sure if it's a bug, but this might be lack of functionality.

Also, overriding width makes local copy in that struct, so this variable is no longer shared for this one.
yeah, I know that it will be overridden, but I still don't get why it ONLY shows up in the debugger if it is.
Like, if I have that_other_function() which is a children of this_function(), but with the width NOT overridden, it won't show width=200, there's just nothing at all...
 

samspade

Member
No. Static variables never show up in the debugger. Whether or not they should is another question. But it does make sense that they don't. Static variables belong to the specific functions, i.e. either the method variable or script function. This is true even for constructors. The static variable belongs to the constructor, not the struct. And we can't inspect functions in the debugger. We can inspect structs, but the struct doesn't have those functions (though they clearly have some sort of invisible pointer back to it or something).

The reason variables show up after modification is they are no longer the static variable held by the constructor function. At that point they are a variable local to that struct and only that struct.
 
The reason variables show up after modification is they are no longer the static variable held by the constructor function. At that point they are a variable local to that struct and only that struct.
Makes sense when you put it that way.
Guess I'll stop using statics for variables I'm not 100% sure ALL of the children won't have to modify then, it really confuses/annoys me when something is not in the debugger, even in the game is playing 100% fine
 

chamaeleon

Member
Besides not showing up in the debugger, they won't show up as part of serialization, whether it be using string() or, perhaps more importantly, json_stringify().
 
Besides not showing up in the debugger, they won't show up as part of serialization, whether it be using string() or, perhaps more importantly, json_stringify().
What?!? Not sure I get that right, do they just don't show up, or it's not there at all, no "pointer", no nothing?
EDIT: Damn, you're totally right, mate...wow... so long struct inheritance, see you (maybe) in a couple updates...
 

gnysek

Member
You may report it as a bug. Debugger could show that static things are linked to contstructor somehow, and display it.
 
Top