mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-22 12:58:36 +00:00
trace_cmd: parser for sched_switch events and fixes
- Compiled regular expressions in EVENT_PARSER_MAP now get handled correctly. - regex_body_parser now attemts to convert field values to ints, bringing it inline with the default parser behavior. - There is now a regex for sched_switch events.
This commit is contained in:
parent
6a85dff94f
commit
0f60e9600f
@ -164,7 +164,11 @@ def regex_body_parser(regex, flags=0):
|
|||||||
def regex_parser_func(event, text):
|
def regex_parser_func(event, text):
|
||||||
match = regex.search(text)
|
match = regex.search(text)
|
||||||
if match:
|
if match:
|
||||||
event.fields.update(match.groupdict())
|
for k, v in match.groupdict().iteritems():
|
||||||
|
try:
|
||||||
|
event.fields[k] = int(v)
|
||||||
|
except ValueError:
|
||||||
|
event.fields[k] = v
|
||||||
|
|
||||||
return regex_parser_func
|
return regex_parser_func
|
||||||
|
|
||||||
@ -178,6 +182,11 @@ def regex_body_parser(regex, flags=0):
|
|||||||
# regex). In case of a string/regex, it's named groups will be used to populate
|
# regex). In case of a string/regex, it's named groups will be used to populate
|
||||||
# the event's attributes.
|
# the event's attributes.
|
||||||
EVENT_PARSER_MAP = {
|
EVENT_PARSER_MAP = {
|
||||||
|
'sched_switch': re.compile(
|
||||||
|
r'(?P<prev_comm>\S.*):(?P<prev_pid>\d+) \[(?P<prev_prio>\d+)\] (?P<status>\S+)'
|
||||||
|
r' ==> '
|
||||||
|
r'(?P<next_comm>\S.*):(?P<next_pid>\d+) \[(?P<next_prio>\d+)\]'
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_EVENT_REGEX = re.compile(r'^\s+(?P<thread>\S+.*?\S+)\s+\[(?P<cpu_id>\d+)\]\s+(?P<ts>[\d.]+):\s+'
|
TRACE_EVENT_REGEX = re.compile(r'^\s+(?P<thread>\S+.*?\S+)\s+\[(?P<cpu_id>\d+)\]\s+(?P<ts>[\d.]+):\s+'
|
||||||
@ -248,7 +257,7 @@ class TraceCmdTrace(object):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
body_parser = EVENT_PARSER_MAP.get(event_name, default_body_parser)
|
body_parser = EVENT_PARSER_MAP.get(event_name, default_body_parser)
|
||||||
if isinstance(body_parser, basestring):
|
if isinstance(body_parser, basestring) or isinstance(body_parser, re._pattern_type): # pylint: disable=protected-access
|
||||||
body_parser = regex_body_parser(body_parser)
|
body_parser = regex_body_parser(body_parser)
|
||||||
yield TraceCmdEvent(parser=body_parser, **match.groupdict())
|
yield TraceCmdEvent(parser=body_parser, **match.groupdict())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user