mac-arm64: Don’t attempt to determine the CPU frequency
Apple has never exposed the CPU frequency on ARM systems. Report it as 0
on mac-arm64 without attempting to obtain it from the system (which
would log a warning in the process).
This will resolve these harmless warnings produced when Crashpad creates
a snapshot on arm64:
[pid:tid:yyyymmdd,hhmmss.µµµµµµ:WARNING system_snapshot_mac.cc:50] sysctlbyname hw.cpufrequency: No such file or directory (2)
[pid:tid:yyyymmdd,hhmmss.µµµµµµ:WARNING system_snapshot_mac.cc:50] sysctlbyname hw.cpufrequency_max: No such file or directory (2)
Bug: chromium:1103944
Change-Id: Iedea50355430546de5f94a028ecc91ed83319245
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2392076
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
GitOrigin-RevId: ca88ff1edb8e998c8af3fdb985ec6e3f22ee2663
diff --git a/snapshot/mac/system_snapshot_mac.cc b/snapshot/mac/system_snapshot_mac.cc
index 22ef936..7a12e74 100644
--- a/snapshot/mac/system_snapshot_mac.cc
+++ b/snapshot/mac/system_snapshot_mac.cc
@@ -186,8 +186,18 @@
void SystemSnapshotMac::CPUFrequency(
uint64_t* current_hz, uint64_t* max_hz) const {
INITIALIZATION_STATE_DCHECK_VALID(initialized_);
+#if defined(ARCH_CPU_X86_FAMILY)
*current_hz = ReadIntSysctlByName<uint64_t>("hw.cpufrequency", 0);
*max_hz = ReadIntSysctlByName<uint64_t>("hw.cpufrequency_max", 0);
+#elif defined(ARCH_CPU_ARM64)
+ // TODO(https://crashpad.chromium.org/bug/352): When production arm64
+ // hardware is available, determine whether CPU frequency is visible anywhere
+ // (likely via a sysctl or via IOKit) and use it if feasible.
+ *current_hz = 0;
+ *max_hz = 0;
+#else
+#error port to your architecture
+#endif
}
uint32_t SystemSnapshotMac::CPUX86Signature() const {