//===-- SourcePrinter.cpp - source interleaving utilities ----------------===// // // 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 // //===----------------------------------------------------------------------===// // // This file implements the LiveVariablePrinter and SourcePrinter classes to // keep track of DWARF info as the current address is updated, and print out the // source file line and variable liveness as needed. // //===----------------------------------------------------------------------===// #include "SourcePrinter.h" #include "llvm-objdump.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringSet.h" #include "llvm/DebugInfo/DWARF/DWARFExpression.h" #include "llvm/DebugInfo/Symbolize/SymbolizableModule.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/FormatVariadic.h" #define DEBUG_TYPE … namespace llvm { namespace objdump { bool LiveVariable::liveAtAddress(object::SectionedAddress Addr) { … } void LiveVariable::print(raw_ostream &OS, const MCRegisterInfo &MRI) const { … } void LiveVariablePrinter::addVariable(DWARFDie FuncDie, DWARFDie VarDie) { … } void LiveVariablePrinter::addFunction(DWARFDie D) { … } // Get the column number (in characters) at which the first live variable // line should be printed. unsigned LiveVariablePrinter::getIndentLevel() const { … } // Indent to the first live-range column to the right of the currently // printed line, and return the index of that column. // TODO: formatted_raw_ostream uses "column" to mean a number of characters // since the last \n, and we use it to mean the number of slots in which we // put live variable lines. Pick a less overloaded word. unsigned LiveVariablePrinter::moveToFirstVarColumn(formatted_raw_ostream &OS) { … } unsigned LiveVariablePrinter::findFreeColumn() { … } void LiveVariablePrinter::dump() const { … } void LiveVariablePrinter::addCompileUnit(DWARFDie D) { … } /// Update to match the state of the instruction between ThisAddr and /// NextAddr. In the common case, any live range active at ThisAddr is /// live-in to the instruction, and any live range active at NextAddr is /// live-out of the instruction. If IncludeDefinedVars is false, then live /// ranges starting at NextAddr will be ignored. void LiveVariablePrinter::update(object::SectionedAddress ThisAddr, object::SectionedAddress NextAddr, bool IncludeDefinedVars) { … } enum class LineChar { … }; const char *LiveVariablePrinter::getLineChar(LineChar C) const { … } /// Print live ranges to the right of an existing line. This assumes the /// line is not an instruction, so doesn't start or end any live ranges, so /// we only need to print active ranges or empty columns. If AfterInst is /// true, this is being printed after the last instruction fed to update(), /// otherwise this is being printed before it. void LiveVariablePrinter::printAfterOtherLine(formatted_raw_ostream &OS, bool AfterInst) { … } /// Print any live variable range info needed to the right of a /// non-instruction line of disassembly. This is where we print the variable /// names and expressions, with thin line-drawing characters connecting them /// to the live range which starts at the next instruction. If MustPrint is /// true, we have to print at least one line (with the continuation of any /// already-active live ranges) because something has already been printed /// earlier on this line. void LiveVariablePrinter::printBetweenInsts(formatted_raw_ostream &OS, bool MustPrint) { … } /// Print the live variable ranges to the right of a disassembled instruction. void LiveVariablePrinter::printAfterInst(formatted_raw_ostream &OS) { … } bool SourcePrinter::cacheSource(const DILineInfo &LineInfo) { … } void SourcePrinter::printSourceLine(formatted_raw_ostream &OS, object::SectionedAddress Address, StringRef ObjectFilename, LiveVariablePrinter &LVP, StringRef Delimiter) { … } void SourcePrinter::printLines(formatted_raw_ostream &OS, const DILineInfo &LineInfo, StringRef Delimiter, LiveVariablePrinter &LVP) { … } // Get the source line text for LineInfo: // - use LineInfo::LineSource if available; // - use LineCache if LineInfo::Source otherwise. StringRef SourcePrinter::getLine(const DILineInfo &LineInfo, StringRef ObjectFilename) { … } void SourcePrinter::printSources(formatted_raw_ostream &OS, const DILineInfo &LineInfo, StringRef ObjectFilename, StringRef Delimiter, LiveVariablePrinter &LVP) { … } SourcePrinter::SourcePrinter(const object::ObjectFile *Obj, StringRef DefaultArch) : … { … } } // namespace objdump } // namespace llvm