From ad59259604f008e20490f9c82cf287d5a601a66c Mon Sep 17 00:00:00 2001 From: Thiago Jung Bauermann Date: Thu, 22 Aug 2024 19:42:45 -0300 Subject: 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 --- gdb/python/py-unwind.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gdb/python') diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 68deaf9..c1a01bf 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -812,7 +812,7 @@ pyuw_prev_register (const frame_info_ptr &this_frame, void **cache_ptr, for (; reg_info < reg_info_end; ++reg_info) { if (regnum == reg_info->num) - return frame_unwind_got_bytes (this_frame, regnum, reg_info->data.get ()); + return frame_unwind_got_bytes (this_frame, regnum, reg_info->data); } return frame_unwind_got_optimized (this_frame, regnum); @@ -936,8 +936,9 @@ pyuw_sniffer (const struct frame_unwind *self, const frame_info_ptr &this_frame, cached_reg_t *cached = new (&cached_frame->reg[i]) cached_reg_t (); cached->num = reg->number; - cached->data.reset ((gdb_byte *) xmalloc (data_size)); - memcpy (cached->data.get (), value->contents ().data (), data_size); + cached->data.resize (data_size); + gdb::array_view contents = value->contents (); + cached->data.assign (contents.begin (), contents.end ()); } } -- cgit v1.1