summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-03-10 22:04:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-03-10 22:04:07 +0000
commitad64c38f5652c8557c3f61953a92c457da3e82d4 (patch)
tree22c9638e9a09b88a96425f0df09af24ef13a4eda
parent2435622d30695d8f51cb203f2637643ea14170e5 (diff)
parent0356f47c4faf6075348ce340ca0b0cc46cee060f (diff)
downloadextras-ad64c38f5652c8557c3f61953a92c457da3e82d4.tar.gz
Merge "simpleperf: check if dwarf callgraph is supported by kernel before testing." into nyc-dev
-rw-r--r--simpleperf/cmd_report_test.cpp16
-rw-r--r--simpleperf/event_fd.cpp1
-rw-r--r--simpleperf/event_fd.h3
-rw-r--r--simpleperf/event_selection_set.cpp2
-rw-r--r--simpleperf/event_selection_set.h3
5 files changed, 18 insertions, 7 deletions
diff --git a/simpleperf/cmd_report_test.cpp b/simpleperf/cmd_report_test.cpp
index a5ece01b..e27f71e6 100644
--- a/simpleperf/cmd_report_test.cpp
+++ b/simpleperf/cmd_report_test.cpp
@@ -24,6 +24,7 @@
#include <android-base/test_utils.h>
#include "command.h"
+#include "event_selection_set.h"
#include "get_test_data.h"
#include "read_apk.h"
#include "test_util.h"
@@ -252,17 +253,22 @@ TEST_F(ReportCommandTest, use_branch_address) {
hit_set.end());
}
-#if defined(__ANDROID__) || defined(__linux__)
+#if defined(__linux__)
static std::unique_ptr<Command> RecordCmd() {
return CreateCommandInstance("record");
}
TEST_F(ReportCommandTest, dwarf_callgraph) {
- TemporaryFile tmp_file;
- ASSERT_TRUE(RecordCmd()->Run({"-g", "-o", tmp_file.path, "sleep", SLEEP_SEC}));
- ReportRaw(tmp_file.path, {"-g"});
- ASSERT_TRUE(success);
+ if (IsDwarfCallChainSamplingSupported()) {
+ TemporaryFile tmp_file;
+ ASSERT_TRUE(RecordCmd()->Run({"-g", "-o", tmp_file.path, "sleep", SLEEP_SEC}));
+ ReportRaw(tmp_file.path, {"-g"});
+ ASSERT_TRUE(success);
+ } else {
+ GTEST_LOG_(INFO)
+ << "This test does nothing as dwarf callchain sampling is not supported on this device.";
+ }
}
#endif
diff --git a/simpleperf/event_fd.cpp b/simpleperf/event_fd.cpp
index ec06f6fd..808639bd 100644
--- a/simpleperf/event_fd.cpp
+++ b/simpleperf/event_fd.cpp
@@ -17,6 +17,7 @@
#include "event_fd.h"
#include <fcntl.h>
+#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
diff --git a/simpleperf/event_fd.h b/simpleperf/event_fd.h
index cc0c0618..c1a7d753 100644
--- a/simpleperf/event_fd.h
+++ b/simpleperf/event_fd.h
@@ -17,7 +17,6 @@
#ifndef SIMPLE_PERF_EVENT_FD_H_
#define SIMPLE_PERF_EVENT_FD_H_
-#include <poll.h>
#include <sys/types.h>
#include <memory>
@@ -35,6 +34,8 @@ struct PerfCounter {
uint64_t id; // The id of the perf_event_file.
};
+struct pollfd;
+
// EventFd represents an opened perf_event_file.
class EventFd {
public:
diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp
index df731f1a..d99966a2 100644
--- a/simpleperf/event_selection_set.cpp
+++ b/simpleperf/event_selection_set.cpp
@@ -16,6 +16,8 @@
#include "event_selection_set.h"
+#include <poll.h>
+
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h
index cba9dc62..746abfa7 100644
--- a/simpleperf/event_selection_set.h
+++ b/simpleperf/event_selection_set.h
@@ -17,7 +17,6 @@
#ifndef SIMPLE_PERF_EVENT_SELECTION_SET_H_
#define SIMPLE_PERF_EVENT_SELECTION_SET_H_
-#include <poll.h>
#include <functional>
#include <map>
#include <vector>
@@ -38,6 +37,8 @@ struct CountersInfo {
std::vector<CounterInfo> counters;
};
+struct pollfd;
+
// EventSelectionSet helps to monitor events.
// Firstly, the user creates an EventSelectionSet, and adds the specific event types to monitor.
// Secondly, the user defines how to monitor the events (by setting enable_on_exec flag,