]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add support for --dwarf-[3|4|5] to assembler command line.
authorNick Clifton <nickc@redhat.com>
Fri, 6 Mar 2020 14:52:14 +0000 (14:52 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 6 Mar 2020 14:52:14 +0000 (14:52 +0000)
PR 25612
* as.c (dwarf_level): Define.
(show_usage): Add --gdwarf-3, --gdwarf-4 and --gdwarf-5.
(parse_args): Add support for the new options.
as.h (dwarf_level): Prototype.
* dwarf2dbg.c (DWARF2_VERSION): Use dwarf_level as default version
value.
* config/tc-ia64.h (DWARF2_VERISION): Update definition.
(DWARF2_LINE_VERSION): Remove definition.
* doc/as.texi: Document the new options.

gas/ChangeLog
gas/as.c
gas/as.h
gas/config/tc-ia64.h
gas/doc/as.texi
gas/dwarf2dbg.c

index e2984b59c7f1cde0877d80f8dffd3c4d9624704d..1b377fd3b346210b09c734feafd9bbcf4da483e4 100644 (file)
@@ -1,3 +1,16 @@
+2020-03-06  Nick Clifton  <nickc@redhat.com>
+
+       PR 25612
+       * as.c (dwarf_level): Define.
+       (show_usage): Add --gdwarf-3, --gdwarf-4 and --gdwarf-5.
+       (parse_args): Add support for the new options.
+       as.h (dwarf_level): Prototype.
+       * dwarf2dbg.c (DWARF2_VERSION): Use dwarf_level as default version
+       value.
+       * config/tc-ia64.h (DWARF2_VERISION): Update definition.
+       (DWARF2_LINE_VERSION): Remove definition.
+       * doc/as.texi: Document the new options.
+
 2020-03-06  Nick Clifton  <nickc@redhat.com>
 
        PR 25572
index 51bb7210ec825a7bc63f1858d973f1ca8be6b167..4c5881abd88c8fd493b8448fa7859810f1d8c197 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -102,6 +102,9 @@ int verbose = 0;
    MD_AFTER_PARSE_ARGS.  */
 int flag_dwarf_cie_version = -1;
 
+/* The maximum level of DWARF DEBUG information we should manufacture.  */
+unsigned int dwarf_level = 0;
+
 #if defined OBJ_ELF || defined OBJ_MAYBE_ELF
 int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON;
 bfd_boolean flag_generate_build_notes = DEFAULT_GENERATE_BUILD_NOTES;
@@ -338,7 +341,7 @@ Options:\n\
   fprintf (stream, _("\
   --gstabs+               generate STABS debug info with GNU extensions\n"));
   fprintf (stream, _("\
-  --gdwarf-2              generate DWARF2 debugging information\n"));
+  --gdwarf-<N>            generate DWARF<N> debugging information. 2 <= <N> <= 5\n"));
   fprintf (stream, _("\
   --gdwarf-sections       generate per-function section names for DWARF line information\n"));
   fprintf (stream, _("\
@@ -484,7 +487,10 @@ parse_args (int * pargc, char *** pargv)
       OPTION_DEPFILE,
       OPTION_GSTABS,
       OPTION_GSTABS_PLUS,
-      OPTION_GDWARF2,
+      OPTION_GDWARF_2,
+      OPTION_GDWARF_3,
+      OPTION_GDWARF_4,
+      OPTION_GDWARF_5,
       OPTION_GDWARF_SECTIONS,
       OPTION_GDWARF_CIE_VERSION,
       OPTION_STRIP_LOCAL_ABSOLUTE,
@@ -537,10 +543,13 @@ parse_args (int * pargc, char *** pargv)
     ,{"generate-missing-build-notes", required_argument, NULL, OPTION_ELF_BUILD_NOTES}
 #endif
     ,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
-    ,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF2}
-    /* GCC uses --gdwarf-2 but GAS uses to use --gdwarf2,
+    ,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF_2}
+    ,{"gdwarf-3", no_argument, NULL, OPTION_GDWARF_3}
+    ,{"gdwarf-4", no_argument, NULL, OPTION_GDWARF_4}
+    ,{"gdwarf-5", no_argument, NULL, OPTION_GDWARF_5}
+    /* GCC uses --gdwarf-2 but GAS used to to use --gdwarf2,
        so we keep it here for backwards compatibility.  */
-    ,{"gdwarf2", no_argument, NULL, OPTION_GDWARF2}
+    ,{"gdwarf2", no_argument, NULL, OPTION_GDWARF_2}
     ,{"gdwarf-sections", no_argument, NULL, OPTION_GDWARF_SECTIONS}
     ,{"gdwarf-cie-version", required_argument, NULL, OPTION_GDWARF_CIE_VERSION}
     ,{"gen-debug", no_argument, NULL, 'g'}
@@ -817,7 +826,10 @@ This program has absolutely no warranty.\n"));
          if (md_debug_format_selector)
            debug_type = md_debug_format_selector (& use_gnu_debug_info_extensions);
          else if (IS_ELF)
-           debug_type = DEBUG_DWARF2;
+           {
+             debug_type = DEBUG_DWARF2;
+             dwarf_level = 2;
+           }
          else
            debug_type = DEBUG_STABS;
          break;
@@ -829,8 +841,24 @@ This program has absolutely no warranty.\n"));
          debug_type = DEBUG_STABS;
          break;
 
-       case OPTION_GDWARF2:
+       case OPTION_GDWARF_2:
+         debug_type = DEBUG_DWARF2;
+         dwarf_level = 2;
+         break;
+
+       case OPTION_GDWARF_3:
+         debug_type = DEBUG_DWARF2;
+         dwarf_level = 3;
+         break;
+
+       case OPTION_GDWARF_4:
          debug_type = DEBUG_DWARF2;
+         dwarf_level = 4;
+         break;
+
+       case OPTION_GDWARF_5:
+         debug_type = DEBUG_DWARF2;
+         dwarf_level = 5;
          break;
 
        case OPTION_GDWARF_SECTIONS:
@@ -845,6 +873,21 @@ This program has absolutely no warranty.\n"));
               || flag_dwarf_cie_version == 2
               || flag_dwarf_cie_version > 4)
             as_fatal (_("Invalid --gdwarf-cie-version `%s'"), optarg);
+         switch (flag_dwarf_cie_version)
+           {
+           case 1:
+             if (dwarf_level < 2)
+               dwarf_level = 2;
+             break;
+           case 3:
+             if (dwarf_level < 3)
+               dwarf_level = 3;
+             break;
+           default:
+             if (dwarf_level < 4)
+               dwarf_level = 4;
+             break;
+           }
          break;
 
        case 'J':
index b8d3d74f737614c8d606d55939d439bd1e3aedb3..7a72239dc23b305cde60127953bc482338b5551d 100644 (file)
--- a/gas/as.h
+++ b/gas/as.h
@@ -413,6 +413,7 @@ extern enum debug_info_type debug_type;
 extern int use_gnu_debug_info_extensions;
 COMMON bfd_boolean flag_dwarf_sections;
 extern int flag_dwarf_cie_version;
+extern unsigned int dwarf_level;
 \f
 /* Maximum level of macro nesting.  */
 extern int max_macro_nest;
index b8abcf6843d85d0451c4dcfa2d9bca0c7222f8c9..3a50f86b229e0ceca6a597d1197e7df5d2589485 100644 (file)
@@ -325,6 +325,5 @@ typedef struct unwind_record
 
 /* VMS backtraces expect dwarf version 3.  */
 #ifdef TE_VMS
-#define DWARF2_VERSION 3
-#define DWARF2_LINE_VERSION 3
+#define DWARF2_VERSION      (dwarf_level < 3 ? 3  : debug_level)
 #endif
index e97042c680110aef063d48cdef973f83ca667f27..ff0ef63fbd81335cc14e3e10bfc23e36db519535 100644 (file)
@@ -230,7 +230,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
  [@b{--compress-debug-sections}]  [@b{--nocompress-debug-sections}]
  [@b{--debug-prefix-map} @var{old}=@var{new}]
  [@b{--defsym} @var{sym}=@var{val}] [@b{-f}] [@b{-g}] [@b{--gstabs}]
- [@b{--gstabs+}] [@b{--gdwarf-2}] [@b{--gdwarf-sections}]
+ [@b{--gstabs+}] [@b{--gdwarf-<N>}] [@b{--gdwarf-sections}]
  [@b{--gdwarf-cie-version}=@var{VERSION}]
  [@b{--help}] [@b{-I} @var{dir}] [@b{-J}]
  [@b{-K}] [@b{-L}] [@b{--listing-lhs-width}=@var{NUM}]
@@ -763,6 +763,27 @@ Generate DWARF2 debugging information for each assembler line.  This
 may help debugging assembler code, if the debugger can handle it.  Note---this
 option is only supported by some targets, not all of them.
 
+@item --gdwarf-3
+This option is the same as the @option{--gdwarf-2} option, except that it
+allows for the possibility of the generation of extra debug information as per
+version 3 of the DWARF specification.  Note - enabling this option does not
+guarantee the generation of any extra infortmation, the choice to do so is on a
+per target basis.
+
+@item --gdwarf-4
+This option is the same as the @option{--gdwarf-2} option, except that it
+allows for the possibility of the generation of extra debug information as per
+version 4 of the DWARF specification.  Note - enabling this option does not
+guarantee the generation of any extra infortmation, the choice to do so is on a
+per target basis.
+
+@item --gdwarf-5
+This option is the same as the @option{--gdwarf-2} option, except that it
+allows for the possibility of the generation of extra debug information as per
+version 4 of the DWARF specification.  Note - enabling this option does not
+guarantee the generation of any extra infortmation, the choice to do so is on a
+per target basis.
+
 @item --gdwarf-sections
 Instead of creating a .debug_line section, create a series of
 .debug_line.@var{foo} sections where @var{foo} is the name of the
index 40a44355423c10b10df0a43d8a6f037fa6941e2f..7384a17c57759bb19a0c578ee2071d723408ebee 100644 (file)
@@ -89,7 +89,7 @@
 #endif
 
 #ifndef DWARF2_VERSION
-#define DWARF2_VERSION 2
+#define DWARF2_VERSION dwarf_level
 #endif
 
 /* The .debug_aranges version has been 2 in DWARF version 2, 3 and 4. */