aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2015-11-23 09:44:16 -0800
committerJoel Brobecker <brobecker@adacore.com>2015-11-23 09:44:16 -0800
commit155bfbd30aacd4e01a9ac8ca8032d804ed7ece47 (patch)
tree5d93d14d78e8f88d6e1ae02aaf4ada4b6d0eadda /gdb/testsuite/gdb.ada
parente49d43ff73a309548dd2b576bb7b602f62be66d6 (diff)
downloadfsf-binutils-gdb-155bfbd30aacd4e01a9ac8ca8032d804ed7ece47.zip
fsf-binutils-gdb-155bfbd30aacd4e01a9ac8ca8032d804ed7ece47.tar.gz
fsf-binutils-gdb-155bfbd30aacd4e01a9ac8ca8032d804ed7ece47.tar.bz2
gdb/dwarf2read: Minimal handling of non-constant struct sizes.
Using the gdb.ada/var_rec_arr.exp test, where the program declares an array of variant records... type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; type Array_Type is array (Integer range <>) of Record_Type; ... and then a variable A1 of type Array_Type, the following command ocassionally trigger an internal error trying to allocate more memory than we have left: (gdb) ptype a1(1) [...]/utils.c:1089: internal-error: virtual memory exhausted. A problem internal to GDB has been detected, [...] What happens is that recent versions of GNAT are able to generate DWARF expressions for type Record_Type, and therefore the record's DW_AT_byte_size is not a constant, which unfortunately breaks an assumption made by dwarf2read.c:read_structure_type when it does: attr = dwarf2_attr (die, DW_AT_byte_size, cu); if (attr) { TYPE_LENGTH (type) = DW_UNSND (attr); } As a result of this, when ada_evaluate_subexp tries to create a value_zero for a1(1) while processing the OP_FUNCALL operator as part of evaluating the subscripting operation in no-side-effect mode, we try to allocate a value with a bogus size, potentially triggering the out-of-memory internal error. This patch avoids this issue by setting the length to zero in this case. Until we decide to start supporting dynamic type lengths in GDB's type struct, and it's not clear yet that this is worth the effort (see added comment), that's probably the best we can do. gdb/ChangeLog: * dwarf2read.c (read_structure_type): Set the type's length to zero if it has a DW_AT_byte_size attribute which is not a constant. gdb/testsuite/ChangeLog: * testsuite/gdb.ada/var_rec_arr.exp: Add "ptype a1(1)" test.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/var_rec_arr.exp6
1 files changed, 6 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/var_rec_arr.exp b/gdb/testsuite/gdb.ada/var_rec_arr.exp
index 82ca857..66525e7 100644
--- a/gdb/testsuite/gdb.ada/var_rec_arr.exp
+++ b/gdb/testsuite/gdb.ada/var_rec_arr.exp
@@ -49,3 +49,9 @@ gdb_test "print a2(2)" \
gdb_test "print a2(3)" \
" = \\(i => 0, s => \"\"\\)"
+
+gdb_test "ptype a1(1)" \
+ [multi_line "type = record" \
+ " i: pck\\.small_type;" \
+ " s: access array \\((<>|1 \\.\\. i)\\) of character;" \
+ "end record"]