aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Bellasi <patrick.bellasi@arm.com>2017-06-14 11:41:33 +0100
committerKP Singh <kpsingh@google.com>2017-06-15 00:18:40 +0200
commit750f7187a8d0ad2d72a0261261bc9a7d81fbae93 (patch)
tree01445ba3be61ef6616d2bad14c37c57e61ef418f
parent663f1042f35a3dad09f8610bf60d4ecb30efec24 (diff)
downloadtrappy-750f7187a8d0ad2d72a0261261bc9a7d81fbae93.tar.gz
trappy/ftrace: add support to account line numbers
Knowing the line number of a trace event into the original trace file can be super useful for two main reasons: 1. it can be used as a truly unique ID of each DF entry, since it is not subject to the possible index collisions due to the timestamp resoluton 2. it can be super-useful to correlate DF entries with the original trace If this ID is also tracked the same way tools like kernelshark does, than we have a definitive and easy tool to match DF records with kernelshark. Since kernelshark uses a 0-based indexing for trace events, let's account for proper trace events line numbers starting from 0. This number is available as a class property, in case we are interested to know to real total number of events which are available in the original trace. Moreover, it will be used by a following patch to add a unique ID to each DF entry. Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com> Reviewed-by: KP Singh <kpsingh@google.com>
-rw-r--r--trappy/ftrace.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/trappy/ftrace.py b/trappy/ftrace.py
index c9ece0c..56d6199 100644
--- a/trappy/ftrace.py
+++ b/trappy/ftrace.py
@@ -178,7 +178,10 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
actual_trace = itertools.takewhile(self.trace_hasnt_finished(),
actual_trace)
- for line in itertools.ifilter(contains_unique_word, actual_trace):
+ for line in actual_trace:
+ if not contains_unique_word(line):
+ self.lines += 1
+ continue
for unique_word, cls in cls_for_unique_word.iteritems():
if unique_word in line:
trace_class = cls
@@ -204,6 +207,7 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
if (timestamp < window[0] + self.basetime) or \
(timestamp < abs_window[0]):
+ self.lines += 1
continue
if (window[1] and timestamp > window[1] + self.basetime) or \
@@ -214,6 +218,7 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
data_str = re.sub(r"[A-Za-z0-9_]+=\{\} ", r"", data_str)
trace_class.append_data(timestamp, comm, pid, cpu, data_str)
+ self.lines += 1
def trace_hasnt_started(self):
"""Return a function that accepts a line and returns true if this line
@@ -265,6 +270,7 @@ is part of the trace.
try:
with open(trace_file) as fin:
+ self.lines = 0
self.__populate_data(
fin, cls_for_unique_word, window, abs_window)
except FTraceParseError as e: