#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <dlfcn.h>
#include <fcntl.h>
#include <stdint.h>
#include <sys/prctl.h>
#include <memory>
#include "base/android/library_loader/anchor_functions.h"
#include "base/android/library_loader/anchor_functions_buildflags.h"
#include "base/debug/elf_reader.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/format_macros.h"
#include "base/memory/page_size.h"
#include "base/metrics/histogram_macros.h"
#include "base/process/process_metrics.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h"
#include "third_party/abseil-cpp/absl/strings/ascii.h"
extern char __ehdr_start;
namespace memory_instrumentation {
namespace {
VmRegion;
VmRegionPtr;
const char kClearPeakRssCommand[] = …;
const uint32_t kMaxLineSize = …;
base::FilePath GetProcPidDir(base::ProcessId pid) { … }
bool GetResidentAndSharedPagesFromStatmFile(int fd,
uint64_t* resident_pages,
uint64_t* shared_pages) { … }
bool ResetPeakRSSIfPossible(base::ProcessId pid) { … }
std::unique_ptr<base::ProcessMetrics> CreateProcessMetrics(
base::ProcessId pid) { … }
struct ModuleData { … };
ModuleData GetMainModuleData() { … }
bool ParseSmapsHeader(const char* header_line,
const ModuleData& main_module_data,
VmRegion* region) { … }
uint64_t ReadCounterBytes(char* counter_line) { … }
uint32_t ParseSmapsCounter(char* counter_line, VmRegion* region) { … }
uint32_t ReadLinuxProcSmapsFile(FILE* smaps_file,
std::vector<VmRegionPtr>* maps) { … }
class ScopedProcessSetDumpable { … };
}
FILE* g_proc_smaps_for_testing = …;
void OSMetrics::SetProcSmapsForTesting(FILE* f) { … }
bool OSMetrics::FillOSMemoryDump(base::ProcessId pid,
mojom::RawOSMemDump* dump) { … }
std::vector<VmRegionPtr> OSMetrics::GetProcessMemoryMaps(base::ProcessId pid) { … }
OSMetrics::MappedAndResidentPagesDumpState OSMetrics::GetMappedAndResidentPages(
const size_t start_address,
const size_t end_address,
std::vector<uint8_t>* accessed_pages_bitmap) { … }
size_t OSMetrics::GetPeakResidentSetSize(base::ProcessId pid) { … }
}