diff options
author | Yabin Cui <yabinc@google.com> | 2015-07-16 20:26:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-07-16 20:26:36 +0000 |
commit | dece0f92f30bb6dbfd988907cda2bab15be2d732 (patch) | |
tree | b280b963d956bc7c184b5e3f6fddab0abea364ad /simpleperf | |
parent | a209544b63ca766af379337bd97ca19091f631c2 (diff) | |
parent | 6bf8ca070ef6e2834b21cd0a4271fbc1b6fb92d2 (diff) | |
download | extras-dece0f92f30bb6dbfd988907cda2bab15be2d732.tar.gz |
Merge "Simpleperf: dump thread comm/mmaps for selected threads."
Diffstat (limited to 'simpleperf')
-rw-r--r-- | simpleperf/cmd_record.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp index 71c4e4cd..dd77ec3c 100644 --- a/simpleperf/cmd_record.cpp +++ b/simpleperf/cmd_record.cpp @@ -119,7 +119,7 @@ class RecordCommand : public Command { bool SetEventSelection(); bool WriteData(const char* data, size_t size); bool DumpKernelAndModuleMmaps(); - bool DumpThreadCommAndMmaps(); + bool DumpThreadCommAndMmaps(bool all_threads, const std::vector<pid_t>& selected_threads); bool DumpAdditionalFeatures(const std::vector<std::string>& args); bool DumpBuildIdFeature(); @@ -207,7 +207,7 @@ bool RecordCommand::Run(const std::vector<std::string>& args) { if (!DumpKernelAndModuleMmaps()) { return false; } - if (system_wide_collection_ && !DumpThreadCommAndMmaps()) { + if (!DumpThreadCommAndMmaps(system_wide_collection_, monitored_threads_)) { return false; } @@ -431,11 +431,24 @@ bool RecordCommand::DumpKernelAndModuleMmaps() { return true; } -bool RecordCommand::DumpThreadCommAndMmaps() { +bool RecordCommand::DumpThreadCommAndMmaps(bool all_threads, + const std::vector<pid_t>& selected_threads) { std::vector<ThreadComm> thread_comms; if (!GetThreadComms(&thread_comms)) { return false; } + // Decide which processes and threads to dump. + std::set<pid_t> dump_processes; + std::set<pid_t> dump_threads; + for (auto& tid : selected_threads) { + dump_threads.insert(tid); + } + for (auto& thread : thread_comms) { + if (dump_threads.find(thread.tid) != dump_threads.end()) { + dump_processes.insert(thread.pid); + } + } + const perf_event_attr& attr = event_selection_set_.FindEventAttrByType(measured_event_type_modifier_->event_type); @@ -444,6 +457,9 @@ bool RecordCommand::DumpThreadCommAndMmaps() { if (thread.pid != thread.tid) { continue; } + if (!all_threads && dump_processes.find(thread.pid) == dump_processes.end()) { + continue; + } CommRecord record = CreateCommRecord(attr, thread.pid, thread.tid, thread.comm); if (!record_file_writer_->WriteData(record.BinaryFormat())) { return false; @@ -471,6 +487,9 @@ bool RecordCommand::DumpThreadCommAndMmaps() { if (thread.pid == thread.tid) { continue; } + if (!all_threads && dump_threads.find(thread.tid) == dump_threads.end()) { + continue; + } ForkRecord fork_record = CreateForkRecord(attr, thread.pid, thread.tid, thread.pid, thread.pid); if (!record_file_writer_->WriteData(fork_record.BinaryFormat())) { return false; |