Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] ptype: show members of an unnamed struct inside an union
Date: Fri, 24 Aug 2007 16:02:00 -0000	[thread overview]
Message-ID: <46CF00DB.6050100@linux.vnet.ibm.com> (raw)
In-Reply-To: <20070824155210.GN7552@adacore.com>

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joel

Here's a testcase. In order to see the issue, do the following:

1. Compile it with -g flag
2. Run gdb
3. b main
4. ptype struct my_page

You'll see:

type = struct my_page {
    union {
        struct {...};
    };
}

Using the proposed patch, you'll see:


type = struct my_page {
    union {
        struct {int mapping; };
    };
}

If you want, you may use a more complex union, such as:

struct my_page {
       union {
           struct {
               int mapping;
               long foo;
               char *pointer;
           };
           struct {
               char blah;
               int test;
           };
           struct {
               char blahblah;
           };
           struct {
           };
       };
};

Any questions, feel free to contact me.

Thanks and regards,

- --
Carlos Eduardo Seo
Software Engineer
IBM Linux Technology Center



Joel Brobecker wrote:
> Carlos,
>
>> The attached patched fixes an issue described on this post:
>>
>> http://sourceware.org/ml/gdb-patches/2002-04/msg01114.html
>
>> 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.
>
> Could you add a testcase for this issue? Being new at reviewing
> other people's patches, it's sometimes hard for me to understand
> what you are trying to do. A testcase would help in two ways: not
> only ensure that we do not regress in the future, but also help
> me understand clearly what it is that we're trying to fix.
>
> Thank you!
>
>> 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)
>


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGzwDaqvq7Aov/qQARArN6AJ9i06xbZqjUGhRXRZg5LReVZtmi6gCghOZB
PgEYEpPTi3YfX6rXvQoXlZY=
=sCUb
-----END PGP SIGNATURE-----


[-- Attachment #2: mypage.c --]
[-- Type: text/plain, Size: 149 bytes --]

struct my_page {
       union {
           struct {
               int mapping;
           };
       };
};

main()
{
       struct my_page mypage;
}

[-- Attachment #3: mypage.c.sig --]
[-- Type: application/octet-stream, Size: 65 bytes --]

  reply	other threads:[~2007-08-24 16:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-16 22:39 Carlos Eduardo Seo
2007-08-24 15:48 ` Joel Brobecker
2007-08-24 16:02   ` Carlos Eduardo Seo [this message]
2007-08-24 17:39     ` Joel Brobecker
2007-08-28 17:14 ` Joel Brobecker
2007-08-28 19:03   ` Luis Machado
2007-08-28 20:04     ` Joel Brobecker
2007-08-28 20:12       ` Carlos Eduardo Seo
2007-08-28 20:34         ` Joel Brobecker
2007-08-29  2:56           ` Daniel Jacobowitz
2007-08-29  4:36             ` Joel Brobecker
2007-08-29 16:30               ` Daniel Jacobowitz
2007-08-29 18:32                 ` Joel Brobecker
2007-08-29 18:36                   ` Daniel Jacobowitz
2007-08-29 18:48                     ` Joel Brobecker
2007-08-29 18:50                       ` Carlos Eduardo Seo
2007-08-29 20:14                       ` Carlos Eduardo Seo
2007-08-29 20:23                         ` Daniel Jacobowitz
2007-08-29 20:26                           ` Carlos Eduardo Seo
2007-08-29 20:41                             ` Joel Brobecker
2007-08-29 20:44                               ` Daniel Jacobowitz
2007-08-29 21:01                                 ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46CF00DB.6050100@linux.vnet.ibm.com \
    --to=cseo@linux.vnet.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox