X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fbtrace.h;h=0fcf669597a041ac9324c5fccad8ec0231c842d1;hb=8c9ae6df3c244a7a738085ab461cb098df1d46f6;hp=8fefc84da3228a21e8c335c8adf4a1184abce7a7;hpb=f158f208759703b94dbfc6de2222ae7740420faf;p=binutils-gdb.git diff --git a/gdb/btrace.h b/gdb/btrace.h index 8fefc84da32..0fcf669597a 100644 --- a/gdb/btrace.h +++ b/gdb/btrace.h @@ -1,6 +1,6 @@ /* Branch trace support for GDB, the GNU debugger. - Copyright (C) 2013-2017 Free Software Foundation, Inc. + Copyright (C) 2013-2022 Free Software Foundation, Inc. Contributed by Intel Corp. . @@ -26,9 +26,9 @@ inferior. For presentation purposes, the branch trace is represented as a list of sequential control-flow blocks, one such list per thread. */ -#include "btrace-common.h" +#include "gdbsupport/btrace-common.h" #include "target/waitstatus.h" /* For enum target_stop_reason. */ -#include "common/enum-flags.h" +#include "gdbsupport/enum-flags.h" #if defined (HAVE_LIBIPT) # include @@ -81,17 +81,6 @@ struct btrace_insn btrace_insn_flags flags; }; -/* A vector of branch trace instructions. */ -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 { @@ -142,29 +131,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; + std::vector insn; /* 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. @@ -186,7 +183,7 @@ struct btrace_function int level; /* A bit-vector of btrace_function_flag. */ - btrace_function_flags flags; + btrace_function_flags flags = 0; }; /* A branch trace instruction iterator. */ @@ -195,12 +192,11 @@ struct btrace_insn_iterator /* The branch trace information for this thread. Will never be NULL. */ const struct btrace_thread_info *btinfo; - /* The branch trace function segment containing the instruction. - Will never be NULL. */ - const struct btrace_function *function; + /* 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. */ @@ -232,7 +228,7 @@ struct btrace_call_history }; /* Branch trace thread flags. */ -enum btrace_thread_flag +enum btrace_thread_flag : unsigned { /* The thread is to be stepped forwards. */ BTHR_STEP = (1 << 0), @@ -268,9 +264,6 @@ struct btrace_pt_packet struct pt_packet packet; }; -/* Define functions operating on a vector of packets. */ -typedef struct btrace_pt_packet btrace_pt_packet_s; -DEF_VEC_O (btrace_pt_packet_s); #endif /* defined (HAVE_LIBIPT) */ /* Branch trace iteration state for "maintenance btrace packet-history". */ @@ -304,7 +297,7 @@ struct btrace_maint_info struct { /* A vector of decoded packets. */ - VEC (btrace_pt_packet_s) *packets; + std::vector *packets; /* The packet history iterator. We are iterating over the above PACKETS vector. */ @@ -332,18 +325,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. */ - std::vector 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 functions; /* The function level offset. When added to each function's LEVEL, this normalizes the function levels such that the smallest level @@ -397,8 +382,10 @@ extern void btrace_teardown (struct thread_info *); extern const char *btrace_decode_error (enum btrace_format format, int errcode); -/* Fetch the branch trace for a single thread. */ -extern void btrace_fetch (struct thread_info *); +/* Fetch the branch trace for a single thread. If CPU is not NULL, assume + CPU for trace decode. */ +extern void btrace_fetch (struct thread_info *, + const struct btrace_cpu *cpu); /* Clear the branch trace for a single thread. */ extern void btrace_clear (struct thread_info *); @@ -458,7 +445,7 @@ extern int btrace_find_insn_by_number (struct btrace_insn_iterator *, unsigned int number); /* Dereference a branch trace call iterator. Return a pointer to the - function the iterator points to or NULL if the interator points past + function the iterator points to or NULL if the iterator points past the end of the branch trace. */ extern const struct btrace_function * btrace_call_get (const struct btrace_call_iterator *); @@ -517,7 +504,4 @@ extern int btrace_is_replaying (struct thread_info *tp); /* Return non-zero if the branch trace for TP is empty; zero otherwise. */ extern int btrace_is_empty (struct thread_info *tp); -/* Create a cleanup for DATA. */ -extern struct cleanup *make_cleanup_btrace_data (struct btrace_data *data); - #endif /* BTRACE_H */