aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2loc.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-05-28 08:06:54 -0600
committerTom Tromey <tom@tromey.com>2017-07-09 10:46:49 -0600
commit0327869232a2f447474306a4d88214324d8abd40 (patch)
tree816c0a96acba61464c8df452677f1d6ddb00f9ef /gdb/dwarf2loc.c
parentf4db828807aa2ad2279b6afa582c64bb5e3153d5 (diff)
downloadgdb-0327869232a2f447474306a4d88214324d8abd40.zip
gdb-0327869232a2f447474306a4d88214324d8abd40.tar.gz
gdb-0327869232a2f447474306a4d88214324d8abd40.tar.bz2
Fix size check in dwarf2_evaluate_loc_desc_full
This Rust bug report: https://github.com/rust-lang/rust/issues/41970 noted an error from gdb. What is happening here (for me, the original report had a different error) is that a pieced DWARF expression is not writing to every byte in the resulting value. GDB errors in this case. However, it seems to me that it is always valid to write fewer bytes; the issue comes from writing too many -- that is, the test is reversed. The test was also checking the sub-object, but this also seems incorrect, as it's expected for the expression to write the entirety of the enclosing object. So, this patch reverses the test and applies it to the outer type, not the subobject type. Regtested on the buildbot. gdb/ChangeLog 2017-07-09 Tom Tromey <tom@tromey.com> * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Reverse size check and apply to outer type. gdb/testsuite/ChangeLog 2017-07-09 Tom Tromey <tom@tromey.com> * gdb.dwarf2/shortpiece.exp: New file.
Diffstat (limited to 'gdb/dwarf2loc.c')
-rw-r--r--gdb/dwarf2loc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 8506f3e..d33c83e 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2398,7 +2398,9 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
for (i = 0; i < ctx.num_pieces; ++i)
bit_size += ctx.pieces[i].size;
- if (8 * (subobj_byte_offset + TYPE_LENGTH (subobj_type)) > bit_size)
+ /* Complain if the expression is larger than the size of the
+ outer type. */
+ if (bit_size > 8 * TYPE_LENGTH (type))
invalid_synthetic_pointer ();
c = allocate_piece_closure (per_cu, ctx.num_pieces, ctx.pieces,