diff options
author | Joel Fernandes <joelaf@google.com> | 2017-06-11 22:04:45 -0700 |
---|---|---|
committer | KP Singh <kpsingh@google.com> | 2017-06-14 23:40:08 +0200 |
commit | 2e58198d1ea27e93a0e8c622d1ecc13be06f645f (patch) | |
tree | 88d526039853e552a2b2781d6c8d98d05544fd81 | |
parent | 43bb10340af5eaa41eb70c0fc8e3cb245e3f56bb (diff) | |
download | trappy-2e58198d1ea27e93a0e8c622d1ecc13be06f645f.tar.gz |
trappy/systrace: Provide custom data string parsing
Here we provide custom data string parsing for Android userspace events.
Borrowed the regex and parsing logic from Patrick's patch.
Co-developed-by: Patrick Bellasi <patrick.bellasi@arm.com>
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-by: KP Singh <kpsingh@google.com>
-rw-r--r-- | trappy/systrace.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/trappy/systrace.py b/trappy/systrace.py index 6e917a6..e18abf8 100644 --- a/trappy/systrace.py +++ b/trappy/systrace.py @@ -14,6 +14,10 @@ # from trappy.ftrace import GenericFTrace +import re + +SYSTRACE_EVENT = re.compile( + r'^(?P<event>[A-Z])(\|(?P<pid>\d+)\|(?P<func>.*)(\|(?P<data>\d+))?)?') class drop_before_trace(object): """Object that, when called, returns True if the line is not part of @@ -75,3 +79,16 @@ class SysTrace(GenericFTrace): """ return lambda x: not x.endswith("</script>\n") + + def generate_data_dict(self, data_str): + """ Custom parsing for systrace's userspace events """ + data_dict = None + + match = SYSTRACE_EVENT.match(data_str) + if match: + data_dict = { 'event': match.group('event'), + 'pid' : match.group('pid'), + 'func' : match.group('func'), + 'data' : match.group('data') } + + return data_dict |