Commit 5d7be90e authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf tools: Fix modifier to be applied on correct events

The event modifier needs to be applied only on the event definition it
is attached to.

The current state is that in case of multiple events definition (in
single '-e' option, separated by ',') all will get modifier of the last
one.

Fixing this by adding separated list for each event definition, so the
modifier is applied only to proper event(s). Added automated test to
catch this, plus some other modifier tests.
Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1332267341-26338-3-git-send-email-jolsa@redhat.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9fafd98f
...@@ -877,6 +877,58 @@ static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) ...@@ -877,6 +877,58 @@ static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
return test__checkevent_genhw(evlist); return test__checkevent_genhw(evlist);
} }
static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist)
{
struct perf_evsel *evsel = list_entry(evlist->entries.next,
struct perf_evsel, node);
TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
return test__checkevent_breakpoint(evlist);
}
static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist)
{
struct perf_evsel *evsel = list_entry(evlist->entries.next,
struct perf_evsel, node);
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
return test__checkevent_breakpoint_x(evlist);
}
static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist)
{
struct perf_evsel *evsel = list_entry(evlist->entries.next,
struct perf_evsel, node);
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
return test__checkevent_breakpoint_r(evlist);
}
static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist)
{
struct perf_evsel *evsel = list_entry(evlist->entries.next,
struct perf_evsel, node);
TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
return test__checkevent_breakpoint_w(evlist);
}
static int test__checkevent_pmu(struct perf_evlist *evlist) static int test__checkevent_pmu(struct perf_evlist *evlist)
{ {
...@@ -893,6 +945,47 @@ static int test__checkevent_pmu(struct perf_evlist *evlist) ...@@ -893,6 +945,47 @@ static int test__checkevent_pmu(struct perf_evlist *evlist)
return 0; return 0;
} }
static int test__checkevent_list(struct perf_evlist *evlist)
{
struct perf_evsel *evsel;
TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
/* r1 */
evsel = list_entry(evlist->entries.next, struct perf_evsel, node);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1);
TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2);
TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
/* syscalls:sys_enter_open:k */
evsel = list_entry(evsel->node.next, struct perf_evsel, node);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
TEST_ASSERT_VAL("wrong sample_type",
(PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | PERF_SAMPLE_CPU) ==
evsel->attr.sample_type);
TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
/* 1:1:hp */
evsel = list_entry(evsel->node.next, struct perf_evsel, node);
TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
return 0;
}
static struct test__event_st { static struct test__event_st {
const char *name; const char *name;
__u32 type; __u32 type;
...@@ -974,10 +1067,30 @@ static struct test__event_st { ...@@ -974,10 +1067,30 @@ static struct test__event_st {
.name = "L1-dcache-load-miss:kp", .name = "L1-dcache-load-miss:kp",
.check = test__checkevent_genhw_modifier, .check = test__checkevent_genhw_modifier,
}, },
{
.name = "mem:0:u",
.check = test__checkevent_breakpoint_modifier,
},
{
.name = "mem:0:x:k",
.check = test__checkevent_breakpoint_x_modifier,
},
{
.name = "mem:0:r:hp",
.check = test__checkevent_breakpoint_r_modifier,
},
{
.name = "mem:0:w:up",
.check = test__checkevent_breakpoint_w_modifier,
},
{ {
.name = "cpu/config=10,config1,config2=3,period=1000/u", .name = "cpu/config=10,config1,config2=3,period=1000/u",
.check = test__checkevent_pmu, .check = test__checkevent_pmu,
}, },
{
.name = "r1,syscalls:sys_enter_open:k,1:1:hp",
.check = test__checkevent_list,
},
}; };
#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st)) #define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))
...@@ -1003,10 +1116,9 @@ static int test__parse_events(void) ...@@ -1003,10 +1116,9 @@ static int test__parse_events(void)
} }
ret = e->check(evlist); ret = e->check(evlist);
perf_evlist__delete(evlist);
if (ret) if (ret)
break; break;
perf_evlist__delete(evlist);
} }
return ret; return ret;
......
/* A Bison parser, made by GNU Bison 2.4.3. */ /* A Bison parser, made by GNU Bison 2.5. */
/* Skeleton implementation for Bison's Yacc-like parsers in C /* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -45,7 +44,7 @@ ...@@ -45,7 +44,7 @@
#define YYBISON 1 #define YYBISON 1
/* Bison version. */ /* Bison version. */
#define YYBISON_VERSION "2.4.3" #define YYBISON_VERSION "2.5"
/* Skeleton name. */ /* Skeleton name. */
#define YYSKELETON_NAME "yacc.c" #define YYSKELETON_NAME "yacc.c"
...@@ -74,8 +73,8 @@ ...@@ -74,8 +73,8 @@
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
/* Line 189 of yacc.c */ /* Line 268 of yacc.c */
#line 6 "util/parse-events.y" #line 7 "util/parse-events.y"
#define YYDEBUG 1 #define YYDEBUG 1
...@@ -96,8 +95,8 @@ do { \ ...@@ -96,8 +95,8 @@ do { \
/* Line 189 of yacc.c */ /* Line 268 of yacc.c */
#line 101 "util/parse-events-bison.c" #line 100 "util/parse-events-bison.c"
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
...@@ -145,8 +144,8 @@ do { \ ...@@ -145,8 +144,8 @@ do { \
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 214 of yacc.c */ /* Line 293 of yacc.c */
#line 45 "util/parse-events.y" #line 46 "util/parse-events.y"
char *str; char *str;
unsigned long num; unsigned long num;
...@@ -155,8 +154,8 @@ typedef union YYSTYPE ...@@ -155,8 +154,8 @@ typedef union YYSTYPE
/* Line 214 of yacc.c */ /* Line 293 of yacc.c */
#line 160 "util/parse-events-bison.c" #line 159 "util/parse-events-bison.c"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
...@@ -167,8 +166,8 @@ typedef union YYSTYPE ...@@ -167,8 +166,8 @@ typedef union YYSTYPE
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
/* Line 264 of yacc.c */ /* Line 343 of yacc.c */
#line 172 "util/parse-events-bison.c" #line 171 "util/parse-events-bison.c"
#ifdef short #ifdef short
# undef short # undef short
...@@ -271,11 +270,11 @@ YYID (yyi) ...@@ -271,11 +270,11 @@ YYID (yyi)
# define alloca _alloca # define alloca _alloca
# else # else
# define YYSTACK_ALLOC alloca # define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef _STDLIB_H # ifndef EXIT_SUCCESS
# define _STDLIB_H 1 # define EXIT_SUCCESS 0
# endif # endif
# endif # endif
# endif # endif
...@@ -298,24 +297,24 @@ YYID (yyi) ...@@ -298,24 +297,24 @@ YYID (yyi)
# ifndef YYSTACK_ALLOC_MAXIMUM # ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif # endif
# if (defined __cplusplus && ! defined _STDLIB_H \ # if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \ && ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free))) && (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef _STDLIB_H # ifndef EXIT_SUCCESS
# define _STDLIB_H 1 # define EXIT_SUCCESS 0
# endif # endif
# endif # endif
# ifndef YYMALLOC # ifndef YYMALLOC
# define YYMALLOC malloc # define YYMALLOC malloc
# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif # endif
# endif # endif
# ifndef YYFREE # ifndef YYFREE
# define YYFREE free # define YYFREE free
# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */ void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif # endif
...@@ -344,23 +343,7 @@ union yyalloc ...@@ -344,23 +343,7 @@ union yyalloc
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ YYSTACK_GAP_MAXIMUM) + YYSTACK_GAP_MAXIMUM)
/* Copy COUNT objects from FROM to TO. The source and destination do # define YYCOPY_NEEDED 1
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
/* Relocate STACK from its old location to the new one. The /* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of local variables YYSIZE and YYSTACKSIZE give the old and new number of
...@@ -380,6 +363,26 @@ union yyalloc ...@@ -380,6 +363,26 @@ union yyalloc
#endif #endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */ /* YYFINAL -- State number of the termination state. */
#define YYFINAL 25 #define YYFINAL 25
/* YYLAST -- Last index in YYTABLE. */ /* YYLAST -- Last index in YYTABLE. */
...@@ -463,10 +466,10 @@ static const yytype_int8 yyrhs[] = ...@@ -463,10 +466,10 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] = static const yytype_uint8 yyrline[] =
{ {
0, 54, 54, 54, 57, 62, 64, 65, 66, 67, 0, 55, 55, 55, 58, 69, 74, 75, 76, 77,
68, 69, 70, 73, 80, 89, 98, 103, 108, 114, 78, 79, 80, 83, 90, 99, 108, 113, 118, 124,
119, 125, 131, 137, 143, 153, 165, 174, 183, 192, 129, 135, 141, 147, 153, 163, 175, 184, 193, 202,
200, 208, 208, 210, 210, 210 210, 218, 218, 220, 220, 220
}; };
#endif #endif
...@@ -514,8 +517,8 @@ static const yytype_uint8 yyr2[] = ...@@ -514,8 +517,8 @@ static const yytype_uint8 yyr2[] =
1, 1, 0, 1, 1, 0 1, 1, 0, 1, 1, 0
}; };
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
STATE-NUM when YYTABLE doesn't specify something else to do. Zero Performed when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */ means the default is an error. */
static const yytype_uint8 yydefact[] = static const yytype_uint8 yydefact[] =
{ {
...@@ -556,8 +559,7 @@ static const yytype_int8 yypgoto[] = ...@@ -556,8 +559,7 @@ static const yytype_int8 yypgoto[] =
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says. number is the opposite. If YYTABLE_NINF, syntax error. */
If YYTABLE_NINF, syntax error. */
#define YYTABLE_NINF -1 #define YYTABLE_NINF -1
static const yytype_uint8 yytable[] = static const yytype_uint8 yytable[] =
{ {
...@@ -568,6 +570,12 @@ static const yytype_uint8 yytable[] = ...@@ -568,6 +570,12 @@ static const yytype_uint8 yytable[] =
38, 54, 0, 43 38, 54, 0, 43
}; };
#define yypact_value_is_default(yystate) \
((yystate) == (-15))
#define yytable_value_is_error(yytable_value) \
YYID (0)
static const yytype_int8 yycheck[] = static const yytype_int8 yycheck[] =
{ {
14, 15, 16, 0, 3, 4, 5, 16, 7, 18, 14, 15, 16, 0, 3, 4, 5, 16, 7, 18,
...@@ -622,13 +630,12 @@ do \ ...@@ -622,13 +630,12 @@ do \
{ \ { \
yychar = (Token); \ yychar = (Token); \
yylval = (Value); \ yylval = (Value); \
yytoken = YYTRANSLATE (yychar); \
YYPOPSTACK (1); \ YYPOPSTACK (1); \
goto yybackup; \ goto yybackup; \
} \ } \
else \ else \
{ \ { \
yyerror (list, idx, YY_("syntax error: cannot back up")); \ yyerror (list_all, list_event, idx, YY_("syntax error: cannot back up")); \
YYERROR; \ YYERROR; \
} \ } \
while (YYID (0)) while (YYID (0))
...@@ -664,19 +671,10 @@ while (YYID (0)) ...@@ -664,19 +671,10 @@ while (YYID (0))
#endif #endif
/* YY_LOCATION_PRINT -- Print the location on the stream. /* This macro is provided for backward compatibility. */
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT #ifndef YY_LOCATION_PRINT
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0) # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif #endif
...@@ -708,7 +706,7 @@ do { \ ...@@ -708,7 +706,7 @@ do { \
{ \ { \
YYFPRINTF (stderr, "%s ", Title); \ YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \ yy_symbol_print (stderr, \
Type, Value, list, idx); \ Type, Value, list_all, list_event, idx); \
YYFPRINTF (stderr, "\n"); \ YYFPRINTF (stderr, "\n"); \
} \ } \
} while (YYID (0)) } while (YYID (0))
...@@ -722,20 +720,22 @@ do { \ ...@@ -722,20 +720,22 @@ do { \
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
static void static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *list, int *idx) yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *list_all, struct list_head *list_event, int *idx)
#else #else
static void static void
yy_symbol_value_print (yyoutput, yytype, yyvaluep, list, idx) yy_symbol_value_print (yyoutput, yytype, yyvaluep, list_all, list_event, idx)
FILE *yyoutput; FILE *yyoutput;
int yytype; int yytype;
YYSTYPE const * const yyvaluep; YYSTYPE const * const yyvaluep;
struct list_head *list; struct list_head *list_all;
struct list_head *list_event;
int *idx; int *idx;
#endif #endif
{ {
if (!yyvaluep) if (!yyvaluep)
return; return;
YYUSE (list); YYUSE (list_all);
YYUSE (list_event);
YYUSE (idx); YYUSE (idx);
# ifdef YYPRINT # ifdef YYPRINT
if (yytype < YYNTOKENS) if (yytype < YYNTOKENS)
...@@ -758,14 +758,15 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, list, idx) ...@@ -758,14 +758,15 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, list, idx)
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
static void static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *list, int *idx) yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct list_head *list_all, struct list_head *list_event, int *idx)
#else #else
static void static void
yy_symbol_print (yyoutput, yytype, yyvaluep, list, idx) yy_symbol_print (yyoutput, yytype, yyvaluep, list_all, list_event, idx)
FILE *yyoutput; FILE *yyoutput;
int yytype; int yytype;
YYSTYPE const * const yyvaluep; YYSTYPE const * const yyvaluep;
struct list_head *list; struct list_head *list_all;
struct list_head *list_event;
int *idx; int *idx;
#endif #endif
{ {
...@@ -774,7 +775,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, list, idx) ...@@ -774,7 +775,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, list, idx)
else else
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
yy_symbol_value_print (yyoutput, yytype, yyvaluep, list, idx); yy_symbol_value_print (yyoutput, yytype, yyvaluep, list_all, list_event, idx);
YYFPRINTF (yyoutput, ")"); YYFPRINTF (yyoutput, ")");
} }
...@@ -817,13 +818,14 @@ do { \ ...@@ -817,13 +818,14 @@ do { \
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
static void static void
yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct list_head *list, int *idx) yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct list_head *list_all, struct list_head *list_event, int *idx)
#else #else
static void static void
yy_reduce_print (yyvsp, yyrule, list, idx) yy_reduce_print (yyvsp, yyrule, list_all, list_event, idx)
YYSTYPE *yyvsp; YYSTYPE *yyvsp;
int yyrule; int yyrule;
struct list_head *list; struct list_head *list_all;
struct list_head *list_event;
int *idx; int *idx;
#endif #endif
{ {
...@@ -838,7 +840,7 @@ yy_reduce_print (yyvsp, yyrule, list, idx) ...@@ -838,7 +840,7 @@ yy_reduce_print (yyvsp, yyrule, list, idx)
YYFPRINTF (stderr, " $%d = ", yyi + 1); YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)]) &(yyvsp[(yyi + 1) - (yynrhs)])
, list, idx); , list_all, list_event, idx);
YYFPRINTF (stderr, "\n"); YYFPRINTF (stderr, "\n");
} }
} }
...@@ -846,7 +848,7 @@ yy_reduce_print (yyvsp, yyrule, list, idx) ...@@ -846,7 +848,7 @@ yy_reduce_print (yyvsp, yyrule, list, idx)
# define YY_REDUCE_PRINT(Rule) \ # define YY_REDUCE_PRINT(Rule) \
do { \ do { \
if (yydebug) \ if (yydebug) \
yy_reduce_print (yyvsp, Rule, list, idx); \ yy_reduce_print (yyvsp, Rule, list_all, list_event, idx); \
} while (YYID (0)) } while (YYID (0))
/* Nonzero means print parse trace. It is left uninitialized so that /* Nonzero means print parse trace. It is left uninitialized so that
...@@ -876,7 +878,6 @@ int yydebug; ...@@ -876,7 +878,6 @@ int yydebug;
# define YYMAXDEPTH 10000 # define YYMAXDEPTH 10000
#endif #endif
#if YYERROR_VERBOSE #if YYERROR_VERBOSE
...@@ -979,115 +980,142 @@ yytnamerr (char *yyres, const char *yystr) ...@@ -979,115 +980,142 @@ yytnamerr (char *yyres, const char *yystr)
} }
# endif # endif
/* Copy into YYRESULT an error message about the unexpected token /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
YYCHAR while in state YYSTATE. Return the number of bytes copied, about the unexpected token YYTOKEN for the state stack whose top is
including the terminating null byte. If YYRESULT is null, do not YYSSP.
copy anything; just return the number of bytes that would be
copied. As a special case, return 0 if an ordinary "syntax error"
message will do. Return YYSIZE_MAXIMUM if overflow occurs during
size calculation. */
static YYSIZE_T
yysyntax_error (char *yyresult, int yystate, int yychar)
{
int yyn = yypact[yystate];
if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
return 0; not large enough to hold the message. In that case, also set
else *YYMSG_ALLOC to the required number of bytes. Return 2 if the
{ required number of bytes is too large to store. */
int yytype = YYTRANSLATE (yychar); static int
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
YYSIZE_T yysize = yysize0; YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1; YYSIZE_T yysize1;
int yysize_overflow = 0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = 0;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
int yyx; /* Number of reported tokens (one for the "unexpected", one per
"expected"). */
# if 0 int yycount = 0;
/* This is so xgettext sees the translatable formats that are
constructed on the fly. */ /* There are many possibilities here to consider:
YY_("syntax error, unexpected %s"); - Assume YYFAIL is not used. It's too flawed to consider. See
YY_("syntax error, unexpected %s, expecting %s"); <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
YY_("syntax error, unexpected %s, expecting %s or %s"); for details. YYERROR is fine as it does not invoke this
YY_("syntax error, unexpected %s, expecting %s or %s or %s"); function.
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); - If this state is a consistent state with a default action, then
# endif the only way this function was invoked is if the default action
char *yyfmt; is an error action. In that case, don't check for expected
char const *yyf; tokens because there are none.
static char const yyunexpected[] = "syntax error, unexpected %s"; - The only way there can be no lookahead present (in yychar) is if
static char const yyexpecting[] = ", expecting %s"; this state is a consistent state with a default action. Thus,
static char const yyor[] = " or %s"; detecting the absence of a lookahead is sufficient to determine
char yyformat[sizeof yyunexpected that there is no unexpected or expected token to report. In that
+ sizeof yyexpecting - 1 case, just report a simple "syntax error".
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - Don't assume there isn't a lookahead just because this state is a
* (sizeof yyor - 1))]; consistent state with a default action. There might have been a
char const *yyprefix = yyexpecting; previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated yychar.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (yytoken != YYEMPTY)
{
int yyn = yypact[*yyssp];
yyarg[yycount++] = yytname[yytoken];
if (!yypact_value_is_default (yyn))
{
/* Start YYX at -YYN if negative to avoid negative indexes in /* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. */ YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0; int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */ /* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1; int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yycount = 1; int yyx;
yyarg[0] = yytname[yytype];
yyfmt = yystpcpy (yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx) for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{ {
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{ {
yycount = 1; yycount = 1;
yysize = yysize0; yysize = yysize0;
yyformat[sizeof yyunexpected - 1] = '\0';
break; break;
} }
yyarg[yycount++] = yytname[yyx]; yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize1 = yysize + yytnamerr (0, yytname[yyx]);
yysize_overflow |= (yysize1 < yysize); if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1; yysize = yysize1;
yyfmt = yystpcpy (yyfmt, yyprefix); }
yyprefix = yyor; }
} }
yyf = YY_(yyformat); switch (yycount)
yysize1 = yysize + yystrlen (yyf); {
yysize_overflow |= (yysize1 < yysize); # define YYCASE_(N, S) \
yysize = yysize1; case N: \
yyformat = S; \
break
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef YYCASE_
}
if (yysize_overflow) yysize1 = yysize + yystrlen (yyformat);
return YYSIZE_MAXIMUM; if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
yysize = yysize1;
if (yyresult) if (*yymsg_alloc < yysize)
{ {
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 1;
}
/* Avoid sprintf, as that infringes on the user's name space. /* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */ produced a string with the wrong number of "%s"s. */
char *yyp = yyresult;
int yyi = 0;
while ((*yyp = *yyf) != '\0')
{ {
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{ {
yyp += yytnamerr (yyp, yyarg[yyi++]); yyp += yytnamerr (yyp, yyarg[yyi++]);
yyf += 2; yyformat += 2;
} }
else else
{ {
yyp++; yyp++;
yyf++; yyformat++;
}
} }
} }
return yysize; return 0;
}
} }
#endif /* YYERROR_VERBOSE */ #endif /* YYERROR_VERBOSE */
/*-----------------------------------------------. /*-----------------------------------------------.
| Release the memory associated to this symbol. | | Release the memory associated to this symbol. |
...@@ -1097,19 +1125,21 @@ yysyntax_error (char *yyresult, int yystate, int yychar) ...@@ -1097,19 +1125,21 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
static void static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct list_head *list, int *idx) yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct list_head *list_all, struct list_head *list_event, int *idx)
#else #else
static void static void
yydestruct (yymsg, yytype, yyvaluep, list, idx) yydestruct (yymsg, yytype, yyvaluep, list_all, list_event, idx)
const char *yymsg; const char *yymsg;
int yytype; int yytype;
YYSTYPE *yyvaluep; YYSTYPE *yyvaluep;
struct list_head *list; struct list_head *list_all;
struct list_head *list_event;
int *idx; int *idx;
#endif #endif
{ {
YYUSE (yyvaluep); YYUSE (yyvaluep);
YYUSE (list); YYUSE (list_all);
YYUSE (list_event);
YYUSE (idx); YYUSE (idx);
if (!yymsg) if (!yymsg)
...@@ -1124,6 +1154,7 @@ yydestruct (yymsg, yytype, yyvaluep, list, idx) ...@@ -1124,6 +1154,7 @@ yydestruct (yymsg, yytype, yyvaluep, list, idx)
} }
} }
/* Prevent warnings from -Wmissing-prototypes. */ /* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM #ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus #if defined __STDC__ || defined __cplusplus
...@@ -1133,7 +1164,7 @@ int yyparse (); ...@@ -1133,7 +1164,7 @@ int yyparse ();
#endif #endif
#else /* ! YYPARSE_PARAM */ #else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus #if defined __STDC__ || defined __cplusplus
int yyparse (struct list_head *list, int *idx); int yyparse (struct list_head *list_all, struct list_head *list_event, int *idx);
#else #else
int yyparse (); int yyparse ();
#endif #endif
...@@ -1150,10 +1181,9 @@ YYSTYPE yylval; ...@@ -1150,10 +1181,9 @@ YYSTYPE yylval;
int yynerrs; int yynerrs;
/*----------.
/*-------------------------. | yyparse. |
| yyparse or yypush_parse. | `----------*/
`-------------------------*/
#ifdef YYPARSE_PARAM #ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
...@@ -1169,17 +1199,16 @@ yyparse (YYPARSE_PARAM) ...@@ -1169,17 +1199,16 @@ yyparse (YYPARSE_PARAM)
#if (defined __STDC__ || defined __C99__FUNC__ \ #if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER) || defined __cplusplus || defined _MSC_VER)
int int
yyparse (struct list_head *list, int *idx) yyparse (struct list_head *list_all, struct list_head *list_event, int *idx)
#else #else
int int
yyparse (list, idx) yyparse (list_all, list_event, idx)
struct list_head *list; struct list_head *list_all;
struct list_head *list_event;
int *idx; int *idx;
#endif #endif
#endif #endif
{ {
int yystate; int yystate;
/* Number of tokens to shift before error messages enabled. */ /* Number of tokens to shift before error messages enabled. */
int yyerrstatus; int yyerrstatus;
...@@ -1334,7 +1363,7 @@ yyparse (list, idx) ...@@ -1334,7 +1363,7 @@ yyparse (list, idx)
/* First try to decide what to do without reference to lookahead token. */ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate]; yyn = yypact[yystate];
if (yyn == YYPACT_NINF) if (yypact_value_is_default (yyn))
goto yydefault; goto yydefault;
/* Not known => get a lookahead token if don't already have one. */ /* Not known => get a lookahead token if don't already have one. */
...@@ -1365,7 +1394,7 @@ yyparse (list, idx) ...@@ -1365,7 +1394,7 @@ yyparse (list, idx)
yyn = yytable[yyn]; yyn = yytable[yyn];
if (yyn <= 0) if (yyn <= 0)
{ {
if (yyn == 0 || yyn == YYTABLE_NINF) if (yytable_value_is_error (yyn))
goto yyerrlab; goto yyerrlab;
yyn = -yyn; yyn = -yyn;
goto yyreduce; goto yyreduce;
...@@ -1421,124 +1450,139 @@ yyparse (list, idx) ...@@ -1421,124 +1450,139 @@ yyparse (list, idx)
{ {
case 4: case 4:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 58 "util/parse-events.y" #line 59 "util/parse-events.y"
{ {
ABORT_ON(parse_events_modifier(list, (yyvsp[(2) - (2)].str))); /*
;} * Apply modifier on all events added by single event definition
* (there could be more events added for multiple tracepoint
* definitions via '*?'.
*/
ABORT_ON(parse_events_modifier(list_event, (yyvsp[(2) - (2)].str)));
parse_events_update_lists(list_event, list_all);
}
break;
case 5:
/* Line 1806 of yacc.c */
#line 70 "util/parse-events.y"
{
parse_events_update_lists(list_event, list_all);
}
break; break;
case 13: case 13:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 74 "util/parse-events.y" #line 84 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_pmu(list, idx, (yyvsp[(1) - (4)].str), (yyvsp[(3) - (4)].head))); ABORT_ON(parse_events_add_pmu(list_event, idx, (yyvsp[(1) - (4)].str), (yyvsp[(3) - (4)].head)));
parse_events__free_terms((yyvsp[(3) - (4)].head)); parse_events__free_terms((yyvsp[(3) - (4)].head));
;} }
break; break;
case 14: case 14:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 81 "util/parse-events.y" #line 91 "util/parse-events.y"
{ {
int type = (yyvsp[(1) - (4)].num) >> 16; int type = (yyvsp[(1) - (4)].num) >> 16;
int config = (yyvsp[(1) - (4)].num) & 255; int config = (yyvsp[(1) - (4)].num) & 255;
ABORT_ON(parse_events_add_numeric(list, idx, type, config, (yyvsp[(3) - (4)].head))); ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, (yyvsp[(3) - (4)].head)));
parse_events__free_terms((yyvsp[(3) - (4)].head)); parse_events__free_terms((yyvsp[(3) - (4)].head));
;} }
break; break;
case 15: case 15:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 90 "util/parse-events.y" #line 100 "util/parse-events.y"
{ {
int type = (yyvsp[(1) - (2)].num) >> 16; int type = (yyvsp[(1) - (2)].num) >> 16;
int config = (yyvsp[(1) - (2)].num) & 255; int config = (yyvsp[(1) - (2)].num) & 255;
ABORT_ON(parse_events_add_numeric(list, idx, type, config, NULL)); ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, NULL));
;} }
break; break;
case 16: case 16:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 99 "util/parse-events.y" #line 109 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str))); ABORT_ON(parse_events_add_cache(list_event, idx, (yyvsp[(1) - (5)].str), (yyvsp[(3) - (5)].str), (yyvsp[(5) - (5)].str)));
;} }
break; break;
case 17: case 17:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 104 "util/parse-events.y" #line 114 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str), NULL)); ABORT_ON(parse_events_add_cache(list_event, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str), NULL));
;} }
break; break;
case 18: case 18:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 109 "util/parse-events.y" #line 119 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_cache(list, idx, (yyvsp[(1) - (1)].str), NULL, NULL)); ABORT_ON(parse_events_add_cache(list_event, idx, (yyvsp[(1) - (1)].str), NULL, NULL));
;} }
break; break;
case 19: case 19:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 115 "util/parse-events.y" #line 125 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) (yyvsp[(2) - (5)].num), (yyvsp[(4) - (5)].str))); ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) (yyvsp[(2) - (5)].num), (yyvsp[(4) - (5)].str)));
;} }
break; break;
case 20: case 20:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 120 "util/parse-events.y" #line 130 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) (yyvsp[(2) - (3)].num), NULL)); ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) (yyvsp[(2) - (3)].num), NULL));
;} }
break; break;
case 21: case 21:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 126 "util/parse-events.y" #line 136 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_tracepoint(list, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str))); ABORT_ON(parse_events_add_tracepoint(list_event, idx, (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str)));
;} }
break; break;
case 22: case 22:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 132 "util/parse-events.y" #line 142 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_numeric(list, idx, (yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num), NULL)); ABORT_ON(parse_events_add_numeric(list_event, idx, (yyvsp[(1) - (3)].num), (yyvsp[(3) - (3)].num), NULL));
;} }
break; break;
case 23: case 23:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 138 "util/parse-events.y" #line 148 "util/parse-events.y"
{ {
ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, (yyvsp[(1) - (1)].num), NULL)); ABORT_ON(parse_events_add_numeric(list_event, idx, PERF_TYPE_RAW, (yyvsp[(1) - (1)].num), NULL));
;} }
break; break;
case 24: case 24:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 144 "util/parse-events.y" #line 154 "util/parse-events.y"
{ {
struct list_head *head = (yyvsp[(1) - (3)].head); struct list_head *head = (yyvsp[(1) - (3)].head);
struct parse_events__term *term = (yyvsp[(3) - (3)].term); struct parse_events__term *term = (yyvsp[(3) - (3)].term);
...@@ -1546,13 +1590,13 @@ yyparse (list, idx) ...@@ -1546,13 +1590,13 @@ yyparse (list, idx)
ABORT_ON(!head); ABORT_ON(!head);
list_add_tail(&term->list, head); list_add_tail(&term->list, head);
(yyval.head) = (yyvsp[(1) - (3)].head); (yyval.head) = (yyvsp[(1) - (3)].head);
;} }
break; break;
case 25: case 25:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 154 "util/parse-events.y" #line 164 "util/parse-events.y"
{ {
struct list_head *head = malloc(sizeof(*head)); struct list_head *head = malloc(sizeof(*head));
struct parse_events__term *term = (yyvsp[(1) - (1)].term); struct parse_events__term *term = (yyvsp[(1) - (1)].term);
...@@ -1561,78 +1605,89 @@ yyparse (list, idx) ...@@ -1561,78 +1605,89 @@ yyparse (list, idx)
INIT_LIST_HEAD(head); INIT_LIST_HEAD(head);
list_add_tail(&term->list, head); list_add_tail(&term->list, head);
(yyval.head) = head; (yyval.head) = head;
;} }
break; break;
case 26: case 26:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 166 "util/parse-events.y" #line 176 "util/parse-events.y"
{ {
struct parse_events__term *term; struct parse_events__term *term;
ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR, ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_STR,
(yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str), 0)); (yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].str), 0));
(yyval.term) = term; (yyval.term) = term;
;} }
break; break;
case 27: case 27:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 175 "util/parse-events.y" #line 185 "util/parse-events.y"
{ {
struct parse_events__term *term; struct parse_events__term *term;
ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM, ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
(yyvsp[(1) - (3)].str), NULL, (yyvsp[(3) - (3)].num))); (yyvsp[(1) - (3)].str), NULL, (yyvsp[(3) - (3)].num)));
(yyval.term) = term; (yyval.term) = term;
;} }
break; break;
case 28: case 28:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 184 "util/parse-events.y" #line 194 "util/parse-events.y"
{ {
struct parse_events__term *term; struct parse_events__term *term;
ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM, ABORT_ON(parse_events__new_term(&term, PARSE_EVENTS__TERM_TYPE_NUM,
(yyvsp[(1) - (1)].str), NULL, 1)); (yyvsp[(1) - (1)].str), NULL, 1));
(yyval.term) = term; (yyval.term) = term;
;} }
break; break;
case 29: case 29:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 193 "util/parse-events.y" #line 203 "util/parse-events.y"
{ {
struct parse_events__term *term; struct parse_events__term *term;
ABORT_ON(parse_events__new_term(&term, (yyvsp[(1) - (3)].num), NULL, NULL, (yyvsp[(3) - (3)].num))); ABORT_ON(parse_events__new_term(&term, (yyvsp[(1) - (3)].num), NULL, NULL, (yyvsp[(3) - (3)].num)));
(yyval.term) = term; (yyval.term) = term;
;} }
break; break;
case 30: case 30:
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 201 "util/parse-events.y" #line 211 "util/parse-events.y"
{ {
struct parse_events__term *term; struct parse_events__term *term;
ABORT_ON(parse_events__new_term(&term, (yyvsp[(1) - (1)].num), NULL, NULL, 1)); ABORT_ON(parse_events__new_term(&term, (yyvsp[(1) - (1)].num), NULL, NULL, 1));
(yyval.term) = term; (yyval.term) = term;
;} }
break; break;
/* Line 1464 of yacc.c */ /* Line 1806 of yacc.c */
#line 1634 "util/parse-events-bison.c" #line 1678 "util/parse-events-bison.c"
default: break; default: break;
} }
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen); YYPOPSTACK (yylen);
...@@ -1660,44 +1715,47 @@ yyparse (list, idx) ...@@ -1660,44 +1715,47 @@ yyparse (list, idx)
| yyerrlab -- here on detecting error | | yyerrlab -- here on detecting error |
`------------------------------------*/ `------------------------------------*/
yyerrlab: yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */ /* If not already recovering from an error, report this error. */
if (!yyerrstatus) if (!yyerrstatus)
{ {
++yynerrs; ++yynerrs;
#if ! YYERROR_VERBOSE #if ! YYERROR_VERBOSE
yyerror (list, idx, YY_("syntax error")); yyerror (list_all, list_event, idx, YY_("syntax error"));
#else #else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{ {
YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); char const *yymsgp = YY_("syntax error");
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{ {
YYSIZE_T yyalloc = 2 * yysize;
if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
yyalloc = YYSTACK_ALLOC_MAXIMUM;
if (yymsg != yymsgbuf) if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg); YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yyalloc); yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (yymsg) if (!yymsg)
yymsg_alloc = yyalloc;
else
{ {
yymsg = yymsgbuf; yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf; yymsg_alloc = sizeof yymsgbuf;
} yysyntax_error_status = 2;
}
if (0 < yysize && yysize <= yymsg_alloc)
{
(void) yysyntax_error (yymsg, yystate, yychar);
yyerror (list, idx, yymsg);
} }
else else
{ {
yyerror (list, idx, YY_("syntax error")); yysyntax_error_status = YYSYNTAX_ERROR;
if (yysize != 0) yymsgp = yymsg;
goto yyexhaustedlab;
} }
} }
yyerror (list_all, list_event, idx, yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif #endif
} }
...@@ -1717,7 +1775,7 @@ yyparse (list, idx) ...@@ -1717,7 +1775,7 @@ yyparse (list, idx)
else else
{ {
yydestruct ("Error: discarding", yydestruct ("Error: discarding",
yytoken, &yylval, list, idx); yytoken, &yylval, list_all, list_event, idx);
yychar = YYEMPTY; yychar = YYEMPTY;
} }
} }
...@@ -1756,7 +1814,7 @@ yyparse (list, idx) ...@@ -1756,7 +1814,7 @@ yyparse (list, idx)
for (;;) for (;;)
{ {
yyn = yypact[yystate]; yyn = yypact[yystate];
if (yyn != YYPACT_NINF) if (!yypact_value_is_default (yyn))
{ {
yyn += YYTERROR; yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
...@@ -1773,7 +1831,7 @@ yyparse (list, idx) ...@@ -1773,7 +1831,7 @@ yyparse (list, idx)
yydestruct ("Error: popping", yydestruct ("Error: popping",
yystos[yystate], yyvsp, list, idx); yystos[yystate], yyvsp, list_all, list_event, idx);
YYPOPSTACK (1); YYPOPSTACK (1);
yystate = *yyssp; yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp); YY_STACK_PRINT (yyss, yyssp);
...@@ -1808,15 +1866,20 @@ yyparse (list, idx) ...@@ -1808,15 +1866,20 @@ yyparse (list, idx)
| yyexhaustedlab -- memory exhaustion comes here. | | yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/ `-------------------------------------------------*/
yyexhaustedlab: yyexhaustedlab:
yyerror (list, idx, YY_("memory exhausted")); yyerror (list_all, list_event, idx, YY_("memory exhausted"));
yyresult = 2; yyresult = 2;
/* Fall through. */ /* Fall through. */
#endif #endif
yyreturn: yyreturn:
if (yychar != YYEMPTY) if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead", yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, list, idx); yytoken, &yylval, list_all, list_event, idx);
}
/* Do not reclaim the symbols of the rule which action triggered /* Do not reclaim the symbols of the rule which action triggered
this YYABORT or YYACCEPT. */ this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen); YYPOPSTACK (yylen);
...@@ -1824,7 +1887,7 @@ yyparse (list, idx) ...@@ -1824,7 +1887,7 @@ yyparse (list, idx)
while (yyssp != yyss) while (yyssp != yyss)
{ {
yydestruct ("Cleanup: popping", yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp, list, idx); yystos[*yyssp], yyvsp, list_all, list_event, idx);
YYPOPSTACK (1); YYPOPSTACK (1);
} }
#ifndef yyoverflow #ifndef yyoverflow
...@@ -1841,11 +1904,13 @@ yyparse (list, idx) ...@@ -1841,11 +1904,13 @@ yyparse (list, idx)
/* Line 1684 of yacc.c */ /* Line 2067 of yacc.c */
#line 212 "util/parse-events.y" #line 222 "util/parse-events.y"
void parse_events_error(struct list_head *list __used, int *idx __used, void parse_events_error(struct list_head *list_all __used,
struct list_head *list_event __used,
int *idx __used,
char const *msg __used) char const *msg __used)
{ {
} }
......
/* A Bison parser, made by GNU Bison 2.4.3. */ /* A Bison parser, made by GNU Bison 2.5. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -59,8 +58,8 @@ ...@@ -59,8 +58,8 @@
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 1685 of yacc.c */ /* Line 2068 of yacc.c */
#line 45 "util/parse-events.y" #line 46 "util/parse-events.y"
char *str; char *str;
unsigned long num; unsigned long num;
...@@ -69,8 +68,8 @@ typedef union YYSTYPE ...@@ -69,8 +68,8 @@ typedef union YYSTYPE
/* Line 1685 of yacc.c */ /* Line 2068 of yacc.c */
#line 74 "util/parse-events-bison.h" #line 73 "util/parse-events-bison.h"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
......
...@@ -23,7 +23,8 @@ struct event_symbol { ...@@ -23,7 +23,8 @@ struct event_symbol {
const char *alias; const char *alias;
}; };
int parse_events_parse(struct list_head *list, int *idx); int parse_events_parse(struct list_head *list, struct list_head *list_tmp,
int *idx);
#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x #define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x #define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
...@@ -671,6 +672,18 @@ int parse_events_add_pmu(struct list_head *list, int *idx, ...@@ -671,6 +672,18 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
return add_event(list, idx, &attr, (char *) "pmu"); return add_event(list, idx, &attr, (char *) "pmu");
} }
void parse_events_update_lists(struct list_head *list_event,
struct list_head *list_all)
{
/*
* Called for single event definition. Update the
* 'all event' list, and reinit the 'signle event'
* list, for next event definition.
*/
list_splice_tail(list_event, list_all);
INIT_LIST_HEAD(list_event);
}
int parse_events_modifier(struct list_head *list, char *str) int parse_events_modifier(struct list_head *list, char *str)
{ {
struct perf_evsel *evsel; struct perf_evsel *evsel;
...@@ -736,14 +749,14 @@ int parse_events_modifier(struct list_head *list, char *str) ...@@ -736,14 +749,14 @@ int parse_events_modifier(struct list_head *list, char *str)
int parse_events(struct perf_evlist *evlist, const char *str, int unset __used) int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
{ {
struct perf_evsel *evsel, *h;
LIST_HEAD(list); LIST_HEAD(list);
LIST_HEAD(list_tmp);
YY_BUFFER_STATE buffer; YY_BUFFER_STATE buffer;
int ret, idx = evlist->nr_entries; int ret, idx = evlist->nr_entries;
buffer = parse_events__scan_string(str); buffer = parse_events__scan_string(str);
ret = parse_events_parse(&list, &idx); ret = parse_events_parse(&list, &list_tmp, &idx);
parse_events__flush_buffer(buffer); parse_events__flush_buffer(buffer);
parse_events__delete_buffer(buffer); parse_events__delete_buffer(buffer);
...@@ -754,9 +767,11 @@ int parse_events(struct perf_evlist *evlist, const char *str, int unset __used) ...@@ -754,9 +767,11 @@ int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
return 0; return 0;
} }
list_for_each_entry_safe(evsel, h, &list, node) /*
perf_evsel__delete(evsel); * There are 2 users - builtin-record and builtin-test objects.
* Both call perf_evlist__delete in case of error, so we dont
* need to bother.
*/
fprintf(stderr, "invalid or unsupported event: '%s'\n", str); fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
fprintf(stderr, "Run 'perf list' for a list of valid events\n"); fprintf(stderr, "Run 'perf list' for a list of valid events\n");
return ret; return ret;
......
...@@ -76,8 +76,11 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx, ...@@ -76,8 +76,11 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx,
void *ptr, char *type); void *ptr, char *type);
int parse_events_add_pmu(struct list_head *list, int *idx, int parse_events_add_pmu(struct list_head *list, int *idx,
char *pmu , struct list_head *head_config); char *pmu , struct list_head *head_config);
void parse_events_error(struct list_head *list, int *idx, void parse_events_update_lists(struct list_head *list_event,
char const *msg); struct list_head *list_all);
void parse_events_error(struct list_head *list_all,
struct list_head *list_event,
int *idx, char const *msg);
void print_events(const char *event_glob); void print_events(const char *event_glob);
void print_events_type(u8 type); void print_events_type(u8 type);
......
%name-prefix "parse_events_" %name-prefix "parse_events_"
%parse-param {struct list_head *list} %parse-param {struct list_head *list_all}
%parse-param {struct list_head *list_event}
%parse-param {int *idx} %parse-param {int *idx}
%{ %{
...@@ -56,10 +57,19 @@ events ',' event | event ...@@ -56,10 +57,19 @@ events ',' event | event
event: event:
event_def PE_MODIFIER_EVENT event_def PE_MODIFIER_EVENT
{ {
ABORT_ON(parse_events_modifier(list, $2)); /*
* Apply modifier on all events added by single event definition
* (there could be more events added for multiple tracepoint
* definitions via '*?'.
*/
ABORT_ON(parse_events_modifier(list_event, $2));
parse_events_update_lists(list_event, list_all);
} }
| |
event_def event_def
{
parse_events_update_lists(list_event, list_all);
}
event_def: event_pmu | event_def: event_pmu |
event_legacy_symbol | event_legacy_symbol |
...@@ -72,7 +82,7 @@ event_def: event_pmu | ...@@ -72,7 +82,7 @@ event_def: event_pmu |
event_pmu: event_pmu:
PE_NAME '/' event_config '/' PE_NAME '/' event_config '/'
{ {
ABORT_ON(parse_events_add_pmu(list, idx, $1, $3)); ABORT_ON(parse_events_add_pmu(list_event, idx, $1, $3));
parse_events__free_terms($3); parse_events__free_terms($3);
} }
...@@ -82,7 +92,7 @@ PE_VALUE_SYM '/' event_config '/' ...@@ -82,7 +92,7 @@ PE_VALUE_SYM '/' event_config '/'
int type = $1 >> 16; int type = $1 >> 16;
int config = $1 & 255; int config = $1 & 255;
ABORT_ON(parse_events_add_numeric(list, idx, type, config, $3)); ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, $3));
parse_events__free_terms($3); parse_events__free_terms($3);
} }
| |
...@@ -91,52 +101,52 @@ PE_VALUE_SYM sep_slash_dc ...@@ -91,52 +101,52 @@ PE_VALUE_SYM sep_slash_dc
int type = $1 >> 16; int type = $1 >> 16;
int config = $1 & 255; int config = $1 & 255;
ABORT_ON(parse_events_add_numeric(list, idx, type, config, NULL)); ABORT_ON(parse_events_add_numeric(list_event, idx, type, config, NULL));
} }
event_legacy_cache: event_legacy_cache:
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT
{ {
ABORT_ON(parse_events_add_cache(list, idx, $1, $3, $5)); ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, $5));
} }
| |
PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT
{ {
ABORT_ON(parse_events_add_cache(list, idx, $1, $3, NULL)); ABORT_ON(parse_events_add_cache(list_event, idx, $1, $3, NULL));
} }
| |
PE_NAME_CACHE_TYPE PE_NAME_CACHE_TYPE
{ {
ABORT_ON(parse_events_add_cache(list, idx, $1, NULL, NULL)); ABORT_ON(parse_events_add_cache(list_event, idx, $1, NULL, NULL));
} }
event_legacy_mem: event_legacy_mem:
PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
{ {
ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, $4)); ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, $4));
} }
| |
PE_PREFIX_MEM PE_VALUE sep_dc PE_PREFIX_MEM PE_VALUE sep_dc
{ {
ABORT_ON(parse_events_add_breakpoint(list, idx, (void *) $2, NULL)); ABORT_ON(parse_events_add_breakpoint(list_event, idx, (void *) $2, NULL));
} }
event_legacy_tracepoint: event_legacy_tracepoint:
PE_NAME ':' PE_NAME PE_NAME ':' PE_NAME
{ {
ABORT_ON(parse_events_add_tracepoint(list, idx, $1, $3)); ABORT_ON(parse_events_add_tracepoint(list_event, idx, $1, $3));
} }
event_legacy_numeric: event_legacy_numeric:
PE_VALUE ':' PE_VALUE PE_VALUE ':' PE_VALUE
{ {
ABORT_ON(parse_events_add_numeric(list, idx, $1, $3, NULL)); ABORT_ON(parse_events_add_numeric(list_event, idx, $1, $3, NULL));
} }
event_legacy_raw: event_legacy_raw:
PE_RAW PE_RAW
{ {
ABORT_ON(parse_events_add_numeric(list, idx, PERF_TYPE_RAW, $1, NULL)); ABORT_ON(parse_events_add_numeric(list_event, idx, PERF_TYPE_RAW, $1, NULL));
} }
event_config: event_config:
...@@ -211,7 +221,9 @@ sep_slash_dc: '/' | ':' | ...@@ -211,7 +221,9 @@ sep_slash_dc: '/' | ':' |
%% %%
void parse_events_error(struct list_head *list __used, int *idx __used, void parse_events_error(struct list_head *list_all __used,
struct list_head *list_event __used,
int *idx __used,
char const *msg __used) char const *msg __used)
{ {
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment