diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 605eb39972..437dbc20d0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2015-11-23 Joel Brobecker + + * 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. + 2015-11-23 Tristan Gingold * darwin-nat.c (darwin_ptrace): Avoid a cast. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 48921e78bf..298757cde6 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -13218,7 +13218,20 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) attr = dwarf2_attr (die, DW_AT_byte_size, cu); if (attr) { - TYPE_LENGTH (type) = DW_UNSND (attr); + if (attr_form_is_constant (attr)) + TYPE_LENGTH (type) = DW_UNSND (attr); + else + { + /* For the moment, dynamic type sizes are not supported + by GDB's struct type. The actual size is determined + on-demand when resolving the type of a given object, + so set the type's length to zero for now. Otherwise, + we record an expression as the length, and that expression + could lead to a very large value, which could eventually + lead to us trying to allocate that much memory when creating + a value of that type. */ + TYPE_LENGTH (type) = 0; + } } else { diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 68ede89f56..ee01eb66b4 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-11-23 Joel Brobecker + + * testsuite/gdb.ada/var_rec_arr.exp: Add "ptype a1(1)" test. + 2015-11-20 Jose E. Marchesi * gdb.base/callfuncs.exp (fetch_all_registers): Filter out the diff --git a/gdb/testsuite/gdb.ada/var_rec_arr.exp b/gdb/testsuite/gdb.ada/var_rec_arr.exp index 82ca8572b4..66525e7828 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"]