On 11/09/2017 07:34 PM, Alexandre Oliva wrote:
> This patch introduces an option to enable the generation of location
> views along with location lists.  The exact format depends on the
> DWARF version: it can be a separate attribute (DW_AT_GNU_locviews) or
> (DW_LLE_view_pair) entries in DWARF5+ loclists.
> 
> Line number tables are also affected.  If the assembler is found, at
> compiler build time, to support .loc views, we use them and
> assembler-computed view labels, otherwise we output compiler-generated
> line number programs with conservatively-computed view labels.  In
> either case, we output view information next to line number changes
> when verbose assembly output is requested.
> 
> This patch requires an LVU patch that modifies the exported API of
> final_scan_insn.  It also expects the entire SFN patchset to be
> installed first, although SFN is not a requirement for LVU.
> 
> for  include/ChangeLog
> 
>       * dwarf2.def (DW_AT_GNU_locviews): New.
>       * dwarf2.h (enum dwarf_location_list_entry_type): Add
>       DW_LLE_GNU_view_pair.
>       (DW_LLE_view_pair): Define.
> 
> for  gcc/ChangeLog
> 
>       * common.opt (gvariable-location-views): New.
>       * config.in: Rebuilt.
>       * configure: Rebuilt.
>       * configure.ac: Test assembler for view support.
>       * dwarf2asm.c (dw2_asm_output_symname_uleb128): New.
>       * dwarf2asm.h (dw2_asm_output_symname_uleb128): Declare.
>       * dwarf2out.c (var_loc_view): New typedef.
>       (struct dw_loc_list_struct): Add vl_symbol, vbegin, vend.
>       (dwarf2out_locviews_in_attribute): New.
>       (dwarf2out_locviews_in_loclist): New.
>       (dw_val_equal_p): Compare val_view_list of dw_val_class_view_lists.
>       (enum dw_line_info_opcode): Add LI_adv_address.
>       (struct dw_line_info_table): Add view.
>       (RESET_NEXT_VIEW, RESETTING_VIEW_P): New macros.
>       (DWARF2_ASM_VIEW_DEBUG_INFO): Define default.
>       (zero_view_p): New variable.
>       (ZERO_VIEW_P): New macro.
>       (output_asm_line_debug_info): New.
>       (struct var_loc_node): Add view.
>       (add_AT_view_list, AT_loc_list): New.
>       (add_var_loc_to_decl): Add view param.  Test it against last.
>       (new_loc_list): Add view params.  Record them.
>       (AT_loc_list_ptr): Handle loc and view lists.
>       (view_list_to_loc_list_val_node): New.
>       (print_dw_val): Handle dw_val_class_view_list.
>       (size_of_die): Likewise.
>       (value_format): Likewise.
>       (loc_list_has_views): New.
>       (gen_llsym): Set vl_symbol too.
>       (maybe_gen_llsym, skip_loc_list_entry): New.
>       (dwarf2out_maybe_output_loclist_view_pair): New.
>       (output_loc_list): Output view list or entries too.
>       (output_view_list_offset): New.
>       (output_die): Handle dw_val_class_view_list.
>       (output_dwarf_version): New.
>       (output_compilation_unit_header): Use it.
>       (output_skeleton_debug_sections): Likewise.
>       (output_rnglists, output_line_info): Likewise.
>       (output_pubnames, output_aranges): Update version comments.
>       (output_one_line_info_table): Output view numbers in asm comments.
>       (dw_loc_list): Determine current endview, pass it to new_loc_list.
>       Call maybe_gen_llsym.
>       (loc_list_from_tree_1): Adjust.
>       (add_AT_location_description): Create view list attribute if
>       needed, check it's absent otherwise.
>       (convert_cfa_to_fb_loc_list): Adjust.
>       (maybe_emit_file): Call output_asm_line_debug_info for test.
>       (dwarf2out_var_location): Reset views as needed.  Precompute
>       add_var_loc_to_decl args.  Call get_attr_min_length only if we have the
>       attribute.  Set view.
>       (new_line_info_table): Reset next view.
>       (set_cur_line_info_table): Call output_asm_line_debug_info for test.
>       (dwarf2out_source_line): Likewise.  Output view resets and labels to
>       the assembler, or select appropriate line info opcodes.
>       (prune_unused_types_walk_attribs): Handle dw_val_class_view_list.
>       (optimize_string_length): Catch it.  Adjust.
>       (resolve_addr): Copy vl_symbol along with ll_symbol.  Handle
>       dw_val_class_view_list, and remove it if no longer needed.
>       (hash_loc_list): Hash view numbers.
>       (loc_list_hasher::equal): Compare them.
>       (optimize_location_lists): Check whether a view list symbol is
>       needed, and whether the locview attribute is present, and
>       whether they match.  Remove the locview attribute if no longer
>       needed.
>       (index_location_lists): Call skip_loc_list_entry for test.
>       (dwarf2out_finish): Call output_asm_line_debug_info for test.
>       Use output_dwarf_version.
>       * dwarf2out.h (enum dw_val_class): Add dw_val_class_view_list.
>       (struct dw_val_node): Add val_view_list.
>       * final.c: Include langhooks.h.
>       (SEEN_NEXT_VIEW): New.
>       (set_next_view_needed): New.
>       (clear_next_view_needed): New.
>       (maybe_output_next_view): New.
>       (final_start_function): Rename to...
>       (final_start_function_1): ... this.  Take pointer to FIRST,
>       add SEEN parameter.  Emit param bindings in the initial view.
>       (final_start_function): Reintroduce SEEN-less interface.
>       (final): Rename to...
>       (final_1): ... this.  Take SEEN parameter.  Output final pending
>       next view at the end.
>       (final): Reintroduce seen-less interface.
>       (final_scan_insn): Output pending next view before switching
>       sections or ending a block.  Mark the next view as needed when
>       outputting variable locations.  Notify debug backend of section
>       changes, and of location view changes.
>       (rest_of_handle_final): Adjust.
>       * opts.c (common_handle_option): Accept -gdwarf version 6.
>       * toplev.c (process_options): Autodetect value for debug variable
>       location views option.
>       * doc/invoke.texi (gvariable-location-views): New.
>       (gno-variable-location-views): New.
> ---
> diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c
> index 8e3e86f224c1..f19e6d65020e 100644
> --- a/gcc/dwarf2asm.c
> +++ b/gcc/dwarf2asm.c
> @@ -768,6 +768,31 @@ dw2_asm_output_data_sleb128 (HOST_WIDE_INT value,
>  }
>  
>  void
> +dw2_asm_output_symname_uleb128 (const char *lab1 ATTRIBUTE_UNUSED,
> +                             const char *comment, ...)
Needs a function comment.  Yes I realize others are missing in that
file.  But I think it's best to avoid making the problem worse.

The stuff outside dwarf2*.c is OK.  We really need Jason or Jakub to
comment on the meat of the dwarf2 bits.

Jeff

Reply via email to