60 #define UW_RECIPE_MAP_DEBUG 0 62 #define UW_RECIPE_MAP_DEBUG_VERBOSE 0 64 #if UW_RECIPE_MAP_DEBUG_VERBOSE 65 #undef UW_RECIPE_MAP_DEBUG 66 #define UW_RECIPE_MAP_DEBUG 1 70 #if UW_RECIPE_MAP_DEBUG 109 #define SKIPLIST_HEIGHT 8 217 if (GF_ilmstat_btuwi) {
220 while (GF_ilmstat_btuwi && n <
NUM_NODES) {
237 #if UW_RECIPE_MAP_DEBUG 283 #define MAX_STAT_STR 14 284 #define LDMOD_NAME_LEN 128 285 #define MAX_ILDMODSTAT_STR MAX_INTERVAL_STR+LDMOD_NAME_LEN+MAX_STAT_STR 292 #if UW_RECIPE_MAP_DEBUG 296 fprintf(stderr,
"%s [start=%p, end=%p)\n", op, start, end);
299 #define uw_recipe_map_report(op, start, end) 307 #if UW_RECIPE_MAP_DEBUG_VERBOSE 312 case NEVER: strcpy(str,
" NEVER");
break;
313 case DEFERRED: strcpy(str,
" DEFERRED");
break;
314 case FORTHCOMING: strcpy(str,
"FORTHCOMING");
break;
315 case READY: strcpy(str,
" READY");
break;
316 default: strcpy(str,
"STAT_ERROR");
321 load_module_tostr(
void*
lm,
char str[])
333 ildmod_stat_tostr(
void* ilms,
char str[])
339 load_module_tostr(pair->
lm, ldmodstr);
342 sprintf(str,
"(%s %s %s)", intervalstr, ldmodstr, statstr);
348 max_ilmstat_btuwi_pair_len()
355 ILdMod_Stat_MaxSpaces[] =
" ";
361 ildmod_stat_maxspaces()
363 return ILdMod_Stat_MaxSpaces;
374 cskl_ilmstat_btuwi_any_node_tostr(
void* nodeval,
int node_height,
int max_height,
375 char str[],
int max_cskl_str_len,
unwinder_t uw)
384 char itpairStr[max_ilmstat_btuwi_pair_len()];
394 ildmod_stat_tostr(it_pair, firststr);
396 snprintf(itpairStr, strlen(firststr) + strlen(secondstr) + 6,
"%s%s%s%s%s",
397 "(", firststr,
", ", secondstr,
")");
405 cskl_ilmstat_btuwi_dwarf_node_tostr(
void* nodeval,
int node_height,
int max_height,
406 char str[],
int max_cskl_str_len)
408 cskl_ilmstat_btuwi_any_node_tostr(nodeval, node_height, max_height, str, max_cskl_str_len,
413 cskl_ilmstat_btuwi_native_node_tostr(
void* nodeval,
int node_height,
int max_height,
414 char str[],
int max_cskl_str_len)
416 cskl_ilmstat_btuwi_any_node_tostr(nodeval, node_height, max_height, str, max_cskl_str_len,
421 (*cskl_ilmstat_btuwi_node_tostr[
NUM_UNWINDERS])(
void* nodeval,
int node_height,
int max_height,
422 char str[],
int max_cskl_str_len) =
436 fprintf(stderr,
"%s", buf);
440 #define uw_recipe_map_report_and_dump(op, start, end) 508 if (ilmstat_btuwi ==
NULL)
513 #if UW_RECIPE_MAP_DEBUG 514 assert(ilmstat_btuwi !=
NULL);
540 if (end < UINTPTR_MAX) {
573 TMSG(UW_RECIPE_MAP,
"uw_recipe_map_delete_range from %p to %p", start, end);
605 #if UW_RECIPE_MAP_DEBUG 606 fprintf(stderr,
"uw_recipe_map_init: call a2r_map_init(my_alloc) ... \n");
610 #if UW_RECIPE_MAP_DEBUG 611 fprintf(stderr,
"%s: mcs_init(&GFL_lock), call bitree_uwi_init() \n", __func__);
616 TMSG(UW_RECIPE_MAP,
"init address-to-recipe map");
623 addr2recipe_map[uw] =
662 void *fcn_start, *fcn_end;
664 TMSG(UW_RECIPE_MAP,
"BAD fnbounds_enclosing_addr failed: addr %p", addr);
667 if (addr < fcn_start || fcn_end <= addr) {
668 TMSG(UW_RECIPE_MAP,
"BAD fnbounds_enclosing_addr failed: addr %p " 669 "not within fcn range %p to %p", addr, fcn_start, fcn_end);
689 #if UW_RECIPE_MAP_DEBUG 690 assert(ilm_btui !=
NULL);
712 if (btuwi_stat.
error != 0) {
713 TMSG(UW_RECIPE_MAP,
"build_intervals: fcn range %p to %p: error %d",
714 fcn_start, fcn_end, btuwi_stat.
error);
723 EMSG(
"Fail to get interval %p to %p", fcn_start, fcn_end);
731 if (oldstat ==
NEVER) {
737 TMSG(UW_RECIPE_MAP_LOOKUP,
"found in unwind tree: addr %p", addr);
742 unwr_info->
lm = ilm_btui->
lm;
static void cskl_ilmstat_btuwi_free_uw(void *anode, unwinder_t uw)
static ilmstat_btuwi_pair_t * ilmstat__btuwi_pair_init(ilmstat_btuwi_pair_t *node, tree_stat_t treestat, load_module_t *lm, uintptr_t start, uintptr_t end)
void *(* mem_alloc)(size_t size)
static mem_alloc my_alloc
bitree_uwi_t * bitree_uwi_rebalance(bitree_uwi_t *tree, int count)
void mcs_lock(mcs_lock_t *l, mcs_node_t *me)
static void uw_recipe_map_notify_init()
static mcs_lock_t GFL_lock
void cskl_tostr(cskiplist_t *cskl, cskl_node_tostr node_tostr, char csklstr[], int max_cskl_str_len)
static __thread ilmstat_btuwi_pair_t * _lf_ilmstat_btuwi
static void(* cskl_ilmstat_btuwi_free[])(void *anode)
static bool uw_recipe_map_cmp_del_bulk_unsynch(ilmstat_btuwi_pair_t *key, unwinder_t uw)
int interval_t_cmp(void *lhs, void *rhs)
void hpcrun_loadmap_notify_register(loadmap_notify_t *n)
cskiplist_t * cskl_new(void *lsentinel, void *rsentinel, int max_height, val_cmp compare, val_cmp inrange, mem_alloc m_alloc)
int interval_t_inrange(void *lhs, void *val)
void cskl_free(void *anode)
static void uw_recipe_map_notify_unmap(void *start, void *end)
static void cskl_ilmstat_btuwi_free_0(void *anode)
bool cskl_inrange_del_bulk_unsynch(cskiplist_t *cskl, void *lo, void *hi, mem_free m_free)
static ilmstat_btuwi_pair_t * ilmstat_btuwi_pair_build(uintptr_t start, uintptr_t end, load_module_t *lm, tree_stat_t treestat, mem_alloc m_alloc)
static int ilmstat_btuwi_pair_inrange(void *itp, void *address)
#define MAX_CSKIPLIST_STR
void * cskl_inrange_find(cskiplist_t *cskl, void *value)
btuwi_status_t build_intervals(char *ins, unsigned int len, unwinder_t uw)
bool cskl_cmp_del_bulk_unsynch(cskiplist_t *cskl, void *lo, void *hi, mem_free m_free)
bitree_uwi_t * bitree_uwi_inrange(bitree_uwi_t *tree, uintptr_t address)
#define atomic_load_explicit(object, order)
static ilmstat_btuwi_pair_t * ilmstat_btuwi_pair_malloc(uintptr_t start, uintptr_t end, load_module_t *lm, tree_stat_t treestat, mem_alloc m_alloc)
bool uw_recipe_map_lookup(void *addr, unwinder_t uw, unwindr_info_t *unwr_info)
#define atomic_store_explicit(object, desired, order)
bool mcs_trylock(mcs_lock_t *l, mcs_node_t *me)
void mcs_unlock(mcs_lock_t *l, mcs_node_t *me)
static void uw_recipe_map_poison(uintptr_t start, uintptr_t end, unwinder_t uw)
sigjmp_buf_t bad_interval
#define MAX_ILDMODSTAT_STR
loadmap_notify_range_t map
static ilmstat_btuwi_pair_t * uw_recipe_map_inrange_find(uintptr_t addr, unwinder_t uw)
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure)
void hpcrun_set_real_siglongjmp(void)
static void uw_recipe_map_notify_map(void *start, void *end)
struct bitree_uwi_s bitree_uwi_t
static void cskl_ilmstat_btuwi_free_1(void *anode)
static ilmstat_btuwi_pair_t * GF_ilmstat_btuwi
static void uw_recipe_map_repoison(uintptr_t start, uintptr_t end, unwinder_t uw)
sigjmp_buf_t * current_jmp_buf
void * hpcrun_malloc(size_t size)
#define uw_recipe_map_report_and_dump(op, start, end)
csklnode_t * cskl_insert(cskiplist_t *cskl, void *value, mem_alloc m_alloc)
struct ilmstat_btuwi_pair_s ilmstat_btuwi_pair_t
void cskl_append_node_str(char nodestr[], char str[], int max_cskl_str_len)
void bitree_uwi_init(mem_alloc m_alloc)
void bitree_uwi_free(unwinder_t uw, bitree_uwi_t *tree)
void interval_t_tostr(void *ptrinterval, char result[])
#define uw_recipe_map_report(op, start, end)
void cskl_levels_tostr(int height, int max_height, char str[], int max_cskl_str_len)
enum unwinder_e unwinder_t
static void ilmstat_btuwi_pair_free(ilmstat_btuwi_pair_t *pair, unwinder_t uw)
static void push_free_pair(ilmstat_btuwi_pair_t **list, ilmstat_btuwi_pair_t *pair)
<!-- ********************************************************************--> n<!-- HPCToolkit Experiment DTD --> n<!-- Version 2.1 --> n<!-- ********************************************************************--> n<!ELEMENT HPCToolkitExperiment(Header,(SecCallPathProfile|SecFlatProfile) *)> n<!ATTLIST HPCToolkitExperiment\n version CDATA #REQUIRED > n n<!-- ******************************************************************--> n n<!-- Info/NV:flexible name-value pairs:(n) ame;(t) ype;(v) alue --> n<!ELEMENT Info(NV *)> n<!ATTLIST Info\n n CDATA #IMPLIED > n<!ELEMENT NV EMPTY > n<!ATTLIST NV\n n CDATA #REQUIRED\n t CDATA #IMPLIED\n v CDATA #REQUIRED > n n<!-- ******************************************************************--> n<!-- Header --> n<!-- ******************************************************************--> n<!ELEMENT Header(Info *)> n<!ATTLIST Header\n n CDATA #REQUIRED > n n<!-- ******************************************************************--> n<!-- Section Header --> n<!-- ******************************************************************--> n<!ELEMENT SecHeader(MetricTable?, MetricDBTable?, TraceDBTable?, LoadModuleTable?, FileTable?, ProcedureTable?, Info *)> n n<!-- MetricTable:--> n<!ELEMENT MetricTable(Metric) * > n n<!-- Metric:(i) d;(n) ame --> n<!--(v) alue-type:transient type of values --> n<!--(t) ype:persistent type of metric --> n<!-- fmt:format;show;--> n<!ELEMENT Metric(MetricFormula *, Info?)> n<!ATTLIST Metric\n i CDATA #REQUIRED\n n CDATA #REQUIRED\n es CDATA #IMPLIED\n em CDATA #IMPLIED\n ep CDATA #IMPLIED\n v(raw|final|derived-incr|derived) \"raw\\ t (inclusive|exclusive|nil) \nil\\ partner CDATA #IMPLIED\ fmt CDATA #IMPLIED\ show (1|0) \1\\ show-percent (1|0) \1> n n<!-- MetricFormula represents derived metrics: (t)ype; (frm): formula --> n<!ELEMENT MetricFormula (Info?)> n<!ATTLIST MetricFormula\ t (combine|finalize) \finalize\\ i CDATA #IMPLIED\ frm CDATA #REQUIRED> n n<!-- Metric data, used in sections: (n)ame [from Metric]; (v)alue --> n<!ELEMENT M EMPTY> n<!ATTLIST M\ n CDATA #REQUIRED\ v CDATA #REQUIRED> n n<!-- MetricDBTable: --> n<!ELEMENT MetricDBTable (MetricDB)*> n n<!-- MetricDB: (i)d; (n)ame --> n<!-- (t)ype: persistent type of metric --> n<!-- db-glob: file glob describing files in metric db --> n<!-- db-id: id within metric db --> n<!-- db-num-metrics: number of metrics in db --> n<!-- db-header-sz: size (in bytes) of a db file header --> n<!ELEMENT MetricDB EMPTY> n<!ATTLIST MetricDB\ i CDATA #REQUIRED\ n CDATA #REQUIRED\ t (inclusive|exclusive|nil) \nil\\ partner CDATA #IMPLIED\ db-glob CDATA #IMPLIED\ db-id CDATA #IMPLIED\ db-num-metrics CDATA #IMPLIED\ db-header-sz CDATA #IMPLIED> n n<!-- TraceDBTable: --> n<!ELEMENT TraceDBTable (TraceDB)> n n<!-- TraceDB: (i)d --> n<!-- db-min-time: min beginning time stamp (global) --> n<!-- db-max-time: max ending time stamp (global) --> n<!ELEMENT TraceDB EMPTY> n<!ATTLIST TraceDB\ i CDATA #REQUIRED\ db-glob CDATA #IMPLIED\ db-min-time CDATA #IMPLIED\ db-max-time CDATA #IMPLIED\ db-header-sz CDATA #IMPLIED> n n<!-- LoadModuleTable assigns a short name to a load module --> n<!ELEMENT LoadModuleTable (LoadModule)*> n n<!ELEMENT LoadModule (Info?)> n<!ATTLIST LoadModule\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!-- FileTable assigns a short name to a file --> n<!ELEMENT FileTable (File)*> n n<!ELEMENT File (Info?)> n<!ATTLIST File\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!-- ProcedureTable assigns a short name to a procedure --> n<!ELEMENT ProcedureTable (Procedure)*> n n<!-- Info/NV: flexible name-value pairs: (n)ame; (t)ype; (v)alue --> n<!-- f: family of the procedure (fake, root, ...)--> n<!ELEMENT Procedure (Info?)> n<!ATTLIST Procedure\ i CDATA #REQUIRED\ n CDATA #REQUIRED\ f CDATA #IMPLIED> n n<!-- ****************************************************************** --> n<!-- Section: Call path profile --> n<!-- ****************************************************************** --> n<!ELEMENT SecCallPathProfile (SecHeader, SecCallPathProfileData)> n<!ATTLIST SecCallPathProfile\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!ELEMENT SecCallPathProfileData (PF|M)*> n<!-- Procedure frame --> n<!-- (i)d: unique identifier for cross referencing --> n<!-- (s)tatic scope id --> n<!-- (n)ame: a string or an id in ProcedureTable --> n<!-- (lm) load module: a string or an id in LoadModuleTable --> n<!-- (f)ile name: a string or an id in LoadModuleTable --> n<!-- (l)ine range: \beg-end\ (inclusive range) --> n<!-- (a)lien: whether frame is alien to enclosing P --> n<!-- (str)uct: hpcstruct node id --> n<!-- (t)ype: hpcrun node type: memory access, variable declaration, ... --> n<!-- (v)ma-range-set: \{[beg-end), [beg-end)...}\ --> n<!ELEMENT PF (PF|Pr|L|C|S|M)*> n<!ATTLIST PF\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ n CDATA #REQUIRED\ lm CDATA #IMPLIED\ f CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Procedure (static): GOAL: replace with 'P' --> n<!ELEMENT Pr (Pr|L|C|S|M)*> n<!ATTLIST Pr\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ n CDATA #REQUIRED\ lm CDATA #IMPLIED\ f CDATA #IMPLIED\ l CDATA #IMPLIED\ a (1|0) \0\\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Callsite (a special StatementRange) --> n<!ELEMENT C (PF|M)*> n<!ATTLIST C\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n n<!-- ****************************************************************** --> n<!-- Section: Flat profile --> n<!-- ****************************************************************** --> n<!ELEMENT SecFlatProfile (SecHeader, SecFlatProfileData)> n<!ATTLIST SecFlatProfile\ i CDATA #REQUIRED\ n CDATA #REQUIRED> n n<!ELEMENT SecFlatProfileData (LM|M)*> n<!-- Load module: (i)d; (n)ame; (v)ma-range-set --> n<!ELEMENT LM (F|P|M)*> n<!ATTLIST LM\ i CDATA #IMPLIED\ n CDATA #REQUIRED\ v CDATA #IMPLIED> n<!-- File --> n<!ELEMENT F (P|L|S|M)*> n<!ATTLIST F\ i CDATA #IMPLIED\ n CDATA #REQUIRED> n<!-- Procedure (Note 1) --> n<!ELEMENT P (P|A|L|S|C|M)*> n<!ATTLIST P\ i CDATA #IMPLIED\ n CDATA #REQUIRED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Alien (Note 1) --> n<!ELEMENT A (A|L|S|C|M)*> n<!ATTLIST A\ i CDATA #IMPLIED\ f CDATA #IMPLIED\ n CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Loop (Note 1,2) --> n<!ELEMENT L (A|Pr|L|S|C|M)*> n<!ATTLIST L\ i CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ f CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Statement (Note 2) --> n<!-- (it): trace record identifier --> n<!ELEMENT S (S|M)*> n<!ATTLIST S\ i CDATA #IMPLIED\ it CDATA #IMPLIED\ s CDATA #IMPLIED\ l CDATA #IMPLIED\ str CDATA #IMPLIED\ v CDATA #IMPLIED> n<!-- Note 1: Contained Cs may not contain PFs --> n<!-- Note 2: The 's' attribute is not used for flat profiles --> n
static void uw_recipe_map_unpoison(uintptr_t start, uintptr_t end, unwinder_t uw)
static void mcs_init(mcs_lock_t *l)
static ilmstat_btuwi_pair_t * pop_free_pair(ilmstat_btuwi_pair_t **list)
static cskiplist_t * addr2recipe_map[NUM_UNWINDERS]
static int ilmstat_btuwi_pair_cmp(void *lhs, void *rhs)
bool fnbounds_enclosing_addr(void *ip, void **start, void **end, load_module_t **lm)
void bitree_uwi_tostring_indent(bitree_uwi_t *tree, char *indents, char treestr[], unwinder_t uw)
thread_data_t *(* hpcrun_get_thread_data)(void)
void uw_recipe_map_init(void)
loadmap_notify_range_t unmap