#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/services/heap_profiling/json_exporter.h"
#include <inttypes.h>
#include <map>
#include <unordered_map>
#include "base/containers/adapters.h"
#include "base/json/json_writer.h"
#include "base/json/string_escape.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/traced_value.h"
#include "base/values.h"
#include "services/resource_coordinator/public/cpp/memory_instrumentation/tracing_observer_traced_value.h"
namespace heap_profiling {
namespace {
StringTable;
AllocationToNodeId;
constexpr int kAllocatorCount = …;
struct BacktraceNode { … };
BacktraceTable;
constexpr int kUnknownTypeId = …;
const char* StringForAllocatorType(uint32_t type) { … }
base::Value::Dict BuildAllocatorsSummary(const AllocationMap& allocations) { … }
base::Value BuildMemoryMaps(const ExportParams& params) { … }
int AddOrGetString(const std::string& str,
StringTable* string_table,
ExportParams* params) { … }
void FillContextStrings(ExportParams* params,
StringTable* string_table,
std::map<int, int>* context_to_string_id_map) { … }
int AddOrGetBacktraceNode(BacktraceNode node,
BacktraceTable* backtrace_table,
ExportParams* params) { … }
int AppendBacktraceStrings(const AllocationSite& alloc,
BacktraceTable* backtrace_table,
StringTable* string_table,
ExportParams* params) { … }
base::Value::List BuildStrings(const StringTable& string_table) { … }
base::Value::List BuildMapNodes(const BacktraceTable& nodes) { … }
base::Value::List BuildTypeNodes(const std::map<int, int>& type_to_string) { … }
base::Value::Dict BuildAllocations(const AllocationMap& allocations,
const AllocationToNodeId& alloc_to_node_id) { … }
}
ExportParams::ExportParams() = default;
ExportParams::~ExportParams() = default;
std::string ExportMemoryMapsAndV2StackTraceToJSON(ExportParams* params) { … }
}