76 #include <sys/param.h> 77 #include <sys/types.h> 81 #include <include/hpctoolkit-config.h> 119 #define PERFORM_RELOCATION(addr, offset) \ 120 ((void *) (((unsigned long) addr) + ((long) offset))) 122 #define MAPPING_END(addr, length) \ 123 ((void *) (((unsigned long) addr) + ((unsigned long) length))) 135 #define FNBOUNDS_LOCK do { \ 136 spinlock_lock(&fnbounds_lock); \ 137 TD_GET(fnbounds_lock) = 1; \ 140 #define FNBOUNDS_UNLOCK do { \ 141 spinlock_unlock(&fnbounds_lock); \ 142 TD_GET(fnbounds_lock) = 0; \ 213 (
void**) start, (
void**) end);
258 if(!var_table)
return;
261 for (i = 0; i < num; i+=2) {
262 size_t num_bytes = (size_t)var_table[i+1];
270 data_info->
bytes = num_bytes;
290 char *filename = dso->
name;
299 if (var_table !=
NULL)
313 FILE* loadmap = fopen(
"/proc/self/maps",
"r");
315 EMSG(
"Could not open /proc/self/maps");
318 char linebuf[1024 + 1];
322 char* l = fgets(linebuf,
sizeof(linebuf), loadmap);
323 if (feof(loadmap))
break;
325 const char delim[] =
" \n";
326 addr = strtok_r(l, delim, &save);
327 char* perms = strtok_r(
NULL, delim, &save);
329 for (
int i=0; i < 3; i++) { (void) strtok_r(
NULL, delim, &save);}
330 char* name = strtok_r(
NULL, delim, &save);
331 realpath(name, tmpname);
332 if ((strncmp(perms,
"r-x", 3) == 0) && (strcmp(tmpname, exename) == 0))
break;
336 const char dash[] =
"-";
337 char* start_str = strtok_r(addr, dash, &save);
338 char* end_str = strtok_r(
NULL, dash, &save);
339 *start = (
void*) (uintptr_t) strtol(start_str,
NULL, 16);
340 *end = (
void*) (uintptr_t) strtol(end_str,
NULL, 16);
346 char filename[PATH_MAX];
351 TMSG(MAP_EXEC,
"Entry");
352 realpath(
"/proc/self/exe", filename);
355 EMSG(
"No nm_table for executable %s", filename);
359 EMSG(
"fnbounds returns no symbols for file %s, (all intervals poisoned)", filename);
362 TMSG(MAP_EXEC,
"Relocatable exec");
364 if (nm_table[0] >= start && nm_table[0] <= end) {
370 TMSG(MAP_EXEC,
"Bounds for relocatable exec = %p, %p", start, end);
373 TMSG(MAP_EXEC,
"NON relocatable exec");
378 executable_name, &mstart, &mend)) {
379 start = (
void*) mstart;
415 EMSG(
"!! INTERNAL ERROR, not possible to map dso for %s (%p, %p)",
416 module_name, start, end);
439 TMSG(LOADMAP,
"Unmapping closed dsos");
444 TMSG(LOADMAP,
"Unmapping %s", current->
name);
448 current = current->
next;
481 char exename[PATH_MAX];
482 realpath(
"/proc/self/exe", exename);
483 TMSG(INTERVALS_PRINT,
"name of loadmap = %s", exename);
485 TMSG(INTERVALS_PRINT,
"load module found = %p", exe_lm);
487 TMSG(INTERVALS_PRINT,
"dso info for load module = %p", exe_lm->
dso_info);
514 char filename[PATH_MAX];
518 if (incoming_filename ==
NULL) {
524 if (strncmp(incoming_filename,
"linux-vdso.so", 13) == 0
525 || strncmp(incoming_filename,
"linux-gate.so", 13) == 0) {
529 realpath(incoming_filename, filename);
532 if (nm_table ==
NULL) {
538 EMSG(
"fnbounds returns no symbols for file %s, (all intervals poisoned)", filename);
546 if (nm_table[0] >= start && nm_table[0] <= end) {
556 executable_name, &mstart, &mend)) {
557 start = (
void*) mstart;
596 char module_name[PATH_MAX];
static void fnbounds_run_var_analysis(dso_info_t *dso)
struct datatree_info_s * right
long hpcrun_dlopen_pending(void)
void hpcrun_loadmap_unmap(load_module_t *lm)
load_module_t * hpcrun_loadmap_findByName(const char *name)
static spinlock_t fnbounds_lock
const char * HPCRUN_EVENT_LIST
int fnbounds_table_lookup(void **table, int length, void *ip, void **start, void **end)
dso_info_t * hpcrun_dso_make(const char *name, void **table, struct fnbounds_file_header *fh, void *startaddr, void *endaddr, unsigned long map_size)
void hpcrun_syserv_fini(void)
void fnbounds_map_open_dsos()
void * hpcrun_syserv_query(const char *fname, struct fnbounds_file_header *fh)
void fnbounds_release_lock(void)
#define DATACENTRIC_MIN_BYTES
void datatree_splay_insert(struct datatree_info_s *node)
struct datatree_info_s * left
int dylib_addr_is_mapped(void *addr)
void fnbounds_unmap_closed_dsos()
fnbounds_table_t fnbounds_fetch_executable_table(void)
#define EVNAME_DATACENTRIC
bool fnbounds_ensure_mapped_dso(const char *module_name, void *start, void *end)
void * hpcrun_syserv_query_var(const char *fname, struct fnbounds_file_header *fh)
uintptr_t start_to_ref_dist
dso_info_t * fnbounds_dso_exec(void)
load_module_t * hpcrun_loadmap_map(dso_info_t *dso)
static bool fnbounds_is_datacentric_enabled()
struct load_module_t * next
void dylib_map_open_dsos()
static void insert_var_table(void **var_table, unsigned long num)
int hpcrun_syserv_init(void)
static void DATACENTRIC()
void * hpcrun_malloc(size_t size)
int dylib_find_module_containing_addr(void *addr, char *module_name, void **start, void **end)
#define DATA_STATIC_MAGIC
static dso_info_t * fnbounds_compute(const char *filename, void *start, void *end)
bool hpcrun_get_disabled(void)
load_module_t * hpcrun_loadmap_findByAddr(void *begin, void *end)
static void fnbounds_map_executable()
#define PERFORM_RELOCATION(addr, offset)
static void fnbounds_find_exec_bounds_proc_maps(char *exename, void **start, void **end)
#define SPINLOCK_UNLOCKED
bool fnbounds_enclosing_addr(void *ip, void **start, void **end, load_module_t **lm)
static load_module_t * fnbounds_get_loadModule(void *ip)
hpcrun_loadmap_t * hpcrun_getLoadmap()