#How to access tuple members in lldb?

1 messages · Page 1 of 1 (latest)

mossy cape
#

I have tried the syntax tup[4] and tup.4 ...

mossy cape
#

chatGPT suggested p tup["4"] which also fails 😉

#

then I clarified that it was a Zig Tuple and it suggested p tup._4 which also failed....

regal bobcat
#

what about tup.0?

summer geyser
#

As background, in case you didn't know yet, tuples are structs with field names that are implicitly numbered 0... so in Zig you can access them with tup.@"0", tup.@"1" (although now you can use tup[0] as well.
But I haven't found a way in lldb to print struct fields with names that aren't valid identifiers yet...

regal bobcat
#

maybe tup.@"0"

#

I been sniped

summer geyser
#

Haha same

#

It does let you do p tup though, works fine

#

You can do some nonsense to manually find the offsets of each field like p *(int*)(&(tup) + 2), but that's not particularly convenient. Also, in what I just tested, the fields were reordered anyway, making it even less convenient

steel void
#

what about fr v tup."4"

mossy cape
#

we have a winner!

#

Thanks all ❤️