chromium/tools/memory/partition_allocator/pa_tcache_inspect.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Connects to a running Chrome process, and outputs statistics about its thread
// caches.

#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 {

// Scans the process memory to look for the thread cache registry address. This
// does not need symbols.
uintptr_t FindThreadCacheRegistry(RemoteProcessMemoryReader& reader) {}

// List all thread names for a given PID.
std::map<base::PlatformThreadId, std::string> ThreadNames(pid_t pid) {}

}  // namespace

class ThreadCacheInspector {};

class PartitionRootInspector {};

ThreadCacheInspector::ThreadCacheInspector(uintptr_t registry_addr, pid_t pid)
    :{}

// NO_THREAD_SAFETY_ANALYSIS: Well, reading a running process' memory is not
// really thread-safe.
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) {}

}  // namespace

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) {}
}  // namespace partition_alloc::tools

int main(int argc, char** argv) {}