1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[MC] Add --dwarf64 to generate DWARF64 debug info [1/7]

The patch adds an option `--dwarf64` to instruct a tool to generate
debug information in the 64-bit DWARF format. There is no real
implementation yet, only a few compatibility checks.

Differential Revision: https://reviews.llvm.org/D81143
This commit is contained in:
Igor Kudrin 2020-06-03 13:15:51 +07:00
parent 125618570c
commit 02872c9d70
8 changed files with 49 additions and 5 deletions

View File

@ -185,6 +185,9 @@ namespace llvm {
/// The maximum version of dwarf that we should emit.
uint16_t DwarfVersion = 4;
/// The format of dwarf that we emit.
dwarf::DwarfFormat DwarfFormat = dwarf::DWARF32;
/// Honor temporary labels, this is useful for debugging semantic
/// differences between temporary and non-temporary labels (primarily on
/// Darwin).
@ -694,10 +697,8 @@ namespace llvm {
void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
dwarf::DwarfFormat getDwarfFormat() const {
// TODO: Support DWARF64
return dwarf::DWARF32;
}
void setDwarfFormat(dwarf::DwarfFormat f) { DwarfFormat = f; }
dwarf::DwarfFormat getDwarfFormat() const { return DwarfFormat; }
void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
uint16_t getDwarfVersion() const { return DwarfVersion; }

View File

@ -53,6 +53,7 @@ public:
/// Preserve Comments in Assembly.
bool PreserveAsmComments : 1;
bool Dwarf64 : 1;
int DwarfVersion = 0;
std::string ABIName;

View File

@ -30,6 +30,8 @@ bool getIncrementalLinkerCompatible();
int getDwarfVersion();
bool getDwarf64();
bool getShowMCInst();
bool getFatalWarnings();

View File

@ -16,7 +16,7 @@ MCTargetOptions::MCTargetOptions()
MCNoWarn(false), MCNoDeprecatedWarn(false), MCSaveTempLabels(false),
MCUseDwarfDirectory(false), MCIncrementalLinkerCompatible(false),
ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false),
PreserveAsmComments(true) {}
PreserveAsmComments(true), Dwarf64(false) {}
StringRef MCTargetOptions::getABIName() const {
return ABIName;

View File

@ -38,6 +38,7 @@ using namespace llvm;
MCOPT_EXP(bool, RelaxAll)
MCOPT(bool, IncrementalLinkerCompatible)
MCOPT(int, DwarfVersion)
MCOPT(bool, Dwarf64)
MCOPT(bool, ShowMCInst)
MCOPT(bool, FatalWarnings)
MCOPT(bool, NoWarn)
@ -66,6 +67,11 @@ llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
cl::init(0));
MCBINDOPT(DwarfVersion);
static cl::opt<bool> Dwarf64(
"dwarf64",
cl::desc("Generate debugging info in the 64-bit DWARF format"));
MCBINDOPT(Dwarf64);
static cl::opt<bool> ShowMCInst(
"asm-show-inst",
cl::desc("Emit internal instruction representation to assembly file"));
@ -97,6 +103,7 @@ MCTargetOptions llvm::mc::InitMCTargetOptionsFromFlags() {
MCTargetOptions Options;
Options.MCRelaxAll = getRelaxAll();
Options.MCIncrementalLinkerCompatible = getIncrementalLinkerCompatible();
Options.Dwarf64 = getDwarf64();
Options.DwarfVersion = getDwarfVersion();
Options.ShowMCInst = getShowMCInst();
Options.ABIName = getABIName();

View File

@ -0,0 +1,3 @@
# RUN: not llvm-mc -dwarf64 -triple x86_64-unknown-windows-gnu %s -o - 2>&1 | FileCheck %s
# CHECK: the 64-bit DWARF format is not supported for x86_64-unknown-windows-gnu

View File

@ -0,0 +1,5 @@
# RUN: not llvm-mc -g -dwarf-version 2 -dwarf64 -triple x86_64 %s -o - 2>&1 | FileCheck --check-prefix=DWARF2 %s
# RUN: not llvm-mc -g -dwarf-version 5 -dwarf64 -triple i686 %s -o - 2>&1 | FileCheck --check-prefix=I686 %s
# DWARF2: the 64-bit DWARF format is not supported for DWARF versions prior to 3
# I686: the 64-bit DWARF format is only supported for 64-bit targets

View File

@ -387,6 +387,31 @@ int main(int argc, char **argv) {
return 1;
}
Ctx.setDwarfVersion(DwarfVersion);
if (MCOptions.Dwarf64) {
// The 64-bit DWARF format was introduced in DWARFv3.
if (DwarfVersion < 3) {
errs() << ProgName
<< ": the 64-bit DWARF format is not supported for DWARF versions "
"prior to 3\n";
return 1;
}
// 32-bit targets don't support DWARF64, which requires 64-bit relocations.
if (MAI->getCodePointerSize() < 8) {
errs() << ProgName
<< ": the 64-bit DWARF format is only supported for 64-bit "
"targets\n";
return 1;
}
// If needsDwarfSectionOffsetDirective is true, we would eventually call
// MCStreamer::emitSymbolValue() with IsSectionRelative = true, but that
// is supported only for 4-byte long references.
if (MAI->needsDwarfSectionOffsetDirective()) {
errs() << ProgName << ": the 64-bit DWARF format is not supported for "
<< TheTriple.normalize() << "\n";
return 1;
}
Ctx.setDwarfFormat(dwarf::DWARF64);
}
if (!DwarfDebugFlags.empty())
Ctx.setDwarfDebugFlags(StringRef(DwarfDebugFlags));
if (!DwarfDebugProducer.empty())