aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-exp.y
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-07-01 18:25:17 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-07-01 18:25:17 +0000
commit18920c42269018b87630cab5d90ed7b323dbfd55 (patch)
tree2ec74f0260fb2958393f00d98094e9b1466f3dc6 /gdb/ada-exp.y
parentc90092fe9e8d9932f59c5927c67d83c231e47407 (diff)
downloadgdb-18920c42269018b87630cab5d90ed7b323dbfd55.zip
gdb-18920c42269018b87630cab5d90ed7b323dbfd55.tar.gz
gdb-18920c42269018b87630cab5d90ed7b323dbfd55.tar.bz2
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.
Diffstat (limited to 'gdb/ada-exp.y')
-rw-r--r--gdb/ada-exp.y6
1 files changed, 5 insertions, 1 deletions
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)
{