[sampling profiler] Enable tests for Android arm64

This functionality is live but the tests were mistakenly never enabled.

Bug: 380487894
Change-Id: I233ae949a130e915a31804285230f790a3cf3bd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6219812
Commit-Queue: Thiabaud Engelbrecht <thiabaud@google.com>
Reviewed-by: Thiabaud Engelbrecht <thiabaud@google.com>
Cr-Commit-Position: refs/heads/main@{#1414956}
diff --git a/base/profiler/stack_sampling_profiler_test_util.cc b/base/profiler/stack_sampling_profiler_test_util.cc
index 159d5b78..b87505b 100644
--- a/base/profiler/stack_sampling_profiler_test_util.cc
+++ b/base/profiler/stack_sampling_profiler_test_util.cc
@@ -17,6 +17,7 @@
 #include "base/location.h"
 #include "base/memory/raw_ptr.h"
 #include "base/path_service.h"
+#include "base/profiler/frame_pointer_unwinder.h"
 #include "base/profiler/native_unwinder_android_map_delegate.h"
 #include "base/profiler/native_unwinder_android_memory_regions_map.h"
 #include "base/profiler/profiler_buildflags.h"
@@ -28,13 +29,16 @@
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
-#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(ENABLE_ARM_CFI_TABLE)
+#if BUILDFLAG(IS_ANDROID) && \
+    (BUILDFLAG(ENABLE_ARM_CFI_TABLE) || defined(ARCH_CPU_ARM64))
+#include "base/no_destructor.h"
+#include "base/profiler/native_unwinder_android.h"
+#if BUILDFLAG(ENABLE_ARM_CFI_TABLE)
 #include "base/android/apk_assets.h"
 #include "base/android/library_loader/anchor_functions.h"
 #include "base/files/memory_mapped_file.h"
-#include "base/no_destructor.h"
 #include "base/profiler/chrome_unwinder_android_32.h"
-#include "base/profiler/native_unwinder_android.h"
+#endif
 #endif
 
 #if !BUILDFLAG(IS_ANDROID)
@@ -108,7 +112,8 @@
   [[maybe_unused]] volatile int i = 0;
 }
 
-#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(ENABLE_ARM_CFI_TABLE)
+#if BUILDFLAG(IS_ANDROID) && \
+    (BUILDFLAG(ENABLE_ARM_CFI_TABLE) || defined(ARCH_CPU_ARM64))
 class NativeUnwinderAndroidMapDelegateForTesting
     : public NativeUnwinderAndroidMapDelegate {
  public:
@@ -141,6 +146,7 @@
       exclude_module_with_base_address, GetMapDelegateForTesting());
 }
 
+#if BUILDFLAG(ENABLE_ARM_CFI_TABLE)
 std::unique_ptr<Unwinder> CreateChromeUnwinderAndroid32ForTesting(
     uintptr_t chrome_module_base_address) {
   static constexpr char kCfiFileName[] = "assets/unwind_cfi_32_v2";
@@ -177,7 +183,9 @@
       chrome_module_base_address,
       /* text_section_start_address= */ base::android::kStartOfText);
 }
-#endif  // #if BUILDFLAG(IS_ANDROID) && BUILDFLAG(ENABLE_ARM_CFI_TABLE)
+#endif  // BUILDFLAG(ENABLE_ARM_CFI_TABLE)
+#endif  // BUILDFLAG(IS_ANDROID) && (BUILDFLAG(ENABLE_ARM_CFI_TABLE) ||
+        // defined(ARCH_CPU_ARM64))
 
 }  // namespace
 
@@ -471,6 +479,22 @@
         return unwinders;
       },
       std::move(unwinders));
+#elif BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_ARM64)
+  std::vector<std::unique_ptr<Unwinder>> unwinders;
+  unwinders.push_back(CreateNativeUnwinderAndroidForTesting(
+      reinterpret_cast<uintptr_t>(&__executable_start)));
+  unwinders.push_back(std::make_unique<base::FramePointerUnwinder>(
+      base::BindRepeating([](const base::Frame& current_frame) {
+        return current_frame.module &&
+               current_frame.module->GetBaseAddress() ==
+                   reinterpret_cast<uintptr_t>(&__executable_start);
+      }),
+      /*is_system_unwinder=*/false));
+  return BindOnce(
+      [](std::vector<std::unique_ptr<Unwinder>> unwinders) {
+        return unwinders;
+      },
+      std::move(unwinders));
 #elif BUILDFLAG(IS_ANDROID)
   return StackSamplingProfiler::UnwindersFactory();
 #else
diff --git a/base/profiler/stack_sampling_profiler_unittest.cc b/base/profiler/stack_sampling_profiler_unittest.cc
index 0563591..3b15e7d 100644
--- a/base/profiler/stack_sampling_profiler_unittest.cc
+++ b/base/profiler/stack_sampling_profiler_unittest.cc
@@ -57,7 +57,8 @@
 // initialized.
 #if (BUILDFLAG(IS_WIN) && defined(ARCH_CPU_X86_64)) || (BUILDFLAG(IS_MAC)) || \
     (BUILDFLAG(IS_IOS) && defined(ARCH_CPU_64_BITS)) ||                       \
-    (BUILDFLAG(IS_ANDROID) && BUILDFLAG(ENABLE_ARM_CFI_TABLE)) ||             \
+    (BUILDFLAG(IS_ANDROID) &&                                                 \
+     (BUILDFLAG(ENABLE_ARM_CFI_TABLE) || defined(ARCH_CPU_ARM64))) ||         \
     (BUILDFLAG(IS_CHROMEOS) &&                                                \
      (defined(ARCH_CPU_X86_64) || defined(ARCH_CPU_ARM64)) &&                 \
      !defined(MEMORY_SANITIZER))