Lysa»Blog

Parsing Variable Names

I've been scratching my head a bit lately, trying to figure out how to handle a string of variables (eg var.member.another_member). The parsing part is relatively simple since I decided to only parse exactly what I need, but getting the variable data out of the debug symbols is hanging me up.

There are a handful of ways I can think to get this done, but none of them jump out as great solutions just yet. It may involve changing some other parts of Lysa to work nicely.

Anyway, I wrote a few thoughts down on Patreon to update any followers. You can check it out if you like.

You stay classy, o7
This may be stating the obvious somewhat but in "var.member.another_member" the "var" should be a variable in scope. Then using the type info you can get the offset of the "member" field and recurse to get the offset to "another_member" field.

Then interpret the data there according to what type another_member is. Follow pointer as needed.

Do keep in mind that the user will want to see values interpreted in various ways, and sometimes following void* but then inspecting into the struct it points to.
Jeremiah Goerdt,
ratchetfreak
This may be stating the obvious somewhat but in "var.member.another_member" the "var" should be a variable in scope. Then using the type info you can get the offset of the "member" field and recurse to get the offset to "another_member" field.

Then interpret the data there according to what type another_member is. Follow pointer as needed.


I can already get all of this information, I just made some assumptions before that I shouldn't have. The problem I have now is reusing what I already wrote, tweaking it to fit a more general case, or just rewriting it from scratch.

ratchetfreak
Do keep in mind that the user will want to see values interpreted in various ways, and sometimes following void* but then inspecting into the struct it points to.


That's a great point and something I need to consider. Thanks!