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] |
Hello, This is a regression I noticed after introducing "set print array-indexes". Consider the code submitted in the gdb.ada/arrayidx testcase: http://sources.redhat.com/ml/gdb-patches/2005-10/msg00046.html You have an enumerated type declared, and then an array type declared using that enumerated type as its index: type Index is (One, Two, Three); type RTable is array (Index range Two .. Three) of Integer; As you see, the array type does not use the entire enumerated type range as its index, but only a subrange of it. So when printing an array of this type, such as: R_Two_Three : RTable := (2, 3); The debugger should notice that the lower bound of the array is not the first element of the enumerated type, and therefore should explicitly print the index of the first array element, like this: (gdb) print r_two_three $1 = (two => 2, 3) However, we currently get this: (gdb) print r_two_three $1 = (two => 2, 3) What happens is that GDB sees in print_optional_low_bound() that the index type is a TYPE_CODE_RANGE, failing to see that underneath there is an enumerated type. So it therefore compares the value of the low bound against 1, which it should compare it against the value of the first enumeration in the enumerated type. The underlying value of an enumerated type is typically zero, so "one" is zero, and "two" is 1. Just to make it easier to see what's after the patch, here is a copy of the switch seen in the patch: switch (TYPE_CODE (index_type)) { case TYPE_CODE_ENUM: if (low_bound == TYPE_FIELD_BITPOS (index_type, 0)) return 0; break; case TYPE_CODE_UNDEF: index_type = builtin_type_long; /* FALL THROUGH */ default: if (low_bound == 1) return 0; break; } The patch fixes this problem. It's not sufficient to fix the problem, due to another problem I eluded to when submitting gdb.ada/arrayidx.exp. But this patch will be needed. 2005-10-05 Joel Brobecker <brobecker@adacore.com> * ada-valprint.c (print_optional_low_bound): Handle properly cases where the array index type is a TYPE_CODE_RANGE. Tested on x86-linux. No regression. Thanks, -- Joel
Attachment:
ada-valprint.c.diff
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |