This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [RFC] python: gdb.Type: strip typedefs past pointers too


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'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]