[llvm] r207739 - Record the DWARF version in MCContext
Eric Christopher
echristo at gmail.com
Wed Jun 18 20:31:25 PDT 2014
Heh. Nice catch. Probably a rename to mc-dwarf-version would be
best/easiest.
On Jun 18, 2014 8:25 PM, "Alp Toker" <alp at nuanti.com> wrote:
>
> On 01/05/2014 11:46, Oliver Stannard wrote:
>
>> Author: olista01
>> Date: Thu May 1 03:46:02 2014
>> New Revision: 207739
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=207739&view=rev
>> Log:
>> Record the DWARF version in MCContext
>>
>> Record the DWARF version in MCContext, and use it when
>> emitting the dwarf version into the debug info.
>>
>>
>> Modified:
>> llvm/trunk/include/llvm/MC/MCContext.h
>> llvm/trunk/lib/MC/MCDwarf.cpp
>> llvm/trunk/test/MC/ELF/gen-dwarf.s
>> llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>>
>> Modified: llvm/trunk/include/llvm/MC/MCContext.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
>> llvm/MC/MCContext.h?rev=207739&r1=207738&r2=207739&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/include/llvm/MC/MCContext.h (original)
>> +++ llvm/trunk/include/llvm/MC/MCContext.h Thu May 1 03:46:02 2014
>> @@ -147,6 +147,9 @@ namespace llvm {
>> /// non-empty.
>> StringRef DwarfDebugProducer;
>> + /// The maximum version of dwarf that we should emit.
>> + uint16_t DwarfVersion;
>> +
>> /// Honor temporary labels, this is useful for debugging semantic
>> /// differences between temporary and non-temporary labels
>> (primarily on
>> /// Darwin).
>> @@ -396,6 +399,9 @@ namespace llvm {
>> void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
>> StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
>> + void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
>> + uint16_t getDwarfVersion() const { return DwarfVersion; }
>> +
>> /// @}
>> char *getSecureLogFile() { return SecureLogFile; }
>>
>> Modified: llvm/trunk/lib/MC/MCDwarf.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/
>> MCDwarf.cpp?rev=207739&r1=207738&r2=207739&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/MC/MCDwarf.cpp (original)
>> +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu May 1 03:46:02 2014
>> @@ -645,8 +645,8 @@ static void EmitGenDwarfInfo(MCStreamer
>> const MCExpr *Length = MakeStartMinusEndExpr(*MCOS, *InfoStart,
>> *InfoEnd, 4);
>> MCOS->EmitAbsValue(Length, 4);
>> - // The 2 byte DWARF version, which is 2.
>> - MCOS->EmitIntValue(2, 2);
>> + // The 2 byte DWARF version.
>> + MCOS->EmitIntValue(context.getDwarfVersion(), 2);
>> // 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.
>>
>> Modified: llvm/trunk/test/MC/ELF/gen-dwarf.s
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/
>> ELF/gen-dwarf.s?rev=207739&r1=207738&r2=207739&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/test/MC/ELF/gen-dwarf.s (original)
>> +++ llvm/trunk/test/MC/ELF/gen-dwarf.s Thu May 1 03:46:02 2014
>> @@ -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 -triple i686-pc-linux-gnu %s -filetype=asm -o - |
>> FileCheck --check-prefix=ASM %s
>> +// RUN: llvm-mc -g -dwarf-version 2 -triple i686-pc-linux-gnu %s
>> -filetype=obj -o - | llvm-readobj -r | FileCheck %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:
>> @@ -35,7 +39,9 @@ foo:
>> // Second instance of the section has the CU
>> // ASM: .section .debug_info
>> // Dwarf version
>> -// ASM: .short 2
>> +// DWARF2: .short 2
>> +// DWARF3: .short 3
>> +// DWARF4: .short 4
>> // ASM-NEXT: .long [[ABBREV_LABEL]]
>> // First .byte 1 is the abbreviation number for the compile_unit abbrev
>> // ASM: .byte 1
>> @@ -44,3 +50,5 @@ foo:
>> // ASM: .section .debug_line
>> // ASM-NEXT: [[LINE_LABEL]]
>> +// DWARF1: Dwarf version 1 is not supported.
>> +// DWARF5: Dwarf version 5 is not supported.
>>
>> Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-
>> mc/llvm-mc.cpp?rev=207739&r1=207738&r2=207739&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
>> +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Thu May 1 03:46:02 2014
>> @@ -154,6 +154,9 @@ static cl::opt<bool>
>> GenDwarfForAssembly("g", cl::desc("Generate dwarf debugging info for
>> assembly "
>> "source files"));
>> +static cl::opt<int>
>> +DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(4));
>> +
>>
>
> Hi Oliver,
>
> It looks like this "dwarf-version" option introduced to llvm-mc.cpp
> conflicts with an existing one in lib/CodeGen/AsmPrinter/DwarfDebug.cpp:
>
> $ bin/llvm-mc
> <premain>: CommandLine Error: Argument 'dwarf-version' defined more than
> once!
>
> Due to a bug in CommandLine registration the errors got reported on stderr
> but didn't trigger any test failures so the issue went unnoticed.
>
> Could you coordinate with DwarfDebug.cpp to either share a single option
> definition, rename one of the two flags, or adjust link dependencies to
> eliminate the conflict?
>
> Once that's done I'll land the necessary CommandLine checks to make sure
> conflicting registrations get detected in future.
>
> Alp.
>
>
> static cl::opt<std::string>
>> DebugCompilationDir("fdebug-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.setGenDwarfForAssembly(GenDwarfForAssembly);
>> + if (DwarfVersion < 2 || DwarfVersion > 4) {
>> + errs() << ProgName << ": Dwarf version " << DwarfVersion
>> + << " is not supported." << '\n';
>> + return 1;
>> + }
>> + Ctx.setDwarfVersion(DwarfVersion);
>> if (!DwarfDebugFlags.empty())
>> Ctx.setDwarfDebugFlags(StringRef(DwarfDebugFlags));
>> if (!DwarfDebugProducer.empty())
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
> --
> http://www.nuanti.com
> the browser experts
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140618/e7f06ed7/attachment.html>
More information about the llvm-commits
mailing list