[go: nahoru, domu]

Remove "v2" suffix from `ChromeUnwinderAndroid`.

With https://crrev.com/c/4061659, this is the canonical version
of the unwinder.

Bug: 1393052, 1315603
Change-Id: Ia09f20e812752730115a71c898541890a29833ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4061914
Auto-Submit: Tushar Agarwal <agarwaltushar@google.com>
Reviewed-by: John Chen <johnchen@chromium.org>
Commit-Queue: Tushar Agarwal <agarwaltushar@google.com>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1077538}
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 7b37671..1d92549 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -1746,8 +1746,8 @@
       sources += [
         "profiler/chrome_unwind_info_android.cc",
         "profiler/chrome_unwind_info_android.h",
-        "profiler/chrome_unwinder_android_v2.cc",
-        "profiler/chrome_unwinder_android_v2.h",
+        "profiler/chrome_unwinder_android.cc",
+        "profiler/chrome_unwinder_android.h",
       ]
     }
 
@@ -3635,7 +3635,7 @@
     if (current_cpu == "arm") {
       sources += [
         "profiler/chrome_unwind_info_android_unittest.cc",
-        "profiler/chrome_unwinder_android_v2_unittest.cc",
+        "profiler/chrome_unwinder_android_unittest.cc",
       ]
     }
     if (!exclude_unwind_tables &&
diff --git a/base/profiler/chrome_unwinder_android_v2.cc b/base/profiler/chrome_unwinder_android.cc
similarity index 97%
rename from base/profiler/chrome_unwinder_android_v2.cc
rename to base/profiler/chrome_unwinder_android.cc
index 2e8e56a..da959ce8 100644
--- a/base/profiler/chrome_unwinder_android_v2.cc
+++ b/base/profiler/chrome_unwinder_android.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/profiler/chrome_unwinder_android_v2.h"
+#include "base/profiler/chrome_unwinder_android.h"
 
 #include <algorithm>
 
@@ -68,7 +68,7 @@
 
 }  // namespace
 
-ChromeUnwinderAndroidV2::ChromeUnwinderAndroidV2(
+ChromeUnwinderAndroid::ChromeUnwinderAndroid(
     const ChromeUnwindInfoAndroid& unwind_info,
     uintptr_t chrome_module_base_address,
     uintptr_t text_section_start_address)
@@ -78,14 +78,14 @@
   DCHECK_GT(text_section_start_address_, chrome_module_base_address_);
 }
 
-bool ChromeUnwinderAndroidV2::CanUnwindFrom(const Frame& current_frame) const {
+bool ChromeUnwinderAndroid::CanUnwindFrom(const Frame& current_frame) const {
   return current_frame.module &&
          current_frame.module->GetBaseAddress() == chrome_module_base_address_;
 }
 
-UnwindResult ChromeUnwinderAndroidV2::TryUnwind(RegisterContext* thread_context,
-                                                uintptr_t stack_top,
-                                                std::vector<Frame>* stack) {
+UnwindResult ChromeUnwinderAndroid::TryUnwind(RegisterContext* thread_context,
+                                              uintptr_t stack_top,
+                                              std::vector<Frame>* stack) {
   DCHECK(CanUnwindFrom(stack->back()));
   uintptr_t frame_initial_sp = RegisterContextStackPointer(thread_context);
   const uintptr_t unwind_initial_pc =
diff --git a/base/profiler/chrome_unwinder_android_v2.h b/base/profiler/chrome_unwinder_android.h
similarity index 85%
rename from base/profiler/chrome_unwinder_android_v2.h
rename to base/profiler/chrome_unwinder_android.h
index 574ca0b..7f8fdc5 100644
--- a/base/profiler/chrome_unwinder_android_v2.h
+++ b/base/profiler/chrome_unwinder_android.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef BASE_PROFILER_CHROME_UNWINDER_ANDROID_V2_H_
-#define BASE_PROFILER_CHROME_UNWINDER_ANDROID_V2_H_
+#ifndef BASE_PROFILER_CHROME_UNWINDER_ANDROID_H_
+#define BASE_PROFILER_CHROME_UNWINDER_ANDROID_H_
 
 #include <stdint.h>
 
@@ -18,15 +18,14 @@
 namespace base {
 
 // Chrome unwinder implementation for Android, using ChromeUnwindInfoAndroid,
-// a separate binary resource. This implementation is intended to replace
-// `ChromeUnwinderAndroid`, which uses ArmCfiTable.
-class BASE_EXPORT ChromeUnwinderAndroidV2 : public Unwinder {
+// a separate binary resource.
+class BASE_EXPORT ChromeUnwinderAndroid : public Unwinder {
  public:
-  ChromeUnwinderAndroidV2(const ChromeUnwindInfoAndroid& unwind_info,
-                          uintptr_t chrome_module_base_address,
-                          uintptr_t text_section_start_address);
-  ChromeUnwinderAndroidV2(const ChromeUnwinderAndroidV2&) = delete;
-  ChromeUnwinderAndroidV2& operator=(const ChromeUnwinderAndroidV2&) = delete;
+  ChromeUnwinderAndroid(const ChromeUnwindInfoAndroid& unwind_info,
+                        uintptr_t chrome_module_base_address,
+                        uintptr_t text_section_start_address);
+  ChromeUnwinderAndroid(const ChromeUnwinderAndroid&) = delete;
+  ChromeUnwinderAndroid& operator=(const ChromeUnwinderAndroid&) = delete;
 
   // Unwinder:
   bool CanUnwindFrom(const Frame& current_frame) const override;
@@ -112,4 +111,4 @@
 
 }  // namespace base
 
-#endif  // BASE_PROFILER_CHROME_UNWINDER_ANDROID_V2_H_
+#endif  // BASE_PROFILER_CHROME_UNWINDER_ANDROID_H_
diff --git a/base/profiler/chrome_unwinder_android_v2_unittest.cc b/base/profiler/chrome_unwinder_android_unittest.cc
similarity index 95%
rename from base/profiler/chrome_unwinder_android_v2_unittest.cc
rename to base/profiler/chrome_unwinder_android_unittest.cc
index e25a583..4e2080b 100644
--- a/base/profiler/chrome_unwinder_android_v2_unittest.cc
+++ b/base/profiler/chrome_unwinder_android_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/profiler/chrome_unwinder_android_v2.h"
+#include "base/profiler/chrome_unwinder_android.h"
 
 #include "base/memory/aligned_memory.h"
 #include "base/profiler/chrome_unwind_info_android.h"
@@ -659,7 +659,7 @@
   EXPECT_EQ(0xfffffffful, thread_context.arm_sp);
 }
 
-TEST(ChromeUnwinderAndroidV2Test,
+TEST(ChromeUnwinderAndroidTest,
      TestFunctionOffsetTableLookupExactMatchingOffset) {
   const uint8_t function_offset_table[] = {
       // Function 1: [(130, 2), (128, 3), (0, 4)]
@@ -684,7 +684,7 @@
                      /* instruction_offset_from_function_start */ 128));
 }
 
-TEST(ChromeUnwinderAndroidV2Test,
+TEST(ChromeUnwinderAndroidTest,
      TestFunctionOffsetTableLookupNonExactMatchingOffset) {
   const uint8_t function_offset_table[] = {
       // Function 1: [(130, 2), (128, 3), (0, 4)]
@@ -709,7 +709,7 @@
                      /* instruction_offset_from_function_start */ 129));
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TestFunctionOffsetTableLookupZeroOffset) {
+TEST(ChromeUnwinderAndroidTest, TestFunctionOffsetTableLookupZeroOffset) {
   const uint8_t function_offset_table[] = {
       // Function 1: [(130, 2), (128, 3), (0, 4)]
       // offset = 130
@@ -733,7 +733,7 @@
                      /* instruction_offset_from_function_start */ 0));
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TestAddressTableLookupEntryInPage) {
+TEST(ChromeUnwinderAndroidTest, TestAddressTableLookupEntryInPage) {
   const uint32_t page_start_instructions[] = {0, 2};
   const FunctionTableEntry function_offset_table_indices[] = {
       // Page 0
@@ -791,7 +791,7 @@
   }
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TestAddressTableLookupEmptyPage) {
+TEST(ChromeUnwinderAndroidTest, TestAddressTableLookupEmptyPage) {
   const uint32_t page_start_instructions[] = {0, 1, 1};
   const FunctionTableEntry function_offset_table_indices[] = {
       // Page 0
@@ -818,8 +818,7 @@
   EXPECT_EQ(20ul, entry_found->function_offset_table_byte_index);
 }
 
-TEST(ChromeUnwinderAndroidV2Test,
-     TestAddressTableLookupInvalidIntructionOffset) {
+TEST(ChromeUnwinderAndroidTest, TestAddressTableLookupInvalidIntructionOffset) {
   const uint32_t page_start_instructions[] = {0, 1};
   const FunctionTableEntry function_offset_table_indices[] = {
       // Page 0
@@ -856,7 +855,7 @@
   }
 }
 
-TEST(ChromeUnwinderAndroidV2Test,
+TEST(ChromeUnwinderAndroidTest,
      TestAddressTableLookupOnSecondPageOfFunctionSpanningPageBoundary) {
   const uint32_t page_start_instructions[] = {0, 1, 2};
   const FunctionTableEntry function_offset_table_indices[] = {
@@ -887,7 +886,7 @@
   EXPECT_EQ(20ul, entry_found->function_offset_table_byte_index);
 }
 
-TEST(ChromeUnwinderAndroidV2Test,
+TEST(ChromeUnwinderAndroidTest,
      TestAddressTableLookupWithinFunctionSpanningMultiplePages) {
   const uint32_t page_start_instructions[] = {0, 1, 1, 1};
   const FunctionTableEntry function_offset_table_indices[] = {
@@ -962,7 +961,7 @@
   return module_ptr;
 }
 
-TEST(ChromeUnwinderAndroidV2Test, CanUnwindFrom) {
+TEST(ChromeUnwinderAndroidTest, CanUnwindFrom) {
   const uint32_t page_table[] = {0};
   const FunctionTableEntry function_table[] = {{0, 0}};
   const uint8_t function_offset_table[] = {0};
@@ -978,10 +977,10 @@
   auto non_chrome_module = std::make_unique<TestModule>(0x2000, 0x500);
 
   ModuleCache module_cache;
-  ChromeUnwinderAndroidV2 unwinder(dummy_unwind_info,
-                                   chrome_module->GetBaseAddress(),
-                                   /* text_section_start_address */
-                                   chrome_module->GetBaseAddress() + 4);
+  ChromeUnwinderAndroid unwinder(dummy_unwind_info,
+                                 chrome_module->GetBaseAddress(),
+                                 /* text_section_start_address */
+                                 chrome_module->GetBaseAddress() + 4);
   unwinder.Initialize(&module_cache);
 
   EXPECT_TRUE(unwinder.CanUnwindFrom({0x1100, chrome_module.get()}));
@@ -1028,7 +1027,7 @@
 
 }  // namespace
 
-TEST(ChromeUnwinderAndroidV2Test, TryUnwind) {
+TEST(ChromeUnwinderAndroidTest, TryUnwind) {
   const uint32_t page_table[] = {0, 2};
   const size_t number_of_pages = std::size(page_table);
   const size_t page_size = 1 << 17;
@@ -1084,8 +1083,8 @@
                          0x1000, number_of_pages * page_size, "ChromeModule"));
 
   uintptr_t text_section_start_address = 0x1100;
-  ChromeUnwinderAndroidV2 unwinder(unwind_info, chrome_module->GetBaseAddress(),
-                                   text_section_start_address);
+  ChromeUnwinderAndroid unwinder(unwind_info, chrome_module->GetBaseAddress(),
+                                 text_section_start_address);
 
   unwinder.Initialize(&module_cache);
 
@@ -1117,7 +1116,7 @@
                  unwound_frames);
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TryUnwindInfiniteLoopSingleFrame) {
+TEST(ChromeUnwinderAndroidTest, TryUnwindInfiniteLoopSingleFrame) {
   const uint32_t page_table[] = {0, 2};
   const size_t number_of_pages = std::size(page_table);
   const size_t page_size = 1 << 17;
@@ -1158,8 +1157,8 @@
                          0x1000, number_of_pages * page_size, "ChromeModule"));
 
   uintptr_t text_section_start_address = 0x1100;
-  ChromeUnwinderAndroidV2 unwinder(unwind_info, chrome_module->GetBaseAddress(),
-                                   text_section_start_address);
+  ChromeUnwinderAndroid unwinder(unwind_info, chrome_module->GetBaseAddress(),
+                                 text_section_start_address);
 
   unwinder.Initialize(&module_cache);
   uintptr_t pc = text_section_start_address + 0x20;
@@ -1184,7 +1183,7 @@
   ExpectFramesEq(std::vector<Frame>({{pc, chrome_module}}), unwound_frames);
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TryUnwindInfiniteLoopMultipleFrames) {
+TEST(ChromeUnwinderAndroidTest, TryUnwindInfiniteLoopMultipleFrames) {
   // This test aims to produce a scenario, where after the unwind of a number
   // of frames, the sp and pc get to their original state before the unwind.
 
@@ -1249,8 +1248,8 @@
                          0x1000, number_of_pages * page_size, "ChromeModule"));
 
   uintptr_t text_section_start_address = 0x1100;
-  ChromeUnwinderAndroidV2 unwinder(unwind_info, chrome_module->GetBaseAddress(),
-                                   text_section_start_address);
+  ChromeUnwinderAndroid unwinder(unwind_info, chrome_module->GetBaseAddress(),
+                                 text_section_start_address);
 
   unwinder.Initialize(&module_cache);
   uintptr_t first_pc = text_section_start_address + 0x20;    // Function 1.
@@ -1279,7 +1278,7 @@
                  unwound_frames);
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TryUnwindUnalignedSPFrameUnwind) {
+TEST(ChromeUnwinderAndroidTest, TryUnwindUnalignedSPFrameUnwind) {
   // SP should be 2-uintptr_t aligned before/after each frame unwind.
   const uint32_t page_table[] = {0, 2};
   const size_t number_of_pages = std::size(page_table);
@@ -1321,8 +1320,8 @@
                          0x1000, number_of_pages * page_size, "ChromeModule"));
 
   uintptr_t text_section_start_address = 0x1100;
-  ChromeUnwinderAndroidV2 unwinder(unwind_info, chrome_module->GetBaseAddress(),
-                                   text_section_start_address);
+  ChromeUnwinderAndroid unwinder(unwind_info, chrome_module->GetBaseAddress(),
+                                 text_section_start_address);
 
   unwinder.Initialize(&module_cache);
   uintptr_t pc = text_section_start_address + 0x20;
@@ -1350,7 +1349,7 @@
   ExpectFramesEq(std::vector<Frame>({{pc, chrome_module}}), unwound_frames);
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TryUnwindUnalignedSPInstructionUnwind) {
+TEST(ChromeUnwinderAndroidTest, TryUnwindUnalignedSPInstructionUnwind) {
   // SP should be uintptr_t aligned before/after each unwind instruction
   // execution.
 
@@ -1394,8 +1393,8 @@
                          0x1000, number_of_pages * page_size, "ChromeModule"));
 
   uintptr_t text_section_start_address = 0x1100;
-  ChromeUnwinderAndroidV2 unwinder(unwind_info, chrome_module->GetBaseAddress(),
-                                   text_section_start_address);
+  ChromeUnwinderAndroid unwinder(unwind_info, chrome_module->GetBaseAddress(),
+                                 text_section_start_address);
 
   unwinder.Initialize(&module_cache);
   uintptr_t pc = text_section_start_address + 0x20;
@@ -1423,7 +1422,7 @@
   ExpectFramesEq(std::vector<Frame>({{pc, chrome_module}}), unwound_frames);
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TryUnwindSPOverflow) {
+TEST(ChromeUnwinderAndroidTest, TryUnwindSPOverflow) {
   const uint32_t page_table[] = {0, 2};
   const size_t number_of_pages = std::size(page_table);
   const size_t page_size = 1 << 17;
@@ -1465,8 +1464,8 @@
                          0x1000, number_of_pages * page_size, "ChromeModule"));
 
   uintptr_t text_section_start_address = 0x1100;
-  ChromeUnwinderAndroidV2 unwinder(unwind_info, chrome_module->GetBaseAddress(),
-                                   text_section_start_address);
+  ChromeUnwinderAndroid unwinder(unwind_info, chrome_module->GetBaseAddress(),
+                                 text_section_start_address);
 
   unwinder.Initialize(&module_cache);
   uintptr_t pc = text_section_start_address + 0x20;
@@ -1495,7 +1494,7 @@
   ExpectFramesEq(std::vector<Frame>({{pc, chrome_module}}), unwound_frames);
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TryUnwindNullSP) {
+TEST(ChromeUnwinderAndroidTest, TryUnwindNullSP) {
   const uint32_t page_table[] = {0, 2};
   const size_t number_of_pages = std::size(page_table);
   const size_t page_size = 1 << 17;
@@ -1537,8 +1536,8 @@
                          0x1000, number_of_pages * page_size, "ChromeModule"));
 
   uintptr_t text_section_start_address = 0x1100;
-  ChromeUnwinderAndroidV2 unwinder(unwind_info, chrome_module->GetBaseAddress(),
-                                   text_section_start_address);
+  ChromeUnwinderAndroid unwinder(unwind_info, chrome_module->GetBaseAddress(),
+                                 text_section_start_address);
 
   unwinder.Initialize(&module_cache);
   uintptr_t pc = text_section_start_address + 0x20;
@@ -1567,7 +1566,7 @@
   ExpectFramesEq(std::vector<Frame>({{pc, chrome_module}}), unwound_frames);
 }
 
-TEST(ChromeUnwinderAndroidV2Test, TryUnwindInvalidSPOperation) {
+TEST(ChromeUnwinderAndroidTest, TryUnwindInvalidSPOperation) {
   // This test aims to verify that for each unwind instruction executed, it is
   // always true that sp > frame initial sp.
 
@@ -1612,8 +1611,8 @@
                          0x1000, number_of_pages * page_size, "ChromeModule"));
 
   uintptr_t text_section_start_address = 0x1100;
-  ChromeUnwinderAndroidV2 unwinder(unwind_info, chrome_module->GetBaseAddress(),
-                                   text_section_start_address);
+  ChromeUnwinderAndroid unwinder(unwind_info, chrome_module->GetBaseAddress(),
+                                 text_section_start_address);
 
   unwinder.Initialize(&module_cache);
   uintptr_t pc = text_section_start_address + 0x20;
diff --git a/base/profiler/stack_sampling_profiler_test_util.cc b/base/profiler/stack_sampling_profiler_test_util.cc
index d703d97c..453a5491 100644
--- a/base/profiler/stack_sampling_profiler_test_util.cc
+++ b/base/profiler/stack_sampling_profiler_test_util.cc
@@ -24,7 +24,7 @@
 #include "base/android/apk_assets.h"
 #include "base/android/library_loader/anchor_functions.h"
 #include "base/files/memory_mapped_file.h"
-#include "base/profiler/chrome_unwinder_android_v2.h"
+#include "base/profiler/chrome_unwinder_android.h"
 #include "base/profiler/native_unwinder_android.h"
 #endif
 
@@ -127,15 +127,15 @@
 
   // The wrapper class ensures that `MemoryMappedFile` has the same lifetime
   // as the unwinder.
-  class ChromeUnwinderAndroidForTesting : public ChromeUnwinderAndroidV2 {
+  class ChromeUnwinderAndroidForTesting : public ChromeUnwinderAndroid {
    public:
     ChromeUnwinderAndroidForTesting(std::unique_ptr<MemoryMappedFile> cfi_file,
                                     const ChromeUnwindInfoAndroid& unwind_info,
                                     uintptr_t chrome_module_base_address,
                                     uintptr_t text_section_start_address)
-        : ChromeUnwinderAndroidV2(unwind_info,
-                                  chrome_module_base_address,
-                                  text_section_start_address),
+        : ChromeUnwinderAndroid(unwind_info,
+                                chrome_module_base_address,
+                                text_section_start_address),
           cfi_file_(std::move(cfi_file)) {}
     ~ChromeUnwinderAndroidForTesting() override = default;
 
diff --git a/chrome/android/chrome_common_shared_library.gni b/chrome/android/chrome_common_shared_library.gni
index 87bfcb89..f232005 100644
--- a/chrome/android/chrome_common_shared_library.gni
+++ b/chrome/android/chrome_common_shared_library.gni
@@ -195,7 +195,7 @@
     _library_target = ":$target_name"
 
     # TODO(crbug.com/1315603): Remove generation of v1 unwind asset when
-    # `CFIBacktraceAndroid` is replaced with `ChromeUnwinderAndroidV2`.
+    # `CFIBacktraceAndroid` is replaced with `ChromeUnwinderAndroid`.
     unwind_table_v1("${target_name}_unwind_table_v1") {
       library_target = _library_target
     }
diff --git a/chrome/common/profiler/unwind_util.cc b/chrome/common/profiler/unwind_util.cc
index 8ecf8aa..7efa6f63 100644
--- a/chrome/common/profiler/unwind_util.cc
+++ b/chrome/common/profiler/unwind_util.cc
@@ -34,7 +34,7 @@
 #include "base/android/apk_assets.h"
 #include "base/files/memory_mapped_file.h"
 #include "base/profiler/arm_cfi_table.h"
-#include "base/profiler/chrome_unwinder_android_v2.h"
+#include "base/profiler/chrome_unwinder_android.h"
 #include "chrome/android/modules/stack_unwinder/public/module.h"
 
 extern "C" {
@@ -69,7 +69,7 @@
   ChromeUnwinderCreator& operator=(const ChromeUnwinderCreator&) = delete;
 
   std::unique_ptr<base::Unwinder> Create() {
-    return std::make_unique<base::ChromeUnwinderAndroidV2>(
+    return std::make_unique<base::ChromeUnwinderAndroid>(
         base::CreateChromeUnwindInfoAndroid(
             {chrome_cfi_file_.data(), chrome_cfi_file_.length()}),
         /* chrome_module_base_address= */
diff --git a/testing/test.gni b/testing/test.gni
index 2be7351..56b7e18 100644
--- a/testing/test.gni
+++ b/testing/test.gni
@@ -314,7 +314,7 @@
       # apk, if |add_unwind_tables_in_apk| is specified by the test.
       if (_add_unwind_tables_in_apk) {
         # TODO(crbug.com/1315603): Remove generation of v1 unwind asset when
-        # `CFIBacktraceAndroid` is replaced with `ChromeUnwinderAndroidV2`.
+        # `CFIBacktraceAndroid` is replaced with `ChromeUnwinderAndroid`.
         _unwind_table_name = "${_library_target_name}_unwind_v1"
         unwind_table_v1(_unwind_table_name) {
           library_target = ":$_library_target_name"