Path: blob/main/contrib/llvm-project/llvm/lib/XRay/BlockPrinter.cpp
35234 views
//===- BlockPrinter.cpp - FDR Block Pretty Printer Implementation --------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7#include "llvm/XRay/BlockPrinter.h"89namespace llvm {10namespace xray {1112Error BlockPrinter::visit(BufferExtents &R) {13OS << "\n[New Block]\n";14CurrentState = State::Preamble;15return RP.visit(R);16}1718// Preamble printing.19Error BlockPrinter::visit(NewBufferRecord &R) {20if (CurrentState == State::Start)21OS << "\n[New Block]\n";2223OS << "Preamble: \n";24CurrentState = State::Preamble;25return RP.visit(R);26}2728Error BlockPrinter::visit(WallclockRecord &R) {29CurrentState = State::Preamble;30return RP.visit(R);31}3233Error BlockPrinter::visit(PIDRecord &R) {34CurrentState = State::Preamble;35return RP.visit(R);36}3738// Metadata printing.39Error BlockPrinter::visit(NewCPUIDRecord &R) {40if (CurrentState == State::Preamble)41OS << "\nBody:\n";42if (CurrentState == State::Function)43OS << "\nMetadata: ";44CurrentState = State::Metadata;45OS << " ";46auto E = RP.visit(R);47return E;48}4950Error BlockPrinter::visit(TSCWrapRecord &R) {51if (CurrentState == State::Function)52OS << "\nMetadata:";53CurrentState = State::Metadata;54OS << " ";55auto E = RP.visit(R);56return E;57}5859// Custom events will be rendered like "function" events.60Error BlockPrinter::visit(CustomEventRecord &R) {61if (CurrentState == State::Metadata)62OS << "\n";63CurrentState = State::CustomEvent;64OS << "* ";65auto E = RP.visit(R);66return E;67}6869Error BlockPrinter::visit(CustomEventRecordV5 &R) {70if (CurrentState == State::Metadata)71OS << "\n";72CurrentState = State::CustomEvent;73OS << "* ";74auto E = RP.visit(R);75return E;76}7778Error BlockPrinter::visit(TypedEventRecord &R) {79if (CurrentState == State::Metadata)80OS << "\n";81CurrentState = State::CustomEvent;82OS << "* ";83auto E = RP.visit(R);84return E;85}8687// Function call printing.88Error BlockPrinter::visit(FunctionRecord &R) {89if (CurrentState == State::Metadata)90OS << "\n";91CurrentState = State::Function;92OS << "- ";93auto E = RP.visit(R);94return E;95}9697Error BlockPrinter::visit(CallArgRecord &R) {98CurrentState = State::Arg;99OS << " : ";100auto E = RP.visit(R);101return E;102}103104Error BlockPrinter::visit(EndBufferRecord &R) {105CurrentState = State::End;106OS << " *** ";107auto E = RP.visit(R);108return E;109}110111} // namespace xray112} // namespace llvm113114115