This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
PATCH: printing elements of typedef'ed arrays
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: PATCH: printing elements of typedef'ed arrays
- From: Elena Zannoni <ezannoni at cygnus dot com>
- Date: Thu, 9 Mar 2000 13:51:50 -0500 (EST)
[Sorry, wrong list...]
When an array is typedeffed, like in this example:
typedef long ArrayLong [10];
ArrayLong a1;
typedef struct s
{
int a;
int b;
} structure;
long a2 [10];
structure s1;
int main (void)
{
return 0;
}
Gdb cannot print individual elements of the array a1:
(gdb) p a1
$1 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
(gdb) p a1[0]
$2 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} <<<< is incorrect
(gdb) p a2
$3 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
(gdb) p a2[0]
$4 = 0
(gdb)
The following patch takes care of this.
I tested it on solaris and showed no regressions.
OK to check in?
Elena
% cvs diff -c eval.c
Index: eval.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/eval.c,v
retrieving revision 1.107
diff -c -r1.107 eval.c
*** eval.c 1999/12/11 13:52:47 1.107
--- eval.c 2000/03/09 18:36:54
***************
*** 1875,1881 ****
val =
locate_var_value
(var, block_innermost_frame (exp->elts[pc + 1].block));
! return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (var))),
val);
}
/* FALLTHROUGH */
--- 1875,1881 ----
val =
locate_var_value
(var, block_innermost_frame (exp->elts[pc + 1].block));
! return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (check_typedef (SYMBOL_TYPE (var)))),
val);
}
/* FALLTHROUGH */