Add support for --dwarf-[3|4|5] to assembler command line.

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.
This commit is contained in:
Nick Clifton 2020-03-06 14:52:14 +00:00
parent 09f2921cc9
commit 31bf18645d
6 changed files with 88 additions and 11 deletions

View 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

View File

@ -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':

View File

@ -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;
/* Maximum level of macro nesting. */
extern int max_macro_nest;

View 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

View 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

View 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. */