From cac0dc8f4b0688771a4ab8a4012fceb1323167f1 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Sat, 19 Apr 2014 22:19:02 -0700 Subject: [PATCH] Add gdb.ada/dyn_arrayidx testcase. This add a testcases that verifies correct handling of dynamicity for lower bounds of arrays. gdb/testsuite/ChangeLog: * gdb.ada/dyn_arrayidx: New testcase. --- gdb/testsuite/ChangeLog | 4 +++ gdb/testsuite/gdb.ada/dyn_arrayidx.exp | 36 ++++++++++++++++++++++ gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb | 32 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 gdb/testsuite/gdb.ada/dyn_arrayidx.exp create mode 100644 gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 5bb89a2fa36..8078a423fda 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-04-28 Joel Brobecker + + * gdb.ada/dyn_arrayidx: New testcase. + 2014-04-26 Yao Qi * gdb.dwarf2/dwz.exp: Compile main.c to object. Restart GDB diff --git a/gdb/testsuite/gdb.ada/dyn_arrayidx.exp b/gdb/testsuite/gdb.ada/dyn_arrayidx.exp new file mode 100644 index 00000000000..04c39b0da8a --- /dev/null +++ b/gdb/testsuite/gdb.ada/dyn_arrayidx.exp @@ -0,0 +1,36 @@ +# 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 . + +load_lib "ada.exp" + +if { [skip_ada_tests] } { return -1 } + +standard_ada_testfile foo + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb] +runto "foo.adb:$bp_location" + +# Make sure we do not use any of the descriptive types, even if +# the compiler generated them. +gdb_test_no_output "maintenance set ada ignore-descriptive-types" + +gdb_test "ptype array_type" \ + " = array \\(5 \\.\\. 10\\) of natural" \ diff --git a/gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb b/gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb new file mode 100644 index 00000000000..4deb04d8235 --- /dev/null +++ b/gdb/testsuite/gdb.ada/dyn_arrayidx/foo.adb @@ -0,0 +1,32 @@ +-- 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 . + +procedure Foo is + function Range_Count (L, U : Integer) return Natural + is + type Array_Type is array (L .. U) of Natural; + A : Array_Type := (others => 1); + Result : Natural := 0; + begin + for I of A loop -- START + Result := Result + I; + end loop; + return Result; + end Range_Count; + + R2 : constant Natural := Range_Count (5, 10); +begin + null; +end Foo; -- 2.30.2