diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2017-10-14 08:43:54 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-10-14 08:43:55 -0400 |
commit | 4cdd21a8d3fd943d6993e9d053edf09583802744 (patch) | |
tree | 23e8793e081cdccbc32fa04ae7af0b78bf4933ca /gdb/tracepoint.c | |
parent | d0d292a27402ee2d3f91d541371f134f91730373 (diff) | |
download | gdb-4cdd21a8d3fd943d6993e9d053edf09583802744.zip gdb-4cdd21a8d3fd943d6993e9d053edf09583802744.tar.gz gdb-4cdd21a8d3fd943d6993e9d053edf09583802744.tar.bz2 |
Use std::vector for traceframe_info::memory
Straightforward change from a VEC to std::vector. This allows making
the destruction of a traceframe_info trivial.
I added a constructor with parameters to mem_range to be able to
emplace_back directly with the values. It is necessary to leave a
default constructor there because mem_range is still used in a VEC.
gdb/ChangeLog:
* memrange.h (struct mem_range): Add constructors.
* tracepoint.h (struct traceframe_info) <memory>: Change type to
std::vector<mem_range>.
* tracepoint.c (free_traceframe_info): Don't manually free
vector.
(traceframe_info_start_memory): Adjust to vector change.
(traceframe_available_memory): Likewise.
* tracefile-tfile.c (build_traceframe_info): Likewise.
* ctf.c (ctf_traceframe_info): Likewise.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 2605c0a..a4a6584 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -196,12 +196,7 @@ current_trace_status (void) static void free_traceframe_info (struct traceframe_info *info) { - if (info != NULL) - { - VEC_free (mem_range_s, info->memory); - - delete info; - } + delete info; } /* Free and clear the traceframe info cache of the current @@ -3999,7 +3994,6 @@ traceframe_info_start_memory (struct gdb_xml_parser *parser, void *user_data, VEC(gdb_xml_value_s) *attributes) { struct traceframe_info *info = (struct traceframe_info *) user_data; - struct mem_range *r = VEC_safe_push (mem_range_s, info->memory, NULL); ULONGEST *start_p, *length_p; start_p @@ -4007,8 +4001,7 @@ traceframe_info_start_memory (struct gdb_xml_parser *parser, length_p = (ULONGEST *) xml_find_attribute (attributes, "length")->value; - r->start = *start_p; - r->length = *length_p; + info->memory.emplace_back (*start_p, *length_p); } /* Handle the start of a <tvar> element. */ @@ -4119,13 +4112,10 @@ traceframe_available_memory (VEC(mem_range_s) **result, if (info != NULL) { - struct mem_range *r; - int i; - *result = NULL; - for (i = 0; VEC_iterate (mem_range_s, info->memory, i, r); i++) - if (mem_ranges_overlap (r->start, r->length, memaddr, len)) + for (mem_range &r : info->memory) + if (mem_ranges_overlap (r.start, r.length, memaddr, len)) { ULONGEST lo1, hi1, lo2, hi2; struct mem_range *nr; @@ -4133,8 +4123,8 @@ traceframe_available_memory (VEC(mem_range_s) **result, lo1 = memaddr; hi1 = memaddr + len; - lo2 = r->start; - hi2 = r->start + r->length; + lo2 = r.start; + hi2 = r.start + r.length; nr = VEC_safe_push (mem_range_s, *result, NULL); |