mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 06:17:47 +08:00
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.
This commit is contained in:

committed by
Simon Marchi

parent
d0d292a274
commit
4cdd21a8d3
@ -1,3 +1,15 @@
|
|||||||
|
2017-10-14 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2017-10-14 Simon Marchi <simon.marchi@polymtl.ca>
|
2017-10-14 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* tracepoint.h (struct traceframe_info) <tvars>: Change type to
|
* tracepoint.h (struct traceframe_info) <tvars>: Change type to
|
||||||
|
@ -1663,14 +1663,14 @@ ctf_traceframe_info (struct target_ops *self)
|
|||||||
= bt_ctf_get_top_level_scope (event,
|
= bt_ctf_get_top_level_scope (event,
|
||||||
BT_EVENT_FIELDS);
|
BT_EVENT_FIELDS);
|
||||||
const struct bt_definition *def;
|
const struct bt_definition *def;
|
||||||
struct mem_range *r;
|
|
||||||
|
|
||||||
r = VEC_safe_push (mem_range_s, info->memory, NULL);
|
|
||||||
def = bt_ctf_get_field (event, scope, "address");
|
def = bt_ctf_get_field (event, scope, "address");
|
||||||
r->start = bt_ctf_get_uint64 (def);
|
CORE_ADDR start = bt_ctf_get_uint64 (def);
|
||||||
|
|
||||||
def = bt_ctf_get_field (event, scope, "length");
|
def = bt_ctf_get_field (event, scope, "length");
|
||||||
r->length = (uint16_t) bt_ctf_get_uint64 (def);
|
int length = (uint16_t) bt_ctf_get_uint64 (def);
|
||||||
|
|
||||||
|
info->memory.emplace_back (start, length);
|
||||||
}
|
}
|
||||||
else if (strcmp (name, "tsv") == 0)
|
else if (strcmp (name, "tsv") == 0)
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,12 @@
|
|||||||
|
|
||||||
struct mem_range
|
struct mem_range
|
||||||
{
|
{
|
||||||
|
mem_range () = default;
|
||||||
|
|
||||||
|
mem_range (CORE_ADDR start_, int length_)
|
||||||
|
: start (start_), length (length_)
|
||||||
|
{}
|
||||||
|
|
||||||
/* Lowest address in the range. */
|
/* Lowest address in the range. */
|
||||||
CORE_ADDR start;
|
CORE_ADDR start;
|
||||||
|
|
||||||
|
@ -1050,7 +1050,6 @@ build_traceframe_info (char blocktype, void *data)
|
|||||||
{
|
{
|
||||||
case 'M':
|
case 'M':
|
||||||
{
|
{
|
||||||
struct mem_range *r;
|
|
||||||
ULONGEST maddr;
|
ULONGEST maddr;
|
||||||
unsigned short mlen;
|
unsigned short mlen;
|
||||||
|
|
||||||
@ -1064,10 +1063,7 @@ build_traceframe_info (char blocktype, void *data)
|
|||||||
2, gdbarch_byte_order
|
2, gdbarch_byte_order
|
||||||
(target_gdbarch ()));
|
(target_gdbarch ()));
|
||||||
|
|
||||||
r = VEC_safe_push (mem_range_s, info->memory, NULL);
|
info->memory.emplace_back (maddr, mlen);
|
||||||
|
|
||||||
r->start = maddr;
|
|
||||||
r->length = mlen;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'V':
|
case 'V':
|
||||||
|
@ -196,12 +196,7 @@ current_trace_status (void)
|
|||||||
static void
|
static void
|
||||||
free_traceframe_info (struct traceframe_info *info)
|
free_traceframe_info (struct traceframe_info *info)
|
||||||
{
|
{
|
||||||
if (info != NULL)
|
delete info;
|
||||||
{
|
|
||||||
VEC_free (mem_range_s, info->memory);
|
|
||||||
|
|
||||||
delete info;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free and clear the traceframe info cache of the current
|
/* 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)
|
void *user_data, VEC(gdb_xml_value_s) *attributes)
|
||||||
{
|
{
|
||||||
struct traceframe_info *info = (struct traceframe_info *) user_data;
|
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;
|
ULONGEST *start_p, *length_p;
|
||||||
|
|
||||||
start_p
|
start_p
|
||||||
@ -4007,8 +4001,7 @@ traceframe_info_start_memory (struct gdb_xml_parser *parser,
|
|||||||
length_p
|
length_p
|
||||||
= (ULONGEST *) xml_find_attribute (attributes, "length")->value;
|
= (ULONGEST *) xml_find_attribute (attributes, "length")->value;
|
||||||
|
|
||||||
r->start = *start_p;
|
info->memory.emplace_back (*start_p, *length_p);
|
||||||
r->length = *length_p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the start of a <tvar> element. */
|
/* Handle the start of a <tvar> element. */
|
||||||
@ -4119,13 +4112,10 @@ traceframe_available_memory (VEC(mem_range_s) **result,
|
|||||||
|
|
||||||
if (info != NULL)
|
if (info != NULL)
|
||||||
{
|
{
|
||||||
struct mem_range *r;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
|
|
||||||
for (i = 0; VEC_iterate (mem_range_s, info->memory, i, r); i++)
|
for (mem_range &r : info->memory)
|
||||||
if (mem_ranges_overlap (r->start, r->length, memaddr, len))
|
if (mem_ranges_overlap (r.start, r.length, memaddr, len))
|
||||||
{
|
{
|
||||||
ULONGEST lo1, hi1, lo2, hi2;
|
ULONGEST lo1, hi1, lo2, hi2;
|
||||||
struct mem_range *nr;
|
struct mem_range *nr;
|
||||||
@ -4133,8 +4123,8 @@ traceframe_available_memory (VEC(mem_range_s) **result,
|
|||||||
lo1 = memaddr;
|
lo1 = memaddr;
|
||||||
hi1 = memaddr + len;
|
hi1 = memaddr + len;
|
||||||
|
|
||||||
lo2 = r->start;
|
lo2 = r.start;
|
||||||
hi2 = r->start + r->length;
|
hi2 = r.start + r.length;
|
||||||
|
|
||||||
nr = VEC_safe_push (mem_range_s, *result, NULL);
|
nr = VEC_safe_push (mem_range_s, *result, NULL);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
struct traceframe_info
|
struct traceframe_info
|
||||||
{
|
{
|
||||||
/* Collected memory. */
|
/* Collected memory. */
|
||||||
VEC(mem_range_s) *memory = NULL;
|
std::vector<mem_range> memory;
|
||||||
|
|
||||||
/* Collected trace state variables. */
|
/* Collected trace state variables. */
|
||||||
std::vector<int> tvars;
|
std::vector<int> tvars;
|
||||||
|
Reference in New Issue
Block a user