diff options
author | Joel Brobecker <brobecker@gnat.com> | 2012-10-24 18:06:10 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2012-10-24 18:06:10 +0000 |
commit | 5ded533171a924509f15f951c50d54d5c56389ca (patch) | |
tree | cd3981729249a3a1f14942f8ce97a5b9a0333c1b /gdb/testsuite/gdb.ada | |
parent | d8d842913db1aef24832f8a93d42fda6c6fc58dd (diff) | |
download | gdb-5ded533171a924509f15f951c50d54d5c56389ca.zip gdb-5ded533171a924509f15f951c50d54d5c56389ca.tar.gz gdb-5ded533171a924509f15f951c50d54d5c56389ca.tar.bz2 |
[Ada] Pointers to unconstrained arrays inside variant record.
gdb/ChangeLog:
* ada-lang.c (ada_template_to_fixed_record_type_1): Do not
strip typedef layer when computing the fixed type's field type,
only when computing its size.
gdb/testsuite/ChangeLog:
* gdb.ada/unc_arr_ptr_in_var_rec: New testcase.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r-- | gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp | 84 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/foo.adb | 51 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/pck.adb | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/pck.ads | 19 |
4 files changed, 175 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp new file mode 100644 index 0000000..dc9e863 --- /dev/null +++ b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp @@ -0,0 +1,84 @@ +# Copyright 2012 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 + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP1" ${testdir}/foo.adb] +runto "foo.adb:$bp_location" + +# Print My_Object and My_Object.Ptr when Ptr is null... + +gdb_test "print my_object" \ + "= \\(n => 3, ptr => 0x0, data => \\(3, 5, 8\\)\\)" \ + "print My_Object with null Ptr" + +gdb_test "print my_object.ptr" \ + "= \\(foo.table_access\\) 0x0" \ + "print My_Object.Ptr when null" + +# Same for My_P_Object... + +gdb_test "print my_p_object" \ + "= \\(n => 3, ptr => 0x0, data => \\(3, 5, 8\\)\\)" \ + "print My_P_Object with null Ptr" + +gdb_test "print my_p_object.ptr" \ + "\\(foo.p_table_access\\) 0x0" \ + "print My_P_Object.Ptr when null" + +# Continue until the Ptr component of both objects get allocated. + +set bp_location [gdb_get_line_number "STOP2" ${testdir}/foo.adb] + +gdb_breakpoint "foo.adb:$bp_location" + +gdb_test "continue" \ + "Breakpoint $decimal, foo \\(\\) at .*foo.adb:$decimal.*" \ + "continue to STOP2" + +# Inspect My_Object again... + +gdb_test "print my_object" \ + "= \\(n => 3, ptr => $hex, data => \\(3, 5, 8\\)\\)" \ + "print my_object after setting Ptr" + +gdb_test "print my_object.ptr" \ + "\\(foo.table_access\\) $hex" \ + "print My_P_Object.Ptr when no longer null" + +gdb_test "print my_object.ptr.all" \ + "= \\(13, 21, 34\\)" + +# Same with My_P_Object... + +gdb_test "print my_p_object" \ + "= \\(n => 3, ptr => $hex, data => \\(3, 5, 8\\)\\)" \ + "print my_p_object after setting Ptr" + +gdb_test "print my_p_object.ptr" \ + "= \\(foo.p_table_access\\) $hex" \ + "print My_P_Object.Ptr when no longer null" + +gdb_test "print my_p_object.ptr.all" \ + "\\(13, 21, 34\\)" + diff --git a/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/foo.adb b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/foo.adb new file mode 100644 index 0000000..0b5e4f2 --- /dev/null +++ b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/foo.adb @@ -0,0 +1,51 @@ +-- Copyright 2012 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 Table is array (Positive range <>) of Integer; + type Table_Access is access Table; + + type Object (N : Integer) is record + Ptr : Table_Access; + Data : Table (1 .. N); + end record; + + My_Object : Object := (N => 3, Ptr => null, Data => (3, 5, 8)); + + -- Same as above, but with a pointer to an unconstrained packed array. + + type Byte is range 0 .. 255; + + type P_Table is array (Positive range <>) of Byte; + pragma Pack (P_Table); + type P_Table_Access is access P_Table; + + type P_Object (N : Integer) is record + Ptr : P_Table_Access; + Data : P_Table (1 .. N); + end record; + + My_P_Object : P_Object := (N => 3, Ptr => null, Data => (3, 5, 8)); + +begin + My_Object.Ptr := new Table'(13, 21, 34); -- STOP1 + My_P_Object.Ptr := new P_Table'(13, 21, 34); + Do_Nothing (My_Object'Address); -- STOP2 + Do_Nothing (My_P_Object'Address); +end Foo; + diff --git a/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/pck.adb b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/pck.adb new file mode 100644 index 0000000..1f7d45c --- /dev/null +++ b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/pck.adb @@ -0,0 +1,21 @@ +-- Copyright 2012 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/unc_arr_ptr_in_var_rec/pck.ads b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/pck.ads new file mode 100644 index 0000000..c20c0d8 --- /dev/null +++ b/gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec/pck.ads @@ -0,0 +1,19 @@ +-- Copyright 2012 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; |