llvm/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp

//===-- lib/DebugInfo/Symbolize/MarkupFilter.cpp -------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file defines the implementation of a filter that replaces symbolizer
/// markup with human-readable expressions.
///
/// See https://llvm.org/docs/SymbolizerMarkupFormat.html
///
//===----------------------------------------------------------------------===//

#include "llvm/DebugInfo/Symbolize/MarkupFilter.h"

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/Symbolize/Markup.h"
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
#include "llvm/Debuginfod/Debuginfod.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

usingnamespacellvm;
usingnamespacellvm::symbolize;

MarkupFilter::MarkupFilter(raw_ostream &OS, LLVMSymbolizer &Symbolizer,
                           std::optional<bool> ColorsEnabled)
    :{}

void MarkupFilter::filter(std::string &&InputLine) {}

void MarkupFilter::finish() {}

// See if the given node is a contextual element and handle it if so. This may
// either output or defer the element; in the former case, it will first emit
// any DeferredNodes.
//
// Returns true if the given element was a contextual element. In this case,
// DeferredNodes should be considered handled and should not be emitted. The
// rest of the containing line must also be ignored in case the element was
// deferred to a following line.
bool MarkupFilter::tryContextualElement(
    const MarkupNode &Node, const SmallVector<MarkupNode> &DeferredNodes) {}

bool MarkupFilter::tryMMap(const MarkupNode &Node,
                           const SmallVector<MarkupNode> &DeferredNodes) {}

bool MarkupFilter::tryReset(const MarkupNode &Node,
                            const SmallVector<MarkupNode> &DeferredNodes) {}

bool MarkupFilter::tryModule(const MarkupNode &Node,
                             const SmallVector<MarkupNode> &DeferredNodes) {}

void MarkupFilter::beginModuleInfoLine(const Module *M) {}

void MarkupFilter::endAnyModuleInfoLine() {}

// Handle a node that is known not to be a contextual element.
void MarkupFilter::filterNode(const MarkupNode &Node) {}

bool MarkupFilter::tryPresentation(const MarkupNode &Node) {}

bool MarkupFilter::trySymbol(const MarkupNode &Node) {}

bool MarkupFilter::tryPC(const MarkupNode &Node) {}

bool MarkupFilter::tryBackTrace(const MarkupNode &Node) {}

bool MarkupFilter::tryData(const MarkupNode &Node) {}

bool MarkupFilter::trySGR(const MarkupNode &Node) {}

// Begin highlighting text by picking a different color than the current color
// state.
void MarkupFilter::highlight() {}

// Begin highlighting a field within a highlighted markup string.
void MarkupFilter::highlightValue() {}

// Set the output stream's color to the current color and bold state of the SGR
// abstract machine.
void MarkupFilter::restoreColor() {}

// Set the SGR and output stream's color and bold states back to the default.
void MarkupFilter::resetColor() {}

void MarkupFilter::printRawElement(const MarkupNode &Element) {}

void MarkupFilter::printValue(Twine Value) {}

// This macro helps reduce the amount of indirection done through Optional
// below, since the usual case upon returning a std::nullopt Optional is to
// return std::nullopt.
#define ASSIGN_OR_RETURN_NONE(TYPE, NAME, EXPR)

std::optional<MarkupFilter::Module>
MarkupFilter::parseModule(const MarkupNode &Element) const {}

std::optional<MarkupFilter::MMap>
MarkupFilter::parseMMap(const MarkupNode &Element) const {}

// Parse an address (%p in the spec).
std::optional<uint64_t> MarkupFilter::parseAddr(StringRef Str) const {}

// Parse a module ID (%i in the spec).
std::optional<uint64_t> MarkupFilter::parseModuleID(StringRef Str) const {}

// Parse a size (%i in the spec).
std::optional<uint64_t> MarkupFilter::parseSize(StringRef Str) const {}

// Parse a frame number (%i in the spec).
std::optional<uint64_t> MarkupFilter::parseFrameNumber(StringRef Str) const {}

// Parse a build ID (%x in the spec).
object::BuildID MarkupFilter::parseBuildID(StringRef Str) const {}

// Parses the mode string for an mmap element.
std::optional<std::string> MarkupFilter::parseMode(StringRef Str) const {}

std::optional<MarkupFilter::PCType>
MarkupFilter::parsePCType(StringRef Str) const {}

bool MarkupFilter::checkTag(const MarkupNode &Node) const {}

bool MarkupFilter::checkNumFields(const MarkupNode &Element,
                                  size_t Size) const {}

bool MarkupFilter::checkNumFieldsAtLeast(const MarkupNode &Element,
                                         size_t Size) const {}

void MarkupFilter::warnNumFieldsAtMost(const MarkupNode &Element,
                                       size_t Size) const {}

void MarkupFilter::reportTypeError(StringRef Str, StringRef TypeName) const {}

// Prints two lines that point out the given location in the current Line using
// a caret. The iterator must be within the bounds of the most recent line
// passed to beginLine().
void MarkupFilter::reportLocation(StringRef::iterator Loc) const {}

// Checks for an existing mmap that overlaps the given one and returns a
// pointer to one of them.
const MarkupFilter::MMap *
MarkupFilter::getOverlappingMMap(const MMap &Map) const {}

// Returns the MMap that contains the given address or nullptr if none.
const MarkupFilter::MMap *MarkupFilter::getContainingMMap(uint64_t Addr) const {}

uint64_t MarkupFilter::adjustAddr(uint64_t Addr, PCType Type) const {}

StringRef MarkupFilter::lineEnding() const {}

bool MarkupFilter::MMap::contains(uint64_t Addr) const {}

// Returns the module-relative address for a given virtual address.
uint64_t MarkupFilter::MMap::getModuleRelativeAddr(uint64_t Addr) const {}