61 #define LOADMAP_DEBUG 0 63 #define UW_RECIPE_MAP_DEBUG 0 77 notification_recipients =
n;
112 if (s_dso_free_list) {
114 s_dso_free_list = s_dso_free_list->
next;
115 if (s_dso_free_list) {
121 TMSG(DSO,
" hpcrun_dso_new");
132 void* startaddr,
void* endaddr,
unsigned long map_size)
136 TMSG(DSO,
" hpcrun_dso_make for module %s", name);
138 int namelen = strlen(name) + 1;
140 strcpy(x->
name, name);
164 TMSG(DSO,
"new dso: start = %p, end = %p, name = %s",
165 startaddr, endaddr, name);
185 printf(
"%p-%p %s [dso_info_t *%p, table=%p, nsymbols=%ld, relocatable=%d]\n",
202 x->
id = ++(s_loadmap_ptr->
size);
204 int namelen = strlen(name) + 1;
206 strcpy(x->
name, name);
223 TMSG(LOADMAP,
" --NEW");
226 EMSG(
"New loadmap requested, but allocation failed!!");
239 TMSG(LOADMAP,
"init");
240 memset(x, 0,
sizeof(*x));
254 printf(
"%u %s\n", lm->id, lm->name);
263 TMSG(LOADMAP,
"find by address %p -- %p", begin, end);
265 TMSG(LOADMAP,
"\tload module %s", x->name);
267 TMSG(LOADMAP,
"\t\t [%lx, %lx) table [%lx, %lx)",
268 (uintptr_t) x->dso_info->start_addr,
269 (uintptr_t) x->dso_info->end_addr,
270 ((uintptr_t) x->dso_info->table ? ((uintptr_t) x->dso_info->table[0] +
271 x->dso_info->start_to_ref_dist) : -1),
272 ((uintptr_t) x->dso_info->table ? ((uintptr_t) x->dso_info->table[x->dso_info->nsymbols -1] +
273 x->dso_info->start_to_ref_dist) : -1)
275 if (x->dso_info->start_addr <= begin && end <= x->dso_info->end_addr) {
276 TMSG(LOADMAP,
" --->%s", x->name);
281 TMSG(LOADMAP,
" --->(NOT FOUND)");
289 TMSG(LOADMAP,
"find by name: %s", name);
291 if (strcmp(x->name, name) == 0) {
292 TMSG(LOADMAP,
" --->FOUND", x->name);
296 TMSG(LOADMAP,
" --->(NOT FOUND)");
303 TMSG(LOADMAP,
"find by id %d",
id);
306 TMSG(LOADMAP,
" --->%s", x->name);
310 TMSG(LOADMAP,
" --->(NOT FOUND)");
317 TMSG(LOADMAP,
"find load name: %s", name);
319 if (strstr(x->name, name)) {
320 TMSG(LOADMAP,
" --->%s", x->name);
324 TMSG(LOADMAP,
" --->(NOT FOUND)");
334 TMSG(LOADMAP,
"push front: %s", lm->
name);
344 TMSG(LOADMAP,
" ->First entry");
346 s_loadmap_ptr->
lm_end = lm;
361 if (lm == s_loadmap_ptr->
lm_end) {
383 s_loadmap_ptr->
lm_end = lm;
391 const char* msg =
"";
393 TMSG(LOADMAP,
"map in dso %s", dso->
name);
402 TMSG(LOADMAP,
" !! Internal consistency check fires !!");
407 EMSG(
"hpcrun_loadmap_map(): attempt to both map dso '%s' and place it on the free list!", dso->
name);
416 #if UW_RECIPE_MAP_DEBUG 417 fprintf(stderr,
"hpcrun_loadmap_map: '%s' start=%p end=%p\n",
425 TMSG(LOADMAP,
"hpcrun_loadmap_map: '%s' size=%d %s",
426 dso->
name, s_loadmap_ptr->
size, msg);
435 TMSG(LOADMAP,
"hpcrun_loadmap_unmap: '%s'", lm->
name);
439 if (old_dso ==
NULL)
return;
455 if (s_dso_free_list) {
456 s_dso_free_list->
prev = old_dso;
458 s_dso_free_list = old_dso;
459 TMSG(LOADMAP,
"Deleting unw intervals");
462 assert((uintptr_t)end_addr < UINTPTR_MAX) ;
465 #if UW_RECIPE_MAP_DEBUG 466 fprintf(stderr,
"hpcrun_loadmap_unmap: '%s' start=%p end=%p\n",
467 lm->
name, start_addr, end_addr);
491 notification_recipients =
NULL;
496 s_dso_free_list =
NULL;
static void hpcrun_loadmap_notify_unmap(void *start, void *end)
void hpcrun_loadmap_notify_register(loadmap_notify_t *n)
void hpcrun_loadmap_unmap(load_module_t *lm)
const char * hpcrun_loadmap_findLoadName(const char *name)
load_module_t * hpcrun_loadmap_findByName(const char *name)
dso_info_t * hpcrun_dso_new()
load_module_t * hpcrun_loadModule_new(const char *name)
dso_info_t * hpcrun_dso_make(const char *name, void **table, struct fnbounds_file_header *fh, void *startaddr, void *endaddr, unsigned long map_size)
uint16_t hpcrun_loadModule_add(const char *name)
struct loadmap_notify_t * next
static hpcrun_loadmap_t * s_loadmap_ptr
void hpcrun_loadmap_init(hpcrun_loadmap_t *x)
loadmap_notify_range_t map
void hpcrun_dsoList_dump(dso_info_t *dl_list)
load_module_t * hpcrun_loadmap_findById(uint16_t id)
uintptr_t start_to_ref_dist
load_module_t * hpcrun_loadmap_map(dso_info_t *dso)
struct load_module_t * next
void * hpcrun_malloc(size_t size)
void hpcrun_dso_dump(dso_info_t *x)
void hpcrun_loadmap_print(hpcrun_loadmap_t *loadmap)
static void hpcrun_loadmap_pushFront(load_module_t *lm)
static dso_info_t * s_dso_free_list
static hpcrun_loadmap_t s_loadmap
void hpcrun_initLoadmap()
load_module_t * hpcrun_loadmap_findByAddr(void *begin, void *end)
<!-- ********************************************************************--> 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 hpcrun_loadmap_notify_map(void *start, void *end)
struct load_module_t * prev
hpcrun_loadmap_t * hpcrun_loadmap_new()
static loadmap_notify_t * notification_recipients
loadmap_notify_range_t unmap
hpcrun_loadmap_t * hpcrun_getLoadmap()