mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
Record the DWARF version in MCContext
Record the DWARF version in MCContext, and use it when emitting the dwarf version into the debug info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207739 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -147,6 +147,9 @@ namespace llvm {
|
|||||||
/// non-empty.
|
/// non-empty.
|
||||||
StringRef DwarfDebugProducer;
|
StringRef DwarfDebugProducer;
|
||||||
|
|
||||||
|
/// The maximum version of dwarf that we should emit.
|
||||||
|
uint16_t DwarfVersion;
|
||||||
|
|
||||||
/// Honor temporary labels, this is useful for debugging semantic
|
/// Honor temporary labels, this is useful for debugging semantic
|
||||||
/// differences between temporary and non-temporary labels (primarily on
|
/// differences between temporary and non-temporary labels (primarily on
|
||||||
/// Darwin).
|
/// Darwin).
|
||||||
@ -396,6 +399,9 @@ namespace llvm {
|
|||||||
void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
|
void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
|
||||||
StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
|
StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
|
||||||
|
|
||||||
|
void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
|
||||||
|
uint16_t getDwarfVersion() const { return DwarfVersion; }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
char *getSecureLogFile() { return SecureLogFile; }
|
char *getSecureLogFile() { return SecureLogFile; }
|
||||||
|
@ -645,8 +645,8 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
|
|||||||
const MCExpr *Length = MakeStartMinusEndExpr(*MCOS, *InfoStart, *InfoEnd, 4);
|
const MCExpr *Length = MakeStartMinusEndExpr(*MCOS, *InfoStart, *InfoEnd, 4);
|
||||||
MCOS->EmitAbsValue(Length, 4);
|
MCOS->EmitAbsValue(Length, 4);
|
||||||
|
|
||||||
// The 2 byte DWARF version, which is 2.
|
// The 2 byte DWARF version.
|
||||||
MCOS->EmitIntValue(2, 2);
|
MCOS->EmitIntValue(context.getDwarfVersion(), 2);
|
||||||
|
|
||||||
// The 4 byte offset to the debug abbrevs from the start of the .debug_abbrev,
|
// The 4 byte offset to the debug abbrevs from the start of the .debug_abbrev,
|
||||||
// it is at the start of that section so this is zero.
|
// it is at the start of that section so this is zero.
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
// RUN: llvm-mc -g -triple i686-pc-linux-gnu %s -filetype=obj -o - | llvm-readobj -r | FileCheck %s
|
// RUN: llvm-mc -g -dwarf-version 2 -triple i686-pc-linux-gnu %s -filetype=obj -o - | llvm-readobj -r | FileCheck %s
|
||||||
// RUN: llvm-mc -g -triple i686-pc-linux-gnu %s -filetype=asm -o - | FileCheck --check-prefix=ASM %s
|
// RUN: not llvm-mc -g -dwarf-version 1 -triple i686-pc-linux-gnu %s -filetype=asm -o - 2>&1 | FileCheck --check-prefix=DWARF1 %s
|
||||||
|
// RUN: llvm-mc -g -dwarf-version 2 -triple i686-pc-linux-gnu %s -filetype=asm -o - | FileCheck --check-prefix=ASM --check-prefix=DWARF2 %s
|
||||||
|
// RUN: llvm-mc -g -dwarf-version 3 -triple i686-pc-linux-gnu %s -filetype=asm -o - | FileCheck --check-prefix=ASM --check-prefix=DWARF3 %s
|
||||||
|
// RUN: llvm-mc -g -triple i686-pc-linux-gnu %s -filetype=asm -o - | FileCheck --check-prefix=ASM --check-prefix=DWARF4 %s
|
||||||
|
// RUN: not llvm-mc -g -dwarf-version 5 -triple i686-pc-linux-gnu %s -filetype=asm -o - 2>&1 | FileCheck --check-prefix=DWARF5 %s
|
||||||
|
|
||||||
|
|
||||||
// Test that on ELF:
|
// Test that on ELF:
|
||||||
@ -35,7 +39,9 @@ foo:
|
|||||||
// Second instance of the section has the CU
|
// Second instance of the section has the CU
|
||||||
// ASM: .section .debug_info
|
// ASM: .section .debug_info
|
||||||
// Dwarf version
|
// Dwarf version
|
||||||
// ASM: .short 2
|
// DWARF2: .short 2
|
||||||
|
// DWARF3: .short 3
|
||||||
|
// DWARF4: .short 4
|
||||||
// ASM-NEXT: .long [[ABBREV_LABEL]]
|
// ASM-NEXT: .long [[ABBREV_LABEL]]
|
||||||
// First .byte 1 is the abbreviation number for the compile_unit abbrev
|
// First .byte 1 is the abbreviation number for the compile_unit abbrev
|
||||||
// ASM: .byte 1
|
// ASM: .byte 1
|
||||||
@ -44,3 +50,5 @@ foo:
|
|||||||
// ASM: .section .debug_line
|
// ASM: .section .debug_line
|
||||||
// ASM-NEXT: [[LINE_LABEL]]
|
// ASM-NEXT: [[LINE_LABEL]]
|
||||||
|
|
||||||
|
// DWARF1: Dwarf version 1 is not supported.
|
||||||
|
// DWARF5: Dwarf version 5 is not supported.
|
||||||
|
@ -154,6 +154,9 @@ static cl::opt<bool>
|
|||||||
GenDwarfForAssembly("g", cl::desc("Generate dwarf debugging info for assembly "
|
GenDwarfForAssembly("g", cl::desc("Generate dwarf debugging info for assembly "
|
||||||
"source files"));
|
"source files"));
|
||||||
|
|
||||||
|
static cl::opt<int>
|
||||||
|
DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(4));
|
||||||
|
|
||||||
static cl::opt<std::string>
|
static cl::opt<std::string>
|
||||||
DebugCompilationDir("fdebug-compilation-dir",
|
DebugCompilationDir("fdebug-compilation-dir",
|
||||||
cl::desc("Specifies the debug info's compilation dir"));
|
cl::desc("Specifies the debug info's compilation dir"));
|
||||||
@ -406,6 +409,12 @@ int main(int argc, char **argv) {
|
|||||||
Ctx.setAllowTemporaryLabels(false);
|
Ctx.setAllowTemporaryLabels(false);
|
||||||
|
|
||||||
Ctx.setGenDwarfForAssembly(GenDwarfForAssembly);
|
Ctx.setGenDwarfForAssembly(GenDwarfForAssembly);
|
||||||
|
if (DwarfVersion < 2 || DwarfVersion > 4) {
|
||||||
|
errs() << ProgName << ": Dwarf version " << DwarfVersion
|
||||||
|
<< " is not supported." << '\n';
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Ctx.setDwarfVersion(DwarfVersion);
|
||||||
if (!DwarfDebugFlags.empty())
|
if (!DwarfDebugFlags.empty())
|
||||||
Ctx.setDwarfDebugFlags(StringRef(DwarfDebugFlags));
|
Ctx.setDwarfDebugFlags(StringRef(DwarfDebugFlags));
|
||||||
if (!DwarfDebugProducer.empty())
|
if (!DwarfDebugProducer.empty())
|
||||||
|
Reference in New Issue
Block a user