aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbsupport
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/gdbsupport
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/gdbsupport')
-rw-r--r--gdb/gdbsupport/btrace-common.c18
-rw-r--r--gdb/gdbsupport/btrace-common.h17
2 files changed, 19 insertions, 16 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);
}
}
}
diff --git a/gdb/gdbsupport/btrace-common.h b/gdb/gdbsupport/btrace-common.h
index 0b18924..9c57645 100644
--- a/gdb/gdbsupport/btrace-common.h
+++ b/gdb/gdbsupport/btrace-common.h
@@ -43,11 +43,15 @@ struct btrace_block
/* The address of the first byte of the last instruction in the block. */
CORE_ADDR end;
-};
-/* Define functions operating on a vector of branch trace blocks. */
-typedef struct btrace_block btrace_block_s;
-DEF_VEC_O (btrace_block_s);
+ /* Simple constructor. */
+ btrace_block (CORE_ADDR begin, CORE_ADDR end)
+ : begin (begin),
+ end (end)
+ {
+ /* Nothing. */
+ }
+};
/* Enumeration of btrace formats. */
@@ -137,8 +141,9 @@ struct btrace_config
struct btrace_data_bts
{
/* Branch trace is represented as a vector of branch trace blocks starting
- with the most recent block. */
- VEC (btrace_block_s) *blocks;
+ with the most recent block. This needs to be a pointer as we place
+ btrace_data_bts into a union. */
+ std::vector <btrace_block> *blocks;
};
/* Configuration information to go with the trace data. */