blob: 7658eb101a8a25b7150152febe46e182817714d7 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <iostream>
#include <sstream>
#include <string>
#include "src/developer/memory/metrics/capture.h"
#include "src/developer/memory/metrics/digest.h"
#include "src/developer/memory/metrics/summary.h"
#include "src/lib/fxl/macros.h"
namespace memory {
extern const size_t kMaxFormattedStringSize;
const char* FormatSize(uint64_t size, char* buffer);
enum Sorted { UNSORTED, SORTED };
class Printer {
explicit Printer(std::ostream& os) : os_(os) {}
/* Outputs capture as JSON. In this format:
[47325,"",[47353, ...]],
"VmoNames":["scudo:primary", ...],
For size reasons:
- Processes and Vmos have an initial entry that contains the names of the the fields in the
rest of the entries.
- The names of the VMOs are an index into the VMONames array.
void PrintCapture(const Capture& capture);
void PrintSummary(const Summary& summary, CaptureLevel level, Sorted sorted);
void PrintDigest(const Digest& digest);
void OutputSummary(const Summary& summary, Sorted sorted, zx_koid_t pid);
void OutputDigest(const Digest& digest);
void OutputSizes(const Sizes& sizes);
std::ostream& os_;
} // namespace memory