mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-17 20:54:10 +00:00
perf tools: Default to cpu// for events v5
When an event fails to parse and it's not in a new style format, try to parse it again as a cpu event. This allows to use sysfs exported events directly without //, so you can use perf record -e mem-loads ... instead of perf record -e cpu/mem-loads/ Signed-off-by: Andi Kleen <ak@linux.intel.com> Link: http://lkml.kernel.org/r/1366480949-32292-1-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
380512345e
commit
50e200f079
3 changed files with 54 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void *memdup(const void *src, size_t len);
|
void *memdup(const void *src, size_t len);
|
||||||
|
int str_append(char **s, int *len, const char *a);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "parse-options.h"
|
#include "parse-options.h"
|
||||||
#include "parse-events.h"
|
#include "parse-events.h"
|
||||||
#include "exec_cmd.h"
|
#include "exec_cmd.h"
|
||||||
#include "string.h"
|
#include "linux/string.h"
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "header.h"
|
#include "header.h"
|
||||||
|
@ -823,6 +823,32 @@ int parse_events_name(struct list_head *list, char *name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_events__scanner(const char *str, void *data, int start_token);
|
||||||
|
|
||||||
|
static int parse_events_fixup(int ret, const char *str, void *data,
|
||||||
|
int start_token)
|
||||||
|
{
|
||||||
|
char *o = strdup(str);
|
||||||
|
char *s = NULL;
|
||||||
|
char *t = o;
|
||||||
|
char *p;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
if (!o)
|
||||||
|
return ret;
|
||||||
|
while ((p = strsep(&t, ",")) != NULL) {
|
||||||
|
if (s)
|
||||||
|
str_append(&s, &len, ",");
|
||||||
|
str_append(&s, &len, "cpu/");
|
||||||
|
str_append(&s, &len, p);
|
||||||
|
str_append(&s, &len, "/");
|
||||||
|
}
|
||||||
|
free(o);
|
||||||
|
if (!s)
|
||||||
|
return -ENOMEM;
|
||||||
|
return parse_events__scanner(s, data, start_token);
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_events__scanner(const char *str, void *data, int start_token)
|
static int parse_events__scanner(const char *str, void *data, int start_token)
|
||||||
{
|
{
|
||||||
YY_BUFFER_STATE buffer;
|
YY_BUFFER_STATE buffer;
|
||||||
|
@ -843,6 +869,8 @@ static int parse_events__scanner(const char *str, void *data, int start_token)
|
||||||
parse_events__flush_buffer(buffer, scanner);
|
parse_events__flush_buffer(buffer, scanner);
|
||||||
parse_events__delete_buffer(buffer, scanner);
|
parse_events__delete_buffer(buffer, scanner);
|
||||||
parse_events_lex_destroy(scanner);
|
parse_events_lex_destroy(scanner);
|
||||||
|
if (ret && !strchr(str, '/'))
|
||||||
|
ret = parse_events_fixup(ret, str, data, start_token);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,3 +387,27 @@ void *memdup(const void *src, size_t len)
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* str_append - reallocate string and append another
|
||||||
|
* @s: pointer to string pointer
|
||||||
|
* @len: pointer to len (initialized)
|
||||||
|
* @a: string to append.
|
||||||
|
*/
|
||||||
|
int str_append(char **s, int *len, const char *a)
|
||||||
|
{
|
||||||
|
int olen = *s ? strlen(*s) : 0;
|
||||||
|
int nlen = olen + strlen(a) + 1;
|
||||||
|
if (*len < nlen) {
|
||||||
|
*len = *len * 2;
|
||||||
|
if (*len < nlen)
|
||||||
|
*len = nlen;
|
||||||
|
*s = realloc(*s, *len);
|
||||||
|
if (!*s)
|
||||||
|
return -ENOMEM;
|
||||||
|
if (olen == 0)
|
||||||
|
**s = 0;
|
||||||
|
}
|
||||||
|
strcat(*s, a);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue