Skip to content

Commit f083691

Browse files
Address comments
1 parent 4dc5309 commit f083691

File tree

5 files changed

+28
-42
lines changed

5 files changed

+28
-42
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,9 @@ struct DIDumpOptions;
1717

1818
namespace dwarf {
1919

20-
// This class is separate from CFIProgram to decouple CFIPrograms from the
21-
// enclosing DWARF dies and type units, which allows using them in lower-level
22-
// places without build dependencies.
23-
24-
class CFIPrinter {
25-
public:
26-
static void print(const CFIProgram &P, raw_ostream &OS,
27-
DIDumpOptions &DumpOpts, unsigned IndentLevel,
28-
std::optional<uint64_t> Address);
29-
30-
static void printOperand(raw_ostream &OS, DIDumpOptions &DumpOpts,
31-
const CFIProgram &P,
32-
const CFIProgram::Instruction &Instr,
33-
unsigned OperandIdx, uint64_t Operand,
34-
std::optional<uint64_t> &Address);
35-
};
20+
void printCFIProgram(const CFIProgram &P, raw_ostream &OS,
21+
const DIDumpOptions &DumpOpts, unsigned IndentLevel,
22+
std::optional<uint64_t> Address);
3623

3724
} // end namespace dwarf
3825

llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ namespace llvm {
2525

2626
namespace dwarf {
2727

28-
class CFIPrinter;
29-
3028
/// Represent a sequence of Call Frame Information instructions that, when read
3129
/// in order, construct a table mapping PC to frame state. This can also be
3230
/// referred to as "CFI rules" in DWARF literature to avoid confusion with

llvm/lib/DebugInfo/DWARF/DWARFCFIPrinter.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,7 @@
2424
using namespace llvm;
2525
using namespace dwarf;
2626

27-
void CFIPrinter::print(const CFIProgram &P, raw_ostream &OS,
28-
DIDumpOptions &DumpOpts, unsigned IndentLevel,
29-
std::optional<uint64_t> Address) {
30-
for (const auto &Instr : P) {
31-
uint8_t Opcode = Instr.Opcode;
32-
OS.indent(2 * IndentLevel);
33-
OS << P.callFrameString(Opcode) << ":";
34-
for (size_t i = 0; i < Instr.Ops.size(); ++i)
35-
printOperand(OS, DumpOpts, P, Instr, i, Instr.Ops[i], Address);
36-
OS << '\n';
37-
}
38-
}
39-
40-
static void printRegister(raw_ostream &OS, DIDumpOptions &DumpOpts,
27+
static void printRegister(raw_ostream &OS, const DIDumpOptions &DumpOpts,
4128
unsigned RegNum) {
4229
if (DumpOpts.GetNameForDWARFReg) {
4330
auto RegName = DumpOpts.GetNameForDWARFReg(RegNum, DumpOpts.IsEH);
@@ -50,11 +37,11 @@ static void printRegister(raw_ostream &OS, DIDumpOptions &DumpOpts,
5037
}
5138

5239
/// Print \p Opcode's operand number \p OperandIdx which has value \p Operand.
53-
void CFIPrinter::printOperand(raw_ostream &OS, DIDumpOptions &DumpOpts,
54-
const CFIProgram &P,
55-
const CFIProgram::Instruction &Instr,
56-
unsigned OperandIdx, uint64_t Operand,
57-
std::optional<uint64_t> &Address) {
40+
static void printOperand(raw_ostream &OS, const DIDumpOptions &DumpOpts,
41+
const CFIProgram &P,
42+
const CFIProgram::Instruction &Instr,
43+
unsigned OperandIdx, uint64_t Operand,
44+
std::optional<uint64_t> &Address) {
5845
assert(OperandIdx < CFIProgram::MaxOperands);
5946
uint8_t Opcode = Instr.Opcode;
6047
CFIProgram::OperandType Type = P.getOperandTypes()[Opcode][OperandIdx];
@@ -118,3 +105,17 @@ void CFIPrinter::printOperand(raw_ostream &OS, DIDumpOptions &DumpOpts,
118105
break;
119106
}
120107
}
108+
109+
void llvm::dwarf::printCFIProgram(const CFIProgram &P, raw_ostream &OS,
110+
const DIDumpOptions &DumpOpts,
111+
unsigned IndentLevel,
112+
std::optional<uint64_t> Address) {
113+
for (const auto &Instr : P) {
114+
uint8_t Opcode = Instr.Opcode;
115+
OS.indent(2 * IndentLevel);
116+
OS << P.callFrameString(Opcode) << ":";
117+
for (size_t i = 0; i < Instr.Ops.size(); ++i)
118+
printOperand(OS, DumpOpts, P, Instr, i, Instr.Ops[i], Address);
119+
OS << '\n';
120+
}
121+
}

llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,8 @@ void CIE::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
603603
OS << "\n";
604604
}
605605
OS << "\n";
606-
CFIPrinter::print(CFIs, OS, DumpOpts, /*IndentLevel=*/1,
607-
/*InitialLocation=*/{});
606+
printCFIProgram(CFIs, OS, DumpOpts, /*IndentLevel=*/1,
607+
/*InitialLocation=*/{});
608608
OS << "\n";
609609

610610
if (Expected<UnwindTable> RowsOrErr = UnwindTable::create(this))
@@ -632,7 +632,7 @@ void FDE::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
632632
OS << " Format: " << FormatString(IsDWARF64) << "\n";
633633
if (LSDAAddress)
634634
OS << format(" LSDA Address: %016" PRIx64 "\n", *LSDAAddress);
635-
CFIPrinter::print(CFIs, OS, DumpOpts, /*IndentLevel=*/1, InitialLocation);
635+
printCFIProgram(CFIs, OS, DumpOpts, /*IndentLevel=*/1, InitialLocation);
636636
OS << "\n";
637637

638638
if (Expected<UnwindTable> RowsOrErr = UnwindTable::create(this))

llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ void PrinterContext<ELFT>::printEHFrame(const Elf_Shdr *EHFrameShdr) const {
229229
W.indent();
230230
auto DumpOpts = DIDumpOptions();
231231
DumpOpts.IsEH = true;
232-
dwarf::CFIPrinter::print(Entry.cfis(), W.getOStream(), DumpOpts,
233-
W.getIndentLevel(), InitialLocation);
232+
printCFIProgram(Entry.cfis(), W.getOStream(), DumpOpts, W.getIndentLevel(),
233+
InitialLocation);
234234
W.unindent();
235235
W.unindent();
236236
W.getOStream() << "\n";

0 commit comments

Comments
 (0)