This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] const array types
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Ken Werner <ken at linux dot vnet dot ibm dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 24 Sep 2010 00:37:09 +0200
- Subject: Re: [patch] const array types
- References: <201009151920.37105.ken@linux.vnet.ibm.com>
On Wed, 15 Sep 2010 19:20:37 +0200, Ken Werner wrote:
> The attached patch changes the dwarf parsing of const types. In case the const
> qualifier is applied to an array type, the element type is so qualified, not the
> array type. Comments are welcome.
I have filed now http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45765 as
I believe it could be fixed more at the DWARF producer side.
It is questionable whether it gets accepted and fixed by GCC and whether you
would like it then fixed in GDB even for older GCCs and non-GCC compilers.
I believe besides TYPE_CODE_ARRAY the same logic should be applied even to all
the fields of TYPE_CODE_STRUCT and TYPE_CODE_UNION (excluding the static
fields). While ISO C99 does not say so (or does?) GCC behaves correctly:
const struct { int x; } b1;
__typeof__ (b1.x) b2;
(gdb) ptype b1.x
type = int
^^^ = The GDB (and possibly even GCC) bug.
(gdb) ptype b2
type = const int
^^^^^^^^^ GCC is aware the element is in fact `const'.
I would find this patch OK even if it fixes only the TYPE_CODE_ARRAY.
> + while (TYPE_CODE (TYPE_TARGET_TYPE (inner_array)) == TYPE_CODE_ARRAY)
The type can be opaque and TYPE_TARGET_TYPE is then NULL. Opaque type should
not be possible to be produced for an array element but some `error' call
would be nice there.
> + make_cv_type (1, TYPE_VOLATILE (el_type), el_type, 0);
^ NULL?
I would find NULL for a pointer parameter more readable.
Thanks,
Jan