diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-09-16 09:12:27 -0400 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-10-02 14:05:49 +0100 |
commit | 46f29a9a260da1a03176682aff63bad03d8f2e8b (patch) | |
tree | 4fd2bb40deed8e0e8b6745bd2c6f70bab02347d0 /gdb/gdbsupport/btrace-common.c | |
parent | de4859eacb74a440d9fd61e4a0f051e3737a05dd (diff) | |
download | gdb-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/gdbsupport/btrace-common.c')
-rw-r--r-- | gdb/gdbsupport/btrace-common.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/gdb/gdbsupport/btrace-common.c b/gdb/gdbsupport/btrace-common.c index 13f1f1a..d6d3ab5 100644 --- a/gdb/gdbsupport/btrace-common.c +++ b/gdb/gdbsupport/btrace-common.c @@ -73,7 +73,8 @@ btrace_data::fini () return; case BTRACE_FORMAT_BTS: - VEC_free (btrace_block_s, variant.bts.blocks); + delete variant.bts.blocks; + variant.bts.blocks = nullptr; return; case BTRACE_FORMAT_PT: @@ -95,7 +96,7 @@ btrace_data::empty () const return true; case BTRACE_FORMAT_BTS: - return VEC_empty (btrace_block_s, variant.bts.blocks); + return variant.bts.blocks->empty (); case BTRACE_FORMAT_PT: return (variant.pt.size == 0); @@ -132,7 +133,7 @@ btrace_data_append (struct btrace_data *dst, case BTRACE_FORMAT_NONE: dst->format = BTRACE_FORMAT_BTS; - dst->variant.bts.blocks = NULL; + dst->variant.bts.blocks = new std::vector <btrace_block>; /* Fall-through. */ case BTRACE_FORMAT_BTS: @@ -141,15 +142,12 @@ btrace_data_append (struct btrace_data *dst, /* We copy blocks in reverse order to have the oldest block at index zero. */ - blk = VEC_length (btrace_block_s, src->variant.bts.blocks); + blk = src->variant.bts.blocks->size (); while (blk != 0) { - btrace_block_s *block; - - block = VEC_index (btrace_block_s, src->variant.bts.blocks, - --blk); - - VEC_safe_push (btrace_block_s, dst->variant.bts.blocks, block); + const btrace_block &block + = src->variant.bts.blocks->at (--blk); + dst->variant.bts.blocks->push_back (block); } } } |