diff options
author | Alan Hayward <alan.hayward@arm.com> | 2017-06-22 14:09:52 +0100 |
---|---|---|
committer | Alan Hayward <alan.hayward@arm.com> | 2017-06-22 14:10:34 +0100 |
commit | 4fa847d78edd4a3901414655bd4b31234b91ba2a (patch) | |
tree | 2e3db21979a1c9f660987321ba5cfe118f1dee75 /gdb/python | |
parent | 48580982ef41907a45cda259a63d9e6878cbbea3 (diff) | |
download | fsf-binutils-gdb-4fa847d78edd4a3901414655bd4b31234b91ba2a.zip fsf-binutils-gdb-4fa847d78edd4a3901414655bd4b31234b91ba2a.tar.gz fsf-binutils-gdb-4fa847d78edd4a3901414655bd4b31234b91ba2a.tar.bz2 |
Remove MAX_REGISTER_SIZE from py-unwind.c
gdb/
* remote.c (cached_reg): Move from here...
* regcache.h (cached_reg): ...to here.
* python/py-unwind.c (struct reg_info): Remove.
(cached_frame_info): Use cached_reg_t.
(pyuw_prev_register): Likewise.
(pyuw_sniffer): Use cached_reg_t and allocate registers.
(pyuw_dealloc_cache): Free all registers.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-unwind.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index a5c2873..da1703e 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -73,15 +73,6 @@ typedef struct /* The data we keep for a frame we can unwind: frame ID and an array of (register_number, register_value) pairs. */ -struct reg_info -{ - /* Register number. */ - int number; - - /* Register data bytes pointer. */ - gdb_byte data[MAX_REGISTER_SIZE]; -}; - typedef struct { /* Frame ID. */ @@ -93,7 +84,7 @@ typedef struct /* Length of the `reg' array below. */ int reg_count; - struct reg_info reg[]; + cached_reg_t reg[]; } cached_frame_info; extern PyTypeObject pending_frame_object_type @@ -483,14 +474,14 @@ pyuw_prev_register (struct frame_info *this_frame, void **cache_ptr, int regnum) { cached_frame_info *cached_frame = (cached_frame_info *) *cache_ptr; - struct reg_info *reg_info = cached_frame->reg; - struct reg_info *reg_info_end = reg_info + cached_frame->reg_count; + cached_reg_t *reg_info = cached_frame->reg; + cached_reg_t *reg_info_end = reg_info + cached_frame->reg_count; TRACE_PY_UNWIND (1, "%s (frame=%p,...,reg=%d)\n", __FUNCTION__, this_frame, regnum); for (; reg_info < reg_info_end; ++reg_info) { - if (regnum == reg_info->number) + if (regnum == reg_info->num) return frame_unwind_got_bytes (this_frame, regnum, reg_info->data); } @@ -566,10 +557,7 @@ pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, saved_reg *reg; int i; - cached_frame - = ((cached_frame_info *) - xmalloc (sizeof (*cached_frame) - + reg_count * sizeof (cached_frame->reg[0]))); + cached_frame = XNEW (cached_frame_info); cached_frame->gdbarch = gdbarch; cached_frame->frame_id = unwind_info->frame_id; cached_frame->reg_count = reg_count; @@ -580,13 +568,14 @@ pyuw_sniffer (const struct frame_unwind *self, struct frame_info *this_frame, struct value *value = value_object_to_value (reg->value); size_t data_size = register_size (gdbarch, reg->number); - cached_frame->reg[i].number = reg->number; + cached_frame->reg[i].num = reg->number; /* `value' validation was done before, just assert. */ gdb_assert (value != NULL); gdb_assert (data_size == TYPE_LENGTH (value_type (value))); gdb_assert (data_size <= MAX_REGISTER_SIZE); + cached_frame->reg[i].data = (gdb_byte *) xmalloc (data_size); memcpy (cached_frame->reg[i].data, value_contents (value), data_size); } } @@ -601,6 +590,11 @@ static void pyuw_dealloc_cache (struct frame_info *this_frame, void *cache) { TRACE_PY_UNWIND (3, "%s: enter", __FUNCTION__); + cached_frame_info *cached_frame = (cached_frame_info *) cache; + + for (int i = 0; cached_frame->reg_count; i++) + xfree (cached_frame->reg[i].data); + xfree (cache); } |