chromium/tools/memory/partition_allocator/inspect_utils.h

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

#ifndef TOOLS_MEMORY_PARTITION_ALLOCATOR_INSPECT_UTILS_H_
#define TOOLS_MEMORY_PARTITION_ALLOCATOR_INSPECT_UTILS_H_

// This file includes utilities used in PartitionAlloc tools, also
// found in this directory.

#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <optional>

#include "base/files/file.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_MAC)
#include <mach/mach.h>
#endif

namespace partition_alloc::tools {

// SIGSTOPs a process.
class ScopedSigStopper {};

base::ScopedFD OpenProcMem(pid_t pid);
base::ScopedFD OpenPagemap(pid_t pid);

char* CreateMappingAtAddress(uintptr_t address, size_t size);

// Reads the memory of a remote process.
class RemoteProcessMemoryReader {};

uintptr_t IndexThreadCacheNeedleArray(RemoteProcessMemoryReader& reader,
                                      size_t index);

// Allows to access an object copied from remote memory "as if" it were
// local. Of course, dereferencing any pointer from within it will at best
// fault.
template <typename T>
class RawBuffer {};

}  // namespace partition_alloc::tools

#endif  // TOOLS_MEMORY_PARTITION_ALLOCATOR_INSPECT_UTILS_H_