gdb: Fix build failure with GCC 7
[deliverable/binutils-gdb.git] / gdb / btrace.h
index 07ed10c6ad6c07d622d3bdf8ccc8c0e3a659b107..9fde919b0639913978b0fc88a5e27235b152d994 100644 (file)
@@ -34,6 +34,8 @@
 #  include <intel-pt.h>
 #endif
 
+#include <vector>
+
 struct thread_info;
 struct btrace_function;
 
@@ -83,13 +85,6 @@ struct btrace_insn
 typedef struct btrace_insn btrace_insn_s;
 DEF_VEC_O (btrace_insn_s);
 
-/* A doubly-linked list of branch trace function segments.  */
-struct btrace_func_link
-{
-  struct btrace_function *prev;
-  struct btrace_function *next;
-};
-
 /* Flags for btrace function segments.  */
 enum btrace_function_flag
 {
@@ -140,29 +135,37 @@ enum btrace_pt_error
    We do not allow function segments without instructions otherwise.  */
 struct btrace_function
 {
+  btrace_function (struct minimal_symbol *msym_, struct symbol *sym_,
+                  unsigned int number_, unsigned int insn_offset_, int level_)
+    : msym (msym_), sym (sym_), insn_offset (insn_offset_), number (number_),
+      level (level_)
+  {
+  }
+
   /* The full and minimal symbol for the function.  Both may be NULL.  */
   struct minimal_symbol *msym;
   struct symbol *sym;
 
-  /* The previous and next segment belonging to the same function.
-     If a function calls another function, the former will have at least
-     two segments: one before the call and another after the return.  */
-  struct btrace_func_link segment;
+  /* The function segment numbers of the previous and next segment belonging to
+     the same function.  If a function calls another function, the former will
+     have at least two segments: one before the call and another after the
+     return.  Will be zero if there is no such function segment.  */
+  unsigned int prev = 0;
+  unsigned int next = 0;
 
-  /* The previous and next function in control flow order.  */
-  struct btrace_func_link flow;
-
-  /* The directly preceding function segment in a (fake) call stack.  */
-  struct btrace_function *up;
+  /* The function segment number of the directly preceding function segment in
+     a (fake) call stack.  Will be zero if there is no such function segment in
+     the record.  */
+  unsigned int up = 0;
 
   /* The instructions in this function segment.
      The instruction vector will be empty if the function segment
      represents a decode error.  */
-  VEC (btrace_insn_s) *insn;
+  VEC (btrace_insn_s) *insn = NULL;
 
   /* The error code of a decode error that led to a gap.
      Must be zero unless INSN is empty; non-zero otherwise.  */
-  int errcode;
+  int errcode = 0;
 
   /* The instruction number offset for the first instruction in this
      function segment.
@@ -170,7 +173,7 @@ struct btrace_function
      segment in control-flow order.  */
   unsigned int insn_offset;
 
-  /* The function number in control-flow order.
+  /* The 1-based function number in control-flow order.
      If INSN is empty indicating a gap in the trace due to a decode error,
      we still count the gap as a function.  */
   unsigned int number;
@@ -184,21 +187,20 @@ struct btrace_function
   int level;
 
   /* A bit-vector of btrace_function_flag.  */
-  btrace_function_flags flags;
+  btrace_function_flags flags = 0;
 };
 
-typedef struct btrace_function *btrace_fun_p;
-DEF_VEC_P (btrace_fun_p);
-
 /* A branch trace instruction iterator.  */
 struct btrace_insn_iterator
 {
-  /* The branch trace function segment containing the instruction.
-     Will never be NULL.  */
-  const struct btrace_function *function;
+  /* The branch trace information for this thread.  Will never be NULL.  */
+  const struct btrace_thread_info *btinfo;
+
+  /* The index of the function segment in BTINFO->FUNCTIONS.  */
+  unsigned int call_index;
 
   /* The index into the function segment's instruction vector.  */
-  unsigned int index;
+  unsigned int insn_index;
 };
 
 /* A branch trace function call iterator.  */
@@ -207,9 +209,8 @@ struct btrace_call_iterator
   /* The branch trace information for this thread.  Will never be NULL.  */
   const struct btrace_thread_info *btinfo;
 
-  /* The branch trace function segment.
-     This will be NULL for the iterator pointing to the end of the trace.  */
-  const struct btrace_function *function;
+  /* The index of the function segment in BTINFO->FUNCTIONS.  */
+  unsigned int index;
 };
 
 /* Branch trace iteration state for "record instruction-history".  */
@@ -331,18 +332,10 @@ struct btrace_thread_info
   /* The raw branch trace data for the below branch trace.  */
   struct btrace_data data;
 
-  /* The current branch trace for this thread (both inclusive).
-
-     The last instruction of END is the current instruction, which is not
-     part of the execution history.
-     Both will be NULL if there is no branch trace available.  If there is
-     branch trace available, both will be non-NULL.  */
-  struct btrace_function *begin;
-  struct btrace_function *end;
-
-  /* Vector of pointer to decoded function segments.  These are in execution
-     order with the first element == BEGIN and the last element == END.  */
-  VEC (btrace_fun_p) *functions;
+  /* Vector of decoded function segments in execution flow order.
+     Note that the numbering for btrace function segments starts with 1, so
+     function segment i will be at index (i - 1).  */
+  std::vector<btrace_function> functions;
 
   /* The function level offset.  When added to each function's LEVEL,
      this normalizes the function levels such that the smallest level
This page took 0.029182 seconds and 4 git commands to generate.