aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-main.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-10-16 10:14:53 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2017-10-16 11:07:18 -0400
commita79b1bc6f690f3d146a3caddabd9f13a886c856a (patch)
treea80d8994788044e3c175bb974b2893352b065db5 /gdb/mi/mi-main.c
parent63f0e930d4667eb7dbc95c78f770cd58acd328ef (diff)
downloadgdb-a79b1bc6f690f3d146a3caddabd9f13a886c856a.zip
gdb-a79b1bc6f690f3d146a3caddabd9f13a886c856a.tar.gz
gdb-a79b1bc6f690f3d146a3caddabd9f13a886c856a.tar.bz2
Get rid of VEC(mem_range_s)
This patch replaces the last usages of VEC(mem_range_s) with std::vector<mem_range>. This allows getting rid of a few cleanups and of the DEF_VEC_O(mem_range_s). I added a test for normalize_mem_ranges to make sure I didn't break anything there. Regtested on the buildbot. gdb/ChangeLog: * memrange.h (struct mem_range): Define operator< and operator==. (mem_range_s): Remove. (DEF_VEC_O (mem_range_s)): Remove. (normalize_mem_ranges): Change parameter type to std::vector. * memrange.c (compare_mem_ranges): Remove. (normalize_mem_ranges): Change parameter type to std::vector, adjust to vector change. * exec.c (section_table_available_memory): Return vector, remove parameter. (section_table_read_available_memory): Adjust to std::vector change. * remote.c (remote_read_bytes): Adjust to std::vector change. * tracepoint.h (traceframe_available_memory): Change parameter type to std::vector. * tracepoint.c (traceframe_available_memory): Change parameter type to std::vector, adjust. * gdb/mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to std::vector change. * gdb/Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/memrange-selftests.c. (SUBDIR_UNITTESTS_OBS): Add memrange-selftests.o. * gdb/unittests/memrange-selftests.c: New file.
Diffstat (limited to 'gdb/mi/mi-main.c')
-rw-r--r--gdb/mi/mi-main.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index a94e329..8dc955d 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2752,40 +2752,34 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc)
/* Memory. */
{
- struct cleanup *cleanups;
- VEC(mem_range_s) *available_memory = NULL;
- struct mem_range *r;
- int i;
+ std::vector<mem_range> available_memory;
traceframe_available_memory (&available_memory, 0, ULONGEST_MAX);
- cleanups = make_cleanup (VEC_cleanup(mem_range_s), &available_memory);
ui_out_emit_list list_emitter (uiout, "memory");
- for (i = 0; VEC_iterate (mem_range_s, available_memory, i, r); i++)
+ for (const mem_range &r : available_memory)
{
struct gdbarch *gdbarch = target_gdbarch ();
ui_out_emit_tuple tuple_emitter (uiout, NULL);
- uiout->field_core_addr ("address", gdbarch, r->start);
- uiout->field_int ("length", r->length);
+ uiout->field_core_addr ("address", gdbarch, r.start);
+ uiout->field_int ("length", r.length);
- gdb::byte_vector data (r->length);
+ gdb::byte_vector data (r.length);
if (memory_contents)
{
- if (target_read_memory (r->start, data.data (), r->length) == 0)
+ if (target_read_memory (r.start, data.data (), r.length) == 0)
{
- std::string data_str = bin2hex (data.data (), r->length);
+ std::string data_str = bin2hex (data.data (), r.length);
uiout->field_string ("contents", data_str.c_str ());
}
else
uiout->field_skip ("contents");
}
}
-
- do_cleanups (cleanups);
}
}