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.
This commit is contained in:
Simon Marchi
2017-10-16 10:14:53 -04:00
parent 63f0e930d4
commit a79b1bc6f6
10 changed files with 205 additions and 110 deletions

View File

@ -8465,7 +8465,7 @@ remote_read_bytes (struct target_ops *ops, CORE_ADDR memaddr,
if (get_traceframe_number () != -1)
{
VEC(mem_range_s) *available;
std::vector<mem_range> available;
/* If we fail to get the set of available memory, then the
target does not support querying traceframe info, and so we
@ -8473,27 +8473,20 @@ remote_read_bytes (struct target_ops *ops, CORE_ADDR memaddr,
target implements the old QTro packet then). */
if (traceframe_available_memory (&available, memaddr, len))
{
struct cleanup *old_chain;
old_chain = make_cleanup (VEC_cleanup(mem_range_s), &available);
if (VEC_empty (mem_range_s, available)
|| VEC_index (mem_range_s, available, 0)->start != memaddr)
if (available.empty () || available[0].start != memaddr)
{
enum target_xfer_status res;
/* Don't read into the traceframe's available
memory. */
if (!VEC_empty (mem_range_s, available))
if (!available.empty ())
{
LONGEST oldlen = len;
len = VEC_index (mem_range_s, available, 0)->start - memaddr;
len = available[0].start - memaddr;
gdb_assert (len <= oldlen);
}
do_cleanups (old_chain);
/* This goes through the topmost target again. */
res = remote_xfer_live_readonly_partial (ops, myaddr, memaddr,
len, unit_size, xfered_len);
@ -8512,9 +8505,7 @@ remote_read_bytes (struct target_ops *ops, CORE_ADDR memaddr,
case the target implements the deprecated QTro packet to
cater for older GDBs (the target's knowledge of read-only
sections may be outdated by now). */
len = VEC_index (mem_range_s, available, 0)->length;
do_cleanups (old_chain);
len = available[0].length;
}
}