diff options
author | Tom Tromey <tom@tromey.com> | 2017-09-23 11:21:58 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-09-29 21:12:19 -0600 |
commit | 386c8614d5e65431e977b1b20cc4642f944faca1 (patch) | |
tree | 22cdc54c0b8c61dfc6aa1da002e2fa7b2e7bdc40 /gdb/target.h | |
parent | 789c4b5ea14b0c441e6021f07503e61ccfacb427 (diff) | |
download | binutils-386c8614d5e65431e977b1b20cc4642f944faca1.zip binutils-386c8614d5e65431e977b1b20cc4642f944faca1.tar.gz binutils-386c8614d5e65431e977b1b20cc4642f944faca1.tar.bz2 |
Remove free_memory_read_result_vector
This changes read_memory_robust to return a std::vector, allowing the
removal of free_memory_read_result_vector and associated cleanups.
This patch also changes the functions it touches to be a bit more
robust with regards to deallocation; it's perhaps possible that
read_memory_robust could have leaked in some situations.
This patch is based on my earlier series to remove some MI cleanups.
Regression tested by the buildbot.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* target.c (read_whatever_is_readable): Change type of "result".
Update.
(free_memory_read_result_vector): Remove.
(read_memory_robust): Change return type. Update.
* mi/mi-main.c (mi_cmd_data_read_memory_bytes): Update. Use
bin2hex, std::string.
* target.h (memory_read_result_s): Remove typedef.
(free_memory_read_result_vector): Remove.
(read_memory_robust): Return std::vector.
Diffstat (limited to 'gdb/target.h')
-rw-r--r-- | gdb/target.h | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/gdb/target.h b/gdb/target.h index 87482dc..f5ad1e5 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -287,22 +287,31 @@ extern LONGEST target_read (struct target_ops *ops, ULONGEST offset, LONGEST len); struct memory_read_result +{ + memory_read_result (ULONGEST begin_, ULONGEST end_, + gdb::unique_xmalloc_ptr<gdb_byte> &&data_) + : begin (begin_), + end (end_), + data (std::move (data_)) { - /* First address that was read. */ - ULONGEST begin; - /* Past-the-end address. */ - ULONGEST end; - /* The data. */ - gdb_byte *data; -}; -typedef struct memory_read_result memory_read_result_s; -DEF_VEC_O(memory_read_result_s); + } + + ~memory_read_result () = default; + + memory_read_result (memory_read_result &&other) = default; -extern void free_memory_read_result_vector (void *); + DISABLE_COPY_AND_ASSIGN (memory_read_result); + + /* First address that was read. */ + ULONGEST begin; + /* Past-the-end address. */ + ULONGEST end; + /* The data. */ + gdb::unique_xmalloc_ptr<gdb_byte> data; +}; -extern VEC(memory_read_result_s)* read_memory_robust (struct target_ops *ops, - const ULONGEST offset, - const LONGEST len); +extern std::vector<memory_read_result> read_memory_robust + (struct target_ops *ops, const ULONGEST offset, const LONGEST len); /* Request that OPS transfer up to LEN addressable units from BUF to the target's OBJECT. When writing to a memory object, the addressable unit |