gdb/17394: cannot put breakpoint only in selected ASM file.
authorMihail-Marian Nistor <mihail.nistor@freescale.com>
Sat, 20 Dec 2014 16:04:44 +0000 (11:04 -0500)
committerJoel Brobecker <brobecker@adacore.com>
Sat, 20 Dec 2014 16:32:25 +0000 (11:32 -0500)
commit87186c6a5ccf857d7f4e55478dda3aa06387c3c4
treea85e9b9aca0ef2e2645846deeaf4395dd49cc4c6
parentbd040da1dbb7e6640440f306ddf993af98441851
gdb/17394: cannot put breakpoint only in selected ASM file.

This patch fixes a problem when trying to insert a breakpoint on
a specific symbol defined in a specific file, eg:

    break foo.c:func

This currently works for files in C/C++/Ada, etc, but doesn't always
work for Asm files. Analysis of the problem showed that this related
to a limitation in gas, which does not generate debug info for functions/
symbols.  Thus, we have a symtab for the file ("info sources" shows
the file), but it contains no symbols.

When find_linespec_symbols is called in linespec_parse_basic, it calls
find_function_symbols, which uses add_matching_symbols_to_info to
collect all matching symbols.

That function does [pardon any mangled formatting]:

  for (ix = 0; VEC_iterate (symtab_ptr, info->file_symtabs, ix, elt); ++ix)
    {
      if (elt == NULL)
        {
          iterate_over_all_matching_symtabs (info->state, name, VAR_DOMAIN,
                                             collect_symbols, info,
                                             pspace, 1);
          search_minsyms_for_name (info, name, pspace);
        }
      else if (pspace == NULL || pspace == SYMTAB_PSPACE (elt))
        {
          /* Program spaces that are executing startup should have
             been filtered out earlier.  */
          gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
          set_current_program_space (SYMTAB_PSPACE (elt));
          iterate_over_file_blocks (elt, name, VAR_DOMAIN,
                                    collect_symbols, info);
        }
    }

This iterates over the symtabs. In the failing use case, ELT is
non-NULL (points to the symtab for the .s file), so it calls
iterate_over_file_blocks. Herein is where the problem exists: it is
assumed that if NAME exists, it must exist in the given symtab -- a
reasonable assumption for "normal" (non-asm) cases. It never searches
minimal symbols (or in the global default symtab).

This patch fixes the problem by doing so. It is important to note that
iterating over minsyms is fairly expensive, so this patch only adds
that extra search if the language is language_asm and
iterate_over_file_blocks returns no symbols.

gdb/ChangeLog:
2014-12-20  Keith Seitz  <keiths@redhat.com>
            Mihail-Marian Nistor  <mihail.nistor@freescale.com>

        PR gdb/17394
        * linespec.c (struct collect_minsyms): Add new member `symtab'.
        (add_minsym): Handle cases where info.symtab is non-NULL.
        (search_minsyms_for_name): Add new parameter `symtab'.
        Handle limiting searches to a specific symtab.
        (add_matching_symtabs_to_info): Search through minimal symbols
        for language_asm files for which no new symbols are found.

gdb/testsuite/ChangeLog:
2014-12-20  Mihail-Marian Nistor  <mihail.nistor@freescale.com>

        PR gdb/17394
        * gdb.linespec/break-asm-file.c: New file.
        * gdb.linespec/break-asm-file.exp: New file.
        * gdb.linespec/break-asm-file0.s: New file.
        * gdb.linespec/break-asm-file1.s: New file.
gdb/ChangeLog
gdb/linespec.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.linespec/break-asm-file.c [new file with mode: 0644]
gdb/testsuite/gdb.linespec/break-asm-file.exp [new file with mode: 0644]
gdb/testsuite/gdb.linespec/break-asm-file0.s [new file with mode: 0644]
gdb/testsuite/gdb.linespec/break-asm-file1.s [new file with mode: 0644]
This page took 0.024718 seconds and 4 git commands to generate.