diff options
author | Yabin Cui <yabinc@google.com> | 2020-11-12 10:14:21 -0800 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2020-11-12 10:24:31 -0800 |
commit | 2cb6c168e6539d9b057ec14d29a8588379cba53a (patch) | |
tree | 8ad7f2cf7a20da551f8f271d7eeed8341b533f06 | |
parent | 769c2b61d5feeafb84b2ed7f436cc0a07b77b64b (diff) | |
download | extras-2cb6c168e6539d9b057ec14d29a8588379cba53a.tar.gz |
simpleperf: wake up per sample in monitor cmd.
It is to show samples in real time.
Also flush stdout after printing each sample.
Bug: none
Test: run simpleperf_unit_test.
Change-Id: I7de8ae82deedb76d736c7635f6818ba7b6f440bc
-rw-r--r-- | simpleperf/cmd_monitor.cpp | 3 | ||||
-rw-r--r-- | simpleperf/event_selection_set.cpp | 9 | ||||
-rw-r--r-- | simpleperf/event_selection_set.h | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/simpleperf/cmd_monitor.cpp b/simpleperf/cmd_monitor.cpp index 4f76bf24..0a1b792c 100644 --- a/simpleperf/cmd_monitor.cpp +++ b/simpleperf/cmd_monitor.cpp @@ -462,6 +462,7 @@ bool MonitorCommand::AdjustPerfEventLimit() { bool MonitorCommand::SetEventSelectionFlags() { event_selection_set_.SampleIdAll(); + event_selection_set_.WakeupPerSample(); if (fp_callchain_sampling_) { event_selection_set_.EnableFpCallChainSampling(); } else if (dwarf_callchain_sampling_) { @@ -512,6 +513,7 @@ void MonitorCommand::DumpSampleRecord(const SampleRecord& sr) { StringAppendF(&output, " pid=%u tid=%u", sr.tid_data.pid, sr.tid_data.tid); StringAppendF(&output, " cpu=%u", sr.cpu_data.cpu); printf("%s\n", output.c_str()); + fflush(stdout); } void MonitorCommand::DumpSampleCallchain(const SampleRecord& sr) { @@ -531,6 +533,7 @@ void MonitorCommand::DumpSampleCallchain(const SampleRecord& sr) { s.dso->Path().c_str(), s.vaddr_in_file); printf("%s\n", output.c_str()); } + fflush(stdout); } } diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp index b92f1005..2ef634b4 100644 --- a/simpleperf/event_selection_set.cpp +++ b/simpleperf/event_selection_set.cpp @@ -488,6 +488,15 @@ bool EventSelectionSet::RecordNotExecutableMaps() const { return groups_[0][0].event_attr.mmap_data == 1; } +void EventSelectionSet::WakeupPerSample() { + for (auto& group : groups_) { + for (auto& selection : group) { + selection.event_attr.watermark = 0; + selection.event_attr.wakeup_events = 1; + } + } +} + bool EventSelectionSet::SetTracepointFilter(const std::string& filter) { // 1. Find the tracepoint event to set filter. EventSelection* selection = nullptr; diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h index c2e2408f..7d84b620 100644 --- a/simpleperf/event_selection_set.h +++ b/simpleperf/event_selection_set.h @@ -128,6 +128,7 @@ class EventSelectionSet { bool NeedKernelSymbol() const; void SetRecordNotExecutableMaps(bool record); bool RecordNotExecutableMaps() const; + void WakeupPerSample(); void SetAddrFilters(std::vector<AddrFilter>&& filters) { addr_filters_ = std::move(filters); } bool SetTracepointFilter(const std::string& filter); |