[PATCH] debug: Pass --gdwarf-N to assembler if fixed gas is detected during configure

Jason Merrill jason@redhat.com
Tue Oct 6 20:57:35 GMT 2020


On 10/6/20 11:54 AM, Mark Wielaard wrote:
> Hi,
> 
> On Fri, 2020-09-18 at 17:21 +0200, Mark Wielaard wrote:
>> On Tue, 2020-09-15 at 20:40 +0200, Jakub Jelinek wrote:
>>> Ok, here it is in patch form.
>>> I've briefly tested it, with the older binutils I have around (no --gdwarf-N
>>> support), with latest gas (--gdwarf-N that can be passed to as even when
>>> compiling C/C++ etc. code and emitting .debug_line) and latest gas with Mark's fix
>>> reverted (--gdwarf-N support, but can only pass it to as when assembling
>>> user .s/.S files, not when compiling C/C++ etc.).
>>> Will bootstrap/regtest (with the older binutils) later tonight.
>>>
>>> 2020-09-15  Jakub Jelinek  <jakub@redhat.com>
>>>
>>> 	* configure.ac (HAVE_AS_GDWARF_5_DEBUG_FLAG,
>>> 	HAVE_AS_WORKING_DWARF_4_FLAG): New tests.
>>> 	* gcc.c (ASM_DEBUG_DWARF_OPTION): Define.
>>> 	(ASM_DEBUG_SPEC): Use ASM_DEBUG_DWARF_OPTION instead of
>>> 	"--gdwarf2".  Use %{cond:opt1;:opt2} style.
>>> 	(ASM_DEBUG_OPTION_DWARF_OPT): Define.
>>> 	(ASM_DEBUG_OPTION_SPEC): Define.
>>> 	(asm_debug_option): New variable.
>>> 	(asm_options): Add "%(asm_debug_option)".
>>> 	(static_specs): Add asm_debug_option entry.
>>> 	(static_spec_functions): Add dwarf-version-gt.
>>> 	(debug_level_greater_than_spec_func): New function.
>>> 	* config/darwin.h (ASM_DEBUG_OPTION_SPEC): Define.
>>> 	* config/darwin9.h (ASM_DEBUG_OPTION_SPEC): Redefine.
>>> 	* config.in: Regenerated.
>>> 	* configure: Regenerated.
>>
>> Once this is in we can more generally emit DW_FORM_line_str for
>> filepaths in CU DIEs for the name and comp_dir attribute. There
>> currently is a bit of a hack to do this in dwarf2out_early_finish, but
>> that only works when the assembler doesn't emit a DWARF5 .debug_line,
>> but gcc does it itself.
>>
>> What do you think of the attached patch?
>>
>> DWARF5 has a new string table specially for file paths. .debug_line
>> file and dir tables reference strings in .debug_line_str.  If a
>> .debug_line_str section is emitted then also place CU DIE file
>> names and comp dirs there.
>>
>> gcc/ChangeLog:
>>
>> 	* dwarf2out.c (add_filepath_AT_string): New function.
>> 	(asm_outputs_debug_line_str): Likewise.
>> 	(add_filename_attribute): Likewise.
>> 	(add_comp_dir_attribute): Call add_filepath_AT_string.
>> 	(gen_compile_unit_die): Call add_filename_attribute for name.
>> 	(init_sections_and_labels): Init debug_line_str_section when
>> 	asm_outputs_debug_line_str return true.
>> 	(dwarf2out_early_finish): Remove DW_AT_name and DW_AT_comp_dir
>> 	hack and call add_filename_attribute for the remap_debug_filename.
> 
> On top of that, we also need the following, which makes sure the actual
> compilation directory is used in a DWARF5 .debug_line directory table
> (and not just a relative path).

All three of these patches (Jakub's, and your two) look good to me, 
except that your add_filepath_AT_string patch is missing comments on 
some of the new functions.

Jason




More information about the Gcc-patches mailing list