GDB (xrefs)
Loading...
Searching...
No Matches
Macros | Functions | Variables
btrace.c File Reference
#include "defs.h"
#include "btrace.h"
#include "gdbthread.h"
#include "inferior.h"
#include "target.h"
#include "record.h"
#include "symtab.h"
#include "disasm.h"
#include "source.h"
#include "filenames.h"
#include "regcache.h"
#include "gdbsupport/rsp-low.h"
#include "gdbcmd.h"
#include "cli/cli-utils.h"
#include "gdbarch.h"
#include "record-btrace.h"
#include <inttypes.h>
#include <ctype.h>
#include <algorithm>

Go to the source code of this file.

Macros

#define DEBUG(msg, args...)
 
#define DEBUG_FTRACE(msg, args...)   DEBUG ("[ftrace] " msg, ##args)
 

Functions

static void btrace_add_pc (struct thread_info *tp)
 
static const char * ftrace_print_function_name (const struct btrace_function *bfun)
 
static const char * ftrace_print_filename (const struct btrace_function *bfun)
 
static const char * ftrace_print_insn_addr (const struct btrace_insn *insn)
 
static void ftrace_debug (const struct btrace_function *bfun, const char *prefix)
 
static unsigned int ftrace_call_num_insn (const struct btrace_function *bfun)
 
static struct btrace_functionftrace_find_call_by_number (struct btrace_thread_info *btinfo, unsigned int number)
 
static const struct btrace_functionftrace_find_call_by_number (const struct btrace_thread_info *btinfo, unsigned int number)
 
static int ftrace_function_switched (const struct btrace_function *bfun, const struct minimal_symbol *mfun, const struct symbol *fun)
 
static struct btrace_functionftrace_new_function (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, struct symbol *fun)
 
static void ftrace_update_caller (struct btrace_function *bfun, struct btrace_function *caller, btrace_function_flags flags)
 
static void ftrace_fixup_caller (struct btrace_thread_info *btinfo, struct btrace_function *bfun, struct btrace_function *caller, btrace_function_flags flags)
 
static struct btrace_functionftrace_new_call (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, struct symbol *fun)
 
static struct btrace_functionftrace_new_tailcall (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, struct symbol *fun)
 
static struct btrace_functionftrace_get_caller (struct btrace_thread_info *btinfo, struct btrace_function *bfun)
 
static struct btrace_functionftrace_find_caller (struct btrace_thread_info *btinfo, struct btrace_function *bfun, struct minimal_symbol *mfun, struct symbol *fun)
 
static struct btrace_functionftrace_find_call (struct btrace_thread_info *btinfo, struct btrace_function *bfun)
 
static struct btrace_functionftrace_new_return (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, struct symbol *fun)
 
static struct btrace_functionftrace_new_switch (struct btrace_thread_info *btinfo, struct minimal_symbol *mfun, struct symbol *fun)
 
static struct btrace_functionftrace_new_gap (struct btrace_thread_info *btinfo, int errcode, std::vector< unsigned int > &gaps)
 
static struct btrace_functionftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc)
 
static void ftrace_update_insns (struct btrace_function *bfun, const btrace_insn &insn)
 
static enum btrace_insn_class ftrace_classify_insn (struct gdbarch *gdbarch, CORE_ADDR pc)
 
static int ftrace_match_backtrace (struct btrace_thread_info *btinfo, struct btrace_function *lhs, struct btrace_function *rhs)
 
static void ftrace_fixup_level (struct btrace_thread_info *btinfo, struct btrace_function *bfun, int adjustment)
 
static void ftrace_compute_global_level_offset (struct btrace_thread_info *btinfo)
 
static void ftrace_connect_bfun (struct btrace_thread_info *btinfo, struct btrace_function *prev, struct btrace_function *next)
 
static void ftrace_connect_backtrace (struct btrace_thread_info *btinfo, struct btrace_function *lhs, struct btrace_function *rhs)
 
static int ftrace_bridge_gap (struct btrace_thread_info *btinfo, struct btrace_function *lhs, struct btrace_function *rhs, int min_matches)
 
static void btrace_bridge_gaps (struct thread_info *tp, std::vector< unsigned int > &gaps)
 
