This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v4] gdb/python: add missing handling for anonymous members of struct and union
- From: Li Yu <raise dot sail at gmail dot com>
- To: gdb-patches at sourceware dot org
- Cc: Paul Koning <paulkoning at comcast dot net>, Tom Tromey <tromey at redhat dot com>
- Date: Tue, 18 Oct 2011 09:43:31 +0800
- Subject: Re: [PATCH v4] gdb/python: add missing handling for anonymous members of struct and union
- References: <CA+WLrf-MM2WPr6r8DLKcZP5-A6qmZst8Sxzy4u5OvrxFET5sEQ@mail.gmail.com>
Is this ready for merge into upsteam ?
thanks
Yu
ä 2011å10æ08æ 13:35, Li Yu åé:
> gdb.Type.fields() missed handling for anonymous members.
>
> This patch fix it, below are details:
>
> Assume that we have a c source as below:
>
> /////////////////////////////
> struct A
> {
> int a;
> union {
> int b0;
> int b1;
> union {
> int bb0;
> int bb1;
> union {
> int bbb0;
> int bbb1;
> };
> };
> };
> int c;
> union {
> union {
> int dd0;
> int dd1;
> };
> int d2;
> int d3;
> };
> };
>
> int main()
> {
> struct A a;
> }
> ////////////////////////////
>
> And have a python gdb script as below:
>
> ##########################
> v = gdb.parse_and_eval("a")
> t = v.type
> fields = t.fields()
> for f in fields:
> print "[%s]" % f.name, v[f.name]
> ##########################
>
> Without this patch, above script will print:
>
> [a] -7616
> [] {{dd0 = 0, dd1 = 0}, d2 = 0, d3 = 0}
> [c] 0
> [] {{dd0 = 0, dd1 = 0}, d2 = 0, d3 = 0}
>
> With this patch, above script will print rightly:
>
> [a] -7616
> [b0] 32767
> [b1] 32767
> [bb0] 32767
> [bb1] 32767
> [bbb0] 32767
> [bbb1] 32767
> [c] 0
> [dd0] 0
> [dd1] 0
> [d2] 0
> [d3] 0
>
> Thanks for Paul and Tom's feedback of this patch.
>
> This version uses recursion implementation, as we discussed, this
> patch is passed by "make check" without regression :)
>
> Signed-off-by: Li Yu <raise.sail@gmail.com>
>
> gdb/python/:
> 2011-10-8 Li Yu <raise.sail@gmail.com>
>
> * py-type.c: Add process for anonymous members of struct and union
>
> py-type.c | 41 ++++++++++++++++++++++++++++++++++-------
> 1 file changed, 34 insertions(+), 7 deletions(-)