#include "base/trace_event/memory_dump_manager.h"
#include <inttypes.h>
#include <stdio.h>
#include <algorithm>
#include <array>
#include <memory>
#include <tuple>
#include <utility>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/debug/alias.h"
#include "base/debug/stack_trace.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "base/trace_event/heap_profiler.h"
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
#include "base/trace_event/malloc_dump_provider.h"
#include "base/trace_event/memory_dump_provider.h"
#include "base/trace_event/memory_dump_scheduler.h"
#include "base/trace_event/memory_infra_background_allowlist.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "build/build_config.h"
#include "partition_alloc/buildflags.h"
#include "third_party/abseil-cpp/absl/base/dynamic_annotations.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/trace_event/java_heap_dump_provider_android.h"
#if BUILDFLAG(CAN_UNWIND_WITH_CFI_TABLE)
#include "base/trace_event/cfi_backtrace_android.h"
#endif
#endif
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "base/trace_event/address_space_dump_provider.h"
#endif
namespace base {
namespace trace_event {
namespace {
MemoryDumpManager* g_memory_dump_manager_for_testing = …;
void DoGlobalDumpWithoutCallback(
MemoryDumpManager::RequestGlobalDumpFunction global_dump_fn,
MemoryDumpType dump_type,
MemoryDumpLevelOfDetail level_of_detail) { … }
}
constexpr const char* MemoryDumpManager::kTraceCategory;
const int MemoryDumpManager::kMaxConsecutiveFailuresCount = …;
const uint64_t MemoryDumpManager::kInvalidTracingProcessId = …;
const char* const MemoryDumpManager::kSystemAllocatorPoolName = …;
#else
nullptr;
#endif
MemoryDumpManager* MemoryDumpManager::GetInstance() { … }
std::unique_ptr<MemoryDumpManager>
MemoryDumpManager::CreateInstanceForTesting() { … }
MemoryDumpManager::MemoryDumpManager() = default;
MemoryDumpManager::~MemoryDumpManager() { … }
void MemoryDumpManager::Initialize(
RequestGlobalDumpFunction request_dump_function,
bool is_coordinator) { … }
void MemoryDumpManager::RegisterDumpProvider(
MemoryDumpProvider* mdp,
const char* name,
scoped_refptr<SingleThreadTaskRunner> task_runner,
MemoryDumpProvider::Options options) { … }
void MemoryDumpManager::RegisterDumpProvider(
MemoryDumpProvider* mdp,
const char* name,
scoped_refptr<SingleThreadTaskRunner> task_runner) { … }
void MemoryDumpManager::RegisterDumpProviderWithSequencedTaskRunner(
MemoryDumpProvider* mdp,
const char* name,
scoped_refptr<SequencedTaskRunner> task_runner,
MemoryDumpProvider::Options options) { … }
void MemoryDumpManager::RegisterDumpProviderInternal(
MemoryDumpProvider* mdp,
const char* name,
scoped_refptr<SequencedTaskRunner> task_runner,
const MemoryDumpProvider::Options& options) { … }
void MemoryDumpManager::UnregisterDumpProvider(MemoryDumpProvider* mdp) { … }
void MemoryDumpManager::UnregisterAndDeleteDumpProviderSoon(
std::unique_ptr<MemoryDumpProvider> mdp) { … }
void MemoryDumpManager::UnregisterDumpProviderInternal(
MemoryDumpProvider* mdp,
bool take_mdp_ownership_and_delete_async) { … }
bool MemoryDumpManager::IsDumpProviderRegisteredForTesting(
MemoryDumpProvider* provider) { … }
void MemoryDumpManager::ResetForTesting() { … }
scoped_refptr<SequencedTaskRunner>
MemoryDumpManager::GetDumpThreadTaskRunner() { … }
scoped_refptr<base::SequencedTaskRunner>
MemoryDumpManager::GetOrCreateBgTaskRunnerLocked() { … }
void MemoryDumpManager::CreateProcessDump(const MemoryDumpRequestArgs& args,
ProcessMemoryDumpCallback callback) { … }
void MemoryDumpManager::ContinueAsyncProcessDump(
ProcessMemoryDumpAsyncState* owned_pmd_async_state) { … }
void MemoryDumpManager::InvokeOnMemoryDump(MemoryDumpProviderInfo* mdpinfo,
ProcessMemoryDump* pmd) { … }
void MemoryDumpManager::FinishAsyncProcessDump(
std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) { … }
void MemoryDumpManager::SetupForTracing(
const TraceConfig::MemoryDumpConfig& memory_dump_config) { … }
void MemoryDumpManager::TeardownForTracing() { … }
MemoryDumpManager::ProcessMemoryDumpAsyncState::ProcessMemoryDumpAsyncState(
MemoryDumpRequestArgs req_args,
const MemoryDumpProviderInfo::OrderedSet& dump_providers,
ProcessMemoryDumpCallback callback,
scoped_refptr<SequencedTaskRunner> dump_thread_task_runner)
: … { … }
MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() =
default;
}
}