2015-06-27 01:56:53 +02:00
|
|
|
//===-------- StackMapPrinter.h - Pretty-print stackmaps --------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TOOLS_LLVM_READOBJ_STACKMAPPRINTER_H
|
|
|
|
#define LLVM_TOOLS_LLVM_READOBJ_STACKMAPPRINTER_H
|
|
|
|
|
|
|
|
#include "llvm/Object/StackMapParser.h"
|
2018-01-10 01:14:19 +01:00
|
|
|
#include "llvm/Support/ScopedPrinter.h"
|
2015-06-27 01:56:53 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
// Pretty print a stackmap to the given ostream.
|
2018-01-10 01:14:19 +01:00
|
|
|
template <typename StackMapParserT>
|
|
|
|
void prettyPrintStackMap(ScopedPrinter &W, const StackMapParserT &SMP) {
|
2015-06-27 01:56:53 +02:00
|
|
|
|
2018-01-10 01:14:19 +01:00
|
|
|
W.printNumber("LLVM StackMap Version", SMP.getVersion());
|
|
|
|
W.printNumber("Num Functions", SMP.getNumFunctions());
|
2015-06-27 01:56:53 +02:00
|
|
|
|
|
|
|
// Functions:
|
|
|
|
for (const auto &F : SMP.functions())
|
2018-01-10 01:14:19 +01:00
|
|
|
W.startLine() << " Function address: " << F.getFunctionAddress()
|
2016-09-14 22:22:03 +02:00
|
|
|
<< ", stack size: " << F.getStackSize()
|
2018-01-10 01:14:19 +01:00
|
|
|
<< ", callsite record count: " << F.getRecordCount() << "\n";
|
2015-06-27 01:56:53 +02:00
|
|
|
|
|
|
|
// Constants:
|
2018-01-10 01:14:19 +01:00
|
|
|
W.printNumber("Num Constants", SMP.getNumConstants());
|
2015-06-27 01:56:53 +02:00
|
|
|
unsigned ConstantIndex = 0;
|
|
|
|
for (const auto &C : SMP.constants())
|
2018-01-10 01:14:19 +01:00
|
|
|
W.startLine() << " #" << ++ConstantIndex << ": " << C.getValue() << "\n";
|
2015-06-27 01:56:53 +02:00
|
|
|
|
|
|
|
// Records:
|
2018-01-10 01:14:19 +01:00
|
|
|
W.printNumber("Num Records", SMP.getNumRecords());
|
2015-06-27 01:56:53 +02:00
|
|
|
for (const auto &R : SMP.records()) {
|
2018-01-10 01:14:19 +01:00
|
|
|
W.startLine() << " Record ID: " << R.getID()
|
|
|
|
<< ", instruction offset: " << R.getInstructionOffset()
|
|
|
|
<< "\n";
|
|
|
|
W.startLine() << " " << R.getNumLocations() << " locations:\n";
|
2015-06-27 01:56:53 +02:00
|
|
|
|
|
|
|
unsigned LocationIndex = 0;
|
|
|
|
for (const auto &Loc : R.locations()) {
|
2018-01-10 01:14:19 +01:00
|
|
|
raw_ostream &OS = W.startLine();
|
|
|
|
OS << " #" << ++LocationIndex << ": ";
|
2015-06-27 01:56:53 +02:00
|
|
|
switch (Loc.getKind()) {
|
|
|
|
case StackMapParserT::LocationKind::Register:
|
2018-01-10 01:14:19 +01:00
|
|
|
OS << "Register R#" << Loc.getDwarfRegNum() << "\n";
|
2015-06-27 01:56:53 +02:00
|
|
|
break;
|
|
|
|
case StackMapParserT::LocationKind::Direct:
|
2018-01-10 01:14:19 +01:00
|
|
|
OS << "Direct R#" << Loc.getDwarfRegNum() << " + " << Loc.getOffset()
|
|
|
|
<< "\n";
|
2015-06-27 01:56:53 +02:00
|
|
|
break;
|
|
|
|
case StackMapParserT::LocationKind::Indirect:
|
2018-01-10 01:14:19 +01:00
|
|
|
OS << "Indirect [R#" << Loc.getDwarfRegNum() << " + " << Loc.getOffset()
|
|
|
|
<< "]\n";
|
2015-06-27 01:56:53 +02:00
|
|
|
break;
|
|
|
|
case StackMapParserT::LocationKind::Constant:
|
2018-01-10 01:14:19 +01:00
|
|
|
OS << "Constant " << Loc.getSmallConstant() << "\n";
|
2015-06-27 01:56:53 +02:00
|
|
|
break;
|
|
|
|
case StackMapParserT::LocationKind::ConstantIndex:
|
|
|
|
OS << "ConstantIndex #" << Loc.getConstantIndex() << " ("
|
2018-01-10 01:14:19 +01:00
|
|
|
<< SMP.getConstant(Loc.getConstantIndex()).getValue() << ")\n";
|
2015-06-27 01:56:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-10 01:14:19 +01:00
|
|
|
raw_ostream &OS = W.startLine();
|
|
|
|
OS << " " << R.getNumLiveOuts() << " live-outs: [ ";
|
2015-06-27 01:56:53 +02:00
|
|
|
for (const auto &LO : R.liveouts())
|
|
|
|
OS << "R#" << LO.getDwarfRegNum() << " ("
|
|
|
|
<< LO.getSizeInBytes() << "-bytes) ";
|
|
|
|
OS << "]\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|