#include "base/profiler/module_cache.h"
#include <iomanip>
#include <map>
#include <memory>
#include <string_view>
#include <utility>
#include <vector>
#include "base/containers/adapters.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/ranges/algorithm.h"
#include "base/test/bind.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
#include "base/debug/proc_maps_linux.h"
#endif
namespace base {
namespace {
int AFunctionForTest() { … }
class IsolatedModule : public ModuleCache::Module { … };
class FakeModule : public ModuleCache::Module { … };
const ModuleCache::Module* AddNonNativeModule(
ModuleCache* cache,
std::unique_ptr<const ModuleCache::Module> module) { … }
#if (BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_IOS) && !defined(ARCH_CPU_ARM64)) || \
BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_WIN)
#define MAYBE_TEST(TestSuite, TestName) …
#else
#define MAYBE_TEST …
#endif
MAYBE_TEST(ModuleCacheTest, GetDebugBasename) { … }
MAYBE_TEST(ModuleCacheTest, LookupCodeAddresses) { … }
MAYBE_TEST(ModuleCacheTest, LookupRange) { … }
MAYBE_TEST(ModuleCacheTest, LookupNonNativeModule) { … }
MAYBE_TEST(ModuleCacheTest, LookupOverlaidNonNativeModule) { … }
MAYBE_TEST(ModuleCacheTest, UpdateNonNativeModulesAdd) { … }
MAYBE_TEST(ModuleCacheTest, UpdateNonNativeModulesRemove) { … }
MAYBE_TEST(ModuleCacheTest, UpdateNonNativeModulesRemoveModuleIsNotDestroyed) { … }
MAYBE_TEST(ModuleCacheTest, UpdateNonNativeModulesPartitioning) { … }
MAYBE_TEST(ModuleCacheTest, UpdateNonNativeModulesReplace) { … }
MAYBE_TEST(ModuleCacheTest,
UpdateNonNativeModulesMultipleRemovedModulesAtSameAddress) { … }
MAYBE_TEST(ModuleCacheTest, UpdateNonNativeModulesCorrectModulesRemoved) { … }
MAYBE_TEST(ModuleCacheTest, ModulesList) { … }
MAYBE_TEST(ModuleCacheTest, InvalidModule) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
(BUILDFLAG(IS_ANDROID) && !defined(ARCH_CPU_ARM64))
TEST(ModuleCacheTest, CheckAgainstProcMaps) { … }
#endif
class MockModuleProvider : public ModuleCache::AuxiliaryModuleProvider { … };
TEST(ModuleCacheTest, RegisterAuxiliaryModuleProvider) { … }
MAYBE_TEST(ModuleCacheTest, NativeModuleOverAuxiliaryModuleProvider) { … }
TEST(ModuleCacheTest, UnregisterAuxiliaryModuleProvider) { … }
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX)
TEST(ModuleCacheTest, TransformELFToSymbolServerFormat) { … }
#endif
}
}