aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--tests/test_base.py8
-rw-r--r--trappy/base.py12
-rw-r--r--trappy/ftrace.py8
3 files changed, 16 insertions, 12 deletions
diff --git a/tests/test_base.py b/tests/test_base.py
index a0a4920..8bebfba 100644
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -85,7 +85,7 @@ class TestBase(utils_tests.SetupDirectory):
in_data = """ kworker/4:1-397 [004] 720.741315: thermal_power_cpu_get: cpus=000000f0 freq=1900000 raw_cpu_power=1259 load={} power=61
kworker/4:1-397 [004] 720.741349: thermal_power_cpu_get: cpus=0000000f freq=1400000 raw_cpu_power=189 load={} power=14"""
- expected_columns = set(["__comm", "__pid", "__cpu", "__line", "cpus", "freq",
+ expected_columns = set(["__comm", "__pid", "__tgid", "__cpu", "__line", "cpus", "freq",
"raw_cpu_power", "power"])
with open("trace.txt", "w") as fout:
@@ -131,7 +131,7 @@ class TestBase(utils_tests.SetupDirectory):
timestamp
)
- expected_columns = set(["__comm", "__pid", "__cpu", "__line", "tag"])
+ expected_columns = set(["__comm", "__pid", "__tgid", "__cpu", "__line", "tag"])
with open("trace.txt", "w") as fout:
fout.write(in_data)
@@ -157,7 +157,7 @@ class TestBase(utils_tests.SetupDirectory):
in_data = """ rcu_preempt-7 [000] 73.604532: my_sched_stat_runtime: comm=Space separated taskname pid=7 runtime=262875 [ns] vruntime=17096359856 [ns]"""
- expected_columns = set(["__comm", "__pid", "__cpu", "__line", "comm", "pid", "runtime", "vruntime"])
+ expected_columns = set(["__comm", "__pid", "__tgid", "__cpu", "__line", "comm", "pid", "runtime", "vruntime"])
with open("trace.txt", "w") as fout:
fout.write(in_data)
@@ -234,7 +234,7 @@ class TestBase(utils_tests.SetupDirectory):
df = trace.equals_event.data_frame
self.assertSetEqual(set(df.columns),
- set(["__comm", "__pid", "__cpu", "__line", "my_field"]))
+ set(["__comm", "__pid", "__tgid", "__cpu", "__line", "my_field"]))
self.assertListEqual(df["my_field"].tolist(),
["foo", "foo=bar", "foo=bar=baz", 1,
"1=2", "1=foo", "1foo=2"])
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):