chromium/tools/dump_process_memory/dump_process.cc

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

#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#include <limits>
#include <string>
#include <vector>

#include "base/debug/proc_maps_linux.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"

namespace {

MappedMemoryRegion;
constexpr size_t kPageSize =;

// See https://www.kernel.org/doc/Documentation/vm/pagemap.txt.
struct PageMapEntry {};
static_assert;

// Calls ptrace() on a process, and detaches in the destructor.
class ScopedPtracer {};

bool ParseProcMaps(pid_t pid, std::vector<MappedMemoryRegion>* regions) {}

// Keep anonynmous rw-p regions.
bool ShouldDump(const MappedMemoryRegion& region) {}

base::File OpenProcPidFile(const char* filename, pid_t pid) {}

bool DumpRegion(const MappedMemoryRegion& region,
                pid_t pid,
                base::File* proc_mem,
                base::File* proc_pagemap) {}

// Dumps the content of all the anonymous rw-p mappings in a given process to
// disk.
bool DumpMappings(pid_t pid) {}

}  // namespace

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