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:
Andi Kleen 2013-04-20 11:02:28 -07:00 committed by Arnaldo Carvalho de Melo
parent 380512345e
commit 50e200f079
3 changed files with 54 additions and 1 deletions

View file

@ -387,3 +387,27 @@ void *memdup(const void *src, size_t len)
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;
}