summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_list.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-06-01 15:39:39 -0700
committerYabin Cui <yabinc@google.com>2016-06-01 15:46:07 -0700
commitebf79f3a65c81ef0f8cd7a3b875771be88157fcc (patch)
treecef9949781d2a3f07ff762412f8ca7e68217d853 /simpleperf/cmd_list.cpp
parent85a3e6e14fd777b92199b2e39a3b80acd77a7a0f (diff)
downloadextras-ebf79f3a65c81ef0f8cd7a3b875771be88157fcc.tar.gz
simpleperf: check perf event limit.
The property security.perf_harden is added in https://android-review.googlesource.com/#/c/233736/5. And simpleperf needs to notice that. Bug: 29054680 Change-Id: I5f1593f5b389d182a56c4bf3bd438a1dc2b66686
Diffstat (limited to 'simpleperf/cmd_list.cpp')
-rw-r--r--simpleperf/cmd_list.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/simpleperf/cmd_list.cpp b/simpleperf/cmd_list.cpp
index b6bf817c..273a8037 100644
--- a/simpleperf/cmd_list.cpp
+++ b/simpleperf/cmd_list.cpp
@@ -22,6 +22,7 @@
#include <android-base/logging.h>
#include "command.h"
+#include "environment.h"
#include "event_attr.h"
#include "event_fd.h"
#include "event_type.h"
@@ -30,9 +31,14 @@ static void PrintEventTypesOfType(uint32_t type, const std::string& type_name,
const std::vector<EventType>& event_types) {
printf("List of %s:\n", type_name.c_str());
for (auto& event_type : event_types) {
- if (event_type.type == type &&
- IsEventAttrSupportedByKernel(CreateDefaultPerfEventAttr(event_type))) {
- printf(" %s\n", event_type.name.c_str());
+ if (event_type.type == type) {
+ perf_event_attr attr = CreateDefaultPerfEventAttr(event_type);
+ // Exclude kernel to list supported events even when
+ // /proc/sys/kernel/perf_event_paranoid is 2.
+ attr.exclude_kernel = 1;
+ if (IsEventAttrSupportedByKernel(attr)) {
+ printf(" %s\n", event_type.name.c_str());
+ }
}
}
printf("\n");
@@ -50,6 +56,10 @@ class ListCommand : public Command {
};
bool ListCommand::Run(const std::vector<std::string>& args) {
+ if (!CheckPerfEventLimit()) {
+ return false;
+ }
+
static std::map<std::string, std::pair<int, std::string>> type_map = {
{"hw", {PERF_TYPE_HARDWARE, "hardware events"}},
{"sw", {PERF_TYPE_SOFTWARE, "software events"}},