+2019-08-15 Tom Tromey <tromey@adacore.com>
+
+ * ada-exp.y (convert_char_literal): Handle "Q%c" encoding.
+ * ada-lang.c (ada_enum_name): Likewise.
+
2019-08-15 Christian Biesinger <cbiesinger@google.com>
* python/lib/gdb/__init__.py (GdbOutputFile): Rename to have a
if (TYPE_CODE (type) != TYPE_CODE_ENUM)
return val;
- xsnprintf (name, sizeof (name), "QU%02x", (int) val);
+ if ((val >= 'a' && val <= 'z') || (val >= '0' && val <= '9'))
+ xsnprintf (name, sizeof (name), "Q%c", (int) val);
+ else
+ xsnprintf (name, sizeof (name), "QU%02x", (int) val);
size_t len = strlen (name);
for (f = 0; f < TYPE_NFIELDS (type); f += 1)
{
if (sscanf (name + 2, "%x", &v) != 1)
return name;
}
+ else if (((name[1] >= '0' && name[1] <= '9')
+ || (name[1] >= 'a' && name[1] <= 'z'))
+ && name[2] == '\0')
+ {
+ GROW_VECT (result, result_len, 4);
+ xsnprintf (result, result_len, "'%c'", name[1]);
+ return result;
+ }
else
return name;
+2019-08-15 Tom Tromey <tromey@adacore.com>
+
+ * gdb.ada/char_enum.exp: Add regression tests.
+ * gdb.ada/char_enum/foo.adb (Char_Enum_Type): Use '_'
+ and '0'.
+ (Char, Gchar): Update.
+ * gdb.ada/char_enum/pck.ads (Global_Enum_Type): Use '+'.
+
2019-08-15 Christian Biesinger <cbiesinger@google.com>
* gdb.python/python.exp: Expect a leading underscore on
set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
runto "foo.adb:$bp_location"
+gdb_test "ptype Char_Enum_Type" "type = \\('A', 'B', 'C', '_', '0'\\)"
gdb_test "print Char_Enum_Type'('B')" "= 1 'B'"
+gdb_test "print Char_Enum_Type'('_')" "= 3 '_'"
+gdb_test "print Char_Enum_Type'('0')" "= 4 '0'"
+gdb_test "ptype pck.Global_Enum_Type" "type = \\('x', 'Y', '\\+'\\)"
+gdb_test "print pck.Global_Enum_Type'('x')" "= 0 'x'"
gdb_test "print pck.Global_Enum_Type'('Y')" "= 1 'Y'"
+gdb_test "print pck.Global_Enum_Type'('+')" "= 2 '\\+'"
with Pck; use Pck;
procedure Foo is
- type Char_Enum_Type is ('A', 'B', 'C', 'D', 'E');
- Char : Char_Enum_Type := 'D';
- Gchar : Global_Enum_Type := 'Z';
+ type Char_Enum_Type is ('A', 'B', 'C', '_', '0');
+ Char : Char_Enum_Type := '_';
+ Gchar : Global_Enum_Type := '+';
begin
Do_Nothing (Char'Address); -- STOP
end Foo;
with System;
package Pck is
- type Global_Enum_Type is ('X', 'Y', 'Z');
+ type Global_Enum_Type is ('x', 'Y', '+');
procedure Do_Nothing (A : System.Address);
end Pck;