This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: dwarf reader and typedefs
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 20 Mar 2009 15:54:41 -0600
- Subject: FYI: dwarf reader and typedefs
- Reply-to: tromey at redhat dot com
I'm checking this in.
This is another patch from the charset branch. After talking with
Joel on irc, I decided to scale back my efforts to split the patch up;
but this part is still relatively independent of the bulk of the
charset work, and I thought it would be good to put it in separately.
This changes the dwarf reader to give types their typedef name.
Before this patch, a lookup of "wchar_t" could yield a type whose name
was "unsigned short"; after the patch, the resulting type is a typedef
whose name is "wchar_t". This makes our internal model a bit more
consistent, and also lets gdb recognize some types by name (in
particular, wchar_t, which is a typedef in C).
The patch includes a couple other parts, to fix regressions we found
after making the dwarf2read.c change. I also did some looking with
stabs, and as far as I can tell, the stabs reader already works this
way.
This was built and regtested on x86-64 (compile farm).
Tom
2009-03-20 Tom Tromey <tromey@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c (process_die): Handle DW_TAG_typedef.
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Strip a single
typedef.
* ada-lang.c (decode_packed_array_type): Call CHECK_TYPEDEF on the
SYMBOL_TYPE result.
* ada-typeprint.c (print_array_type): Do the NULL check
unconditionally.
Index: ada-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-lang.c,v
retrieving revision 1.198
diff -u -r1.198 ada-lang.c
--- ada-lang.c 13 Mar 2009 02:30:55 -0000 1.198
+++ ada-lang.c 20 Mar 2009 21:52:38 -0000
@@ -1783,6 +1783,7 @@
return NULL;
}
shadow_type = SYMBOL_TYPE (sym);
+ CHECK_TYPEDEF (shadow_type);
if (TYPE_CODE (shadow_type) != TYPE_CODE_ARRAY)
{
Index: ada-typeprint.c
===================================================================
RCS file: /cvs/src/src/gdb/ada-typeprint.c,v
retrieving revision 1.25
diff -u -r1.25 ada-typeprint.c
--- ada-typeprint.c 19 Feb 2009 23:59:27 -0000 1.25
+++ ada-typeprint.c 20 Mar 2009 21:52:38 -0000
@@ -357,16 +357,17 @@
bitsize = 0;
fprintf_filtered (stream, "array (");
+ if (type == NULL)
+ {
+ fprintf_filtered (stream, _("<undecipherable array type>"));
+ return;
+ }
+
n_indices = -1;
if (show < 0)
fprintf_filtered (stream, "...");
else
{
- if (type == NULL)
- {
- fprintf_filtered (stream, _("<undecipherable array type>"));
- return;
- }
if (ada_is_simple_array_type (type))
{
struct type *range_desc_type =
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.296
diff -u -r1.296 dwarf2read.c
--- dwarf2read.c 9 Mar 2009 18:53:48 -0000 1.296
+++ dwarf2read.c 20 Mar 2009 21:52:39 -0000
@@ -2849,6 +2849,7 @@
case DW_TAG_base_type:
case DW_TAG_subrange_type:
+ case DW_TAG_typedef:
/* Add a typedef symbol for the type definition, if it has a
DW_AT_name. */
new_symbol (die, read_type_die (die, cu), cu);
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.106
diff -u -r1.106 eval.c
--- eval.c 21 Feb 2009 16:14:47 -0000 1.106
+++ eval.c 20 Mar 2009 21:52:39 -0000
@@ -2475,7 +2475,17 @@
if (noside == EVAL_SKIP)
goto nosideret;
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return allocate_value (exp->elts[pc + 1].type);
+ {
+ struct type *type = exp->elts[pc + 1].type;
+ /* If this is a typedef, then find its immediate target. We
+ use check_typedef to resolve stubs, but we ignore its
+ result because we do not want to dig past all
+ typedefs. */
+ check_typedef (type);
+ if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
+ type = TYPE_TARGET_TYPE (type);
+ return allocate_value (type);
+ }
else
error (_("Attempt to use a type name as an expression"));