perf tools: Separate 'mem:' event scanner bits

Separating 'mem:' scanner processing, so we can parse out modifier
specifically and dont clash with other rules.

This is just precaution for the future, so we dont need to worry about
the rules clashing where we need to parse out any sub-rule of global
rules.

Signed-off-by: Jiri 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/1337584373-2741-5-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Jiri Olsa 2012-05-21 09:12:52 +02:00 committed by Arnaldo Carvalho de Melo
parent b847cbdc67
commit 08d2f762ac
2 changed files with 24 additions and 2 deletions

View File

@ -787,6 +787,7 @@ int parse_events(struct perf_evlist *evlist, const char *str, int unset __used)
parse_events__flush_buffer(buffer); parse_events__flush_buffer(buffer);
parse_events__delete_buffer(buffer); parse_events__delete_buffer(buffer);
parse_events_lex_destroy();
if (!ret) { if (!ret) {
int entries = idx - evlist->nr_entries; int entries = idx - evlist->nr_entries;

View File

@ -1,5 +1,6 @@
%option prefix="parse_events_" %option prefix="parse_events_"
%option stack
%{ %{
#include <errno.h> #include <errno.h>
@ -50,6 +51,8 @@ static int term(int type)
%} %}
%x mem
num_dec [0-9]+ num_dec [0-9]+
num_hex 0x[a-fA-F0-9]+ num_hex 0x[a-fA-F0-9]+
num_raw_hex [a-fA-F0-9]+ num_raw_hex [a-fA-F0-9]+
@ -105,13 +108,12 @@ config2 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG2); }
period { return term(PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } period { return term(PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
branch_type { return term(PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); } branch_type { return term(PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
mem: { return PE_PREFIX_MEM; } mem: { BEGIN(mem); return PE_PREFIX_MEM; }
r{num_raw_hex} { return raw(); } r{num_raw_hex} { return raw(); }
{num_dec} { return value(10); } {num_dec} { return value(10); }
{num_hex} { return value(16); } {num_hex} { return value(16); }
{modifier_event} { return str(PE_MODIFIER_EVENT); } {modifier_event} { return str(PE_MODIFIER_EVENT); }
{modifier_bp} { return str(PE_MODIFIER_BP); }
{name} { return str(PE_NAME); } {name} { return str(PE_NAME); }
"/" { return '/'; } "/" { return '/'; }
- { return '-'; } - { return '-'; }
@ -119,6 +121,25 @@ r{num_raw_hex} { return raw(); }
: { return ':'; } : { return ':'; }
= { return '='; } = { return '='; }
<mem>{
{modifier_bp} { return str(PE_MODIFIER_BP); }
: { return ':'; }
{num_dec} { return value(10); }
{num_hex} { return value(16); }
/*
* We need to separate 'mem:' scanner part, in order to get specific
* modifier bits parsed out. Otherwise we would need to handle PE_NAME
* and we'd need to parse it manually. During the escape from <mem>
* state we need to put the escaping char back, so we dont miss it.
*/
. { unput(*parse_events_text); BEGIN(INITIAL); }
/*
* We destroy the scanner after reaching EOF,
* but anyway just to be sure get back to INIT state.
*/
<<EOF>> { BEGIN(INITIAL); }
}
%% %%
int parse_events_wrap(void) int parse_events_wrap(void)