gdb/dwarf: use offset in dwarf_expr_context::read_mem
The `offset` variable is the offset within the passed-in object where
`addr` falls. We use it to verify whether `addr` falls within that
object's bounds, but then the memcpy fails to consider it, meaning that
we always copy from the beginning of the passed-in object, even if
`addr` lands in the middle of the object. Fix that by adding `offset`
to the source argument of the memcpy. I caught this by writing a patch
later in this series, so this fix is covered by the test added in that
later patch.
Also, I find it a bit odd to compute the offset of `addr` within the
passed-in object, before knowing if `addr` even lands within the
passed-in object's address range. If `addr` is before the object's
address, it does an unsigned underflow, which I guess works, but is not
really intuitive. Change it to check whether `addr` falls within the
object first, and if so, compute the offset of `addr` within the object.
Change-Id: Ibbacab6d57e693e02e2bdfec4f3a7d42d9a1bd4b
Approved-By: Tom Tromey <tom@tromey.com>
1 file changed