This affects only the RISC-V targets, where the compiler options -gvariable-location-views and consequently also -ginline-points are disabled by default, which is unexpected and disables some useful features of the generated debug info.
Due to a bug in the gas assembler the .loc statement is not usable to generate location view debug info. That is detected by configure: configure:31500: checking assembler for dwarf2 debug_view support configure:31509: .../riscv-unknown-elf/bin/as -o conftest.o conftest.s >&5 conftest.s: Assembler messages: conftest.s:5: Error: .uleb128 only supports constant or subtract expressions conftest.s:6: Error: .uleb128 only supports constant or subtract expressions configure:31512: $? = 1 configure: failed program was .file 1 "conftest.s" .loc 1 3 0 view .LVU1 nop .data .uleb128 .LVU1 .uleb128 .LVU1 configure:31523: result: no This results in dwarf2out_as_locview_support being set to false, and that creates a sequence of events, with the end result that most inlined functions either have no DW_AT_entry_pc, or one with a wrong entry pc value. But the location views can also be generated without using any .loc statements, therefore we should enable the option -gvariable-location-views by default, regardless of the status of -gas-locview-support. Note however, that the combination of the following compiler options -g -O2 -gvariable-location-views -gno-as-loc-support turned out to create invalid assembler intermediate files, with lots of assembler errors like: Error: leb128 operand is an undefined symbol: .LVU3 This affects all targets, except RISC-V of course ;-) and is fixed by the changes in dwarf2out.c Finally the .debug_loclists created without assembler locview support did contain location view pairs like v0000000ffffffff v000000000000000 which is the value from FORCE_RESET_NEXT_VIEW, but that is most likely not as expected either, so change that as well. --- gcc/dwarf2out.cc | 16 ++++++++++------ gcc/toplev.cc | 4 +--- 2 files changed, 11 insertions(+), 9 deletions(-) v2: fixed the boot-strap error triggered by v1 on any target, except RISC-V, the issue was triggered by libstdc++-v3/src/c++11/cxx11-ios_failure-lt.s which is generated using -gno-as-loc-support, which triggered a latent issue. diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 346feeb53c8..79f97b5a55e 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -10374,7 +10374,7 @@ dwarf2out_maybe_output_loclist_view_pair (dw_loc_list_ref curr) #ifdef DW_LLE_view_pair dw2_asm_output_data (1, DW_LLE_view_pair, "DW_LLE_view_pair"); - if (dwarf2out_as_locview_support) + if (dwarf2out_as_locview_support && dwarf2out_as_loc_support) { if (ZERO_VIEW_P (curr->vbegin)) dw2_asm_output_data_uleb128 (0, "Location view begin"); @@ -10396,8 +10396,10 @@ dwarf2out_maybe_output_loclist_view_pair (dw_loc_list_ref curr) } else { - dw2_asm_output_data_uleb128 (curr->vbegin, "Location view begin"); - dw2_asm_output_data_uleb128 (curr->vend, "Location view end"); + dw2_asm_output_data_uleb128 (ZERO_VIEW_P (curr->vbegin) + ? 0 : curr->vbegin, "Location view begin"); + dw2_asm_output_data_uleb128 (ZERO_VIEW_P (curr->vend) + ? 0 : curr->vend, "Location view end"); } #endif /* DW_LLE_view_pair */ @@ -10430,7 +10432,7 @@ output_loc_list (dw_loc_list_ref list_head) vcount++; /* ?? dwarf_split_debug_info? */ - if (dwarf2out_as_locview_support) + if (dwarf2out_as_locview_support && dwarf2out_as_loc_support) { char label[MAX_ARTIFICIAL_LABEL_BYTES]; @@ -10460,10 +10462,12 @@ output_loc_list (dw_loc_list_ref list_head) } else { - dw2_asm_output_data_uleb128 (curr->vbegin, + dw2_asm_output_data_uleb128 (ZERO_VIEW_P (curr->vbegin) + ? 0 : curr->vbegin, "View list begin (%s)", list_head->vl_symbol); - dw2_asm_output_data_uleb128 (curr->vend, + dw2_asm_output_data_uleb128 (ZERO_VIEW_P (curr->vend) + ? 0 : curr->vend, "View list end (%s)", list_head->vl_symbol); } diff --git a/gcc/toplev.cc b/gcc/toplev.cc index eee4805b504..292948122de 100644 --- a/gcc/toplev.cc +++ b/gcc/toplev.cc @@ -1475,9 +1475,7 @@ process_options () = (flag_var_tracking && debug_info_level >= DINFO_LEVEL_NORMAL && dwarf_debuginfo_p () - && !dwarf_strict - && dwarf2out_as_loc_support - && dwarf2out_as_locview_support); + && !dwarf_strict); } else if (debug_variable_location_views == -1 && dwarf_version != 5) { -- 2.39.2