llvm.org GIT mirror llvm / 75c9b93
We want the dwarf AT_producer for assembly source files to match clang's AT_producer. Which includes clang's version information so we can tell which version of the compiler was used. This is the first of two steps to allow us to do that. This is the llvm-mc change to provide a method to set the AT_producer string. The second step, coming soon to a clang near you, will have the clang driver pass the value of getClangFullVersion() via an flag when invoking the integrated assembler on assembly source files. rdar://12955296 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172630 91177308-0d34-0410-b5e6-96231b3b80d8 Kevin Enderby 7 years ago
4 changed file(s) with 35 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
128128 /// non-empty.
129129 StringRef DwarfDebugFlags;
130130
131 /// The string to embed in as the dwarf AT_producer for the compile unit, if
132 /// non-empty.
133 StringRef DwarfDebugProducer;
134
131135 /// Honor temporary labels, this is useful for debugging semantic
132136 /// differences between temporary and non-temporary labels (primarily on
133137 /// Darwin).
344348
345349 void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
346350 StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
351
352 void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
353 StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
347354
348355 /// @}
349356
637637 }
638638
639639 // AT_producer, the version of the assembler tool.
640 MCOS->EmitBytes(StringRef("llvm-mc (based on LLVM "));
641 MCOS->EmitBytes(StringRef(PACKAGE_VERSION));
642 MCOS->EmitBytes(StringRef(")"));
640 StringRef DwarfDebugProducer = context.getDwarfDebugProducer();
641 if (!DwarfDebugProducer.empty()){
642 MCOS->EmitBytes(DwarfDebugProducer);
643 }
644 else {
645 MCOS->EmitBytes(StringRef("llvm-mc (based on LLVM "));
646 MCOS->EmitBytes(StringRef(PACKAGE_VERSION));
647 MCOS->EmitBytes(StringRef(")"));
648 }
643649 MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string.
644650
645651 // AT_language, a 4 byte value. We use DW_LANG_Mips_Assembler as the dwarf2
0 // RUN: env DEBUG_PRODUCER="my producer" llvm-mc -g -triple i386-apple-darwin10 %s -filetype=obj -o %t
1 // RUN: llvm-dwarfdump %t | FileCheck %s
2
3 .globl _bar
4 _bar:
5 ret
6
7 // CHECK: DW_AT_producer [DW_FORM_string] ("my producer")
233233 if (i + 1 < argc)
234234 DwarfDebugFlags += " ";
235235 }
236 }
237
238 static std::string DwarfDebugProducer;
239 static void setDwarfDebugProducer(void) {
240 if(!getenv("DEBUG_PRODUCER"))
241 return;
242 DwarfDebugProducer += getenv("DEBUG_PRODUCER");
236243 }
237244
238245 static int AsLexInput(SourceMgr &SrcMgr, MCAsmInfo &MAI, tool_output_file *Out) {
352359 TripleName = Triple::normalize(TripleName);
353360 setDwarfDebugFlags(argc, argv);
354361
362 setDwarfDebugProducer();
363
355364 const char *ProgName = argv[0];
356365 const Target *TheTarget = GetTarget(ProgName);
357366 if (!TheTarget)
392401 Ctx.setGenDwarfForAssembly(GenDwarfForAssembly);
393402 if (!DwarfDebugFlags.empty())
394403 Ctx.setDwarfDebugFlags(StringRef(DwarfDebugFlags));
404 if (!DwarfDebugProducer.empty())
405 Ctx.setDwarfDebugProducer(StringRef(DwarfDebugProducer));
395406 if (!DebugCompilationDir.empty())
396407 Ctx.setCompilationDir(DebugCompilationDir);
397408 if (!MainFileName.empty())