diff options
author | Joel Fernandes <joelaf@google.com> | 2017-06-13 20:38:08 -0700 |
---|---|---|
committer | KP Singh <kpsingh@google.com> | 2017-06-14 23:40:19 +0200 |
commit | 071bbff272362e8f0eeb027ba7b148070b465403 (patch) | |
tree | 5b306a3aed4358a2c78c263648b899de22f73736 | |
parent | 2e58198d1ea27e93a0e8c622d1ecc13be06f645f (diff) | |
download | trappy-071bbff272362e8f0eeb027ba7b148070b465403.tar.gz |
trappy: Handle the case for special events injected with tracing_mark_write
Certain fake events can be injected using tracing_mark_write and should be
classified into their own event classes than tracing_mark_write. One way to
handle this is to use tracing_mark_write only as a backup. For this reason lets
introduced the concept of backup event classes and classify TracingMarkWrite as
that.
This case normally doesn't happen because dynamic events are inserted into the
beginning of the event list from what I've seen. Since tracing_mark_write is a
built-in event, and not dynamic, its always at after and so is less preferred.
However we should protect for the future case where there might be a built-in
which happens to be after TrackingMarkWrite class in the list, so lets handle
it now.
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-by: KP Singh <kpsingh@google.com>
-rw-r--r-- | trappy/base.py | 7 | ||||
-rw-r--r-- | trappy/ftrace.py | 6 | ||||
-rw-r--r-- | trappy/tracing_mark_write.py | 3 |
3 files changed, 13 insertions, 3 deletions
diff --git a/trappy/base.py b/trappy/base.py index e603f37..93ce60c 100644 --- a/trappy/base.py +++ b/trappy/base.py @@ -95,10 +95,15 @@ class Base(object): :param parse_raw: If :code:`True`, raw trace data (-R option) to trace-cmd will be used + :param fallback: If :code:`True`, the parsing class will be used + only if no other candidate class's unique_word matched. subclasses + should override this (for ex. TracingMarkWrite uses it) + This class acts as a base class for all TRAPpy events """ - def __init__(self, parse_raw=False): + def __init__(self, parse_raw=False, fallback=False): + self.fallback = fallback self.tracer = None self.data_frame = pd.DataFrame() self.data_array = [] diff --git a/trappy/ftrace.py b/trappy/ftrace.py index 7444516..5bd6872 100644 --- a/trappy/ftrace.py +++ b/trappy/ftrace.py @@ -181,9 +181,11 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace.""" for unique_word, cls in cls_for_unique_word.iteritems(): if unique_word in line: trace_class = cls - break + if not cls.fallback: + break else: - raise FTraceParseError("No unique word in '{}'".format(line)) + if not trace_class: + raise FTraceParseError("No unique word in '{}'".format(line)) line = line[:-1] diff --git a/trappy/tracing_mark_write.py b/trappy/tracing_mark_write.py index 9f10cbc..49a23b0 100644 --- a/trappy/tracing_mark_write.py +++ b/trappy/tracing_mark_write.py @@ -37,4 +37,7 @@ class TracingMarkWrite(Base): data_dict = { 'string': data_str } return data_dict + def __init__(self): + super(TracingMarkWrite, self).__init__(fallback=True) + register_ftrace_parser(TracingMarkWrite) |