summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
authorZheng Yan <zheng.z.yan@intel.com>2012-06-15 08:31:39 +0200
committerIngo Molnar <mingo@kernel.org>2012-06-18 12:13:24 +0200
commitac20de6fff445d6deb0c44c25946d198f79f2f00 (patch)
tree8d0ec729ea5b5aa8965e46370df50167506b1e61 /tools/perf/util/parse-events.c
parentperf/tool: Use data struct for arg passing in event parse function (diff)
downloadlinux-ac20de6fff445d6deb0c44c25946d198f79f2f00.tar.xz
linux-ac20de6fff445d6deb0c44c25946d198f79f2f00.zip
perf/tool: Make the event parser re-entrant
Make the event parser reentrant by creating separate scanner for each parsing. The scanner is passed to the bison as and argument to the lexer. Signed-off-by: Zheng Yan <zheng.z.yan@intel.com> [ Cleaned up the patch. ] Signed-off-by: Jiri Olsa <jolsa@redhat.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1339741902-8449-11-git-send-email-zheng.z.yan@intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index c71b29ad26ec..ca8665e19c0d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -11,6 +11,7 @@
#include "cache.h"
#include "header.h"
#include "debugfs.h"
+#include "parse-events-bison.h"
#include "parse-events-flex.h"
#include "pmu.h"
@@ -26,7 +27,7 @@ struct event_symbol {
#ifdef PARSER_DEBUG
extern int parse_events_debug;
#endif
-int parse_events_parse(void *data);
+int parse_events_parse(void *data, void *scanner);
#define CHW(x) .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_##x
#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
@@ -787,26 +788,38 @@ int parse_events_modifier(struct list_head *list, char *str)
return 0;
}
-int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
+static int parse_events__scanner(const char *str, void *data)
{
- struct parse_events_data__events data = {
- .list = LIST_HEAD_INIT(data.list),
- .idx = evlist->nr_entries,
- };
YY_BUFFER_STATE buffer;
+ void *scanner;
int ret;
- buffer = parse_events__scan_string(str);
+ ret = parse_events_lex_init(&scanner);
+ if (ret)
+ return ret;
+
+ buffer = parse_events__scan_string(str, scanner);
#ifdef PARSER_DEBUG
parse_events_debug = 1;
#endif
- ret = parse_events_parse(&data);
+ ret = parse_events_parse(data, scanner);
+
+ parse_events__flush_buffer(buffer, scanner);
+ parse_events__delete_buffer(buffer, scanner);
+ parse_events_lex_destroy(scanner);
+ return ret;
+}
- parse_events__flush_buffer(buffer);
- parse_events__delete_buffer(buffer);
- parse_events_lex_destroy();
+int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
+{
+ struct parse_events_data__events data = {
+ .list = LIST_HEAD_INIT(data.list),
+ .idx = evlist->nr_entries,
+ };
+ int ret;
+ ret = parse_events__scanner(str, &data);
if (!ret) {
int entries = data.idx - evlist->nr_entries;
perf_evlist__splice_list_tail(evlist, &data.list, entries);