aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
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/testsuite/gdb.ada
parentc90092fe9e8d9932f59c5927c67d83c231e47407 (diff)
downloadfsf-binutils-gdb-18920c42269018b87630cab5d90ed7b323dbfd55.zip
fsf-binutils-gdb-18920c42269018b87630cab5d90ed7b323dbfd55.tar.gz
fsf-binutils-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/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/char_enum.exp35
-rw-r--r--gdb/testsuite/gdb.ada/char_enum/foo.adb23
-rw-r--r--gdb/testsuite/gdb.ada/char_enum/pck.adb22
-rw-r--r--gdb/testsuite/gdb.ada/char_enum/pck.ads21
4 files changed, 101 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/char_enum.exp b/gdb/testsuite/gdb.ada/char_enum.exp
new file mode 100644
index 0000000..b1996e3
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/char_enum.exp
@@ -0,0 +1,35 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib "ada.exp"
+
+set testdir "char_enum"
+set testfile "${testdir}/foo"
+set srcfile ${srcdir}/${subdir}/${testfile}.adb
+set binfile ${objdir}/${subdir}/${testfile}
+
+file mkdir ${objdir}/${subdir}/${testdir}
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
+runto "foo.adb:$bp_location"
+
+gdb_test "print Char_Enum_Type'('B')" "= 1 'B'"
+
+
diff --git a/gdb/testsuite/gdb.ada/char_enum/foo.adb b/gdb/testsuite/gdb.ada/char_enum/foo.adb
new file mode 100644
index 0000000..1e60214
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/char_enum/foo.adb
@@ -0,0 +1,23 @@
+-- Copyright 2011 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+with Pck; use Pck;
+
+procedure Foo is
+ type Char_Enum_Type is ('A', 'B', 'C', 'D', 'E');
+ Char : Char_Enum_Type := 'D';
+begin
+ Do_Nothing (Char'Address); -- STOP
+end Foo;
diff --git a/gdb/testsuite/gdb.ada/char_enum/pck.adb b/gdb/testsuite/gdb.ada/char_enum/pck.adb
new file mode 100644
index 0000000..01fdc3d
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/char_enum/pck.adb
@@ -0,0 +1,22 @@
+-- Copyright 2011 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package body Pck is
+ procedure Do_Nothing (A : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
+
diff --git a/gdb/testsuite/gdb.ada/char_enum/pck.ads b/gdb/testsuite/gdb.ada/char_enum/pck.ads
new file mode 100644
index 0000000..a9e3cde
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/char_enum/pck.ads
@@ -0,0 +1,21 @@
+-- Copyright 2011 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+with System;
+
+package Pck is
+ procedure Do_Nothing (A : System.Address);
+end Pck;
+