From 18920c42269018b87630cab5d90ed7b323dbfd55 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Fri, 1 Jul 2011 18:25:17 +0000 Subject: handle character-based enumeration typedefs Consider the following type: type Char_Enum_Type is ('A', 'B', 'C', 'D'); If the compiler generates a Char_Enum_Type typedef in the debugging information, the debugger fails in the following case: (gdb) p Char_Enum_Type'('B') $1 = 66 For our type, the underlying value of 'B' is actually 1, not 66 (ASCII 'B'). We are failing this case because we were not handling typedef to enum types before. This patch fixes this. gdb/ChangeLog: * ada-exp.y (convert_char_literal): Handle typedef types. gdb/testsuite/ChangeLog: * gdb.ada/char_enum: New testcase. --- gdb/ada-exp.y | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gdb/ada-exp.y') diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index e64d1eb..9576be5e 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1449,8 +1449,12 @@ convert_char_literal (struct type *type, LONGEST val) char name[7]; int f; - if (type == NULL || TYPE_CODE (type) != TYPE_CODE_ENUM) + if (type == NULL) return val; + type = check_typedef (type); + if (TYPE_CODE (type) != TYPE_CODE_ENUM) + return val; + xsnprintf (name, sizeof (name), "QU%02x", (int) val); for (f = 0; f < TYPE_NFIELDS (type); f += 1) { -- cgit v1.1