aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2019-09-16 09:12:27 -0400
committerAndrew Burgess <andrew.burgess@embecosm.com>2019-10-02 14:05:49 +0100
commit46f29a9a260da1a03176682aff63bad03d8f2e8b (patch)
tree4fd2bb40deed8e0e8b6745bd2c6f70bab02347d0 /gdb/nat
parentde4859eacb74a440d9fd61e4a0f051e3737a05dd (diff)
downloadgdb-46f29a9a260da1a03176682aff63bad03d8f2e8b.zip
gdb-46f29a9a260da1a03176682aff63bad03d8f2e8b.tar.gz
gdb-46f29a9a260da1a03176682aff63bad03d8f2e8b.tar.bz2
gdb: Remove a VEC from gdbsupport/btrace-common.h
Converts a VEC into a std::vector in gdbsupport/btrace-common.h. This commit just performs a mechanical conversion and doesn't do any refactoring. One consequence of this is that the std::vector must actually be a pointer to std::vector as it is placed within a union. It might be possible in future to refactor to a class hierarchy and remove the need for a union, but I'd rather have that be a separate change to make it easier to see the evolution of the code. gdb/ChangeLog: * btrace.c (btrace_compute_ftrace_bts): Update for std::vector, make accesses into the vector constant references. (btrace_add_pc): Update for std::vector. (btrace_stitch_bts): Likewise. (parse_xml_btrace_block): Likewise. (btrace_maint_update_packets): Likewise. (btrace_maint_print_packets): Likewise. (maint_info_btrace_cmd): Likewise. * gdbsupport/btrace-common.c (btrace_data::fini): Update for std::vector. (btrace_data::empty): Likewise. (btrace_data_append): Likewise. * gdbsupport/btrace-common.h: Remove use of DEF_VEC_O. (typedef btrace_block_s): Delete. (struct btrace_block): Add constructor. (struct btrace_data_bts) <blocks>: Change to std::vector. * nat/linux-btrace.c (perf_event_read_bts): Update for std::vector. (linux_read_bts): Likewise. gdb/gdbserver/ChangeLog: * linux-low.c (linux_low_read_btrace): Update for change to std::vector.
Diffstat (limited to 'gdb/nat')
-rw-r--r--gdb/nat/linux-btrace.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 8625291..a63973d 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -271,11 +271,11 @@ perf_event_sample_ok (const struct perf_event_sample *sample)
In case the buffer overflows during sampling, one sample may have its lower
part at the end and its upper part at the beginning of the buffer. */
-static VEC (btrace_block_s) *
+static std::vector <btrace_block> *
perf_event_read_bts (struct btrace_target_info* tinfo, const uint8_t *begin,
const uint8_t *end, const uint8_t *start, size_t size)
{
- VEC (btrace_block_s) *btrace = NULL;
+ std::vector <btrace_block> *btrace = new std::vector <btrace_block>;
struct perf_event_sample sample;
size_t read = 0;
struct btrace_block block = { 0, 0 };
@@ -343,7 +343,7 @@ perf_event_read_bts (struct btrace_target_info* tinfo, const uint8_t *begin,
/* We found a valid sample, so we can complete the current block. */
block.begin = psample->bts.to;
- VEC_safe_push (btrace_block_s, btrace, &block);
+ btrace->push_back (block);
/* Start the next block. */
block.end = psample->bts.from;
@@ -354,7 +354,7 @@ perf_event_read_bts (struct btrace_target_info* tinfo, const uint8_t *begin,
reading delta trace, we can fill in the start address later on.
Otherwise we will prune it. */
block.begin = 0;
- VEC_safe_push (btrace_block_s, btrace, &block);
+ btrace->push_back (block);
return btrace;
}
@@ -785,7 +785,8 @@ linux_read_bts (struct btrace_data_bts *btrace,
data_head = *pevent->data_head;
/* Delete any leftover trace from the previous iteration. */
- VEC_free (btrace_block_s, btrace->blocks);
+ delete btrace->blocks;
+ btrace->blocks = nullptr;
if (type == BTRACE_READ_DELTA)
{
@@ -843,9 +844,8 @@ linux_read_bts (struct btrace_data_bts *btrace,
/* Prune the incomplete last block (i.e. the first one of inferior execution)
if we're not doing a delta read. There is no way of filling in its zeroed
BEGIN element. */
- if (!VEC_empty (btrace_block_s, btrace->blocks)
- && type != BTRACE_READ_DELTA)
- VEC_pop (btrace_block_s, btrace->blocks);
+ if (!btrace->blocks->empty () && type != BTRACE_READ_DELTA)
+ btrace->blocks->pop_back ();
return BTRACE_ERR_NONE;
}