diff options
author | Alan Hayward <alan.hayward@arm.com> | 2017-01-18 15:15:50 +0000 |
---|---|---|
committer | Alan Hayward <alan.hayward@arm.com> | 2017-01-18 15:17:55 +0000 |
commit | d1dff2266d29c4739aee6f68c8c587d44b03a717 (patch) | |
tree | 2433b48863c8ad6f05aa6d7b6f0d9d488dbcde82 | |
parent | 9890e4338dcabf4512b4856b09511f25c81d10f1 (diff) | |
download | gdb-d1dff2266d29c4739aee6f68c8c587d44b03a717.zip gdb-d1dff2266d29c4739aee6f68c8c587d44b03a717.tar.gz gdb-d1dff2266d29c4739aee6f68c8c587d44b03a717.tar.bz2 |
Allocate data in cached_reg_t
2017-01-18 Alan Hayward <alan.hayward@arm.com>
* remote.c (struct cached_reg): Change data into a pointer.
* (stop_reply_dtr): Free data pointers before deleting vector.
(process_stop_reply): Likewise.
(remote_parse_stop_reply): Allocate space for data
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/remote.c | 24 |
2 files changed, 25 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8942e25..9e1e67d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2017-01-18 Alan Hayward <alan.hayward@arm.com> + * remote.c (struct cached_reg): Change data into a pointer. + * (stop_reply_dtr): Free data pointers before deleting vector. + (process_stop_reply): Likewise. + (remote_parse_stop_reply): Allocate space for data + +2017-01-18 Alan Hayward <alan.hayward@arm.com> + * amd64-tdep.c (amd64_pseudo_register_read_value): remove MAX_REGISTER_SIZE. (amd64_pseudo_register_read_value): Likewise. diff --git a/gdb/remote.c b/gdb/remote.c index b81bb2f..c4cec91 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -6311,7 +6311,7 @@ remote_console_output (char *msg) typedef struct cached_reg { int num; - gdb_byte data[MAX_REGISTER_SIZE]; + gdb_byte *data; } cached_reg_t; DEF_VEC_O(cached_reg_t); @@ -6407,6 +6407,13 @@ static void stop_reply_dtr (struct notif_event *event) { struct stop_reply *r = (struct stop_reply *) event; + cached_reg_t *reg; + int ix; + + for (ix = 0; + VEC_iterate (cached_reg_t, r->regcache, ix, reg); + ix++) + xfree (reg->data); VEC_free (cached_reg_t, r->regcache); } @@ -6979,6 +6986,7 @@ Packet: '%s'\n"), { struct packet_reg *reg = packet_reg_from_pnum (rsa, pnum); cached_reg_t cached_reg; + struct gdbarch *gdbarch = target_gdbarch (); if (reg == NULL) error (_("Remote sent bad register number %s: %s\n\ @@ -6986,14 +6994,14 @@ Packet: '%s'\n"), hex_string (pnum), p, buf); cached_reg.num = reg->regnum; + cached_reg.data = (gdb_byte *) + xmalloc (register_size (gdbarch, reg->regnum)); p = p1 + 1; fieldsize = hex2bin (p, cached_reg.data, - register_size (target_gdbarch (), - reg->regnum)); + register_size (gdbarch, reg->regnum)); p += 2 * fieldsize; - if (fieldsize < register_size (target_gdbarch (), - reg->regnum)) + if (fieldsize < register_size (gdbarch, reg->regnum)) warning (_("Remote reply is too short: %s"), buf); VEC_safe_push (cached_reg_t, event->regcache, &cached_reg); @@ -7214,9 +7222,13 @@ process_stop_reply (struct stop_reply *stop_reply, int ix; for (ix = 0; - VEC_iterate(cached_reg_t, stop_reply->regcache, ix, reg); + VEC_iterate (cached_reg_t, stop_reply->regcache, ix, reg); ix++) + { regcache_raw_supply (regcache, reg->num, reg->data); + xfree (reg->data); + } + VEC_free (cached_reg_t, stop_reply->regcache); } |