summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_record.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-06-22 12:27:58 -0700
committerYabin Cui <yabinc@google.com>2015-06-22 13:42:09 -0700
commit41d4ba9f6f2781155a0519a784606d5382cda88f (patch)
tree50b8a2931bea7494b21e1a638d315028b129533d /simpleperf/cmd_record.cpp
parent74d6884c4921e584ce7a775b00eeadac792054aa (diff)
downloadextras-41d4ba9f6f2781155a0519a784606d5382cda88f.tar.gz
Simpleperf: better support for per thread comm.
1. Move ProcessEntry to ThreadEntry, and add thread_comm in SampleEntry. 2. Add support of ForkRecord and Mmap2Record. 3. Dump ForkRecord for each thread in record command. 4. Add sort key 'tid' in report command, and change default keys. Bug: 19483574 Change-Id: Iacc690637154aeb7b6f85373730beb50d638ce86
Diffstat (limited to 'simpleperf/cmd_record.cpp')
-rw-r--r--simpleperf/cmd_record.cpp50
1 files changed, 34 insertions, 16 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp
index b59dcdc2..5dd86da9 100644
--- a/simpleperf/cmd_record.cpp
+++ b/simpleperf/cmd_record.cpp
@@ -387,30 +387,48 @@ bool RecordCommand::DumpThreadCommAndMmaps() {
}
const perf_event_attr& attr =
event_selection_set_.FindEventAttrByType(measured_event_type_modifier_->event_type);
+
+ // Dump processes.
for (auto& thread : thread_comms) {
- CommRecord record = CreateCommRecord(attr, thread.tgid, thread.tid, thread.comm);
+ if (thread.pid != thread.tid) {
+ continue;
+ }
+ CommRecord record = CreateCommRecord(attr, thread.pid, thread.tid, thread.comm);
if (!record_file_writer_->WriteData(record.BinaryFormat())) {
return false;
}
- if (thread.is_process) {
- std::vector<ThreadMmap> thread_mmaps;
- if (!GetThreadMmapsInProcess(thread.tgid, &thread_mmaps)) {
- // The thread may exit before we get its info.
- continue;
+ std::vector<ThreadMmap> thread_mmaps;
+ if (!GetThreadMmapsInProcess(thread.pid, &thread_mmaps)) {
+ // The thread may exit before we get its info.
+ continue;
+ }
+ for (auto& thread_mmap : thread_mmaps) {
+ if (thread_mmap.executable == 0) {
+ continue; // No need to dump non-executable mmap info.
}
- for (auto& thread_mmap : thread_mmaps) {
- if (thread_mmap.executable == 0) {
- continue; // No need to dump non-executable mmap info.
- }
- MmapRecord record =
- CreateMmapRecord(attr, false, thread.tgid, thread.tid, thread_mmap.start_addr,
- thread_mmap.len, thread_mmap.pgoff, thread_mmap.name);
- if (!record_file_writer_->WriteData(record.BinaryFormat())) {
- return false;
- }
+ MmapRecord record =
+ CreateMmapRecord(attr, false, thread.pid, thread.tid, thread_mmap.start_addr,
+ thread_mmap.len, thread_mmap.pgoff, thread_mmap.name);
+ if (!record_file_writer_->WriteData(record.BinaryFormat())) {
+ return false;
}
}
}
+
+ // Dump threads.
+ for (auto& thread : thread_comms) {
+ if (thread.pid == thread.tid) {
+ continue;
+ }
+ ForkRecord fork_record = CreateForkRecord(attr, thread.pid, thread.tid, thread.pid, thread.pid);
+ if (!record_file_writer_->WriteData(fork_record.BinaryFormat())) {
+ return false;
+ }
+ CommRecord comm_record = CreateCommRecord(attr, thread.pid, thread.tid, thread.comm);
+ if (!record_file_writer_->WriteData(comm_record.BinaryFormat())) {
+ return false;
+ }
+ }
return true;
}