52 #ifdef _PERF_SKID_DEBUG_ 59 #include <sys/syscall.h> 61 #include <linux/perf_event.h> 77 #define HPCRUN_OPTION_PRECISE_IP "HPCRUN_PRECISE_IP" 79 #define PRECISE_IP_CHAR_MODIFIER 'p' 81 #define PRECISE_IP_SUFFIX ":p" 82 #define PRECISE_IP_MAX_SUFFIX ":P" 84 #define DELIMITER_HOWOFTEN '@' 111 const char *str_val= getenv(env_var);
115 long val = strtol( str_val, &end_ptr, 10 );
116 if ( end_ptr != env_var && (val < LONG_MAX && val > LONG_MIN) ) {
121 return default_value;
132 while ((found = strstr(haystack + pos, needle)) != 0)
135 pos = (found - haystack) + 1;
147 const char *end = ptr_att + strlen(suffix);
151 if (*end == allowed) end++;
152 if (*end == allowed) end++;
193 return attr->precise_ip;
213 attr->precise_ip = val;
230 return attr->precise_ip;
246 int len_evt = strlen(event_string);
249 if (len_evt <= len_suf) {
253 *event_string_without_skidmarks = strdup(event_string);
260 #ifdef _PERF_SKID_DEBUG_ 261 memset(buffer,1,
sizeof(buffer));
263 memcpy(buffer, event_string, ptr_att - event_string);
264 buffer[ptr_att - event_string] = 0;
266 *event_string_without_skidmarks = strdup(buffer);
275 *event_string_without_skidmarks = strdup(event_string);
278 #ifdef _PERF_SKID_DEBUG_ 279 memset(buffer,1,
sizeof(buffer));
281 memcpy(buffer, event_string, ptr_att - event_string);
282 buffer[ptr_att - event_string] = 0;
285 const char *ptr_next = ptr_att + len_suf;
298 strcat(buffer, ptr_next);
299 }
else if (*ptr_next !=
'\0') {
304 *event_string_without_skidmarks = strdup(buffer);
310 #ifdef _PERF_SKID_DEBUG_ 313 #define MAX_NAME_EVENT 128 315 main (
int argc,
char *argv[])
317 char *ev[] = {
"cycles:p",
"cycles:pp",
"cycles",
"cycles::popo:peer",
318 "cycles::popo:oeer:ppp",
"cycles::popo:peer:p",
"cycles@100",
319 "cycles::popo:oeer:p@100",
"cycles::popo:peer:p@f10",
320 "cycles::popo:peer:ppp@5050",
"cycles::popo:peer:pp",
321 "cs:P",
"cs:Pp",
"cs:pppp",
"cs:P@10000" };
322 int num_events =
sizeof(ev)/
sizeof(ev[9]);
325 for (i=0; i<num_events; i++) {
328 printf(
"event: %s name: %s -> %d\n", ev[i], name_event, r);
#define HPCRUN_OPTION_PRECISE_IP
int perf_skid_set_max_precise_ip(struct perf_event_attr *attr)
#define PERF_EVENT_SKID_ZERO_REQUIRED
const int perf_skid_flavors
#define PERF_EVENT_AUTODETECT_SKID
#define PRECISE_IP_MAX_SUFFIX
#define PERF_EVENT_SKID_CONSTANT
long perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags)
#define PERF_EVENT_SKID_ARBITRARY
#define PRECISE_IP_SUFFIX
static const char * find_precise_suffix(const char *s, const char *suffix, char allowed)
int main(int argc, char *argv[])
#define PERF_EVENT_SKID_ZERO_REQUESTED
int perf_skid_parse_event(const char *event_string, char **event_string_without_skidmarks)
const int perf_skid_precision[]
#define PRECISE_IP_CHAR_MODIFIER
static long getEnvLong(const char *env_var, long default_value)
static char * strlaststr(const char *haystack, const char *needle)
u64 perf_skid_get_precise_ip(struct perf_event_attr *attr)
#define DELIMITER_HOWOFTEN