Bug 32511

Summary: Ada import symbols not created by DWARF indexer
Product: gdb Reporter: Tom Tromey <tromey>
Component: symtabAssignee: Tom Tromey <tromey>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: HEAD   
Target Milestone: 18.1   
Host: Target:
Build: Last reconfirmed:
Project(s) to access: ssh public key:
Bug Depends on:    
Bug Blocks: 29366, 16998    

Description Tom Tromey 2025-01-02 20:38:43 UTC
If you add some "clean_restart" calls to the
test case gdb.ada/import.exp, it will cause failures.
This happens because the DWARF indexer does not
create symbols for these DIEs.
The test currently works because the CUs in question
are already expanded.
Comment 1 Tom Tromey 2025-01-19 00:00:36 UTC
I have a patch for this.

Probably the Ada compiler should be changed to emit these
using imported declarations, though.  The current approach
seems a bit fragile maybe.
Comment 2 Sourceware Commits 2025-09-10 22:17:41 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a7343246f5319e67e7e96ba98596c94cda115560

commit a7343246f5319e67e7e96ba98596c94cda115560
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Jan 2 13:40:27 2025 -0700

    Ada import functions not in index
    
    The cooked index does not currently contain entries for Ada import
    functions.  This means that whether or not these are visible to
    "break" depends on which CUs were previously expanded -- clearly a
    bug.
    
    This patch fixes the issue.  I think the comments in the patch explain
    the fix reasonably well.
    
    Perhaps one to-do item here is to change GNAT to use
    DW_TAG_imported_declaration for these imports.  This may eventually
    let us remove some of the current hacks.
    
    This version includes a fix from Simon to initialize the new member.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32511
    Acked-By: Simon Marchi <simon.marchi@efficios.com>
Comment 3 Tom Tromey 2025-09-10 23:58:49 UTC
Fixed.

The Ada compiler should still be changed, and gdb should
handle imported declarations more generically, but that's
a bigger and separate project.