Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions llvm/docs/CommandGuide/llvm-objdump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ OPTIONS
debug information for stripped binaries. Multiple instances of this argument
are searched in the order given.

.. option:: --debuginfod, --no-debuginfod

Whether or not to try debuginfod lookups for debug binaries. Unless specified,
debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
and at least one server URL was provided by the environment variable
``DEBUGINFOD_URLS``.

.. option:: --debug-indent=<width>

Distance to indent the source-level variable or inlined function display,
Expand All @@ -155,15 +148,22 @@ OPTIONS
.. option:: --debug-inlined-funcs[=<format>]

Print the locations of inlined functions alongside disassembly.
``format`` may be ``unicode``, ``ascii`` or ``line``, defaulting to
``format`` may be ``ascii``, ``limits-only`` or ``unicode``, defaulting to
``unicode`` if omitted.

.. option:: --debug-vars[=<format>]

Print the locations (in registers or memory) of source-level variables
alongside disassembly. ``format`` may be ``unicode`` or ``ascii``, defaulting
alongside disassembly. ``format`` may be ``ascii`` or ``unicode``, defaulting
to ``unicode`` if omitted.

.. option:: --debuginfod, --no-debuginfod

Whether or not to try debuginfod lookups for debug binaries. Unless specified,
debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
and at least one server URL was provided by the environment variable
``DEBUGINFOD_URLS``.

.. option:: -j, --section=<section1[,section2,...]>

