aboutsummaryrefslogtreecommitdiff
path: root/trappy
diff options
context:
space:
mode:
authorJoel Fernandes <joelaf@google.com>2017-06-28 13:41:03 -0700
committerJoel Fernandes <joelaf@google.com>2017-06-29 14:33:13 -0700
commit7f0b67931d5035205915a27cf6808707cf5b2030 (patch)
treede1aca603470b13e715bb8e8531ab0bdb366b1f1 /trappy
parentf0c228a018cd332d28451f3e851b5e0640d917a6 (diff)
downloadtrappy-7f0b67931d5035205915a27cf6808707cf5b2030.tar.gz
trappy: add support to parse TGID in systrace
Change-Id: Ie79698d90e0406cc11c52d364144ec08c33dfac4 Signed-off-by: Joel Fernandes <joelaf@google.com>
Diffstat (limited to 'trappy')
-rw-r--r--trappy/base.py12
-rw-r--r--trappy/ftrace.py8
2 files changed, 12 insertions, 8 deletions
diff --git a/trappy/base.py b/trappy/base.py
index 06857b5..8a7fb38 100644
--- a/trappy/base.py
+++ b/trappy/base.py
@@ -111,6 +111,7 @@ class Base(object):
self.time_array = []
self.comm_array = []
self.pid_array = []
+ self.tgid_array = []
self.cpu_array = []
self.parse_raw = parse_raw
self.cached = False
@@ -152,7 +153,7 @@ class Base(object):
return ret
- def append_data(self, time, comm, pid, cpu, line, data):
+ def append_data(self, time, comm, pid, tgid, cpu, line, data):
"""Append data parsed from a line to the corresponding arrays
The :mod:`DataFrame` will be created from this when the whole trace
@@ -176,6 +177,7 @@ class Base(object):
self.time_array.append(time)
self.comm_array.append(comm)
self.pid_array.append(pid)
+ self.tgid_array.append(tgid)
self.cpu_array.append(cpu)
self.line_array.append(line)
self.data_array.append(data)
@@ -226,10 +228,10 @@ class Base(object):
check_memory_usage = True
check_memory_count = 1
- for (comm, pid, cpu, line, data_str) in zip(self.comm_array, self.pid_array,
- self.cpu_array, self.line_array,
- self.data_array):
- data_dict = {"__comm": comm, "__pid": pid, "__cpu": cpu, "__line": line}
+ for (comm, pid, tgid, cpu, line, data_str) in zip(self.comm_array, self.pid_array,
+ self.tgid_array, self.cpu_array,
+ self.line_array, self.data_array):
+ data_dict = {"__comm": comm, "__pid": pid, "__tgid": tgid, "__cpu": cpu, "__line": line}
data_dict.update(self.generate_data_dict(data_str))
# When running out of memory, Pandas has been observed to segfault
diff --git a/trappy/ftrace.py b/trappy/ftrace.py
index c0a40c2..ce344c0 100644
--- a/trappy/ftrace.py
+++ b/trappy/ftrace.py
@@ -51,8 +51,8 @@ def _plot_freq_hists(allfreqs, what, axis, title):
"Frequency", xlim, "default")
SPECIAL_FIELDS_RE = re.compile(
- r"^\s*(?P<comm>.*)-(?P<pid>\d+)(?:\s+\(.*\))"\
- r"?\s+\[(?P<cpu>\d+)\](?:\s+....)?\s+"\
+ r"^\s*(?P<comm>.*)-(?P<pid>\d+)\s+\(?(?P<tgid>.*?)?\)"\
+ r"?\s*\[(?P<cpu>\d+)\](?:\s+....)?\s+"\
r"(?P<timestamp>[0-9]+(?P<us>\.[0-9]+)?): (\w+:\s+)+(?P<data>.+)"
)
@@ -279,6 +279,8 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
comm = fields_match.group('comm')
pid = int(fields_match.group('pid'))
cpu = int(fields_match.group('cpu'))
+ tgid = fields_match.group('tgid')
+ tgid = -1 if (not tgid or '-' in tgid) else int(tgid)
# The timestamp, depending on the trace_clock configuration, can be
# reported either in [s].[us] or [ns] format. Let's ensure that we
@@ -305,7 +307,7 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace."""
if "={}" in data_str:
data_str = re.sub(r"[A-Za-z0-9_]+=\{\} ", r"", data_str)
- trace_class.append_data(timestamp, comm, pid, cpu, self.lines, data_str)
+ trace_class.append_data(timestamp, comm, pid, tgid, cpu, self.lines, data_str)
self.lines += 1
def trace_hasnt_started(self):