Hi!
The -gsplit-dwarf changes came a few months after .debug_macro
and the r0-120109 changes just changed the 2nd operand of
DW_MACRO_GNU_{define,undef}_indirect from the usual .debug_str
section offset argument to leb128 index into .debug_str_offsets
without changing the opcodes.
DWARF5 standardized different opcodes for those, but GCC hasn't been changed
yet for that.
This patch starts using DW_MACRO_define_strx and DW_MACRO_undef_strx
instead of DW_MACRO_define_strp and DW_MACRO_undef_strp when -gsplit-dwarf
-gdwarf-5 -g3. I'm not sure what to do if anything with the -gdwarf-4
-gsplit-dwarf -g3 -gno-strict-dwarf case, we've been emitting it that way
for 8 years and it is an extension, so presumably the consumers that cared
have already hacks to handle DW_MACRO_GNU_{define,undef}_indirect
differently in .debug_macro 4 sections depending on if it is
.debug_macro.dwo or .debug_macro.
Another change the patch does is that it will use
DW_MACRO_{define,undef}_str{p,x} even with -gdwarf-5 -gstrict-dwarf -g3,
for DWARF 4 we were doing that only for -gno-strict-dwarf as we've emitted
.debug_macro section only in that case.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2021-03-02 Jakub Jelinek <[email protected]>
PR debug/99319
* dwarf2out.c (output_macinfo_op): Use DW_MACRO_*_str* even with
-gdwarf-5 -gstrict-dwarf. For -gsplit-dwarf -gdwarf-5 use
DW_MACRO_*_strx instead of DW_MACRO_*_strp. Handle
DW_MACRO_define_strx and DW_MACRO_undef_strx.
(save_macinfo_strings): Use DW_MACRO_*_str* even with
-gdwarf-5 -gstrict-dwarf. Handle DW_MACRO_define_strx and
DW_MACRO_undef_strx.
--- gcc/dwarf2out.c.jj 2021-02-27 10:40:22.759330948 +0100
+++ gcc/dwarf2out.c 2021-03-01 16:14:55.150163790 +0100
@@ -28267,13 +28267,17 @@ output_macinfo_op (macinfo_entry *ref)
case DW_MACINFO_define:
case DW_MACINFO_undef:
len = strlen (ref->info) + 1;
- if (!dwarf_strict
+ if ((!dwarf_strict || dwarf_version >= 5)
&& len > (size_t) dwarf_offset_size
&& !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET
&& (debug_str_section->common.flags & SECTION_MERGE) != 0)
{
- ref->code = ref->code == DW_MACINFO_define
- ? DW_MACRO_define_strp : DW_MACRO_undef_strp;
+ if (dwarf_split_debug_info && dwarf_version >= 5)
+ ref->code = ref->code == DW_MACINFO_define
+ ? DW_MACRO_define_strx : DW_MACRO_undef_strx;
+ else
+ ref->code = ref->code == DW_MACINFO_define
+ ? DW_MACRO_define_strp : DW_MACRO_undef_strp;
output_macinfo_op (ref);
return;
}
@@ -28285,7 +28289,18 @@ output_macinfo_op (macinfo_entry *ref)
dw2_asm_output_nstring (ref->info, -1, "The macro");
break;
case DW_MACRO_define_strp:
+ dw2_asm_output_data (1, ref->code, "Define macro strp");
+ goto do_DW_MACRO_define_strpx;
case DW_MACRO_undef_strp:
+ dw2_asm_output_data (1, ref->code, "Undefine macro strp");
+ goto do_DW_MACRO_define_strpx;
+ case DW_MACRO_define_strx:
+ dw2_asm_output_data (1, ref->code, "Define macro strx");
+ goto do_DW_MACRO_define_strpx;
+ case DW_MACRO_undef_strx:
+ dw2_asm_output_data (1, ref->code, "Undefine macro strx");
+ /* FALLTHRU */
+ do_DW_MACRO_define_strpx:
/* NB: dwarf2out_finish performs:
1. save_macinfo_strings
2. hash table traverse of index_string
@@ -28302,10 +28317,6 @@ output_macinfo_op (macinfo_entry *ref)
gcc_assert (node
&& (node->form == DW_FORM_strp
|| node->form == dwarf_FORM (DW_FORM_strx)));
- dw2_asm_output_data (1, ref->code,
- ref->code == DW_MACRO_define_strp
- ? "Define macro strp"
- : "Undefine macro strp");
dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu",
(unsigned long) ref->lineno);
if (node->form == DW_FORM_strp)
@@ -28475,7 +28486,7 @@ save_macinfo_strings (void)
case DW_MACINFO_define:
case DW_MACINFO_undef:
len = strlen (ref->info) + 1;
- if (!dwarf_strict
+ if ((!dwarf_strict || dwarf_version >= 5)
&& len > (unsigned) dwarf_offset_size
&& !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET
&& (debug_str_section->common.flags & SECTION_MERGE) != 0)
@@ -28489,6 +28500,8 @@ save_macinfo_strings (void)
/* Fall through. */
case DW_MACRO_define_strp:
case DW_MACRO_undef_strp:
+ case DW_MACRO_define_strx:
+ case DW_MACRO_undef_strx:
set_indirect_string (find_AT_string (ref->info));
break;
default:
Jakub