This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] [RFC] python: gdb.Type: strip typedefs past pointers too
- From: Andrà PÃnitz <andre dot poenitz at nokia dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 20 Sep 2010 12:14:21 +0200
- Subject: Re: [PATCH] [RFC] python: gdb.Type: strip typedefs past pointers too
- References: <1284753356.21566.10.camel@localhost.localdomain>
On Friday 17 September 2010 21:55:56 ext Paul Bolle wrote:
> 0) gdb.Type.strip_typedefs() stops stripping types if it encounters a
> type that is a pointer to a typedef:
>
> (gdb) ptype wchar_t
> type = long int
> (gdb) ptype wchar_t *
> type = long int *
Funny. What platform and gdb version is that? I seem to get 'wchar_t *'
here with 6.3, 6.8. 7.0, 7.1, and fairly recent git.
>&"ptype wchar_t\n"
>~"type = wchar_t\n"
>^done
>&"ptype wchar_t*\n"
>~"type = wchar_t *\n"
> (gdb) python print gdb.lookup_type("wchar_t").strip_typedefs()
> long int
> (gdb) python print gdb.lookup_type("wchar_t").pointer().strip_typedefs()
> wchar_t *
[This is also in my opinion correct and expected behaviour.]
> 1) I drafted a patch (pasted below this message) that works around this
> limitation:
>
> (gdb) ptype wchar_t
> type = long int
> (gdb) ptype wchar_t *
> type = long int *
> (gdb) python print gdb.lookup_type("wchar_t").strip_typedefs()
> long int
> (gdb) python print gdb.lookup_type("wchar_t").pointer().strip_typedefs()
> long int *
If you need the functionality you can provide it using a few lines of
Python by checking for type.code == gdb.TYPE_CODE_PTR and
recurse if needed.
Andre'