aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fernandes <joelaf@google.com>2017-06-26 17:38:53 -0700
committerKP Singh <kpsingh@google.com>2017-06-29 23:11:27 +0200
commit2a58727813c91d5497ce5452b5bff1bc1a467dc7 (patch)
tree7c624b5404d1c61ae93dfa71ff4499ad6e97ca0e
parent1e326a177d920d27a4a5f0368095d875c6895c91 (diff)
downloadtrappy-2a58727813c91d5497ce5452b5bff1bc1a467dc7.tar.gz
trappy/ftrace: refactor getting class for unique word
Lets move this out of the main parsing loop so that the code is easier to read. Suggested-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/ftrace.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/trappy/ftrace.py b/trappy/ftrace.py
index e2a636c..c0a40c2 100644
--- a/trappy/ftrace.py
+++ b/trappy/ftrace.py
@@ -249,6 +249,15 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
trace_class = DynamicTypeFactory(event_name, (Base,), kwords)
self.class_definitions[event_name] = trace_class
+ def __get_trace_class(self, line, cls_word):
+ trace_class = None
+ for unique_word, cls in cls_word.iteritems():
+ if unique_word in line:
+ trace_class = cls
+ if not cls.fallback:
+ return trace_class
+ return trace_class
+
def __populate_data(self, fin, cls_for_unique_word):
"""Append to trace data from a txt trace"""
@@ -257,16 +266,10 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
actual_trace)
for line in actual_trace:
- trace_class = None
- for unique_word, cls in cls_for_unique_word.iteritems():
- if unique_word in line:
- trace_class = cls
- if not cls.fallback:
- break
- else:
- if not trace_class:
- self.lines += 1
- continue
+ trace_class = self.__get_trace_class(line, cls_for_unique_word)
+ if not trace_class:
+ self.lines += 1
+ continue
line = line[:-1]