[PATCH] D62074: [DebugInfo] Handle '# line "file"' correctly for asm source.
Paul Robinson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 21 04:56:32 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361248: [DebugInfo] Handle '# line "file"' correctly for asm source. (authored by probinson, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D62074?vs=200077&id=200462#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62074/new/
https://reviews.llvm.org/D62074
Files:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/ELF/debug-hash-file.s
Index: llvm/trunk/test/MC/ELF/debug-hash-file.s
===================================================================
--- llvm/trunk/test/MC/ELF/debug-hash-file.s
+++ llvm/trunk/test/MC/ELF/debug-hash-file.s
@@ -0,0 +1,21 @@
+// RUN: llvm-mc -triple x86_64-unknown-linux-gnu -filetype obj -g -dwarf-version 4 -o %t %s
+// RUN: llvm-dwarfdump -debug-info -debug-line %t | FileCheck %s
+
+// CHECK: DW_TAG_compile_unit
+// CHECK-NOT: DW_TAG_
+// CHECK: DW_AT_name ("/MyTest/Inputs{{(/|\\)+}}other.S")
+// CHECK: DW_TAG_label
+// CHECK-NOT: DW_TAG_
+// CHECK: DW_AT_decl_file ("/MyTest/Inputs{{(/|\\)+}}other.S")
+
+// CHECK: include_directories[ 1] = "/MyTest/Inputs"
+// CHECK: file_names[ 1]:
+// CHECK-NEXT: name: "other.S"
+// CHECK-NEXT: dir_index: 1
+
+# 1 "/MyTest/Inputs/other.S"
+
+foo:
+ nop
+ nop
+ nop
Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -165,6 +165,9 @@
};
CppHashInfoTy CppHashInfo;
+ /// The filename from the first cpp hash file line comment, if any.
+ StringRef FirstCppHashFilename;
+
/// List of forward directional labels for diagnosis at the end.
SmallVector<std::tuple<SMLoc, CppHashInfoTy, MCSymbol *>, 4> DirLabels;
@@ -849,6 +852,13 @@
// the assembler source was produced with debug info already) then emit one
// describing the assembler source file itself.
if (getContext().getGenDwarfFileNumber() == 0) {
+ // Use the first #line directive for this, if any. It's preprocessed, so
+ // there is no checksum, and of course no source directive.
+ if (!FirstCppHashFilename.empty())
+ getContext().setMCLineTableRootFile(/*CUID=*/0,
+ getContext().getCompilationDir(),
+ FirstCppHashFilename,
+ /*Cksum=*/None, /*Source=*/None);
const MCDwarfFile &RootFile =
getContext().getMCDwarfLineTable(/*CUID=*/0).getRootFile();
getContext().setGenDwarfFileNumber(getStreamer().EmitDwarfFileDirective(
@@ -2285,11 +2295,14 @@
// Get rid of the enclosing quotes.
Filename = Filename.substr(1, Filename.size() - 2);
- // Save the SMLoc, Filename and LineNumber for later use by diagnostics.
+ // Save the SMLoc, Filename and LineNumber for later use by diagnostics
+ // and possibly DWARF file info.
CppHashInfo.Loc = L;
CppHashInfo.Filename = Filename;
CppHashInfo.LineNumber = LineNumber;
CppHashInfo.Buf = CurBuffer;
+ if (FirstCppHashFilename.empty())
+ FirstCppHashFilename = Filename;
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62074.200462.patch
Type: text/x-patch
Size: 2713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190521/f1fe147c/attachment.bin>
More information about the llvm-commits
mailing list