[PATCH] Emit DWARF info for all code section in an assembly file

Oliver Stannard oliver.stannard at arm.com
Mon Mar 17 05:16:35 PDT 2014


  Changed to make llvm-mc accept `-dwarf-version N` rather than `-gdwarf-N`.

Hi echristo, rengolin,

http://llvm-reviews.chandlerc.com/D2697

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2697?vs=7801&id=7876#toc

Files:
  test/MC/ARM/dwarf-asm-multiple-sections.s
  tools/llvm-mc/llvm-mc.cpp

Index: test/MC/ARM/dwarf-asm-multiple-sections.s
===================================================================
--- test/MC/ARM/dwarf-asm-multiple-sections.s
+++ test/MC/ARM/dwarf-asm-multiple-sections.s
@@ -1,7 +1,9 @@
 // RUN: llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -fdebug-compilation-dir=/tmp
 // RUN: llvm-dwarfdump %t | FileCheck -check-prefix DWARF %s
 // RUN: llvm-objdump -r %t | FileCheck -check-prefix RELOC %s
-// RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -gdwarf-2 2>&1 | FileCheck -check-prefix VERSION %s
+// RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 2 2>&1 | FileCheck -check-prefix VERSION %s
+// RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 1 2>&1 | FileCheck -check-prefix DWARF1 %s
+// RUN: not llvm-mc < %s -triple=armv7-linux-gnueabi -filetype=obj -o %t -g -dwarf-version 5 2>&1 | FileCheck -check-prefix DWARF5 %s
   .section .text, "ax"
 a:
   mov r0, r0
@@ -39,10 +41,10 @@
 
 
 // DWARF: .debug_line contents:
-// DWARF:      0x0000000000000000      7      0      1   0   0  is_stmt
-// DWARF-NEXT: 0x0000000000000004      7      0      1   0   0  is_stmt end_sequence
-// DWARF-NEXT: 0x0000000000000000     11      0      1   0   0  is_stmt
-// DWARF-NEXT: 0x0000000000000004     11      0      1   0   0  is_stmt end_sequence
+// DWARF:      0x0000000000000000      9      0      1   0   0  is_stmt
+// DWARF-NEXT: 0x0000000000000004      9      0      1   0   0  is_stmt end_sequence
+// DWARF-NEXT: 0x0000000000000000     13      0      1   0   0  is_stmt
+// DWARF-NEXT: 0x0000000000000004     13      0      1   0   0  is_stmt end_sequence
 
 
 // DWARF: .debug_ranges contents:
@@ -72,3 +74,6 @@
 
 
 // VERSION: {{.*}} error: DWARF2 only supports one section per compilation unit
+
+// DWARF1: Dwarf version 1 is not supported.
+// DWARF5: Dwarf version 5 is not supported.
Index: tools/llvm-mc/llvm-mc.cpp
===================================================================
--- tools/llvm-mc/llvm-mc.cpp
+++ tools/llvm-mc/llvm-mc.cpp
@@ -152,22 +152,8 @@
 GenDwarfForAssembly("g", cl::desc("Generate dwarf debugging info for assembly "
                                   "source files"));
 
-enum DwarfVersionNumber {
-  DWARF2 = 2,
-  DWARF3 = 3,
-  DWARF4 = 4
-};
-
-static cl::opt<DwarfVersionNumber>
-DwarfVersion(cl::desc("Dwarf version"),
-       cl::init(DWARF3),
-       cl::values(clEnumValN(DWARF2, "gdwarf-2",
-                             "Dwarf version 2"),
-                  clEnumValN(DWARF3, "gdwarf-3",
-                             "Dwarf version 3"),
-                  clEnumValN(DWARF4, "gdwarf-4",
-                             "Dwarf version 4"),
-                  clEnumValEnd));
+static cl::opt<int>
+DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(3));
 
 static cl::opt<std::string>
 DebugCompilationDir("fdebug-compilation-dir",
@@ -411,6 +397,11 @@
     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));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2697.6.patch
Type: text/x-patch
Size: 3380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140317/c58f8fcc/attachment.bin>


More information about the llvm-commits mailing list