static void btrace_compute_ftrace_bts (struct thread_info *tp, const struct btrace_data_bts *btrace, std::vector< unsigned int > &gaps)
 
static void btrace_compute_ftrace_pt (struct thread_info *tp, const struct btrace_data_pt *btrace, std::vector< unsigned int > &gaps)
 
static void btrace_compute_ftrace_1 (struct thread_info *tp, struct btrace_data *btrace, const struct btrace_cpu *cpu, std::vector< unsigned int > &gaps)
 
static void btrace_finalize_ftrace (struct thread_info *tp, std::vector< unsigned int > &gaps)
 
static void btrace_compute_ftrace (struct thread_info *tp, struct btrace_data *btrace, const struct btrace_cpu *cpu)
 
void btrace_enable (struct thread_info *tp, const struct btrace_config *conf)
 
const struct btrace_config * btrace_conf (const struct btrace_thread_info *btinfo)
 
void btrace_disable (struct thread_info *tp)
 
void btrace_teardown (struct thread_info *tp)
 
static int btrace_stitch_bts (struct btrace_data_bts *btrace, struct thread_info *tp)
 
static int btrace_stitch_trace (struct btrace_data *btrace, struct thread_info *tp)
 
static void btrace_clear_history (struct btrace_thread_info *btinfo)
 
static void btrace_maint_clear (struct btrace_thread_info *btinfo)
 
const char * btrace_decode_error (enum btrace_format format, int errcode)
 
void btrace_fetch (struct thread_info *tp, const struct btrace_cpu *cpu)
 
void btrace_clear (struct thread_info *tp)
 
void btrace_free_objfile (struct objfile *objfile)
 
const struct btrace_insnbtrace_insn_get (const struct btrace_insn_iterator *it)
 
int btrace_insn_get_error (const struct btrace_insn_iterator *it)
 
unsigned int btrace_insn_number (const struct btrace_insn_iterator *it)
 
void btrace_insn_begin (struct btrace_insn_iterator *it, const struct btrace_thread_info *btinfo)
 
void btrace_insn_end (struct btrace_insn_iterator *it, const struct btrace_thread_info *btinfo)
 
unsigned int btrace_insn_next (struct btrace_insn_iterator *it, unsigned int stride)
 
unsigned int btrace_insn_prev (struct btrace_insn_iterator *it, unsigned int stride)
 
int btrace_insn_cmp (const struct btrace_insn_iterator *lhs, const struct btrace_insn_iterator *rhs)
 
int btrace_find_insn_by_number (struct btrace_insn_iterator *it, const struct btrace_thread_info *btinfo, unsigned int number)
 
static bool btrace_ends_with_single_insn (const struct btrace_thread_info *btinfo)
 
const struct btrace_functionbtrace_call_get (const struct btrace_call_iterator *it)
 
unsigned int btrace_call_number (const struct btrace_call_iterator *it)
 
void btrace_call_begin (struct btrace_call_iterator *it, const struct btrace_thread_info *btinfo)
 
void btrace_call_end (struct btrace_call_iterator *it, const struct btrace_thread_info *btinfo)
 
unsigned int btrace_call_next (struct btrace_call_iterator *it, unsigned int stride)
 
unsigned int btrace_call_prev (struct btrace_call_iterator *it, unsigned int stride)
 
int btrace_call_cmp (const struct btrace_call_iterator *lhs, const struct btrace_call_iterator *rhs)
 
int btrace_find_call_by_number (struct btrace_call_iterator *it, const struct btrace_thread_info *btinfo, unsigned int number)
 
void btrace_set_insn_history (struct btrace_thread_info *btinfo, const struct btrace_insn_iterator *begin, const struct btrace_insn_iterator *end)
 
void btrace_set_call_history (struct btrace_thread_info *btinfo, const struct btrace_call_iterator *begin, const struct btrace_call_iterator *end)
 
int btrace_is_replaying (struct thread_info *tp)
 
int btrace_is_empty (struct thread_info *tp)
 
static void btrace_maint_update_packets (struct btrace_thread_info *btinfo, unsigned int *begin, unsigned int *end, unsigned int *from, unsigned int *to)
 
