Skip to content

Commit cbf781f

Browse files
[NFC][DebugInfo][DWARF] Create new low-level dwarf library (#145081)
This is the culmination of a series of changes described in [1]. Although somewhat large by line count, it is almost entirely mechanical, creating a new library in DebugInfo/DWARF/LowLevel. This new library has very minimal dependencies, allowing it to be used from more places than the normal DebugInfo/DWARF library--in particular from MC. I am happy to put it in another location, or to structure it differently if that makes sense. Some have suggested in BinaryFormat, but it is not a great fit there. But if that makes more sense to the reviewers, I can do that. Another possibility would be to use pass-through headers to allow clients who don't care to depend only on DebugInfo/DWARF. This would be a much less invasive change, and perhaps easier for clients. But also a system that hides details. Either way, I'm open. 1. https://discourse.llvm.org/t/rfc-debuginfo-dwarf-refactor-into-to-lower-and-higher-level-libraries/86665/2
1 parent f2991bf commit cbf781f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+889
-800
lines changed

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "llvm/CodeGen/DIE.h"
2121
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
2222
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
23-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
2423
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
24+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
2525
#include "llvm/Support/Allocator.h"
2626

2727
#include <list>

bolt/lib/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(LLVM_LINK_COMPONENTS
22
DebugInfoDWARF
3+
DebugInfoDWARFLowLevel
34
Demangle
45
MC
56
MCDisassembler

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
#include "llvm/CodeGen/DIE.h"
1515
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
1616
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
17-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
1817
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
1918
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
2019
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
2120
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
21+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
2222
#include "llvm/Support/Casting.h"
2323
#include "llvm/Support/Debug.h"
2424
#include "llvm/Support/ErrorHandling.h"

bolt/lib/Core/DebugNames.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "bolt/Core/DebugNames.h"
1010
#include "bolt/Core/BinaryContext.h"
11-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
1211
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
12+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
1313
#include "llvm/Support/EndianStream.h"
1414
#include "llvm/Support/LEB128.h"
1515
#include <cstdint>

bolt/lib/Rewrite/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(LLVM_LINK_COMPONENTS
22
Core
33
DebugInfoDWARF
4+
DebugInfoDWARFLowLevel
45
JITLink
56
MC
67
Object

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
2525
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
2626
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
27-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
2827
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
2928
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
3029
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
30+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
3131
#include "llvm/MC/MCAsmBackend.h"
3232
#include "llvm/MC/MCAssembler.h"
3333
#include "llvm/MC/MCObjectWriter.h"

lldb/source/Expression/DWARFExpression.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
#include "lldb/Target/StackID.h"
3737
#include "lldb/Target/Target.h"
3838
#include "lldb/Target/Thread.h"
39-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
39+
#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
40+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
4041

4142
using namespace lldb;
4243
using namespace lldb_private;
@@ -81,7 +82,7 @@ void DWARFExpression::DumpLocation(Stream *s, lldb::DescriptionLevel level,
8182
llvm::DIDumpOptions DumpOpts;
8283
DumpOpts.GetNameForDWARFReg = GetRegName;
8384
llvm::DWARFExpression E(m_data.GetAsLLVM(), m_data.GetAddressByteSize());
84-
llvm::DWARFExpressionPrinter::print(&E, s->AsRawOstream(), DumpOpts, nullptr);
85+
llvm::printDwarfExpression(&E, s->AsRawOstream(), DumpOpts, nullptr);
8586
}
8687

8788
RegisterKind DWARFExpression::GetRegisterKind() const { return m_reg_kind; }

lldb/source/Symbol/UnwindPlan.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#include "lldb/Utility/Log.h"
1818
#include "llvm/ADT/STLExtras.h"
1919
#include "llvm/DebugInfo/DIContext.h"
20-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
20+
#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
21+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
2122
#include <optional>
2223

2324
using namespace lldb;
@@ -89,8 +90,7 @@ static void DumpDWARFExpr(Stream &s, llvm::ArrayRef<uint8_t> expr, Thread *threa
8990
order_and_width->second);
9091
llvm::DWARFExpression E(data, order_and_width->second,
9192
llvm::dwarf::DWARF32);
92-
llvm::DWARFExpressionPrinter::print(&E, s.AsRawOstream(),
93-
llvm::DIDumpOptions(), nullptr);
93+
printDwarfExpression(&E, s.AsRawOstream(), llvm::DIDumpOptions(), nullptr);
9494
} else
9595
s.PutCString("dwarf-expr");
9696
}

lldb/unittests/Symbol/PostfixExpressionTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#include "lldb/Utility/StreamString.h"
1212
#include "llvm/ADT/StringExtras.h"
1313
#include "llvm/DebugInfo/DIContext.h"
14-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
14+
#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
15+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
1516
#include "llvm/Support/FormatVariadic.h"
1617
#include "llvm/Support/raw_ostream.h"
1718
#include "gmock/gmock.h"
@@ -160,7 +161,7 @@ static std::string ParseAndGenerateDWARF(llvm::StringRef expr) {
160161
std::string result;
161162
llvm::raw_string_ostream os(result);
162163
llvm::DWARFExpression E(extractor, addr_size, llvm::dwarf::DWARF32);
163-
llvm::DWARFExpressionPrinter::print(&E, os, llvm::DIDumpOptions(), nullptr);
164+
llvm::printDwarfExpression(&E, os, llvm::DIDumpOptions(), nullptr);
164165
return result;
165166
}
166167

lldb/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include "lldb/Utility/StreamBuffer.h"
1717
#include "lldb/Utility/StreamString.h"
1818
#include "llvm/DebugInfo/DIContext.h"
19-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
19+
#include "llvm/DebugInfo/DWARF/DWARFExpressionPrinter.h"
20+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
2021

2122
using namespace lldb;
2223
using namespace lldb_private;
@@ -40,7 +41,7 @@ CheckValidProgramTranslation(llvm::StringRef fpo_program,
4041
std::string result;
4142
llvm::raw_string_ostream os(result);
4243
llvm::DWARFExpression E(extractor, /*AddressSize=*/4, llvm::dwarf::DWARF32);
43-
llvm::DWARFExpressionPrinter::print(&E, os, llvm::DIDumpOptions(), nullptr);
44+
llvm::printDwarfExpression(&E, os, llvm::DIDumpOptions(), nullptr);
4445

4546
// actual check
4647
ASSERT_EQ(expected_dwarf_expression, result);

0 commit comments

Comments
 (0)