Re: [patch] ptype: show members of an unnamed struct inside an union

Joel Brobecker
2007-08-29T18:32:23Z

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]

> In C, it would be "my_page_var.mapping". The union is transparent.

Oh, I see. (love to learn new things :).

Back to the issue at hand, it therefore seems pretty desirable to
enhance the debugger in that case. Unfortunately, I don't think
the proposed patch is correct, because it bases the logic on the
size of the union/struct instead of whether the field is anonymous
or not. Do you agree?

Just for easier reference, the patch was:

2007-08-16 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>

gdb/c-typeprint.c (c_type_print_base): check value of
TYPE_NFIELDS (type) when displaying members of an
unnamed struct inside an union.

This patch breaks the tests that I just posted for RFA:
http://www.sourceware.org/ml/gdb-patches/2007-08/msg00498.html
But otherwise is reported to not cause any other regression on
the testsuite.

--
Joel

[-- Attachment #2: ptype_issue.diff --]
[-- Type: text/plain, Size: 715 bytes --]

2007-08-16 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>

gdb/c-typeprint.c (c_type_print_base): check value of
TYPE_NFIELDS (type) when displaying members of an
unnamed struct inside an union.

Index: src-git/gdb/c-typeprint.c
===================================================================
--- src-git.orig/gdb/c-typeprint.c 2007-08-16 15:28:04.000000000 -0700
+++ src-git/gdb/c-typeprint.c 2007-08-16 15:29:07.000000000 -0700
@@ -735,7 +735,7 @@
fputs_filtered (" ", stream);
}
wrap_here (" ");
- if (show < 0)
+ if ((show < 0) && (TYPE_NFIELDS (type) == 0))
{
/* If we just printed a tag name, no need to print anything else. */
if (TYPE_TAG_NAME (type) == NULL)