56 #include <sys/types.h> 98 const char* mytag = (tag) ? tag :
"";
99 EMSG(
"-- begin new backtrace (innermost first) [%s] ----------", mytag);
111 const char* lm_name = (lm) ? lm->
name :
"(null)";
113 EMSG(
"%s: ip = %p (%p), load module = %s | lip %s", as_str, ip, x->ip_norm.lm_ip, lm_name, lip_str);
116 if (msg_cnt > msg_limit) {
117 EMSG(
"!!! message limit !!!");
123 if (msg_cnt <= msg_limit && td->btbuf_sav != td->
btbuf_end) {
124 EMSG(
"-- begin cached backtrace ---------------------------");
128 EMSG(
"%s: ip.lm_id = %d | ip.lm_ip = %p | lip %s", as_str,
129 x->ip_norm.lm_id, x->ip_norm.lm_ip, lip_str);
131 if (msg_cnt > msg_limit) {
132 EMSG(
"!!! message limit !!!");
138 EMSG(
"-- end backtrace ------------------------------------\n");
145 bt->
end = bt->
beg + (size - 1);
156 int nFrames = bt_outer - bt_inner;
159 for (
int i = 0; i < skip; ++i) {
165 return &bt_inner[skip];
182 TMSG(BT,
"Generate backtrace (no tramp), skip inner = %d", skipInner);
185 bt->
fence = FENCE_BAD;
231 bt->
fence = FENCE_TRAMP;
278 TMSG(TRAMP,
"WARNING: backtrace detects skipInner != 0 (skipInner = %d)",
281 TMSG(BT,
"* BEFORE Skip inner correction, bt_beg = %p", bt_beg);
284 TMSG(BT,
"* AFTER Skip inner correction, bt_beg = %p", bt_beg);
293 TMSG(BT,
"** Soft Failure **");
297 TMSG(BT,
"succeeds");
308 ucontext_t* context,
int skipInner)
313 if (! ret )
return false;
322 size_t new_frame_count = bt_end - bt_beg;
326 TMSG(BACKTRACE,
"tramp stop: conjoining backtraces");
327 TMSG(TRAMP,
" FOUND TRAMP: constructing cached backtrace");
333 TMSG(TRAMP,
"Check: tramp prefix ra_loc = %p, addr@ra_loc = %p (?= %p tramp), retn_addr = %p",
336 TMSG(TRAMP,
"Check: Old frame count = %d ?= %d (computed frame count)",
339 size_t n_cached_frames = new_frame_count - 1;
341 TMSG(TRAMP,
"cached trace size = (new frames) %d + (old frames) %d = %d",
342 n_cached_frames, old_frame_count, n_cached_frames + old_frame_count);
344 memmove(td->
cached_bt + n_cached_frames, prefix,
345 sizeof(
frame_t) * old_frame_count);
355 TMSG(TRAMP,
"Check: tramp prefix ra_loc = %p, addr@ra_loc = %p (?= %p tramp), retn_addr = %p",
359 TMSG(TRAMP,
"No tramp found: cached backtrace size = %d", new_frame_count);
361 size_t n_cached_frames = new_frame_count - 1;
362 TMSG(TRAMP,
"Confirm: ra_loc(last bt frame) = %p", (bt_beg + n_cached_frames)->
ra_loc);
369 TMSG(TRAMP,
"Dump cached backtrace from backtrace construction");
388 unsigned info_len = info.
u.
len;
size_t cached_frame_count
void hpcrun_stats_num_samples_dropped_inc(void)
void hpcrun_cached_bt_adjust_size(size_t n)
bool hpcrun_generate_backtrace(backtrace_info_t *bt, ucontext_t *context, int skipInner)
#define LUSH_LIP_DATA8_SZ
struct lush_assoc_info_u::lush_assoc_info_s u
void hpcrun_ensure_btbuf_avail(void)
ip_normalized_t the_function
void hpcrun_trampoline(void)
bool hpcrun_generate_backtrace_no_trampoline(backtrace_info_t *bt, ucontext_t *context, int skipInner)
void hpcrun_bt_init(backtrace_t *bt, size_t size)
static void lush_lip2str(char *buf, size_t len, lush_lip_t *lip)
void hpcrun_unw_drop(void)
step_state hpcrun_unw_step(hpcrun_unw_cursor_t *c)
#define LUSH_LIP_STR_MIN_LEN
int hpcrun_msg_ns(char *buf, size_t len, const char *fmt,...)
load_module_t * hpcrun_loadmap_findById(uint16_t id)
void * hpcrun_malloc(size_t size)
bool hpcrun_trampoline_at_entry(void *addr)
hpcrun_unw_cursor_t cursor
static lush_assoc_t lush_assoc_info__get_assoc(lush_assoc_info_t x)
frame_t * hpcrun_skip_chords(frame_t *bt_outer, frame_t *bt_inner, int skip)
enum lush_assoc lush_assoc_t
ip_normalized_t the_function
const char * lush_assoc_tostr(lush_assoc_t as)
static void lush_assoc_info2str(char *buf, size_t len, lush_assoc_info_t info)
void hpcrun_trampoline_bt_dump(void)
#define LUSH_ASSOC_INFO_STR_MIN_LEN
int hpcrun_unw_get_ip_norm_reg(hpcrun_unw_cursor_t *c, ip_normalized_t *reg_value)
void hpcrun_bt_dump(frame_t *unwind, const char *tag)
static char * fence_enum_name(fence_enum_t f)
static const unsigned int msg_limit
void hpcrun_unw_init_cursor(hpcrun_unw_cursor_t *cursor, void *context)
int hpcrun_unw_get_ip_unnorm_reg(hpcrun_unw_cursor_t *c, void **reg_value)
bool hpcrun_trampoline_interior(void *addr)
void * hpcrun_unw_get_ra_loc(hpcrun_unw_cursor_t *c)
uint64_t data8[LUSH_LIP_DATA8_SZ]
thread_data_t *(* hpcrun_get_thread_data)(void)