Consider the following code:
type Table is array (Character) of Natural;
My_Table : Table := (others => 4874);
Printing this table in gdb leads to:
(gdb) p my_table
$1 = ('["00"]' => 4874 <repeats 256 times>)
In this case, the index of the first element in this array is also
the first element of the index type (character type). Similar to what
we do we enumeration types, we do not need to print the index of the
first element when printing the array.
This patch fixes this issue and changes the output as follow:
(gdb) p my_table
$1 = (4874 <repeats 256 times>)
gdb/ChangeLog:
* ada-valprint.c (print_optional_low_bound): Handle
character-indexed array printing like boolean-indexed array
printing.
gdb/testuite/ChangeLog:
* testsuite/gdb.ada/array_char_idx/pck.ads (Table): New type.
(My_Table): New global variable.
* testsuite/gdb.ada/array_char_idx.exp: Add test.
Tested on x86_64-linux.
+2018-01-03 Xavier Roirand <roirand@adacore.com>
+
+ * ada-valprint.c (print_optional_low_bound): Handle
+ character-indexed array printing like boolean-indexed array
+ printing.
+
2018-01-05 Joel Brobecker <brobecker@adacore.com>
* NEWS: Create a new section for the next release branch.
index_type = TYPE_TARGET_TYPE (index_type);
}
+ /* Don't print the lower bound if it's the default one. */
switch (TYPE_CODE (index_type))
{
case TYPE_CODE_BOOL:
+ case TYPE_CODE_CHAR:
if (low_bound == 0)
return 0;
break;
+2018-01-05 Xavier Roirand <brobecker@adacore.com>
+
+ * testsuite/gdb.ada/array_char_idx/pck.ads (Table): New type.
+ (My_Table): New global variable.
+ * testsuite/gdb.ada/array_char_idx.exp: Add test.
+
2018-01-04 Joel Brobecker <brobecker@adacore.com>
PR gdb/22670
gdb_test "ptype global_char_table" \
"= array \\(character\\) of natural"
+
+gdb_test "print my_table" "= \\(0 <repeats 256 times>\\)" \
+ "Display my_table"
of Natural;
Global_Char_Table : Char_Table := (others => 0);
+ type Table is array (Character) of Natural;
+ My_Table : Table := (others => 4874);
+
procedure Do_Nothing (A : System.Address);
end Pck;