aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.c
diff options
context:
space:
mode:
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>2024-08-22 19:42:45 -0300
committerThiago Jung Bauermann <thiago.bauermann@linaro.org>2025-01-09 22:47:21 -0300
commitad59259604f008e20490f9c82cf287d5a601a66c (patch)
tree4e99f99c286fa94b1eefe8effdcb5ebc2dbc7bbf /gdb/remote.c
parent1f493519f703220bc072538ce3586f7363eba904 (diff)
downloadbinutils-ad59259604f008e20490f9c82cf287d5a601a66c.zip
binutils-ad59259604f008e20490f9c82cf287d5a601a66c.tar.gz
binutils-ad59259604f008e20490f9c82cf287d5a601a66c.tar.bz2
GDB: trad-frame: Store length of value_bytes in trad_frame_saved_reg
The goal is to ensure that it is available in frame_unwind_got_bytes () to make sure that the provided buf isn't larger than the size of the register being provisioned. In the process, regcache's cached_reg_t::data also needed to be converted to a gdb::byte_vector, so that the register contents' size can be tracked. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/remote.c')
-rw-r--r--gdb/remote.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 8cb9050..79d91d6 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8224,16 +8224,15 @@ Packet: '%s'\n"),
Packet: '%s'\n"),
hex_string (pnum), p, buf);
+ int reg_size = register_size (event->arch, reg->regnum);
cached_reg.num = reg->regnum;
- cached_reg.data.reset ((gdb_byte *)
- xmalloc (register_size (event->arch,
- reg->regnum)));
+ cached_reg.data.resize (reg_size);
p = p1 + 1;
- fieldsize = hex2bin (p, cached_reg.data.get (),
- register_size (event->arch, reg->regnum));
+ fieldsize = hex2bin (p, cached_reg.data.data (),
+ cached_reg.data.size ());
p += 2 * fieldsize;
- if (fieldsize < register_size (event->arch, reg->regnum))
+ if (fieldsize < reg_size)
warning (_("Remote reply is too short: %s"), buf);
event->regcache.push_back (std::move (cached_reg));
@@ -8572,7 +8571,7 @@ remote_target::process_stop_reply (stop_reply_up stop_reply,
for (cached_reg_t &reg : stop_reply->regcache)
{
- regcache->raw_supply (reg.num, reg.data.get ());
+ regcache->raw_supply (reg.num, reg.data);
rs->last_seen_expedited_registers.insert (reg.num);
}
}