https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87362

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #7)
> The following makes it work for a simple C int main() {}.  It's also a little
> bit less hacky...
> 
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c     (revision 264418)
> +++ gcc/dwarf2out.c     (working copy)
> @@ -26896,6 +26896,10 @@ dwarf2out_decl (tree decl)
>  static void
>  dwarf2out_function_decl (tree decl)
>  {
> +  if (in_lto_p)
> +    /* This helps debuggers to build a symbol table.  */
> +    if (dw_die_ref die = lookup_decl_die (decl))
> +      add_linkage_attr (die, decl);
>    dwarf2out_decl (decl);
>    call_arg_locations = NULL;
>    call_arg_loc_last = NULL;

Doesn't seem to help gdb at all.

Maybe gdb pulls in all the early CUs because of the stray DIEs we have
for optimized out functions, like

 <2><423bc64>: Abbrev Number: 5 (DW_TAG_subprogram)
    <423bc65>   DW_AT_abstract_origin: <0x3419cf1>
    <423bc69>   DW_AT_sibling     : <0x423bc73>
 <3><423bc6d>: Abbrev Number: 6 (DW_TAG_formal_parameter)
    <423bc6e>   DW_AT_abstract_origin: <0x3419cfe>
 <3><423bc72>: Abbrev Number: 0

since we create them at tree streaming time rather than when actually
outputting them (PR83941).  My idea for that is to create those lazily
somehow, like having dwarf2out_register_external_die populate an
on-the-side representation and lookup_decl_die querying that if the
DIE wasn't created already.

I also notice that breaking on a function doesn't seem to work (if there are
only inline/IPA optimized instances(?)).  gdb doesn't stop.

auto-completion also takes ages.  So whatever gdb does it isn't very
efficient ;)

Reply via email to