Wrong type for 'Length result.
Consider the following code: type Color is (Black, Red, Green, Blue, White); type Primary_Table is array (Color range Red .. Blue) of Boolean; Prim : Primary_Table := (True, False, False); GDB prints the length of arrays in a fairly odd way: (gdb) p prim'length $2 = blue The length returned should be an integer, not the array index type, and this patch fixes this. gdb/ChangeLog: * ada-lang.c (ada_evaluate_subexp): Set the type of the value returned by the 'Length attribute to integer. testsuite/ChangeLog: * gdb.ada/tick_length_array_enum_idx: New testcase.
This commit is contained in:
parent
9dee8cc6aa
commit
aa4fb036e9
|
@ -1,3 +1,8 @@
|
|||
2014-02-10 Joel Brobecker <brobecker@adacore.com>
|
||||
|
||||
* ada-lang.c (ada_evaluate_subexp): Set the type of the value
|
||||
returned by the 'Length attribute to integer.
|
||||
|
||||
2014-02-10 Joel Brobecker <brobecker@adacore.com>
|
||||
|
||||
* ada-lang.c (_initialize_ada_language): Initialize
|
||||
|
|
|
@ -10410,10 +10410,15 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
|
|||
if (ada_is_constrained_packed_array_type (value_type (arg1)))
|
||||
arg1 = ada_coerce_to_simple_array (arg1);
|
||||
|
||||
type = ada_index_type (value_type (arg1), tem,
|
||||
ada_attribute_name (op));
|
||||
if (type == NULL)
|
||||
if (op == OP_ATR_LENGTH)
|
||||
type = builtin_type (exp->gdbarch)->builtin_int;
|
||||
else
|
||||
{
|
||||
type = ada_index_type (value_type (arg1), tem,
|
||||
ada_attribute_name (op));
|
||||
if (type == NULL)
|
||||
type = builtin_type (exp->gdbarch)->builtin_int;
|
||||
}
|
||||
|
||||
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||
return allocate_value (type);
|
||||
|
@ -10466,9 +10471,14 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
|
|||
if (ada_is_constrained_packed_array_type (type_arg))
|
||||
type_arg = decode_constrained_packed_array_type (type_arg);
|
||||
|
||||
type = ada_index_type (type_arg, tem, ada_attribute_name (op));
|
||||
if (type == NULL)
|
||||
if (op == OP_ATR_LENGTH)
|
||||
type = builtin_type (exp->gdbarch)->builtin_int;
|
||||
else
|
||||
{
|
||||
type = ada_index_type (type_arg, tem, ada_attribute_name (op));
|
||||
if (type == NULL)
|
||||
type = builtin_type (exp->gdbarch)->builtin_int;
|
||||
}
|
||||
|
||||
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||
return allocate_value (type);
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2014-02-10 Joel Brobecker <brobecker@adacore.com>
|
||||
|
||||
* gdb.ada/tick_length_array_enum_idx: New testcase.
|
||||
|
||||
2014-02-10 Doug Evans <xdje42@gmail.com>
|
||||
|
||||
* configure.ac (AC_OUTPUT): Add gdb.guile.
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Copyright 2014 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"
|
||||
|
||||
standard_ada_testfile foo_n207_004
|
||||
|
||||
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } {
|
||||
return -1
|
||||
}
|
||||
|
||||
clean_restart ${testfile}
|
||||
|
||||
set bp_location [gdb_get_line_number "STOP" ${testdir}/foo_n207_004.adb]
|
||||
runto "foo_n207_004.adb:$bp_location"
|
||||
|
||||
gdb_test "print full'length" "= 5"
|
||||
gdb_test "print prim'length" "= 3"
|
||||
gdb_test "print cold'length" "= 3"
|
||||
gdb_test "print vars'length" "= 2"
|
||||
|
||||
gdb_test "ptype full'length" "type = <$decimal-byte integer>"
|
||||
gdb_test "ptype prim'length" "type = <$decimal-byte integer>"
|
||||
gdb_test "ptype cold'length" "type = <$decimal-byte integer>"
|
||||
gdb_test "ptype vars'length" "type = <$decimal-byte integer>"
|
||||
|
||||
gdb_test "ptype full_table'length" "type = <$decimal-byte integer>"
|
||||
gdb_test "ptype primary_table'length" "type = <$decimal-byte integer>"
|
||||
gdb_test "ptype variable_table'length" "type = <$decimal-byte integer>"
|
|
@ -0,0 +1,28 @@
|
|||
-- Copyright 2014 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_n207_004 is
|
||||
Full : Full_Table := (False, True, False, True, False);
|
||||
Prim : Primary_Table := (True, False, False);
|
||||
Cold : Variable_Table := (Green => False, Blue => True, White => True);
|
||||
Vars : Variable_Table := New_Variable_Table (Low => Red, High => Green);
|
||||
begin
|
||||
Do_Nothing (Full'Address); -- STOP
|
||||
Do_Nothing (Prim'Address);
|
||||
Do_Nothing (Cold'Address);
|
||||
Do_Nothing (Vars'Address);
|
||||
end Foo_n207_004;
|
|
@ -0,0 +1,34 @@
|
|||
-- Copyright 2014 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
|
||||
|
||||
function New_Variable_Table (Low: Color; High: Color) return Variable_Table
|
||||
is
|
||||
Result : Variable_Table (Low .. High);
|
||||
begin
|
||||
for J in Low .. High loop
|
||||
Result (J) := (J = Black or J = Green or J = White);
|
||||
end loop;
|
||||
return Result;
|
||||
end New_Variable_Table;
|
||||
|
||||
procedure Do_Nothing (A : System.Address) is
|
||||
begin
|
||||
null;
|
||||
end Do_Nothing;
|
||||
end Pck;
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
-- Copyright 2014 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
|
||||
type Color is (Black, Red, Green, Blue, White);
|
||||
|
||||
type Full_Table is array (Color) of Boolean;
|
||||
type Primary_Table is array (Color range Red .. Blue) of Boolean;
|
||||
type Variable_Table is array (Color range <>) of Boolean;
|
||||
|
||||
function New_Variable_Table (Low: Color; High: Color) return Variable_Table;
|
||||
|
||||
procedure Do_Nothing (A : System.Address);
|
||||
end Pck;
|
||||
|
Loading…
Reference in New Issue