public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/24671] [ada] printing FAILs with "has unknown type" when  using -readnow
       [not found] <bug-24671-4717@http.sourceware.org/bugzilla/>
@ 2020-03-10 15:42 ` vries at gcc dot gnu.org
  2020-03-24  7:40 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-03-10 15:42 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=24671

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca,
                   |                            |vries at gcc dot gnu.org

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
This looks related to add_nonlocal_symbols in ada-lang.c, which uses
objfile->sf->qf->map_matching_symbols:
...
  for (objfile *objfile : current_program_space->objfiles ())
    {
      data.objfile = objfile;

      objfile->sf->qf->map_matching_symbols (objfile, lookup_name,
                                             domain, global, callback,
                                             (is_wild_match
                                              ? NULL : compare_names));

      for (compunit_symtab *cu : objfile->compunits ())
        {
          const struct block *global_block
            = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cu), GLOBAL_BLOCK);

          if (ada_add_block_renamings (obstackp, global_block, lookup_name,
                                       domain))
            data.found_sym = 1;
        }
    }

  if (num_defns_collected (obstackp) == 0 && global && !is_wild_match)
    {
      const char *name = ada_lookup_name (lookup_name);
      lookup_name_info name1 (std::string ("<_ada_") + name + '>',
                              symbol_name_match_type::FULL);

      for (objfile *objfile : current_program_space->objfiles ())
        {
          data.objfile = objfile;
          objfile->sf->qf->map_matching_symbols (objfile, name1,
                                                 domain, global, callback,
                                                 compare_names);
        }
    }
...

There are 3 types of quick functions (excluding debug_sym_quick_functions):
...
const struct quick_symbol_functions psym_functions;
const struct quick_symbol_functions dwarf2_gdb_index_functions;
const struct quick_symbol_functions dwarf2_debug_names_functions;
...

Normally we use psym_functions, and qf->map_matching_symbols is implemented by
psym_map_matching_symbols.

When using -readnow, we use dwarf2_gdb_index_functions instead, and
qf->map_matching_symbols is implemented by dw2_map_matching_symbols, which
doesn't do anything:
...
static void
dw2_map_matching_symbols
  (struct objfile *objfile,
   const lookup_name_info &name, domain_enum domain,
   int global,
   gdb::function_view<symbol_found_callback_ftype> callback,
   symbol_compare_ftype *ordered_compare)
{
  /* Currently unimplemented; used for Ada.  The function can be called if the  
     current language is Ada for a non-Ada objfile using GNU index.  As Ada     
     does not look for non-Ada symbols this function should just return.  */
}
...

Note: even if we force dwarf2_initialize_objfile to use
dw_index_kind::DEBUG_NAMES when encountering -readnow, that doesn't help either
because we basically hit the same problem in
dw2_debug_names_map_matching_symbols:
...
static void
dw2_debug_names_map_matching_symbols
  (struct objfile *objfile,
   const lookup_name_info &name, domain_enum domain,
   int global,
   gdb::function_view<symbol_found_callback_ftype> callback,
   symbol_compare_ftype *ordered_compare)
{
  struct dwarf2_per_objfile *dwarf2_per_objfile
    = get_dwarf2_per_objfile (objfile);

  /* debug_names_table is NULL if OBJF_READNOW.  */
  if (!dwarf2_per_objfile->debug_names_table)
    return;
...

So, AFAIU, it seems the root cause is that add_nonlocal_symbols does not tap
into the normal, full symtabs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ada/24671] [ada] printing FAILs with "has unknown type" when  using -readnow
       [not found] <bug-24671-4717@http.sourceware.org/bugzilla/>
  2020-03-10 15:42 ` [Bug ada/24671] [ada] printing FAILs with "has unknown type" when using -readnow vries at gcc dot gnu.org
@ 2020-03-24  7:40 ` vries at gcc dot gnu.org
  2020-04-02  6:58 ` cvs-commit at gcc dot gnu.org
  2020-04-02  6:59 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-03-24  7:40 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=24671

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
posted patch:
https://sourceware.org/pipermail/gdb-patches/2020-March/166945.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ada/24671] [ada] printing FAILs with "has unknown type" when  using -readnow
       [not found] <bug-24671-4717@http.sourceware.org/bugzilla/>
  2020-03-10 15:42 ` [Bug ada/24671] [ada] printing FAILs with "has unknown type" when using -readnow vries at gcc dot gnu.org
  2020-03-24  7:40 ` vries at gcc dot gnu.org
@ 2020-04-02  6:58 ` cvs-commit at gcc dot gnu.org
  2020-04-02  6:59 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-02  6:58 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=24671

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

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

commit 1aa98955b19676497f89112a0962f24f359ce761
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Apr 2 08:58:38 2020 +0200

    [gdb/ada] Fix -readnow FAILs

    When running test-case gdb.ada/access_to_packed_array we have:
    ...
    (gdb) print pack.a^M
    $1 = (0 => 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)^M
    ...
    but with target board readnow.exp, we have instead:
    ...
    (gdb) print pack.a^M
    'pack.a' has unknown type; cast it to its declared type^M
    ...

    The symbol is normally found by the map_matching_symbols call in
    ada-lang.c:add_nonlocal_symbols:
    ...
      for (objfile *objfile : current_program_space->objfiles ())
        {
          data.objfile = objfile;

          objfile->sf->qf->map_matching_symbols (objfile, lookup_name,
                                                 domain, global, callback,
                                                 (is_wild_match
                                                  ? NULL : compare_names));
    ...
    which maps onto psym_map_matching_symbols.

    Function psym_map_matching_symbols iterates over all the partial symtabs,
    and:
    - if not expanded, searches in the partial symtab:
      - if not found, continues to the next
      - if found, expands into full symtab
    - searches in the full symtab

    However, with -readnow the call maps onto dw2_map_matching_symbols instead,
    which is unimplemented, and consequently no symbol is found.

    Fix this by detecting -readnow in dw2_map_matching_symbols, and handling
that
    appropriately given that partial symtabs are not present, and full symtabs
    are: iterate over all the symtabs and search them.

    Tested on x86_64-linux, with native and target board -readnow.

    This removes 217 FAILs with board -readnow.

    gdb/ChangeLog:

    2020-04-02  Tom de Vries  <tdevries@suse.de>

            PR ada/24671
            * dwarf2/read.c (dw2_map_matching_symbols): Handle -readnow.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug ada/24671] [ada] printing FAILs with "has unknown type" when  using -readnow
       [not found] <bug-24671-4717@http.sourceware.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-04-02  6:58 ` cvs-commit at gcc dot gnu.org
@ 2020-04-02  6:59 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-02  6:59 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=24671

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch committed, marking resolved-fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-02  6:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-24671-4717@http.sourceware.org/bugzilla/>
2020-03-10 15:42 ` [Bug ada/24671] [ada] printing FAILs with "has unknown type" when using -readnow vries at gcc dot gnu.org
2020-03-24  7:40 ` vries at gcc dot gnu.org
2020-04-02  6:58 ` cvs-commit at gcc dot gnu.org
2020-04-02  6:59 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).