GDB (API)
/home/stan/gdb/src/gdb/btrace.h
Go to the documentation of this file.
00001 /* Branch trace support for GDB, the GNU debugger.
00002 
00003    Copyright (C) 2013 Free Software Foundation, Inc.
00004 
00005    Contributed by Intel Corp. <markus.t.metzger@intel.com>.
00006 
00007    This file is part of GDB.
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 3 of the License, or
00012    (at your option) any later version.
00013 
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018 
00019    You should have received a copy of the GNU General Public License
00020    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00021 
00022 #ifndef BTRACE_H
00023 #define BTRACE_H
00024 
00025 /* Branch tracing (btrace) is a per-thread control-flow execution trace of the
00026    inferior.  For presentation purposes, the branch trace is represented as a
00027    list of sequential control-flow blocks, one such list per thread.  */
00028 
00029 #include "btrace-common.h"
00030 
00031 struct thread_info;
00032 
00033 /* A branch trace instruction.
00034 
00035    This represents a single instruction in a branch trace.  */
00036 struct btrace_inst
00037 {
00038   /* The address of this instruction.  */
00039   CORE_ADDR pc;
00040 };
00041 
00042 /* A branch trace function.
00043 
00044    This represents a function segment in a branch trace, i.e. a consecutive
00045    number of instructions belonging to the same function.  */
00046 struct btrace_func
00047 {
00048   /* The full and minimal symbol for the function.  One of them may be NULL.  */
00049   struct minimal_symbol *msym;
00050   struct symbol *sym;
00051 
00052   /* The source line range of this function segment (both inclusive).  */
00053   int lbegin, lend;
00054 
00055   /* The instruction number range in the instruction trace corresponding
00056      to this function segment (both inclusive).  */
00057   unsigned int ibegin, iend;
00058 };
00059 
00060 /* Branch trace may also be represented as a vector of:
00061 
00062    - branch trace instructions starting with the oldest instruction.
00063    - branch trace functions starting with the oldest function.  */
00064 typedef struct btrace_inst btrace_inst_s;
00065 typedef struct btrace_func btrace_func_s;
00066 
00067 /* Define functions operating on branch trace vectors.  */
00068 DEF_VEC_O (btrace_inst_s);
00069 DEF_VEC_O (btrace_func_s);
00070 
00071 /* Branch trace iteration state for "record instruction-history".  */
00072 struct btrace_insn_iterator
00073 {
00074   /* The instruction index range from begin (inclusive) to end (exclusive)
00075      that has been covered last time.
00076      If end < begin, the branch trace has just been updated.  */
00077   unsigned int begin;
00078   unsigned int end;
00079 };
00080 
00081 /* Branch trace iteration state for "record function-call-history".  */
00082 struct btrace_func_iterator
00083 {
00084   /* The function index range from begin (inclusive) to end (exclusive)
00085      that has been covered last time.
00086      If end < begin, the branch trace has just been updated.  */
00087   unsigned int begin;
00088   unsigned int end;
00089 };
00090 
00091 /* Branch trace information per thread.
00092 
00093    This represents the branch trace configuration as well as the entry point
00094    into the branch trace data.  For the latter, it also contains the index into
00095    an array of branch trace blocks used for iterating though the branch trace
00096    blocks of a thread.  */
00097 struct btrace_thread_info
00098 {
00099   /* The target branch trace information for this thread.
00100 
00101      This contains the branch trace configuration as well as any
00102      target-specific information necessary for implementing branch tracing on
00103      the underlying architecture.  */
00104   struct btrace_target_info *target;
00105 
00106   /* The current branch trace for this thread.  */
00107   VEC (btrace_block_s) *btrace;
00108   VEC (btrace_inst_s) *itrace;
00109   VEC (btrace_func_s) *ftrace;
00110 
00111   /* The instruction history iterator.  */
00112   struct btrace_insn_iterator insn_iterator;
00113 
00114   /* The function call history iterator.  */
00115   struct btrace_func_iterator func_iterator;
00116 };
00117 
00118 /* Enable branch tracing for a thread.  */
00119 extern void btrace_enable (struct thread_info *tp);
00120 
00121 /* Disable branch tracing for a thread.
00122    This will also delete the current branch trace data.  */
00123 extern void btrace_disable (struct thread_info *);
00124 
00125 /* Disable branch tracing for a thread during teardown.
00126    This is similar to btrace_disable, except that it will use
00127    target_teardown_btrace instead of target_disable_btrace.  */
00128 extern void btrace_teardown (struct thread_info *);
00129 
00130 /* Fetch the branch trace for a single thread.  */
00131 extern void btrace_fetch (struct thread_info *);
00132 
00133 /* Clear the branch trace for a single thread.  */
00134 extern void btrace_clear (struct thread_info *);
00135 
00136 /* Clear the branch trace for all threads when an object file goes away.  */
00137 extern void btrace_free_objfile (struct objfile *);
00138 
00139 /* Parse a branch trace xml document into a block vector.  */
00140 extern VEC (btrace_block_s) *parse_xml_btrace (const char*);
00141 
00142 #endif /* BTRACE_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines