1 // Copyright 2023 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_PROFILER_NATIVE_UNWINDER_ANDROID_MEMORY_REGIONS_MAP_IMPL_H_ 6 #define BASE_PROFILER_NATIVE_UNWINDER_ANDROID_MEMORY_REGIONS_MAP_IMPL_H_ 7 8 #include "base/profiler/native_unwinder_android_memory_regions_map.h" 9 10 #include "third_party/libunwindstack/src/libunwindstack/include/unwindstack/Maps.h" 11 #include "third_party/libunwindstack/src/libunwindstack/include/unwindstack/Memory.h" 12 13 namespace base { 14 15 class NativeUnwinderAndroidMemoryRegionsMapImpl 16 : public NativeUnwinderAndroidMemoryRegionsMap { 17 public: 18 NativeUnwinderAndroidMemoryRegionsMapImpl( 19 std::unique_ptr<unwindstack::Maps> maps, 20 std::unique_ptr<unwindstack::Memory> memory); 21 22 ~NativeUnwinderAndroidMemoryRegionsMapImpl() override; 23 maps()24 unwindstack::Maps* maps() { return maps_.get(); } 25 // We use a non-const reference here because some functions in libunwindstack 26 // expect that. memory()27 std::shared_ptr<unwindstack::Memory>& memory() { return memory_; } 28 SetMapsForTesting(std::unique_ptr<unwindstack::Maps> maps)29 void SetMapsForTesting(std::unique_ptr<unwindstack::Maps> maps) { 30 maps_ = std::move(maps); 31 } 32 33 private: 34 std::unique_ptr<unwindstack::Maps> maps_; 35 std::shared_ptr<unwindstack::Memory> memory_; 36 }; 37 38 } // namespace base 39 40 #endif // BASE_PROFILER_NATIVE_UNWINDER_ANDROID_MEMORY_REGIONS_MAP_IMPL_H_ 41