#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <algorithm>
#include <cstring>
#include <ios>
#include <iostream>
#include <map>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/debug/proc_maps_linux.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/scoped_file.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/page_size.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/thread_annotations.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "partition_alloc/partition_root.h"
#include "partition_alloc/partition_stats.h"
#include "partition_alloc/thread_cache.h"
#include "tools/memory/partition_allocator/inspect_utils.h"
namespace partition_alloc::tools {
PlatformThreadId;
BucketIndexLookup;
PartitionBucket;
SlotSpanMetadata;
namespace {
uintptr_t FindThreadCacheRegistry(RemoteProcessMemoryReader& reader) { … }
std::map<base::PlatformThreadId, std::string> ThreadNames(pid_t pid) { … }
}
class ThreadCacheInspector { … };
class PartitionRootInspector { … };
ThreadCacheInspector::ThreadCacheInspector(uintptr_t registry_addr, pid_t pid)
: … { … }
bool ThreadCacheInspector::GetAllThreadCaches() NO_THREAD_SAFETY_ANALYSIS { … }
size_t ThreadCacheInspector::CachedMemory() const { … }
uintptr_t ThreadCacheInspector::GetRootAddress() { … }
std::vector<ThreadCacheInspector::BucketStats>
ThreadCacheInspector::AccumulateThreadCacheBuckets() { … }
void PartitionRootInspector::Update() { … }
namespace {
bool CopySlotSpanList(std::vector<SlotSpanMetadata>& list,
uintptr_t head_address,
RemoteProcessMemoryReader& reader) { … }
}
bool PartitionRootInspector::GatherStatistics() { … }
void DisplayBucket(const ThreadCacheInspector::BucketStats& bucket,
bool is_limit) { … }
void DisplayPerThreadData(
ThreadCacheInspector& inspector,
std::map<base::PlatformThreadId, std::string>& tid_to_name) { … }
void DisplayPerBucketData(ThreadCacheInspector& inspector) { … }
void DisplayRootData(PartitionRootInspector& root_inspector,
size_t detailed_bucket_index) { … }
base::Value::Dict Dump(PartitionRootInspector& root_inspector) { … }
}
int main(int argc, char** argv) { … }