static void btrace_maint_print_packets (struct btrace_thread_info *btinfo, unsigned int begin, unsigned int end)
 
static unsigned int get_uint (const char **arg)
 
static int get_context_size (const char **arg)
 
static void no_chunk (const char *arg)
 
static void maint_btrace_packet_history_cmd (const char *arg, int from_tty)
 
static void maint_btrace_clear_packet_history_cmd (const char *args, int from_tty)
 
static void maint_btrace_clear_cmd (const char *args, int from_tty)
 
static void maint_info_btrace_cmd (const char *args, int from_tty)
 
static void show_maint_btrace_pt_skip_pad (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
 
void _initialize_btrace ()
 

Variables

static struct cmd_list_elementmaint_btrace_cmdlist
 
static struct cmd_list_elementmaint_btrace_set_cmdlist
 
static struct cmd_list_elementmaint_btrace_show_cmdlist
 
static struct cmd_list_elementmaint_btrace_pt_set_cmdlist
 
static struct cmd_list_elementmaint_btrace_pt_show_cmdlist
 
static bool maint_btrace_pt_skip_pad = true
 

Macro Definition Documentation

◆ DEBUG

#define DEBUG ( msg,
args... )
Value:
do \
{ \
if (record_debug != 0) \
gdb_printf (gdb_stdlog, \
"[btrace] " msg "\n", ##args); \
} \
while (0)
unsigned int record_debug
Definition record.c:34
#define gdb_stdlog
Definition utils.h:190

Definition at line 60 of file btrace.c.

Referenced by btrace_bridge_gaps(), btrace_clear(), btrace_compute_ftrace_1(), btrace_disable(), btrace_enable(), btrace_fetch(), btrace_free_objfile(), btrace_stitch_bts(), and btrace_teardown().

◆ DEBUG_FTRACE

#define DEBUG_FTRACE ( msg,
args... )   DEBUG ("[ftrace] " msg, ##args)

Function Documentation

◆ _initialize_btrace()

void _initialize_btrace ( )

Definition at line 3131 of file btrace.c.

Referenced by initialize_all_files().

◆ btrace_add_pc()

static void btrace_add_pc ( struct thread_info * tp)
static

◆ btrace_bridge_gaps()

static void btrace_bridge_gaps ( struct thread_info * tp,
std::vector< unsigned int > & gaps )
static

◆ btrace_call_begin()

void btrace_call_begin ( struct btrace_call_iterator * it,
const struct btrace_thread_info * btinfo )

◆ btrace_call_cmp()

int btrace_call_cmp ( const struct btrace_call_iterator * lhs,
const struct btrace_call_iterator * rhs )

Definition at line 2446 of file btrace.c.

References btrace_call_iterator::btinfo, and btrace_call_iterator::index.

Referenced by btrace_call_history().

◆ btrace_call_end()

void btrace_call_end ( struct btrace_call_iterator * it,
const struct btrace_thread_info * btinfo )

◆ btrace_call_get()

const struct btrace_function * btrace_call_get ( const struct btrace_call_iterator * it)

◆ btrace_call_next()

unsigned int btrace_call_next ( struct btrace_call_iterator * it,
unsigned int stride )

◆ btrace_call_number()

unsigned int btrace_call_number ( const struct btrace_call_iterator * it)

◆ btrace_call_prev()

unsigned int btrace_call_prev ( struct btrace_call_iterator * it,
unsigned int stride )

◆ btrace_clear()

void btrace_clear ( struct thread_info * tp)

◆ btrace_clear_history()

static void btrace_clear_history ( struct btrace_thread_info * btinfo)
static

◆ btrace_compute_ftrace()

static void btrace_compute_ftrace ( struct thread_info * tp,
struct btrace_data * btrace,
const struct btrace_cpu * cpu )
static

Definition at line 1564 of file btrace.c.

References btrace_compute_ftrace_1(), and btrace_finalize_ftrace().

Referenced by btrace_add_pc(), and btrace_fetch().

◆ btrace_compute_ftrace_1()

static void btrace_compute_ftrace_1 ( struct thread_info * tp,
struct btrace_data * btrace,
const struct btrace_cpu * cpu,
std::vector< unsigned int > & gaps )
static

Definition at line 1525 of file btrace.c.

References btrace_compute_ftrace_bts(), btrace_compute_ftrace_pt(), and DEBUG.

Referenced by btrace_compute_ftrace().

◆ btrace_compute_ftrace_bts()

static void btrace_compute_ftrace_bts ( struct thread_info * tp,
const struct btrace_data_bts * btrace,
std::vector< unsigned int > & gaps )
static

◆ btrace_compute_ftrace_pt()

static void btrace_compute_ftrace_pt ( struct thread_info * tp,
const struct btrace_data_pt * btrace,
std::vector< unsigned int > & gaps )
static

Definition at line 1510 of file btrace.c.

Referenced by btrace_compute_ftrace_1().

◆ btrace_conf()

const struct btrace_config * btrace_conf ( const struct btrace_thread_info * btinfo)

◆ btrace_decode_error()

const char * btrace_decode_error ( enum btrace_format format,
int errcode )

◆ btrace_disable()

void btrace_disable ( struct thread_info * tp)

◆ btrace_enable()

void btrace_enable ( struct thread_info * tp,
const struct btrace_config * conf )

◆ btrace_ends_with_single_insn()

static bool btrace_ends_with_single_insn ( const struct btrace_thread_info * btinfo)
static

◆ btrace_fetch()

void btrace_fetch ( struct thread_info * tp,
const struct btrace_cpu * cpu )

◆ btrace_finalize_ftrace()

static void btrace_finalize_ftrace ( struct thread_info * tp,
std::vector< unsigned int > & gaps )
static

Definition at line 1554 of file btrace.c.

References btrace_bridge_gaps().

Referenced by btrace_compute_ftrace().

◆ btrace_find_call_by_number()

int btrace_find_call_by_number ( struct btrace_call_iterator * it,
const struct btrace_thread_info * btinfo,
unsigned int number )

◆ btrace_find_insn_by_number()

int btrace_find_insn_by_number ( struct btrace_insn_iterator * it,
const struct btrace_thread_info * btinfo,
unsigned int number )

◆ btrace_free_objfile()

void btrace_free_objfile ( struct objfile * objfile)

Definition at line 2011 of file btrace.c.

References all_non_exited_threads(), btrace_clear(), and DEBUG.

Referenced by objfile::~objfile().

◆ btrace_insn_begin()

void btrace_insn_begin ( struct btrace_insn_iterator * it,
const struct btrace_thread_info * btinfo )

◆ btrace_insn_cmp()

int btrace_insn_cmp ( const struct btrace_insn_iterator * lhs,
const struct btrace_insn_iterator * rhs )

◆ btrace_insn_end()

void btrace_insn_end ( struct btrace_insn_iterator * it,
const struct btrace_thread_info * btinfo )

◆ btrace_insn_get()

const struct btrace_insn * btrace_insn_get ( const struct btrace_insn_iterator * it)

◆ btrace_insn_get_error()

int btrace_insn_get_error ( const struct btrace_insn_iterator * it)

◆ btrace_insn_next()

unsigned int btrace_insn_next ( struct btrace_insn_iterator * it,
unsigned int stride )

◆ btrace_insn_number()

unsigned int btrace_insn_number ( const struct btrace_insn_iterator * it)

◆ btrace_insn_prev()

unsigned int btrace_insn_prev ( struct btrace_insn_iterator * it,
unsigned int stride )

◆ btrace_is_empty()

int btrace_is_empty ( struct thread_info * tp)

◆ btrace_is_replaying()

int btrace_is_replaying ( struct thread_info * tp)

◆ btrace_maint_clear()

static void btrace_maint_clear ( struct btrace_thread_info * btinfo)
static

◆ btrace_maint_print_packets()

static void btrace_maint_print_packets ( struct btrace_thread_info * btinfo,
unsigned int begin,
unsigned int end )
static

◆ btrace_maint_update_packets()

static void btrace_maint_update_packets ( struct btrace_thread_info * btinfo,
unsigned int * begin,
unsigned int * end,
unsigned int * from,
unsigned int * to )
static

◆ btrace_set_call_history()

void btrace_set_call_history ( struct btrace_thread_info * btinfo,
const struct btrace_call_iterator * begin,
const struct btrace_call_iterator * end )

◆ btrace_set_insn_history()

void btrace_set_insn_history ( struct btrace_thread_info * btinfo,
const struct btrace_insn_iterator * begin,
const struct btrace_insn_iterator * end )

◆ btrace_stitch_bts()

static int btrace_stitch_bts ( struct btrace_data_bts * btrace,
struct thread_info * tp )
static

◆ btrace_stitch_trace()

static int btrace_stitch_trace ( struct btrace_data * btrace,
struct thread_info * tp )
static

Definition at line 1791 of file btrace.c.

References btrace_stitch_bts().

Referenced by btrace_fetch().

◆ btrace_teardown()

void btrace_teardown ( struct thread_info * tp)

◆ ftrace_bridge_gap()

static int ftrace_bridge_gap ( struct btrace_thread_info * btinfo,
struct btrace_function * lhs,
struct btrace_function * rhs,
int min_matches )
static

◆ ftrace_call_num_insn()

static unsigned int ftrace_call_num_insn ( const struct btrace_function * bfun)
static

◆ ftrace_classify_insn()

static enum btrace_insn_class ftrace_classify_insn ( struct gdbarch * gdbarch,
CORE_ADDR pc )
static

◆ ftrace_compute_global_level_offset()

static void ftrace_compute_global_level_offset ( struct btrace_thread_info * btinfo)
static

◆ ftrace_connect_backtrace()

static void ftrace_connect_backtrace ( struct btrace_thread_info * btinfo,
struct btrace_function * lhs,
struct btrace_function * rhs )
static

◆ ftrace_connect_bfun()

static void ftrace_connect_bfun ( struct btrace_thread_info * btinfo,
struct btrace_function * prev,
struct btrace_function * next )
static

◆ ftrace_debug()

static void ftrace_debug ( const struct btrace_function * bfun,
const char * prefix )
static

◆ ftrace_find_call()

static struct btrace_function * ftrace_find_call ( struct btrace_thread_info * btinfo,
struct btrace_function * bfun )
static

◆ ftrace_find_call_by_number() [1/2]

static const struct btrace_function * ftrace_find_call_by_number ( const struct btrace_thread_info * btinfo,
unsigned int number )
static

Definition at line 174 of file btrace.c.

References btrace_thread_info::functions, and btrace_function::number.

◆ ftrace_find_call_by_number() [2/2]

static struct btrace_function * ftrace_find_call_by_number ( struct btrace_thread_info * btinfo,
unsigned int number )
static

◆ ftrace_find_caller()

static struct btrace_function * ftrace_find_caller ( struct btrace_thread_info * btinfo,
struct btrace_function * bfun,
struct minimal_symbol * mfun,
struct symbol * fun )
static

◆ ftrace_fixup_caller()

static void ftrace_fixup_caller ( struct btrace_thread_info * btinfo,
struct btrace_function * bfun,
struct btrace_function * caller,
btrace_function_flags flags )
static

◆ ftrace_fixup_level()

static void ftrace_fixup_level ( struct btrace_thread_info * btinfo,
struct btrace_function * bfun,
int adjustment )
static

◆ ftrace_function_switched()

static int ftrace_function_switched ( const struct btrace_function * bfun,
const struct minimal_symbol * mfun,
const struct symbol * fun )
static

◆ ftrace_get_caller()

static struct btrace_function * ftrace_get_caller ( struct btrace_thread_info * btinfo,
struct btrace_function * bfun )
static

◆ ftrace_match_backtrace()

static int ftrace_match_backtrace ( struct btrace_thread_info * btinfo,
struct btrace_function * lhs,
struct btrace_function * rhs )
static

◆ ftrace_new_call()

static struct btrace_function * ftrace_new_call ( struct btrace_thread_info * btinfo,
struct minimal_symbol * mfun,
struct symbol * fun )
static

◆ ftrace_new_function()

static struct btrace_function * ftrace_new_function ( struct btrace_thread_info * btinfo,
struct minimal_symbol * mfun,
struct symbol * fun )
static

◆ ftrace_new_gap()

static struct btrace_function * ftrace_new_gap ( struct btrace_thread_info * btinfo,
int errcode,
std::vector< unsigned int > & gaps )
static

◆ ftrace_new_return()

static struct btrace_function * ftrace_new_return ( struct btrace_thread_info * btinfo,
struct minimal_symbol * mfun,
struct symbol * fun )
static

◆ ftrace_new_switch()

static struct btrace_function * ftrace_new_switch ( struct btrace_thread_info * btinfo,
struct minimal_symbol * mfun,
struct symbol * fun )
static

◆ ftrace_new_tailcall()

static struct btrace_function * ftrace_new_tailcall ( struct btrace_thread_info * btinfo,
struct minimal_symbol * mfun,
struct symbol * fun )
static

◆ ftrace_print_filename()

static const char * ftrace_print_filename ( const struct btrace_function * bfun)
static

◆ ftrace_print_function_name()

static const char * ftrace_print_function_name ( const struct btrace_function * bfun)
static

◆ ftrace_print_insn_addr()

static const char * ftrace_print_insn_addr ( const struct btrace_insn * insn)
static

Definition at line 115 of file btrace.c.

References btrace_insn::pc.

Referenced by btrace_stitch_bts(), and ftrace_update_function().

◆ ftrace_update_caller()

static void ftrace_update_caller ( struct btrace_function * bfun,
struct btrace_function * caller,
btrace_function_flags flags )
static

◆ ftrace_update_function()

static struct btrace_function * ftrace_update_function ( struct btrace_thread_info * btinfo,
CORE_ADDR pc )
static

◆ ftrace_update_insns()

static void ftrace_update_insns ( struct btrace_function * bfun,
const btrace_insn & insn )
static

Definition at line 665 of file btrace.c.

References ftrace_debug(), btrace_function::insn, and record_debug.

Referenced by btrace_compute_ftrace_bts().

◆ get_context_size()

static int get_context_size ( const char ** arg)
static

Definition at line 2901 of file btrace.c.

Referenced by maint_btrace_packet_history_cmd().

◆ get_uint()

static unsigned int get_uint ( const char ** arg)
static

Definition at line 2877 of file btrace.c.

Referenced by maint_btrace_packet_history_cmd().

◆ maint_btrace_clear_cmd()

static void maint_btrace_clear_cmd ( const char * args,
int from_tty )
static

Definition at line 3049 of file btrace.c.

References btrace_clear(), inferior_ptid, and inferior_thread().

◆ maint_btrace_clear_packet_history_cmd()

static void maint_btrace_clear_packet_history_cmd ( const char * args,
int from_tty )
static

◆ maint_btrace_packet_history_cmd()

static void maint_btrace_packet_history_cmd ( const char * arg,
int from_tty )
static

◆ maint_info_btrace_cmd()

static void maint_info_btrace_cmd ( const char * args,
int from_tty )
static

◆ no_chunk()

static void no_chunk ( const char * arg)
static

Definition at line 2917 of file btrace.c.

Referenced by maint_btrace_packet_history_cmd().

◆ show_maint_btrace_pt_skip_pad()

static void show_maint_btrace_pt_skip_pad ( struct ui_file * file,
int from_tty,
struct cmd_list_element * c,
const char * value )
static

Definition at line 3119 of file btrace.c.

References gdb_printf().

Variable Documentation

◆ maint_btrace_cmdlist

struct cmd_list_element* maint_btrace_cmdlist
static

Definition at line 46 of file btrace.c.

◆ maint_btrace_pt_set_cmdlist

struct cmd_list_element* maint_btrace_pt_set_cmdlist
static

Definition at line 49 of file btrace.c.

◆ maint_btrace_pt_show_cmdlist

struct cmd_list_element* maint_btrace_pt_show_cmdlist
static

Definition at line 50 of file btrace.c.

◆ maint_btrace_pt_skip_pad

bool maint_btrace_pt_skip_pad = true
static

Definition at line 53 of file btrace.c.

◆ maint_btrace_set_cmdlist

struct cmd_list_element* maint_btrace_set_cmdlist
static

Definition at line 47 of file btrace.c.

◆ maint_btrace_show_cmdlist

struct cmd_list_element* maint_btrace_show_cmdlist
static

Definition at line 48 of file btrace.c.