#ifndef _PERF_ANNOTATE_DATA_H
#define _PERF_ANNOTATE_DATA_H
#include <errno.h>
#include <linux/compiler.h>
#include <linux/rbtree.h>
#include <linux/types.h>
#include "dwarf-regs.h"
#include "annotate.h"
#ifdef HAVE_LIBDW_SUPPORT
#include "debuginfo.h"
#endif
struct annotated_op_loc;
struct debuginfo;
struct evsel;
struct hist_browser_timer;
struct hist_entry;
struct map_symbol;
struct thread;
#define pr_debug_dtp(fmt, ...) \
do { \
if (debug_type_profile) \
pr_info(fmt, ##__VA_ARGS__); \
else \
pr_debug3(fmt, ##__VA_ARGS__); \
} while (0)
enum type_state_kind {
TSR_KIND_INVALID = 0,
TSR_KIND_TYPE,
TSR_KIND_PERCPU_BASE,
TSR_KIND_CONST,
TSR_KIND_PERCPU_POINTER,
TSR_KIND_POINTER,
TSR_KIND_CANARY,
};
struct annotated_member {
struct list_head node;
struct list_head children;
char *type_name;
char *var_name;
int offset;
int size;
};
struct type_hist_entry {
int nr_samples;
u64 period;
};
struct type_hist {
u64 nr_samples;
u64 period;
struct type_hist_entry addr[];
};
struct annotated_data_type {
struct rb_node node;
struct annotated_member self;
int nr_histograms;
struct type_hist **histograms;
};
extern struct annotated_data_type unknown_type;
extern struct annotated_data_type stackop_type;
extern struct annotated_data_type canary_type;
struct data_loc_info {
const struct arch *arch;
struct thread *thread;
struct map_symbol *ms;
u64 ip;
u64 var_addr;
u8 cpumode;
struct annotated_op_loc *op;
struct debuginfo *di;
int fbreg;
bool fb_cfa;
int type_offset;
};
struct annotated_data_stat {
int total;
int no_sym;
int no_insn;
int no_insn_ops;
int no_mem_ops;
int no_reg;
int no_dbginfo;
int no_cuinfo;
int no_var;
int no_typeinfo;
int invalid_size;
int bad_offset;
int insn_track;
};
extern struct annotated_data_stat ann_data_stat;
#ifdef HAVE_LIBDW_SUPPORT
struct type_state_reg {
Dwarf_Die type;
u32 imm_value;
s32 offset;
bool ok;
bool caller_saved;
u8 kind;
u8 copied_from;
};
struct type_state_stack {
struct list_head list;
Dwarf_Die type;
int offset;
int ptr_offset;
int size;
bool compound;
u8 kind;
};
#define TYPE_STATE_MAX_REGS 32
struct type_state {
struct type_state_reg regs[TYPE_STATE_MAX_REGS];
struct list_head stack_vars;
int ret_reg;
int stack_reg;
};
struct annotated_data_type *find_data_type(struct data_loc_info *dloc);
int annotated_data_type__update_samples(struct annotated_data_type *adt,
struct evsel *evsel, int offset,
int nr_samples, u64 period);
void annotated_data_type__tree_delete(struct rb_root *root);
void global_var_type__tree_delete(struct rb_root *root);
int hist_entry__annotate_data_tty(struct hist_entry *he, struct evsel *evsel);
int annotated_data_type__get_member_name(struct annotated_data_type *adt,
char *buf, size_t sz, int member_offset);
bool has_reg_type(struct type_state *state, int reg);
struct type_state_stack *findnew_stack_state(struct type_state *state,
int offset, u8 kind,
Dwarf_Die *type_die,
int ptr_offset);
void set_stack_state(struct type_state_stack *stack, int offset, u8 kind,
Dwarf_Die *type_die, int ptr_offset);
struct type_state_stack *find_stack_state(struct type_state *state,
int offset);
bool get_global_var_type(Dwarf_Die *cu_die, struct data_loc_info *dloc,
u64 ip, u64 var_addr, int *var_offset,
Dwarf_Die *type_die);
bool get_global_var_info(struct data_loc_info *dloc, u64 addr,
const char **var_name, int *var_offset);
void pr_debug_type_name(Dwarf_Die *die, enum type_state_kind kind);
#else
static inline struct annotated_data_type *
find_data_type(struct data_loc_info *dloc __maybe_unused)
{
return NULL;
}
static inline int
annotated_data_type__update_samples(struct annotated_data_type *adt __maybe_unused,
struct evsel *evsel __maybe_unused,
int offset __maybe_unused,
int nr_samples __maybe_unused,
u64 period __maybe_unused)
{
return -1;
}
static inline void annotated_data_type__tree_delete(struct rb_root *root __maybe_unused)
{
}
static inline void global_var_type__tree_delete(struct rb_root *root __maybe_unused)
{
}
static inline int hist_entry__annotate_data_tty(struct hist_entry *he __maybe_unused,
struct evsel *evsel __maybe_unused)
{
return -1;
}
static inline int annotated_data_type__get_member_name(struct annotated_data_type *adt __maybe_unused,
char *buf __maybe_unused,
size_t sz __maybe_unused,
int member_offset __maybe_unused)
{
return -1;
}
#endif
#ifdef HAVE_SLANG_SUPPORT
int hist_entry__annotate_data_tui(struct hist_entry *he, struct evsel *evsel,
struct hist_browser_timer *hbt);
#else
static inline int hist_entry__annotate_data_tui(struct hist_entry *he __maybe_unused,
struct evsel *evsel __maybe_unused,
struct hist_browser_timer *hbt __maybe_unused)
{
return -1;
}
#endif
#endif