Perform commands on the specified sections only. For Mach-O use
Expand Down
8 changes: 4 additions & 4 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ Changes to the LLVM tools
* In llvm-objcopy/llvm-strip's ELF port, `--discard-locals` and `--discard-all` now allow and preserve symbols referenced by relocations.
([#47468](https://github.com/llvm/llvm-project/issues/47468))
* llvm-addr2line now supports a `+` prefix when specifying an address.
* llvm-objdump now supports the `--debug-inlined-funcs` flag that prints the
locations of inlined functions alongside disassembly. It also renames
`--debug-vars-indent` flag to `--debug-indent`.

* Support for `SHT_LLVM_BB_ADDR_MAP` versions 0 and 1 has been dropped.
* llvm-objdump now supports the `--debug-inlined-funcs` flag, which prints the
locations of inlined functions alongside disassembly. The
`--debug-vars-indent` flag has also been renamed to `--debug-indent`.

Changes to LLDB
---------------------------------
Expand Down

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions llvm/tools/llvm-objdump/ObjdumpOpts.td
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,22 @@ defm prefix_strip
"paths. No effect without --prefix">,
MetaVarName<"prefix">;

def debug_vars_EQ : Joined<["--"], "debug-vars=">,
HelpText<"Print the locations (in registers or memory) of "
"source-level variables alongside disassembly. "
"Supported formats: ascii, unicode (default)">,
Values<"unicode,ascii">;
def : Flag<["--"], "debug-vars">, Alias<debug_vars_EQ>, AliasArgs<["unicode"]>;
def debug_indent_EQ : Joined<["--"], "debug-indent=">,
HelpText<"Distance to indent the source-level variable and inlined function display, "
"relative to the start of the disassembly">;

def debug_inlined_funcs_EQ : Joined<["--"], "debug-inlined-funcs=">,
HelpText<"Print the locations of inlined functions alongside disassembly. "
"Supported formats: ascii, unicode (default) and line">,
"Supported formats: ascii, line and unicode (default)">,
Values<"unicode,ascii,line">;
def : Flag<["--"], "debug-inlined-funcs">, Alias<debug_inlined_funcs_EQ>, AliasArgs<["unicode"]>;

def debug_indent_EQ : Joined<["--"], "debug-indent=">,
HelpText<"Distance to indent the source-level variable display, "
"relative to the start of the disassembly">;
def debug_vars_EQ : Joined<["--"], "debug-vars=">,
HelpText<"Print the locations (in registers or memory) of "
"source-level variables alongside disassembly. "
"Supported formats: ascii, unicode (default)">,
Values<"unicode,ascii">;
def : Flag<["--"], "debug-vars">, Alias<debug_vars_EQ>, AliasArgs<["unicode"]>;

def x86_asm_syntax_att : Flag<["--"], "x86-asm-syntax=att">,
HelpText<"Emit AT&T-style disassembly">;
Expand Down
83 changes: 42 additions & 41 deletions llvm/tools/llvm-objdump/SourcePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
//
// This file implements the LiveVariablePrinter and SourcePrinter classes to
// This file implements the LiveElementPrinter and SourcePrinter classes to
// keep track of DWARF info as the current address is updated, and print out the
// source file line and variable or inlined function liveness as needed.
//
Expand All @@ -15,7 +15,8 @@
#include "SourcePrinter.h"
#include "llvm-objdump.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/Support/FormatVariadic.h"

Expand All @@ -24,7 +25,7 @@
namespace llvm {
namespace objdump {

bool InlinedFunction::liveAtAddress(object::SectionedAddress Addr) {
bool InlinedFunction::liveAtAddress(object::SectionedAddress Addr) const {
if (!Range.valid())
return false;

Expand Down Expand Up @@ -87,7 +88,7 @@ void InlinedFunction::printElementLine(raw_ostream &OS,
OS << CalleeName << " inlined into " << CallerName << "\n";
}

bool LiveVariable::liveAtAddress(object::SectionedAddress Addr) {
bool LiveVariable::liveAtAddress(object::SectionedAddress Addr) const {
if (LocExpr.Range == std::nullopt)
return false;
return LocExpr.Range->SectionIndex == Addr.SectionIndex &&
Expand Down Expand Up @@ -116,8 +117,8 @@ void LiveVariable::dump(raw_ostream &OS) const {
OS << Name << " @ " << LocExpr.Range << ": ";
}

void LiveVariablePrinter::addInlinedFunction(DWARFDie FuncDie,
DWARFDie InlinedFuncDie) {
void LiveElementPrinter::addInlinedFunction(DWARFDie FuncDie,
DWARFDie InlinedFuncDie) {
uint64_t FuncLowPC, FuncHighPC, SectionIndex;
if (!InlinedFuncDie.getLowAndHighPC(FuncLowPC, FuncHighPC, SectionIndex))
return;
Expand All @@ -129,7 +130,7 @@ void LiveVariablePrinter::addInlinedFunction(DWARFDie FuncDie,
InlinedFuncName, U, FuncDie, InlinedFuncDie, Range));
}

void LiveVariablePrinter::addVariable(DWARFDie FuncDie, DWARFDie VarDie) {
void LiveElementPrinter::addVariable(DWARFDie FuncDie, DWARFDie VarDie) {
uint64_t FuncLowPC, FuncHighPC, SectionIndex;
FuncDie.getLowAndHighPC(FuncLowPC, FuncHighPC, SectionIndex);
const char *VarName = VarDie.getName(DINameKind::ShortName);
Expand Down Expand Up @@ -162,14 +163,14 @@ void LiveVariablePrinter::addVariable(DWARFDie FuncDie, DWARFDie VarDie) {
}
}

void LiveVariablePrinter::addFunction(DWARFDie D) {
void LiveElementPrinter::addFunction(DWARFDie D) {
for (const DWARFDie &Child : D.children()) {
if (DbgVariables != DVDisabled &&
if (DbgVariables != DFDisabled &&
(Child.getTag() == dwarf::DW_TAG_variable ||
Child.getTag() == dwarf::DW_TAG_formal_parameter))
Child.getTag() == dwarf::DW_TAG_formal_parameter)) {
addVariable(D, Child);
else if (DbgInlinedFunctions != DVDisabled &&
Child.getTag() == dwarf::DW_TAG_inlined_subroutine) {
} else if (DbgInlinedFunctions != DFDisabled &&
Child.getTag() == dwarf::DW_TAG_inlined_subroutine) {
addInlinedFunction(D, Child);
addFunction(Child);
} else
Expand All @@ -179,7 +180,7 @@ void LiveVariablePrinter::addFunction(DWARFDie D) {

// Get the column number (in characters) at which the first live element
// line should be printed.
unsigned LiveVariablePrinter::getIndentLevel() const {
unsigned LiveElementPrinter::getIndentLevel() const {
return DbgIndent + getInstStartColumn(STI);
}

Expand All @@ -188,7 +189,7 @@ unsigned LiveVariablePrinter::getIndentLevel() const {
// 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 element lines. Pick a less overloaded word.
unsigned LiveVariablePrinter::moveToFirstVarColumn(formatted_raw_ostream &OS) {
unsigned LiveElementPrinter::moveToFirstVarColumn(formatted_raw_ostream &OS) {
// Logical column number: column zero is the first column we print in, each
// logical column is 2 physical columns wide.
unsigned FirstUnprintedLogicalColumn =
Expand All @@ -204,7 +205,7 @@ unsigned LiveVariablePrinter::moveToFirstVarColumn(formatted_raw_ostream &OS) {
return FirstUnprintedLogicalColumn;
}

unsigned LiveVariablePrinter::findFreeColumn() {
unsigned LiveElementPrinter::findFreeColumn() {
for (unsigned ColIdx = 0; ColIdx < ActiveCols.size(); ++ColIdx)
if (!ActiveCols[ColIdx].isActive())
return ColIdx;
Expand All @@ -214,15 +215,15 @@ unsigned LiveVariablePrinter::findFreeColumn() {
return OldSize;
}

void LiveVariablePrinter::dump() const {
void LiveElementPrinter::dump() const {
for (const std::unique_ptr<LiveElement> &LE : LiveElements) {
LE->dump(dbgs());
LE->print(dbgs(), MRI);
dbgs() << "\n";
}
}

void LiveVariablePrinter::addCompileUnit(DWARFDie D) {
void LiveElementPrinter::addCompileUnit(DWARFDie D) {
if (D.getTag() == dwarf::DW_TAG_subprogram)
addFunction(D);
else
Expand All @@ -235,12 +236,12 @@ void LiveVariablePrinter::addCompileUnit(DWARFDie D) {
/// 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) {
void LiveElementPrinter::update(object::SectionedAddress ThisAddr,
object::SectionedAddress NextAddr,
bool IncludeDefinedVars) {
// Do not create live ranges when debug-inlined-funcs option is provided with
// line format option.
if (DbgInlinedFunctions == DVLine)
if (DbgInlinedFunctions == DFLimitsOnly)
return;

// First, check variables which have already been assigned a column, so
Expand Down Expand Up @@ -302,8 +303,8 @@ enum class LineChar {
LabelCornerActive,
LabelHoriz,
};
const char *LiveVariablePrinter::getLineChar(LineChar C) const {
bool IsASCII = DbgVariables == DVASCII || DbgInlinedFunctions == DVASCII;
const char *LiveElementPrinter::getLineChar(LineChar C) const {
bool IsASCII = DbgVariables == DFASCII || DbgInlinedFunctions == DFASCII;
switch (C) {
case LineChar::RangeStart:
return IsASCII ? "^" : (const char *)u8"\u2548";
Expand All @@ -328,8 +329,8 @@ const char *LiveVariablePrinter::getLineChar(LineChar C) const {
/// 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) {
void LiveElementPrinter::printAfterOtherLine(formatted_raw_ostream &OS,
bool AfterInst) {
if (ActiveCols.size()) {
unsigned FirstUnprintedColumn = moveToFirstVarColumn(OS);
for (size_t ColIdx = FirstUnprintedColumn, End = ActiveCols.size();
Expand All @@ -356,8 +357,8 @@ void LiveVariablePrinter::printAfterOtherLine(formatted_raw_ostream &OS,
/// 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) {
void LiveElementPrinter::printBetweenInsts(formatted_raw_ostream &OS,
bool MustPrint) {
bool PrintedSomething = false;
for (unsigned ColIdx = 0, End = ActiveCols.size(); ColIdx < End; ++ColIdx) {
if (ActiveCols[ColIdx].isActive() && ActiveCols[ColIdx].MustDrawLabel) {
Expand Down Expand Up @@ -418,7 +419,7 @@ void LiveVariablePrinter::printBetweenInsts(formatted_raw_ostream &OS,
}

/// Print the live element ranges to the right of a disassembled instruction.
void LiveVariablePrinter::printAfterInst(formatted_raw_ostream &OS) {
void LiveElementPrinter::printAfterInst(formatted_raw_ostream &OS) {
if (!ActiveCols.size())
return;
unsigned FirstUnprintedColumn = moveToFirstVarColumn(OS);
Expand All @@ -437,20 +438,20 @@ void LiveVariablePrinter::printAfterInst(formatted_raw_ostream &OS) {
}
}

void LiveVariablePrinter::printStartLine(formatted_raw_ostream &OS,
object::SectionedAddress Addr) {
void LiveElementPrinter::printStartLine(formatted_raw_ostream &OS,
object::SectionedAddress Addr) {
// Print a line to idenfity the start of an inlined function if line format
// is specified.
if (DbgInlinedFunctions == DVLine)
if (DbgInlinedFunctions == DFLimitsOnly)
for (const std::unique_ptr<LiveElement> &LE : LiveElements)
LE->printElementLine(OS, Addr, false);
}

void LiveVariablePrinter::printEndLine(formatted_raw_ostream &OS,
object::SectionedAddress Addr) {
void LiveElementPrinter::printEndLine(formatted_raw_ostream &OS,
object::SectionedAddress Addr) {
// Print a line to idenfity the end of an inlined function if line format is
// specified.
if (DbgInlinedFunctions == DVLine)
if (DbgInlinedFunctions == DFLimitsOnly)
for (const std::unique_ptr<LiveElement> &LE : LiveElements)
LE->printElementLine(OS, Addr, true);
}
Expand Down Expand Up @@ -489,7 +490,7 @@ bool SourcePrinter::cacheSource(const DILineInfo &LineInfo) {
void SourcePrinter::printSourceLine(formatted_raw_ostream &OS,
object::SectionedAddress Address,
StringRef ObjectFilename,
LiveVariablePrinter &LVP,
LiveElementPrinter &LEP,
StringRef Delimiter) {
if (!Symbolizer)
return;
Expand Down Expand Up @@ -537,16 +538,16 @@ void SourcePrinter::printSourceLine(formatted_raw_ostream &OS,
}

if (PrintLines)
printLines(OS, Address, LineInfo, Delimiter, LVP);
printLines(OS, Address, LineInfo, Delimiter, LEP);
if (PrintSource)
printSources(OS, LineInfo, ObjectFilename, Delimiter, LVP);
printSources(OS, LineInfo, ObjectFilename, Delimiter, LEP);
OldLineInfo = LineInfo;
}

void SourcePrinter::printLines(formatted_raw_ostream &OS,
object::SectionedAddress Address,
const DILineInfo &LineInfo, StringRef Delimiter,
LiveVariablePrinter &LVP) {
LiveElementPrinter &LEP) {
bool PrintFunctionName = LineInfo.FunctionName != DILineInfo::BadString &&
LineInfo.FunctionName != OldLineInfo.FunctionName;
if (PrintFunctionName) {
Expand All @@ -561,7 +562,7 @@ void SourcePrinter::printLines(formatted_raw_ostream &OS,
(OldLineInfo.Line != LineInfo.Line ||
OldLineInfo.FileName != LineInfo.FileName || PrintFunctionName)) {
OS << Delimiter << LineInfo.FileName << ":" << LineInfo.Line;
LVP.printBetweenInsts(OS, true);
LEP.printBetweenInsts(OS, true);
}
}

Expand Down Expand Up @@ -596,7 +597,7 @@ StringRef SourcePrinter::getLine(const DILineInfo &LineInfo,
void SourcePrinter::printSources(formatted_raw_ostream &OS,
const DILineInfo &LineInfo,
StringRef ObjectFilename, StringRef Delimiter,
LiveVariablePrinter &LVP) {
LiveElementPrinter &LEP) {
if (LineInfo.FileName == DILineInfo::BadString || LineInfo.Line == 0 ||
(OldLineInfo.Line == LineInfo.Line &&
OldLineInfo.FileName == LineInfo.FileName))
Expand All @@ -605,7 +606,7 @@ void SourcePrinter::printSources(formatted_raw_ostream &OS,
StringRef Line = getLine(LineInfo, ObjectFilename);
if (!Line.empty()) {
OS << Delimiter << Line;
LVP.printBetweenInsts(OS, true);
LEP.printBetweenInsts(OS, true);
}
}

Expand Down
Loading
Loading