Skip to content

Commit

Permalink
perf tools: Fix parsing of 64 bit raw config value for 32 bit
Browse files Browse the repository at this point in the history
perf record fails on 32 bit with:

 invalid or unsupported event: 'r40000F7E0'

Fixing this by parsing 64 bit num values.

Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1344361396-7237-4-git-send-email-robert.richter@amd.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Robert Richter authored and Arnaldo Carvalho de Melo committed Aug 8, 2012
1 parent 2ede830 commit b527bab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions tools/perf/util/parse-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static int config_attr(struct perf_event_attr *attr,
}

int parse_events_add_numeric(struct list_head **list, int *idx,
unsigned long type, unsigned long config,
u32 type, u64 config,
struct list_head *head_config)
{
struct perf_event_attr attr;
Expand Down Expand Up @@ -1005,7 +1005,7 @@ int parse_events__is_hardcoded_term(struct parse_events__term *term)

static int new_term(struct parse_events__term **_term, int type_val,
int type_term, char *config,
char *str, long num)
char *str, u64 num)
{
struct parse_events__term *term;

Expand Down Expand Up @@ -1034,7 +1034,7 @@ static int new_term(struct parse_events__term **_term, int type_val,
}

int parse_events__term_num(struct parse_events__term **term,
int type_term, char *config, long num)
int type_term, char *config, u64 num)
{
return new_term(term, PARSE_EVENTS__TERM_TYPE_NUM, type_term,
config, NULL, num);
Expand Down
6 changes: 3 additions & 3 deletions tools/perf/util/parse-events.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct parse_events__term {
char *config;
union {
char *str;
long num;
u64 num;
} val;
int type_val;
int type_term;
Expand All @@ -73,7 +73,7 @@ struct parse_events_data__terms {

int parse_events__is_hardcoded_term(struct parse_events__term *term);
int parse_events__term_num(struct parse_events__term **_term,
int type_term, char *config, long num);
int type_term, char *config, u64 num);
int parse_events__term_str(struct parse_events__term **_term,
int type_term, char *config, char *str);
int parse_events__term_clone(struct parse_events__term **new,
Expand All @@ -83,7 +83,7 @@ int parse_events_modifier(struct list_head *list, char *str);
int parse_events_add_tracepoint(struct list_head **list, int *idx,
char *sys, char *event);
int parse_events_add_numeric(struct list_head **list, int *idx,
unsigned long type, unsigned long config,
u32 type, u64 config,
struct list_head *head_config);
int parse_events_add_cache(struct list_head **list, int *idx,
char *type, char *op_result1, char *op_result2);
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/util/parse-events.l
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ YYSTYPE *parse_events_get_lval(yyscan_t yyscanner);

static int __value(YYSTYPE *yylval, char *str, int base, int token)
{
long num;
u64 num;

errno = 0;
num = strtoul(str, NULL, base);
num = strtoull(str, NULL, base);
if (errno)
return PE_ERROR;

Expand Down
10 changes: 5 additions & 5 deletions tools/perf/util/parse-events.y
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ do { \
%union
{
char *str;
unsigned long num;
u64 num;
struct list_head *head;
struct parse_events__term *term;
}
Expand Down Expand Up @@ -207,7 +207,7 @@ PE_VALUE ':' PE_VALUE
struct parse_events_data__events *data = _data;
struct list_head *list = NULL;

ABORT_ON(parse_events_add_numeric(&list, &data->idx, $1, $3, NULL));
ABORT_ON(parse_events_add_numeric(&list, &data->idx, (u32)$1, $3, NULL));
$$ = list;
}

Expand Down Expand Up @@ -282,23 +282,23 @@ PE_TERM '=' PE_NAME
{
struct parse_events__term *term;

ABORT_ON(parse_events__term_str(&term, $1, NULL, $3));
ABORT_ON(parse_events__term_str(&term, (int)$1, NULL, $3));
$$ = term;
}
|
PE_TERM '=' PE_VALUE
{
struct parse_events__term *term;

ABORT_ON(parse_events__term_num(&term, $1, NULL, $3));
ABORT_ON(parse_events__term_num(&term, (int)$1, NULL, $3));
$$ = term;
}
|
PE_TERM
{
struct parse_events__term *term;

ABORT_ON(parse_events__term_num(&term, $1, NULL, 1));
ABORT_ON(parse_events__term_num(&term, (int)$1, NULL, 1));
$$ = term;
}

Expand Down

0 comments on commit b527bab

Please sign in to comment.