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.
This commit is contained in:
parent
c90092fe9e
commit
18920c4226
@ -1,3 +1,7 @@
|
||||
2011-07-01 Joel Brobecker <brobecker@adacore.com>
|
||||
|
||||
* ada-exp.y (convert_char_literal): Handle typedef types.
|
||||
|
||||
2011-07-01 Joel Brobecker <brobecker@adacore.com>
|
||||
|
||||
* ada-lang.c (ada_remove_trailing_digits): Expand documentation.
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1,3 +1,7 @@
|
||||
2011-07-01 Joel Brobecker <brobecker@adacore.com>
|
||||
|
||||
* gdb.ada/char_enum: New testcase.
|
||||
|
||||
2011-07-02 Yao Qi <yao@codesourcery.com>
|
||||
|
||||
* gdb.base/dump.exp (capture_pointer_with_type): New.
|
||||
|
35
gdb/testsuite/gdb.ada/char_enum.exp
Normal file
35
gdb/testsuite/gdb.ada/char_enum.exp
Normal file
@ -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'"
|
||||
|
||||
|
23
gdb/testsuite/gdb.ada/char_enum/foo.adb
Normal file
23
gdb/testsuite/gdb.ada/char_enum/foo.adb
Normal file
@ -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;
|
22
gdb/testsuite/gdb.ada/char_enum/pck.adb
Normal file
22
gdb/testsuite/gdb.ada/char_enum/pck.adb
Normal file
@ -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;
|
||||
|
21
gdb/testsuite/gdb.ada/char_enum/pck.ads
Normal file
21
gdb/testsuite/gdb.ada/char_enum/pck.ads
Normal file
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user