From 5150e1292ec6b16e4717e86b9e3cfb855eec18a3 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Thu, 13 May 2021 00:52:56 +0100 Subject: MapInfo: Add set accessors for the fields This properly encapsulates all MapInfo fields, and changes MapInfo from struct to class. Test: libunwindstack_unit_test Change-Id: I2a07d1a83702267c8af3960279694d25d3c779f1 --- libunwindstack/DexFile.h | 2 +- libunwindstack/Elf.cpp | 6 +- libunwindstack/MapInfo.cpp | 72 +++++++++++----------- libunwindstack/Maps.cpp | 14 ++--- libunwindstack/benchmarks/ElfBenchmark.cpp | 4 +- libunwindstack/include/unwindstack/Elf.h | 2 +- libunwindstack/include/unwindstack/Global.h | 2 +- libunwindstack/include/unwindstack/LocalUnwinder.h | 2 +- libunwindstack/include/unwindstack/MapInfo.h | 23 ++++++- libunwindstack/tests/DexFilesTest.cpp | 6 +- libunwindstack/tests/JitDebugTest.cpp | 6 +- libunwindstack/tests/LocalUpdatableMapsTest.cpp | 30 ++++----- libunwindstack/tests/MapInfoCreateMemoryTest.cpp | 60 +++++++++--------- libunwindstack/tests/MapInfoGetBuildIDTest.cpp | 6 +- libunwindstack/tests/MapInfoGetElfTest.cpp | 18 +++--- libunwindstack/tests/MapInfoGetLoadBiasTest.cpp | 8 +-- libunwindstack/tests/MapInfoTest.cpp | 2 +- libunwindstack/tests/MapsTest.cpp | 32 +++++----- libunwindstack/tests/RegsTest.cpp | 2 +- libunwindstack/tests/UnwinderTest.cpp | 22 +++---- .../tests/fuzz/UnwinderComponentCreator.cpp | 2 +- libunwindstack/tools/unwind_for_offline.cpp | 8 +-- 22 files changed, 174 insertions(+), 155 deletions(-) diff --git a/libunwindstack/DexFile.h b/libunwindstack/DexFile.h index 2a969a5..6775530 100644 --- a/libunwindstack/DexFile.h +++ b/libunwindstack/DexFile.h @@ -32,7 +32,7 @@ namespace unwindstack { -struct MapInfo; +class MapInfo; class Memory; class DexFile { diff --git a/libunwindstack/Elf.cpp b/libunwindstack/Elf.cpp index 4dec11e..b52d294 100644 --- a/libunwindstack/Elf.cpp +++ b/libunwindstack/Elf.cpp @@ -401,7 +401,7 @@ bool Elf::CacheAfterCreateMemory(MapInfo* info) { // In this case, the whole file is the elf, and the name has already // been cached. Add an entry at name:offset to get this directly out // of the cache next time. - info->elf_ = entry->second.first; + info->set_elf(entry->second.first); std::string key = std::string(info->name()) + ':' + std::to_string(info->offset()); (*cache_)[key] = std::make_pair(info->elf(), true); return true; @@ -414,9 +414,9 @@ bool Elf::CacheGet(MapInfo* info) { } auto entry = cache_->find(name); if (entry != cache_->end()) { - info->elf_ = entry->second.first; + info->set_elf(entry->second.first); if (entry->second.second) { - info->elf_offset_ = info->offset(); + info->set_elf_offset(info->offset()); } return true; } diff --git a/libunwindstack/MapInfo.cpp b/libunwindstack/MapInfo.cpp index e25c788..6fcfdaf 100644 --- a/libunwindstack/MapInfo.cpp +++ b/libunwindstack/MapInfo.cpp @@ -41,8 +41,8 @@ bool MapInfo::InitFileMemoryFromPreviousReadOnlyMap(MemoryFileAtOffset* memory) return false; } - uint64_t map_size = end() - prev_real_map_->end(); - if (!memory->Init(name_, prev_real_map_->offset_, map_size)) { + uint64_t map_size = end() - prev_real_map()->end(); + if (!memory->Init(name(), prev_real_map()->offset(), map_size)) { return false; } @@ -55,8 +55,8 @@ bool MapInfo::InitFileMemoryFromPreviousReadOnlyMap(MemoryFileAtOffset* memory) return false; } - elf_offset_ = offset() - prev_real_map_->offset(); - elf_start_offset_ = prev_real_map_->offset(); + set_elf_offset(offset() - prev_real_map()->offset()); + set_elf_start_offset(prev_real_map()->offset()); return true; } @@ -83,24 +83,24 @@ Memory* MapInfo::GetFileMemory() { // and reinit to that size. This is needed because the dynamic linker // only maps in a portion of the original elf, and never the symbol // file data. - uint64_t map_size = end_ - start(); - if (!memory->Init(name_, offset_, map_size)) { + uint64_t map_size = end() - start(); + if (!memory->Init(name(), offset(), map_size)) { return nullptr; } // Check if the start of this map is an embedded elf. uint64_t max_size = 0; if (Elf::GetInfo(memory.get(), &max_size)) { - elf_start_offset_ = offset(); + set_elf_start_offset(offset()); if (max_size > map_size) { if (memory->Init(name(), offset(), max_size)) { return memory.release(); } // Try to reinit using the default map_size. - if (memory->Init(name_, offset_, map_size)) { + if (memory->Init(name(), offset(), map_size)) { return memory.release(); } - elf_start_offset_ = 0; + set_elf_start_offset(0); return nullptr; } return memory.release(); @@ -108,13 +108,13 @@ Memory* MapInfo::GetFileMemory() { // No elf at offset, try to init as if the whole file is an elf. if (memory->Init(name(), 0) && Elf::IsValidElf(memory.get())) { - elf_offset_ = offset(); + set_elf_offset(offset()); // Need to check how to set the elf start offset. If this map is not // the r-x map of a r-- map, then use the real offset value. Otherwise, // use 0. - if (prev_real_map_ == nullptr || prev_real_map_->offset() != 0 || - prev_real_map_->flags() != PROT_READ || prev_real_map_->name() != name()) { - elf_start_offset_ = offset(); + if (prev_real_map() == nullptr || prev_real_map()->offset() != 0 || + prev_real_map()->flags() != PROT_READ || prev_real_map()->name() != name()) { + set_elf_start_offset(offset()); } return memory.release(); } @@ -127,7 +127,7 @@ Memory* MapInfo::GetFileMemory() { // Failed to find elf at start of file or at read-only map, return // file object from the current map. - if (memory->Init(name_, offset_, map_size)) { + if (memory->Init(name(), offset(), map_size)) { return memory.release(); } return nullptr; @@ -138,7 +138,7 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr& process_memory) { return nullptr; } - elf_offset_ = 0; + set_elf_offset(0); // Fail on device maps. if (flags() & MAPS_FLAGS_DEVICE_MAP) { @@ -157,19 +157,19 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr& process_memory) { return nullptr; } - memory_backed_elf_ = true; + set_memory_backed_elf(true); // Need to verify that this elf is valid. It's possible that // only part of the elf file to be mapped into memory is in the executable // map. In this case, there will be another read-only map that includes the // first part of the elf file. This is done if the linker rosegment // option is used. - std::unique_ptr memory(new MemoryRange(process_memory, start(), end_ - start(), 0)); + std::unique_ptr memory(new MemoryRange(process_memory, start(), end() - start(), 0)); if (Elf::IsValidElf(memory.get())) { // Might need to peek at the next map to create a memory object that // includes that map too. - if (offset() != 0 || name_.empty() || next_real_map() == nullptr || - offset() >= next_real_map()->offset() || next_real_map()->name_ != name_) { + if (offset() != 0 || name().empty() || next_real_map() == nullptr || + offset() >= next_real_map()->offset() || next_real_map()->name() != name()) { return memory.release(); } @@ -190,22 +190,22 @@ Memory* MapInfo::CreateMemory(const std::shared_ptr& process_memory) { // doesn't guarantee that this invariant will always be true. However, // if that changes, there is likely something else that will change and // break something. - if (offset() == 0 || name_.empty() || prev_real_map_ == nullptr || - prev_real_map_->name_ != name_ || prev_real_map_->offset() >= offset()) { - memory_backed_elf_ = false; + if (offset() == 0 || name().empty() || prev_real_map() == nullptr || + prev_real_map()->name() != name() || prev_real_map()->offset() >= offset()) { + set_memory_backed_elf(false); return nullptr; } // Make sure that relative pc values are corrected properly. - elf_offset_ = offset() - prev_real_map_->offset(); + set_elf_offset(offset() - prev_real_map()->offset()); // Use this as the elf start offset, otherwise, you always get offsets into // the r-x section, which is not quite the right information. - elf_start_offset_ = prev_real_map_->offset(); + set_elf_start_offset(prev_real_map()->offset()); MemoryRanges* ranges = new MemoryRanges; ranges->Insert(new MemoryRange(process_memory, prev_real_map()->start(), prev_real_map()->end() - prev_real_map()->start(), 0)); - ranges->Insert(new MemoryRange(process_memory, start(), end() - start(), elf_offset_)); + ranges->Insert(new MemoryRange(process_memory, start(), end() - start(), elf_offset())); return ranges; } @@ -253,19 +253,19 @@ Elf* MapInfo::GetElf(const std::shared_ptr& process_memory, ArchEnum exp } if (!elf()->valid()) { - elf_start_offset_ = offset(); - } else if (prev_real_map_ != nullptr && elf_start_offset_ != offset() && - prev_real_map_->offset() == elf_start_offset_ && prev_real_map_->name_ == name_) { + set_elf_start_offset(offset()); + } else if (prev_real_map() != nullptr && elf_start_offset() != offset() && + prev_real_map()->offset() == elf_start_offset() && prev_real_map()->name() == name()) { // If there is a read-only map then a read-execute map that represents the // same elf object, make sure the previous map is using the same elf // object if it hasn't already been set. - std::lock_guard guard(prev_real_map_->mutex_); + std::lock_guard guard(prev_real_map()->mutex_); if (prev_real_map()->elf().get() == nullptr) { - prev_real_map_->elf_ = elf(); - prev_real_map()->memory_backed_elf_ = memory_backed_elf_; + prev_real_map()->set_elf(elf()); + prev_real_map()->set_memory_backed_elf(memory_backed_elf()); } else { // Discard this elf, and use the elf from the previous map instead. - elf_ = prev_real_map_->elf(); + set_elf(prev_real_map()->elf()); } } return elf().get(); @@ -296,10 +296,10 @@ uint64_t MapInfo::GetLoadBias(const std::shared_ptr& process_memory) { if (elf() != nullptr) { if (elf()->valid()) { cur_load_bias = elf()->GetLoadBias(); - load_bias_ = cur_load_bias; + set_load_bias(cur_load_bias); return cur_load_bias; } else { - load_bias_ = 0; + set_load_bias(0); return 0; } } @@ -309,7 +309,7 @@ uint64_t MapInfo::GetLoadBias(const std::shared_ptr& process_memory) { // elf data to get the load bias. std::unique_ptr memory(CreateMemory(process_memory)); cur_load_bias = Elf::GetLoadBias(memory.get()); - load_bias_ = cur_load_bias; + set_load_bias(cur_load_bias); return cur_load_bias; } @@ -351,7 +351,7 @@ SharedString MapInfo::SetBuildID(std::string&& new_build_id) { std::unique_ptr new_build_id_ptr(new SharedString(std::move(new_build_id))); SharedString* expected_id = nullptr; // Strong version since we need to reliably return the stored pointer. - if (build_id_.compare_exchange_strong(expected_id, new_build_id_ptr.get())) { + if (build_id().compare_exchange_strong(expected_id, new_build_id_ptr.get())) { // Value saved, so make sure the memory is not freed. return *new_build_id_ptr.release(); } else { diff --git a/libunwindstack/Maps.cpp b/libunwindstack/Maps.cpp index a1848b4..7a9e2e9 100644 --- a/libunwindstack/Maps.cpp +++ b/libunwindstack/Maps.cpp @@ -89,7 +89,7 @@ void Maps::Add(uint64_t start, uint64_t end, uint64_t offset, uint64_t flags, auto map_info = std::make_unique(prev_map, prev_real_map, start, end, offset, flags, name); - map_info->load_bias_ = load_bias; + map_info->set_load_bias(load_bias); maps_.emplace_back(std::move(map_info)); } @@ -103,8 +103,8 @@ void Maps::Sort() { MapInfo* prev_map = nullptr; MapInfo* prev_real_map = nullptr; for (const auto& map_info : maps_) { - map_info->prev_map_ = prev_map; - map_info->prev_real_map_ = prev_real_map; + map_info->set_prev_map(prev_map); + map_info->set_prev_real_map(prev_real_map); prev_map = map_info.get(); if (!prev_map->IsBlank()) { prev_real_map = prev_map; @@ -194,9 +194,9 @@ bool LocalUpdatableMaps::Reparse(/*out*/ bool* any_changed) { // No need to check search_map_idx = old_map_idx + 1; if (new_map_idx + 1 < maps_.size()) { - maps_[new_map_idx + 1]->prev_map_ = info.get(); - maps_[new_map_idx + 1]->prev_real_map_ = - info->IsBlank() ? info->prev_real_map() : info.get(); + maps_[new_map_idx + 1]->set_prev_map(info.get()); + maps_[new_map_idx + 1]->set_prev_real_map(info->IsBlank() ? info->prev_real_map() + : info.get()); } maps_[new_map_idx] = nullptr; num_deleted_new_entries++; @@ -235,7 +235,7 @@ bool LocalUpdatableMaps::Reparse(/*out*/ bool* any_changed) { } else if (b == nullptr) { return true; } - return a->start_ < b->start_; + return a->start() < b->start(); }); maps_.resize(maps_.size() - num_deleted_old_entries - num_deleted_new_entries); diff --git a/libunwindstack/benchmarks/ElfBenchmark.cpp b/libunwindstack/benchmarks/ElfBenchmark.cpp index 4a004dc..3e1e21f 100644 --- a/libunwindstack/benchmarks/ElfBenchmark.cpp +++ b/libunwindstack/benchmarks/ElfBenchmark.cpp @@ -115,7 +115,7 @@ static void BM_elf_get_build_id_from_object(benchmark::State& state) { unwindstack::SharedString* id = build_id_map_info->build_id(); if (id != nullptr) { delete id; - build_id_map_info->build_id_ = nullptr; + build_id_map_info->set_build_id(nullptr); } state.ResumeTiming(); benchmark::DoNotOptimize(build_id_map_info->GetBuildID()); @@ -133,7 +133,7 @@ static void BM_elf_get_build_id_from_file(benchmark::State& state) { unwindstack::SharedString* id = build_id_map_info->build_id(); if (id != nullptr) { delete id; - build_id_map_info->build_id_ = nullptr; + build_id_map_info->set_build_id(nullptr); } state.ResumeTiming(); benchmark::DoNotOptimize(build_id_map_info->GetBuildID()); diff --git a/libunwindstack/include/unwindstack/Elf.h b/libunwindstack/include/unwindstack/Elf.h index 69c75f0..5a496a7 100644 --- a/libunwindstack/include/unwindstack/Elf.h +++ b/libunwindstack/include/unwindstack/Elf.h @@ -37,7 +37,7 @@ namespace unwindstack { // Forward declaration. -struct MapInfo; +class MapInfo; class Regs; class Elf { diff --git a/libunwindstack/include/unwindstack/Global.h b/libunwindstack/include/unwindstack/Global.h index b9bb141..b790832 100644 --- a/libunwindstack/include/unwindstack/Global.h +++ b/libunwindstack/include/unwindstack/Global.h @@ -32,7 +32,7 @@ namespace unwindstack { // Forward declarations. class Maps; -struct MapInfo; +class MapInfo; class Global { public: diff --git a/libunwindstack/include/unwindstack/LocalUnwinder.h b/libunwindstack/include/unwindstack/LocalUnwinder.h index 80bb53e..b9123b3 100644 --- a/libunwindstack/include/unwindstack/LocalUnwinder.h +++ b/libunwindstack/include/unwindstack/LocalUnwinder.h @@ -33,7 +33,7 @@ namespace unwindstack { // Forward declarations. class Elf; -struct MapInfo; +class MapInfo; struct LocalFrameData { LocalFrameData(MapInfo* map_info, uint64_t pc, uint64_t rel_pc, const std::string& function_name, diff --git a/libunwindstack/include/unwindstack/MapInfo.h b/libunwindstack/include/unwindstack/MapInfo.h index 026bda1..2a4696a 100644 --- a/libunwindstack/include/unwindstack/MapInfo.h +++ b/libunwindstack/include/unwindstack/MapInfo.h @@ -31,7 +31,8 @@ namespace unwindstack { class MemoryFileAtOffset; -struct MapInfo { +class MapInfo { + public: MapInfo(MapInfo* prev_map, MapInfo* prev_real_map, uint64_t start, uint64_t end, uint64_t offset, uint64_t flags, const char* name) : start_(start), @@ -61,20 +62,37 @@ struct MapInfo { ~MapInfo(); inline uint64_t start() const { return start_; } + inline void set_start(uint64_t value) { start_ = value; } inline uint64_t end() const { return end_; } + inline void set_end(uint64_t value) { end_ = value; } inline uint64_t offset() const { return offset_; } + inline void set_offset(uint64_t value) { offset_ = value; } inline uint16_t flags() const { return flags_; } + inline void set_flags(uint16_t value) { flags_ = value; } inline SharedString& name() { return name_; } + inline void set_name(SharedString& value) { name_ = value; } + inline void set_name(const char* value) { name_ = value; } inline std::shared_ptr& elf() { return elf_; } + inline void set_elf(std::shared_ptr& value) { elf_ = value; } + inline void set_elf(Elf* value) { elf_.reset(value); } inline uint64_t elf_offset() const { return elf_offset_; } + inline void set_elf_offset(uint64_t value) { elf_offset_ = value; } inline uint64_t elf_start_offset() const { return elf_start_offset_; } + inline void set_elf_start_offset(uint64_t value) { elf_start_offset_ = value; } inline MapInfo* prev_map() const { return prev_map_; } + inline void set_prev_map(MapInfo* value) { prev_map_ = value; } inline MapInfo* prev_real_map() const { return prev_real_map_; } + inline void set_prev_real_map(MapInfo* value) { prev_real_map_ = value; } inline MapInfo* next_real_map() const { return next_real_map_; } + inline void set_next_real_map(MapInfo* value) { next_real_map_ = value; } inline std::atomic_int64_t& load_bias() { return load_bias_; } + inline void set_load_bias(int64_t value) { load_bias_ = value; } inline std::atomic& build_id() { return build_id_; } + inline void set_build_id(SharedString* value) { build_id_ = value; } inline bool memory_backed_elf() const { return memory_backed_elf_; } + inline void set_memory_backed_elf(bool value) { memory_backed_elf_ = value; } + private: uint64_t start_ = 0; uint64_t end_ = 0; uint64_t offset_ = 0; @@ -115,6 +133,7 @@ struct MapInfo { // Set to true if the elf file data is coming from memory. bool memory_backed_elf_ = false; + public: // This function guarantees it will never return nullptr. Elf* GetElf(const std::shared_ptr& process_memory, ArchEnum expected_arch); @@ -133,7 +152,7 @@ struct MapInfo { // Returns the printable version of the build id (hex dump of raw data). std::string GetPrintableBuildID(); - inline bool IsBlank() { return offset_ == 0 && flags_ == 0 && name_.empty(); } + inline bool IsBlank() { return offset() == 0 && flags() == 0 && name().empty(); } private: MapInfo(const MapInfo&) = delete; diff --git a/libunwindstack/tests/DexFilesTest.cpp b/libunwindstack/tests/DexFilesTest.cpp index cfb4a43..c18a437 100644 --- a/libunwindstack/tests/DexFilesTest.cpp +++ b/libunwindstack/tests/DexFilesTest.cpp @@ -49,7 +49,7 @@ class DexFilesTest : public ::testing::Test { interface->FakeSetDataOffset(data_offset); interface->FakeSetDataVaddrStart(data_vaddr); interface->FakeSetDataVaddrEnd(data_vaddr + data_size); - map_info->elf().reset(elf); + map_info->set_elf(elf); } void Init(ArchEnum arch) { @@ -279,11 +279,11 @@ TEST_F(DexFilesTest, get_method_information_search_libs) { EXPECT_EQ(0x124U, method_offset); MapInfo* map_info = maps_->Get(kMapGlobal); - map_info->name_ = "/system/lib/libart.so"; + map_info->set_name("/system/lib/libart.so"); dex_files_ = CreateDexFiles(ARCH_ARM, process_memory_, libs); // Set the rw map to the same name or this will not scan this entry. map_info = maps_->Get(kMapGlobalRw); - map_info->name_ = "/system/lib/libart.so"; + map_info->set_name("/system/lib/libart.so"); // Make sure that clearing out copy of the libs doesn't affect the // DexFiles object. libs.clear(); diff --git a/libunwindstack/tests/JitDebugTest.cpp b/libunwindstack/tests/JitDebugTest.cpp index f829629..44378a8 100644 --- a/libunwindstack/tests/JitDebugTest.cpp +++ b/libunwindstack/tests/JitDebugTest.cpp @@ -46,7 +46,7 @@ class JitDebugTest : public ::testing::Test { interface->FakeSetDataOffset(data_offset); interface->FakeSetDataVaddrStart(data_vaddr); interface->FakeSetDataVaddrEnd(data_vaddr + data_size); - map_info->elf().reset(elf); + map_info->set_elf(elf); } void Init(ArchEnum arch) { @@ -415,9 +415,9 @@ TEST_F(JitDebugTest, get_elf_search_libs) { // Change the name of the map that includes the value and verify this works. MapInfo* map_info = maps_->Get(5); - map_info->name_ = "/system/lib/libart.so"; + map_info->set_name("/system/lib/libart.so"); map_info = maps_->Get(6); - map_info->name_ = "/system/lib/libart.so"; + map_info->set_name("/system/lib/libart.so"); jit_debug_ = CreateJitDebug(ARCH_ARM, process_memory_, libs); // Make sure that clearing our copy of the libs doesn't affect the // JitDebug object. diff --git a/libunwindstack/tests/LocalUpdatableMapsTest.cpp b/libunwindstack/tests/LocalUpdatableMapsTest.cpp index 07a3dba..0632a44 100644 --- a/libunwindstack/tests/LocalUpdatableMapsTest.cpp +++ b/libunwindstack/tests/LocalUpdatableMapsTest.cpp @@ -119,7 +119,7 @@ TEST_F(LocalUpdatableMapsTest, same_map_new_perms) { EXPECT_EQ(0x4000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); map_info = maps_.Get(1); ASSERT_TRUE(map_info != nullptr); @@ -127,7 +127,7 @@ TEST_F(LocalUpdatableMapsTest, same_map_new_perms) { EXPECT_EQ(0x9000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); auto& saved_maps = maps_.TestGetSavedMaps(); ASSERT_EQ(1U, saved_maps.size()); @@ -137,7 +137,7 @@ TEST_F(LocalUpdatableMapsTest, same_map_new_perms) { EXPECT_EQ(0x4000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); } TEST_F(LocalUpdatableMapsTest, same_map_new_name) { @@ -165,7 +165,7 @@ TEST_F(LocalUpdatableMapsTest, same_map_new_name) { EXPECT_EQ(0x9000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); auto& saved_maps = maps_.TestGetSavedMaps(); ASSERT_EQ(1U, saved_maps.size()); @@ -175,7 +175,7 @@ TEST_F(LocalUpdatableMapsTest, same_map_new_name) { EXPECT_EQ(0x4000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); } TEST_F(LocalUpdatableMapsTest, only_add_maps) { @@ -198,7 +198,7 @@ TEST_F(LocalUpdatableMapsTest, only_add_maps) { EXPECT_EQ(0x2000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); map_info = maps_.Get(1); ASSERT_TRUE(map_info != nullptr); @@ -206,7 +206,7 @@ TEST_F(LocalUpdatableMapsTest, only_add_maps) { EXPECT_EQ(0x4000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); map_info = maps_.Get(2); ASSERT_TRUE(map_info != nullptr); @@ -214,7 +214,7 @@ TEST_F(LocalUpdatableMapsTest, only_add_maps) { EXPECT_EQ(0x9000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); map_info = maps_.Get(3); ASSERT_TRUE(map_info != nullptr); @@ -222,7 +222,7 @@ TEST_F(LocalUpdatableMapsTest, only_add_maps) { EXPECT_EQ(0xf000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); } TEST_F(LocalUpdatableMapsTest, all_new_maps) { @@ -242,7 +242,7 @@ TEST_F(LocalUpdatableMapsTest, all_new_maps) { EXPECT_EQ(0x2000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); map_info = maps_.Get(1); ASSERT_TRUE(map_info != nullptr); @@ -250,7 +250,7 @@ TEST_F(LocalUpdatableMapsTest, all_new_maps) { EXPECT_EQ(0xf000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); auto& saved_maps = maps_.TestGetSavedMaps(); ASSERT_EQ(2U, saved_maps.size()); @@ -260,7 +260,7 @@ TEST_F(LocalUpdatableMapsTest, all_new_maps) { EXPECT_EQ(0x4000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); map_info = saved_maps[1].get(); ASSERT_TRUE(map_info != nullptr); @@ -268,7 +268,7 @@ TEST_F(LocalUpdatableMapsTest, all_new_maps) { EXPECT_EQ(0x9000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); } TEST_F(LocalUpdatableMapsTest, add_map_prev_name_updated) { @@ -289,7 +289,7 @@ TEST_F(LocalUpdatableMapsTest, add_map_prev_name_updated) { EXPECT_EQ(0xA000U, map_info->end()); EXPECT_EQ(0U, map_info->offset()); EXPECT_EQ(PROT_READ | PROT_EXEC, map_info->flags()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); EXPECT_EQ(maps_.Get(1), map_info->prev_map()); } @@ -331,7 +331,7 @@ TEST_F(LocalUpdatableMapsTest, add_map_prev_real_name_updated) { EXPECT_TRUE(map_info->IsBlank()); EXPECT_EQ(maps_.Get(2), map_info->prev_real_map()); EXPECT_EQ(maps_.Get(2), map_info->prev_map()); - EXPECT_TRUE(map_info->name_.empty()); + EXPECT_TRUE(map_info->name().empty()); ASSERT_TRUE( android::base::WriteStringToFile("3000-4000 r-xp 00000 00:00 0 /fake/lib.so\n" diff --git a/libunwindstack/tests/MapInfoCreateMemoryTest.cpp b/libunwindstack/tests/MapInfoCreateMemoryTest.cpp index 53b56a6..d5e04a1 100644 --- a/libunwindstack/tests/MapInfoCreateMemoryTest.cpp +++ b/libunwindstack/tests/MapInfoCreateMemoryTest.cpp @@ -94,12 +94,12 @@ TEST_F(MapInfoCreateMemoryTest, end_le_start) { std::unique_ptr memory(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() == nullptr); - info.end_ = 0xff; + info.set_end(0xff); memory.reset(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() == nullptr); // Make sure this test is valid. - info.end_ = 0x101; + info.set_end(0x101); memory.reset(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); EXPECT_FALSE(info.memory_backed_elf()); @@ -130,47 +130,47 @@ TEST_F(MapInfoCreateMemoryTest, file_backed_non_zero_offset_full_file) { // Now verify the elf start offset is set correctly based on the previous // info. MapInfo prev_info(nullptr, nullptr, 0, 0x100, 0x10, 0, ""); - info.prev_map_ = &prev_info; - info.prev_real_map_ = &prev_info; + info.set_prev_map(&prev_info); + info.set_prev_real_map(&prev_info); // No preconditions met, change each one until it should set the elf start // offset to zero. - info.elf_offset_ = 0; - info.elf_start_offset_ = 0; - info.memory_backed_elf_ = false; + info.set_elf_offset(0); + info.set_elf_start_offset(0); + info.set_memory_backed_elf(false); memory.reset(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); EXPECT_FALSE(info.memory_backed_elf()); ASSERT_EQ(0x100U, info.elf_offset()); EXPECT_EQ(0x100U, info.elf_start_offset()); - prev_info.offset_ = 0; - info.elf_offset_ = 0; - info.elf_start_offset_ = 0; - info.memory_backed_elf_ = false; + prev_info.set_offset(0); + info.set_elf_offset(0); + info.set_elf_start_offset(0); + info.set_memory_backed_elf(false); memory.reset(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); EXPECT_FALSE(info.memory_backed_elf()); ASSERT_EQ(0x100U, info.elf_offset()); EXPECT_EQ(0x100U, info.elf_start_offset()); - prev_info.flags_ = PROT_READ; - info.elf_offset_ = 0; - info.elf_start_offset_ = 0; - info.memory_backed_elf_ = false; + prev_info.set_flags(PROT_READ); + info.set_elf_offset(0); + info.set_elf_start_offset(0); + info.set_memory_backed_elf(false); memory.reset(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); EXPECT_FALSE(info.memory_backed_elf()); ASSERT_EQ(0x100U, info.elf_offset()); EXPECT_EQ(0x100U, info.elf_start_offset()); - prev_info.name_ = info.name(); - info.elf_offset_ = 0; - info.elf_start_offset_ = 0; - info.memory_backed_elf_ = false; + prev_info.set_name(info.name()); + info.set_elf_offset(0); + info.set_elf_start_offset(0); + info.set_memory_backed_elf(false); memory.reset(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); - EXPECT_FALSE(info.memory_backed_elf_); + EXPECT_FALSE(info.memory_backed_elf()); ASSERT_EQ(0x100U, info.elf_offset()); EXPECT_EQ(0U, info.elf_start_offset()); } @@ -182,7 +182,7 @@ TEST_F(MapInfoCreateMemoryTest, file_backed_non_zero_offset_partial_file) { std::unique_ptr memory(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); - EXPECT_FALSE(info.memory_backed_elf_); + EXPECT_FALSE(info.memory_backed_elf()); ASSERT_EQ(0U, info.elf_offset()); EXPECT_EQ(0x1000U, info.elf_start_offset()); @@ -207,7 +207,7 @@ TEST_F(MapInfoCreateMemoryTest, file_backed_non_zero_offset_partial_file_whole_e std::unique_ptr memory(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); - EXPECT_FALSE(info.memory_backed_elf_); + EXPECT_FALSE(info.memory_backed_elf()); ASSERT_EQ(0U, info.elf_offset()); EXPECT_EQ(0x1000U, info.elf_start_offset()); @@ -225,7 +225,7 @@ TEST_F(MapInfoCreateMemoryTest, file_backed_non_zero_offset_partial_file_whole_e std::unique_ptr memory(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); - EXPECT_FALSE(info.memory_backed_elf_); + EXPECT_FALSE(info.memory_backed_elf()); ASSERT_EQ(0U, info.elf_offset()); EXPECT_EQ(0x2000U, info.elf_start_offset()); @@ -267,7 +267,7 @@ TEST_F(MapInfoCreateMemoryTest, process_memory) { std::unique_ptr memory(info.CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); - EXPECT_TRUE(info.memory_backed_elf_); + EXPECT_TRUE(info.memory_backed_elf()); memset(buffer.data(), 0, buffer.size()); ASSERT_TRUE(memory->ReadFully(0, buffer.data(), buffer.size())); @@ -299,7 +299,7 @@ TEST_F(MapInfoCreateMemoryTest, valid_rosegment_zero_offset) { std::unique_ptr mem(map_info->CreateMemory(process_memory_)); ASSERT_TRUE(mem.get() != nullptr); - EXPECT_TRUE(map_info->memory_backed_elf_); + EXPECT_TRUE(map_info->memory_backed_elf()); EXPECT_EQ(0x4000UL, map_info->elf_offset()); EXPECT_EQ(0x4000UL, map_info->offset()); EXPECT_EQ(0U, map_info->elf_start_offset()); @@ -346,7 +346,7 @@ TEST_F(MapInfoCreateMemoryTest, valid_rosegment_non_zero_offset) { std::unique_ptr mem(map_info->CreateMemory(process_memory_)); ASSERT_TRUE(mem.get() != nullptr); - EXPECT_TRUE(map_info->memory_backed_elf_); + EXPECT_TRUE(map_info->memory_backed_elf()); EXPECT_EQ(0x1000UL, map_info->elf_offset()); EXPECT_EQ(0xb000UL, map_info->offset()); EXPECT_EQ(0xa000UL, map_info->elf_start_offset()); @@ -385,7 +385,7 @@ TEST_F(MapInfoCreateMemoryTest, rosegment_from_file) { // extend over the executable segment. std::unique_ptr memory(map_info->CreateMemory(process_memory_)); ASSERT_TRUE(memory.get() != nullptr); - EXPECT_FALSE(map_info->memory_backed_elf_); + EXPECT_FALSE(map_info->memory_backed_elf()); std::vector buffer(0x100); EXPECT_EQ(0x2000U, map_info->offset()); EXPECT_EQ(0U, map_info->elf_offset()); @@ -400,9 +400,9 @@ TEST_F(MapInfoCreateMemoryTest, rosegment_from_file) { ASSERT_EQ(0x1000, lseek(elf_at_1000_.fd, 0x1000, SEEK_SET)); ASSERT_TRUE(android::base::WriteFully(elf_at_1000_.fd, &ehdr, sizeof(ehdr))); - map_info->memory_backed_elf_ = false; + map_info->set_memory_backed_elf(false); memory.reset(map_info->CreateMemory(process_memory_)); - EXPECT_FALSE(map_info->memory_backed_elf_); + EXPECT_FALSE(map_info->memory_backed_elf()); EXPECT_EQ(0x2000U, map_info->offset()); EXPECT_EQ(0x1000U, map_info->elf_offset()); EXPECT_EQ(0x1000U, map_info->elf_start_offset()); @@ -430,7 +430,7 @@ TEST_F(MapInfoCreateMemoryTest, valid_rosegment_offset_overflow) { std::unique_ptr mem(map_info->CreateMemory(process_memory_)); ASSERT_TRUE(mem.get() != nullptr); - EXPECT_TRUE(map_info->memory_backed_elf_); + EXPECT_TRUE(map_info->memory_backed_elf()); EXPECT_EQ(0xfffffffffffff000UL, map_info->elf_offset()); EXPECT_EQ(0xfffffffffffff000UL, map_info->offset()); EXPECT_EQ(0U, map_info->elf_start_offset()); diff --git a/libunwindstack/tests/MapInfoGetBuildIDTest.cpp b/libunwindstack/tests/MapInfoGetBuildIDTest.cpp index a88d120..e123d0e 100644 --- a/libunwindstack/tests/MapInfoGetBuildIDTest.cpp +++ b/libunwindstack/tests/MapInfoGetBuildIDTest.cpp @@ -74,7 +74,7 @@ TEST_F(MapInfoGetBuildIDTest, no_elf_and_no_valid_elf_in_memory) { } TEST_F(MapInfoGetBuildIDTest, from_elf) { - map_info_->elf().reset(elf_container_.release()); + map_info_->set_elf(elf_container_.release()); elf_interface_->FakeSetBuildID("FAKE_BUILD_ID"); EXPECT_EQ("FAKE_BUILD_ID", map_info_->GetBuildID()); @@ -82,7 +82,7 @@ TEST_F(MapInfoGetBuildIDTest, from_elf) { } TEST_F(MapInfoGetBuildIDTest, from_elf_no_sign_extension) { - map_info_->elf().reset(elf_container_.release()); + map_info_->set_elf(elf_container_.release()); std::string build_id = {static_cast(0xfa), static_cast(0xab), static_cast(0x12), static_cast(0x02)}; @@ -125,7 +125,7 @@ void MapInfoGetBuildIDTest::MultipleThreadTest(std::string expected_build_id) { } TEST_F(MapInfoGetBuildIDTest, multiple_thread_elf_exists) { - map_info_->elf().reset(elf_container_.release()); + map_info_->set_elf(elf_container_.release()); elf_interface_->FakeSetBuildID("FAKE_BUILD_ID"); MultipleThreadTest("FAKE_BUILD_ID"); diff --git a/libunwindstack/tests/MapInfoGetElfTest.cpp b/libunwindstack/tests/MapInfoGetElfTest.cpp index 9ba01e0..944f894 100644 --- a/libunwindstack/tests/MapInfoGetElfTest.cpp +++ b/libunwindstack/tests/MapInfoGetElfTest.cpp @@ -92,7 +92,7 @@ TEST_F(MapInfoGetElfTest, valid32) { EXPECT_EQ(ELFCLASS32, elf->class_type()); // Now verify that an empty process memory returns an invalid elf object. - info.elf().reset(); + info.set_elf(nullptr); elf = info.GetElf(std::shared_ptr(), ARCH_ARM); ASSERT_TRUE(elf != nullptr); ASSERT_FALSE(elf->valid()); @@ -167,15 +167,15 @@ TEST_F(MapInfoGetElfTest, end_le_start) { ASSERT_TRUE(elf != nullptr); ASSERT_FALSE(elf->valid()); - info.elf().reset(); - info.end_ = 0xfff; + info.set_elf(nullptr); + info.set_end(0xfff); elf = info.GetElf(process_memory_, ARCH_ARM); ASSERT_TRUE(elf != nullptr); ASSERT_FALSE(elf->valid()); // Make sure this test is valid. - info.elf().reset(); - info.end_ = 0x2000; + info.set_elf(nullptr); + info.set_end(0x2000); elf = info.GetElf(process_memory_, ARCH_ARM); ASSERT_TRUE(elf != nullptr); ASSERT_TRUE(elf->valid()); @@ -316,14 +316,14 @@ TEST_F(MapInfoGetElfTest, check_device_maps) { ASSERT_FALSE(elf->valid()); // Set the name to nothing to verify that it still fails. - info.elf().reset(); - info.name_ = ""; + info.set_elf(nullptr); + info.set_name(""); elf = info.GetElf(process_memory_, ARCH_X86_64); ASSERT_FALSE(elf->valid()); // Change the flags and verify the elf is valid now. - info.elf().reset(); - info.flags_ = PROT_READ; + info.set_elf(nullptr); + info.set_flags(PROT_READ); elf = info.GetElf(process_memory_, ARCH_X86_64); ASSERT_TRUE(elf->valid()); } diff --git a/libunwindstack/tests/MapInfoGetLoadBiasTest.cpp b/libunwindstack/tests/MapInfoGetLoadBiasTest.cpp index d60b600..5ddf1de 100644 --- a/libunwindstack/tests/MapInfoGetLoadBiasTest.cpp +++ b/libunwindstack/tests/MapInfoGetLoadBiasTest.cpp @@ -69,7 +69,7 @@ TEST_F(MapInfoGetLoadBiasTest, no_elf_and_no_valid_elf_in_memory) { } TEST_F(MapInfoGetLoadBiasTest, load_bias_cached_from_elf) { - map_info_->elf().reset(elf_container_.release()); + map_info_->set_elf(elf_container_.release()); elf_->FakeSetLoadBias(0); EXPECT_EQ(0U, map_info_->GetLoadBias(process_memory_)); @@ -79,12 +79,12 @@ TEST_F(MapInfoGetLoadBiasTest, load_bias_cached_from_elf) { } TEST_F(MapInfoGetLoadBiasTest, elf_exists) { - map_info_->elf().reset(elf_container_.release()); + map_info_->set_elf(elf_container_.release()); elf_->FakeSetLoadBias(0); EXPECT_EQ(0U, map_info_->GetLoadBias(process_memory_)); - map_info_->load_bias_ = INT64_MAX; + map_info_->set_load_bias(INT64_MAX); elf_->FakeSetLoadBias(0x1000); EXPECT_EQ(0x1000U, map_info_->GetLoadBias(process_memory_)); } @@ -122,7 +122,7 @@ void MapInfoGetLoadBiasTest::MultipleThreadTest(uint64_t expected_load_bias) { } TEST_F(MapInfoGetLoadBiasTest, multiple_thread_elf_exists) { - map_info_->elf().reset(elf_container_.release()); + map_info_->set_elf(elf_container_.release()); elf_->FakeSetLoadBias(0x1000); MultipleThreadTest(0x1000); diff --git a/libunwindstack/tests/MapInfoTest.cpp b/libunwindstack/tests/MapInfoTest.cpp index b4c1010..59aa79e 100644 --- a/libunwindstack/tests/MapInfoTest.cpp +++ b/libunwindstack/tests/MapInfoTest.cpp @@ -63,7 +63,7 @@ TEST(MapInfoTest, get_function_name) { interface->FakePushFunctionData(FunctionData("function", 1000)); MapInfo map_info(nullptr, nullptr, 1, 2, 3, 4, ""); - map_info.elf().reset(elf); + map_info.set_elf(elf); SharedString name; uint64_t offset; diff --git a/libunwindstack/tests/MapsTest.cpp b/libunwindstack/tests/MapsTest.cpp index 1448149..309bdc2 100644 --- a/libunwindstack/tests/MapsTest.cpp +++ b/libunwindstack/tests/MapsTest.cpp @@ -34,12 +34,12 @@ static void VerifyLine(std::string line, MapInfo* info) { ASSERT_TRUE(maps.Parse()) << "Failed on: " + line; MapInfo* element = maps.Get(0); ASSERT_TRUE(element != nullptr) << "Failed on: " + line; - info->start_ = element->start(); - info->end_ = element->end(); - info->offset_ = element->offset(); - info->flags_ = element->flags(); - info->name_ = element->name(); - info->elf_offset_ = element->elf_offset(); + info->set_start(element->start()); + info->set_end(element->end()); + info->set_offset(element->offset()); + info->set_flags(element->flags()); + info->set_name(element->name()); + info->set_elf_offset(element->elf_offset()); } } @@ -164,10 +164,10 @@ TEST(MapsTest, verify_large_values) { EXPECT_EQ(0xf0b0d0f010305070UL, info.offset()); #else VerifyLine("f2345678-fabcdef8 rwxp f0305070 00:00 0\n", &info); - EXPECT_EQ(0xf2345678UL, info.start_); - EXPECT_EQ(0xfabcdef8UL, info.end_); - EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, info.flags_); - EXPECT_EQ(0xf0305070UL, info.offset_); + EXPECT_EQ(0xf2345678UL, info.start()); + EXPECT_EQ(0xfabcdef8UL, info.end()); + EXPECT_EQ(PROT_READ | PROT_WRITE | PROT_EXEC, info.flags()); + EXPECT_EQ(0xf0305070UL, info.offset()); #endif } @@ -316,10 +316,10 @@ TEST(MapsTest, const_iterate) { Maps::const_iterator it = maps.begin(); EXPECT_EQ(0xa000U, (*it)->start()); - EXPECT_EQ(0xe000U, (*it)->end_); + EXPECT_EQ(0xe000U, (*it)->end()); ++it; EXPECT_EQ(0xe000U, (*it)->start()); - EXPECT_EQ(0xf000U, (*it)->end_); + EXPECT_EQ(0xf000U, (*it)->end()); ++it; EXPECT_EQ(maps.end(), it); } @@ -336,19 +336,19 @@ TEST(MapsTest, device) { MapInfo* info = maps.Get(0); ASSERT_TRUE(info != nullptr); - EXPECT_TRUE(info->flags_ & 0x8000); + EXPECT_TRUE(info->flags() & 0x8000); EXPECT_EQ("/dev/", info->name()); info = maps.Get(1); - EXPECT_TRUE(info->flags_ & 0x8000); + EXPECT_TRUE(info->flags() & 0x8000); EXPECT_EQ("/dev/does_not_exist", info->name()); info = maps.Get(2); - EXPECT_FALSE(info->flags_ & 0x8000); + EXPECT_FALSE(info->flags() & 0x8000); EXPECT_EQ("/dev/ashmem/does_not_exist", info->name()); info = maps.Get(3); - EXPECT_FALSE(info->flags_ & 0x8000); + EXPECT_FALSE(info->flags() & 0x8000); EXPECT_EQ("/devsomething/does_not_exist", info->name()); } diff --git a/libunwindstack/tests/RegsTest.cpp b/libunwindstack/tests/RegsTest.cpp index 1a9e153..716a847 100644 --- a/libunwindstack/tests/RegsTest.cpp +++ b/libunwindstack/tests/RegsTest.cpp @@ -171,7 +171,7 @@ TEST_F(RegsTest, rel_pc_arm) { TEST_F(RegsTest, elf_invalid) { MapInfo map_info(nullptr, nullptr, 0x1000, 0x2000, 0, 0, ""); Elf* invalid_elf = new Elf(nullptr); - map_info.elf().reset(invalid_elf); + map_info.set_elf(invalid_elf); EXPECT_EQ(0x500U, invalid_elf->GetRelPc(0x1500, &map_info)); EXPECT_EQ(2U, GetPcAdjustment(0x500U, invalid_elf, ARCH_ARM)); diff --git a/libunwindstack/tests/UnwinderTest.cpp b/libunwindstack/tests/UnwinderTest.cpp index ea429ab..0efc599 100644 --- a/libunwindstack/tests/UnwinderTest.cpp +++ b/libunwindstack/tests/UnwinderTest.cpp @@ -52,7 +52,7 @@ class UnwinderTest : public ::testing::Test { maps_->Add(start, end, offset, flags, name, static_cast(-1)); MapInfo* map_info = maps_->Find(start); if (elf != nullptr) { - map_info->elf().reset(elf); + map_info->set_elf(elf); } return map_info; } @@ -95,13 +95,13 @@ class UnwinderTest : public ::testing::Test { interface->FakeSetSoname("lib_fake.so"); elf->FakeSetInterface(interface); map_info = AddMapInfo(0x43000, 0x44000, 0x1d000, PROT_READ | PROT_WRITE, "/fake/fake.apk", elf); - map_info->elf_start_offset_ = 0x1d000; + map_info->set_elf_start_offset(0x1d000); AddMapInfo(0x53000, 0x54000, 0, PROT_READ | PROT_WRITE, "/fake/fake.oat"); map_info = AddMapInfo(0xa3000, 0xa4000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/fake.vdex"); - map_info->load_bias_ = 0; + map_info->set_load_bias(0); elf = new ElfFake(new MemoryFake); elf->FakeSetInterface(new ElfInterfaceFake(nullptr)); @@ -113,33 +113,33 @@ class UnwinderTest : public ::testing::Test { elf->FakeSetInterface(new ElfInterfaceFake(nullptr)); map_info = AddMapInfo(0xa7000, 0xa8000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/fake_offset.oat", elf); - map_info->elf_offset_ = 0x8000; + map_info->set_elf_offset(0x8000); elf = new ElfFake(new MemoryFake); elf->FakeSetInterface(new ElfInterfaceFake(nullptr)); map_info = AddMapInfo(0xc0000, 0xc1000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/unreadable.so", elf); - map_info->memory_backed_elf_ = true; + map_info->set_memory_backed_elf(true); elf = new ElfFake(new MemoryFake); elf->FakeSetInterface(new ElfInterfaceFake(nullptr)); map_info = AddMapInfo(0xc1000, 0xc2000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "[vdso]", elf); - map_info->memory_backed_elf_ = true; + map_info->set_memory_backed_elf(true); elf = new ElfFake(new MemoryFake); elf->FakeSetInterface(new ElfInterfaceFake(nullptr)); map_info = AddMapInfo(0xc2000, 0xc3000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "", elf); - map_info->memory_backed_elf_ = true; + map_info->set_memory_backed_elf(true); elf = new ElfFake(new MemoryFake); elf->FakeSetInterface(new ElfInterfaceFake(nullptr)); map_info = AddMapInfo(0xc3000, 0xc4000, 0, PROT_READ | PROT_WRITE | PROT_EXEC, "/memfd:/jit-cache", elf); - map_info->memory_backed_elf_ = true; + map_info->set_memory_backed_elf(true); map_info = AddMapInfo(0xd0000, 0xd1000, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/fake.apk"); - map_info->load_bias_ = 0; + map_info->set_load_bias(0); elf = new ElfFake(new MemoryFake); interface = new ElfInterfaceFake(nullptr); @@ -172,8 +172,8 @@ class UnwinderTest : public ::testing::Test { elf->FakeSetLoadBias(0x300); map_info = AddMapInfo(0x100000, 0x101000, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC, "/fake/jit.so", elf); - map_info->elf_start_offset_ = 0x100; - map_info->offset_ = 0x200; + map_info->set_elf_start_offset(0x100); + map_info->set_offset(0x200); } void SetUp() override { diff --git a/libunwindstack/tests/fuzz/UnwinderComponentCreator.cpp b/libunwindstack/tests/fuzz/UnwinderComponentCreator.cpp index 51a9d8c..9367752 100644 --- a/libunwindstack/tests/fuzz/UnwinderComponentCreator.cpp +++ b/libunwindstack/tests/fuzz/UnwinderComponentCreator.cpp @@ -66,7 +66,7 @@ void ElfAddMapInfo(Maps* maps, uint64_t start, uint64_t end, uint64_t offset, ui maps->Add(start, end, offset, flags, name, static_cast(-1)); if (elf != nullptr) { const auto& map_info = *--maps->end(); - map_info->elf().reset(elf); + map_info->set_elf(elf); } } diff --git a/libunwindstack/tools/unwind_for_offline.cpp b/libunwindstack/tools/unwind_for_offline.cpp index 49ab634..4d3a5f4 100644 --- a/libunwindstack/tools/unwind_for_offline.cpp +++ b/libunwindstack/tools/unwind_for_offline.cpp @@ -204,10 +204,10 @@ map_info_t* FillInAndGetMapInfo(std::unordered_map& maps_b unwindstack::MapInfo* map_info) { auto info = &maps_by_start[map_info->start()]; info->start = map_info->start(); - info->end = map_info->end_; - info->offset = map_info->offset_; - info->name = map_info->name_; - info->flags = map_info->flags_; + info->end = map_info->end(); + info->offset = map_info->offset(); + info->name = map_info->name(); + info->flags = map_info->flags(); return info; } -- cgit v1.2.3