summaryrefslogtreecommitdiff
path: root/simpleperf/test_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'simpleperf/test_util.cpp')
-rw-r--r--simpleperf/test_util.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/simpleperf/test_util.cpp b/simpleperf/test_util.cpp
index 43e21831..60d8ea35 100644
--- a/simpleperf/test_util.cpp
+++ b/simpleperf/test_util.cpp
@@ -43,6 +43,10 @@ bool IsInNativeAbi() {
if (s.find("arm") == std::string::npos && s.find("aarch64") == std::string::npos) {
in_native_abi = 0;
}
+ } else if (GetTargetArch() == ARCH_RISCV64) {
+ if (s.find("riscv") == std::string::npos) {
+ in_native_abi = 0;
+ }
}
}
return in_native_abi == 1;
@@ -81,9 +85,10 @@ bool HasHardwareCounter() {
android::base::StartsWith(fingerprint, "google/sdk_gpc") ||
android::base::StartsWith(fingerprint, "generic/cf");
- if (arch == ARCH_X86_64 || arch == ARCH_X86_32 || is_emulator) {
- // On x86 and x86_64, it's likely to run on an emulator or vm without hardware perf
- // counters. It's hard to enumerate them all. So check the support at runtime.
+ if (arch == ARCH_X86_64 || arch == ARCH_X86_32 || !IsInNativeAbi() || is_emulator) {
+ // On x86 and x86_64, or when we are not in native abi, it's likely to run on an emulator or
+ // vm without hardware perf counters. It's hard to enumerate them all. So check the support
+ // at runtime.
const simpleperf::EventType* type = simpleperf::FindEventTypeByName("cpu-cycles", false);
CHECK(type != nullptr);
perf_event_attr attr = CreateDefaultPerfEventAttr(*type);