59 #define __USE_XOPEN_EXTENDED 62 #include <sys/types.h> 71 #undef _XOPEN_SOURCE // avoid complaint about redefinition 72 #define _XOPEN_SOURCE 600 103 #if defined(__i386__) 104 #ifndef USE_SYS_GCTXT 105 #define USE_SYS_GCTXT 112 #define NUM_DATA_METRICS 2 131 #define DATACENTRIC_USE_HYBRID_LAYOUT 0 133 #define DATACENTRIC_MAGIC 0x68706374 134 #define DATACENTRIC_DEFAULT_PAGESIZE 4096 136 #define HPCRUN_DATACENTRIC_PROB "HPCRUN_DATACENTRIC_PROB" 137 #define DEFAULT_PROB 0.1 139 #ifdef HPCRUN_STATIC_LINK 140 #define real_memalign __real_memalign 141 #define real_valloc __real_valloc 142 #define real_malloc __real_malloc 143 #define real_free __real_free 144 #define real_realloc __real_realloc 146 #define real_memalign __libc_memalign 147 #define real_valloc __libc_valloc 148 #define real_malloc __libc_malloc 149 #define real_free __libc_free 150 #define real_realloc __libc_realloc 182 NULL,
"header",
"footer",
"none" 202 if (strchr(str,
'/') !=
NULL) {
203 if (sscanf(str,
"%d/%d", &x, &y) == 2 && y > 0) {
204 ans = (float)x / (
float)y;
209 if (sscanf(str,
"%f", &ans) < 1) {
291 if (prob_str !=
NULL) {
297 fd = open(
"/dev/urandom", O_RDONLY);
299 read(fd, &seed,
sizeof(seed));
302 gettimeofday(&tv,
NULL);
303 seed += (getpid() << 16) + (tv.tv_usec << 4);
334 #if DATACENTRIC_USE_HYBRID_LAYOUT 335 if (datacentric_same_page(sys_ptr, sys_ptr +
datainfo_size) && align == 0) {
344 *info_ptr = sys_ptr + bytes;
359 #if DATACENTRIC_USE_HYBRID_LAYOUT 362 if (datacentric_same_page(*info_ptr, appl_ptr)
364 && (*info_ptr)->memblock == appl_ptr) {
365 *sys_ptr = *info_ptr;
373 if (*info_ptr ==
NULL) {
377 && (*info_ptr)->memblock == appl_ptr) {
384 if (num_errors < 100) {
385 AMSG(
"DATACENTRIC: Warning: memory corruption in leakinfo node: %p " 386 "sys: %p appl: %p magic: 0x%lx context: %p bytes: %ld memblock: %p",
387 *info_ptr, *sys_ptr, appl_ptr, (*info_ptr)->
magic, (*info_ptr)->context,
388 (*info_ptr)->bytes, (*info_ptr)->memblock);
405 if (info_ptr ==
NULL) {
407 "(NULL leakinfo pointer, this should not happen)",
408 name, bytes, sys_ptr, appl_ptr, info_ptr);
413 info_ptr->
bytes = bytes;
443 value.
p = appl_ptr + bytes;
450 info_aux->num_samples++;
462 loc_str =
"inactive";
468 TMSG(
DATACENTRIC,
"%s: bytes: %ld sys: %p appl: %p info: %p cct: %p (%s)",
469 name, bytes, sys_ptr, appl_ptr, info_ptr, info_ptr->
context, loc_str);
483 int clear, ucontext_t *
uc,
int *ret)
485 void *sys_ptr, *appl_ptr;
487 char *inactive_mesg =
"inactive";
496 }
else if (
TD_GET(inside_dlfcn)) {
498 inactive_mesg =
"unable to monitor: inside dlfcn";
501 inactive_mesg =
"not sampled";
509 *ret = (sys_ptr ==
NULL) ? errno : 0;
514 if (clear && sys_ptr !=
NULL) {
515 memset(sys_ptr, 0, size);
521 name, bytes, sys_ptr, inactive_mesg);
524 if (sys_ptr ==
NULL) {
526 name, bytes, sys_ptr);
580 return (*memptr ==
NULL) ? errno : 0;
586 #else // ! USE_SYS_GCTXT 588 #endif // USE_SYS_GCTXT 609 #else // ! USE_SYS_GCTXT 611 #endif // USE_SYS_GCTXT 632 #else // ! USE_SYS_GCTXT 634 #endif // USE_SYS_GCTXT 655 #else // ! USE_SYS_GCTXT 657 #endif // USE_SYS_GCTXT 674 memset(ptr, 0, nmemb * bytes);
682 #else // ! USE_SYS_GCTXT 684 #endif // USE_SYS_GCTXT 739 void *ptr2, *appl_ptr, *sys_ptr;
740 char *inactive_mesg =
"inactive";
741 int loc, loc2, active;
755 #else // ! USE_SYS_GCTXT 757 #endif // USE_SYS_GCTXT 781 }
else if (
TD_GET(inside_dlfcn)) {
783 inactive_mesg =
"unable to monitor: inside dlfcn";
786 inactive_mesg =
"not sampled";
789 inactive_mesg =
"size too small";
794 memmove(sys_ptr, ptr, bytes);
798 bytes, appl_ptr, inactive_mesg);
810 memmove(ptr2, ptr2 + datainfo_size, bytes);
814 memmove(ptr2 + datainfo_size, ptr, bytes);
void * memalign_fcn(size_t, size_t)
metric_aux_info_t * perf_event_info
void MONITOR_EXT_WRAP_NAME() free(void *ptr)
metric_set_t * hpcrun_reify_metric_set(cct_node_id_t cct_id)
static float datacentric_prob
static void datacentric_initialize(void)
struct datatree_info_s * right
static void hpcrun_safe_exit(void)
static int datacentric_get_malloc_loc(void *sys_ptr, size_t bytes, size_t align, void **appl_ptr, datatree_info_t **info_ptr)
sample_val_t hpcrun_sample_callpath(void *context, int metricId, hpcrun_metricVal_t metricIncr, int skipInner, int isSync, sampling_info_t *data)
void * realloc_fcn(void *, size_t)
void *MONITOR_EXT_WRAP_NAME() valloc(size_t bytes)
int datacentric_get_metric_addr_end()
static const unsigned int MAX_CHAR_FORMULA
#define MONITOR_EXT_WRAP_NAME(name)
static int addr_end_metric_id
void *MONITOR_EXT_WRAP_NAME() calloc(size_t nmemb, size_t bytes)
void hpcrun_metric_std_set(int metric_id, metric_set_t *set, hpcrun_metricVal_t value)
static void * datacentric_malloc_helper(const char *name, size_t bytes, size_t align, int clear, ucontext_t *uc, int *ret)
#define DATACENTRIC_MIN_BYTES
void * malloc_fcn(size_t)
void datatree_splay_insert(struct datatree_info_s *node)
struct datatree_info_s * left
metric_desc_t * hpcrun_set_metric_and_attributes(int metric_id, const char *name, MetricFlags_ValFmt_t valFmt, size_t period, metric_desc_properties_t prop, uint8_t show, uint8_t show_percent)
static int use_datacentric_prob
void * valloc_fcn(size_t)
void *MONITOR_EXT_WRAP_NAME() memalign(size_t boundary, size_t bytes)
struct datatree_info_s * datatree_splay_delete(void *memblock)
static void datacentric_add_leakinfo(const char *name, void *sys_ptr, void *appl_ptr, datatree_info_t *info_ptr, size_t bytes, ucontext_t *uc, int loc)
static long datacentric_pagesize
core_profile_trace_data_t core_profile_trace_data
static void DATACENTRIC()
void * hpcrun_malloc(size_t size)
static char * loc_name[4]
static enum data_overrides_status_e overrides_status
int datacentric_get_metric_addr_start()
static int datacentric_get_free_loc(void *appl_ptr, void **sys_ptr, datatree_info_t **info_ptr)
void *MONITOR_EXT_WRAP_NAME() realloc(void *ptr, size_t bytes)
#define HPCRUN_DATACENTRIC_PROB
static int addr_start_metric_id
ssize_t MONITOR_EXT_WRAP_NAME() read(int fd, void *buf, size_t count)
void *MONITOR_EXT_WRAP_NAME() malloc(size_t bytes)
int hpcrun_new_metric(void)
#define DATACENTRIC_MAGIC
#define DATACENTRIC_METRIC_PREFIX
int MONITOR_EXT_WRAP_NAME() posix_memalign(void **memptr, size_t alignment, size_t bytes)
#define DATACENTRIC_DEFAULT_PAGESIZE
void hpcrun_cct_set_node_allocation(cct_node_t *node)
static float string_to_prob(char *str)
static bool is_initialized()
static int hpcrun_safe_enter(void)
#define INLINE_ASM_GCTXT(uc)
thread_data_t *(* hpcrun_get_thread_data)(void)
#define metric_property_none
static void metric_initialize()