[lldb-dev] Issue with displaying a union of templated type in debugger
Rich Eakin
rtepub at gmail.com
Wed Aug 6 21:46:17 PDT 2014
I'm not sure if this has been reported, but I have come across an issue
with trying to view data that is within a union Xcode's debug view,
specifically when the data type is templated. Please consider the following:
template <typename T>
struct vec2 {
union { T x, r; };
union { T y, g; };
};
int main()
{
vec2<float> foo = { 2.0f, 3.0f };
return 0;
}
If I place a breakpoint on the return statement and exam foo, I see two
tabs with no name. Clicking on either tab shows an array of 'y = 3, g = 3',
while there is no sign of x (or r). Something is going wrong here.
However if I remote the templating:
struct vec2 {
union { float x, r; };
union { float y, g; };
};
int main()
{
vec2 foo = { 2.0f, 3.0f };
return 0;
}
and example the data in the same manner, I see that one tab has an array of
'x = 2, r = 2', and the other is 'y = 3, g = 3'. Is this a known issue? I
discovered this while trying to make use of the popular glm math library (
http://glm.g-truc.net/), which uses unions in this manner to follow the
GLSL types spec.
As an aside, I think the display of unions in general (even without the
templates) is not ideal, at first glance it is difficult to make out what
the data is at all, given that it is a) hidden underneath tabs with no
names and b) duplicated. Has there been any thought towards how to better
represent this data in the debugger?
Thanks,
Rich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140807/1689917f/attachment.html>
More information about the lldb-dev
mailing list