Merge "trace_processor: add userspace LMK events to the instants table"
diff --git a/src/trace_processor/proto_trace_parser.cc b/src/trace_processor/proto_trace_parser.cc
index fedf4b2..e06d155 100644
--- a/src/trace_processor/proto_trace_parser.cc
+++ b/src/trace_processor/proto_trace_parser.cc
@@ -706,9 +706,9 @@
// Storing the pid of the event that is lmk-ed.
auto* instants = context_->storage->mutable_instants();
- UniqueTid utid = context_->process_tracker->UpdateThread(timestamp, pid, 0);
+ UniquePid upid = context_->process_tracker->UpdateProcess(pid);
uint32_t row =
- instants->AddInstantEvent(timestamp, lmk_id_, 0, utid, RefType::kRefUtid);
+ instants->AddInstantEvent(timestamp, lmk_id_, 0, upid, RefType::kRefUpid);
// Store the comm as an arg.
RowId row_id = TraceStorage::CreateRowId(TableId::kInstants, row);
@@ -907,6 +907,22 @@
}
case 'C': {
+ // LMK events from userspace are hacked as counter events with the "value"
+ // of the counter representing the pid of the killed process which is
+ // reset to 0 once the kill is complete.
+ // Homogenise this with kernel LMK events as an instant event, ignoring
+ // the resets to 0.
+ if (point.name == "kill_one_process") {
+ auto killed_pid = static_cast<uint32_t>(point.value);
+ if (killed_pid != 0) {
+ UniquePid killed_upid =
+ context_->process_tracker->UpdateProcess(killed_pid);
+ context_->storage->mutable_instants()->AddInstantEvent(
+ timestamp, lmk_id_, 0, killed_upid, RefType::kRefUpid);
+ }
+ // TODO(tilal6991): we should not add LMK events to the counters table
+ // once the UI has support for displaying instants.
+ }
UniqueTid utid =
context_->process_tracker->UpdateThread(timestamp, point.tid, 0);
StringId name_id = context_->storage->InternString(point.name);
diff --git a/test/trace_processor/index b/test/trace_processor/index
index aaea2e4..0e9c901 100644
--- a/test/trace_processor/index
+++ b/test/trace_processor/index
@@ -19,3 +19,4 @@
../data/android_log.pb android_log_counts.sql android_log_counts.out
../data/android_log.pb android_log_msgs.sql android_log_msgs.out
../data/android_log_ring_buffer_mode.pb android_log_ring_buffer_mode.sql android_log_ring_buffer_mode.out
+../data/lmk_userspace.pb lmk.sql lmk_userspace_lmk.out
\ No newline at end of file
diff --git a/test/trace_processor/lmk.sql b/test/trace_processor/lmk.sql
new file mode 100644
index 0000000..8a5de9e
--- /dev/null
+++ b/test/trace_processor/lmk.sql
@@ -0,0 +1,4 @@
+select ts, process.pid
+from instants
+inner join process
+on instants.ref = process.upid;
\ No newline at end of file
diff --git a/test/trace_processor/lmk_userspace_lmk.out b/test/trace_processor/lmk_userspace_lmk.out
new file mode 100644
index 0000000..dc7ed0a
--- /dev/null
+++ b/test/trace_processor/lmk_userspace_lmk.out
@@ -0,0 +1,5 @@
+"ts","pid"
+732246100696424,17924
+732246180149452,21090
+732246388596557,21120
+732246415955101,21151
diff --git a/tools/install-build-deps b/tools/install-build-deps
index d3309c0..f8bee09 100755
--- a/tools/install-build-deps
+++ b/tools/install-build-deps
@@ -188,8 +188,8 @@
# Example traces for regression tests.
('buildtools/test_data.zip',
- 'https://storage.googleapis.com/perfetto/test-data-20190110.zip',
- '3d6b98a8267782d297594fd1f49789f3f0869eff',
+ 'https://storage.googleapis.com/perfetto/test-data-20190114.zip',
+ '1408d7d6544558e9f459f2a7879f3f664d7278d1',
'all',
),