Use search_domain::FUNCTIONS_DOMAIN when setting breakpoints
authorPedro Alves <palves@redhat.com>
Wed, 8 Nov 2017 14:22:34 +0000 (14:22 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 8 Nov 2017 16:05:46 +0000 (16:05 +0000)
commit56d87ef769e6adab27af77fa86ea294ee7c6ee72
tree40e4443a836cf084ce421af3dbfc571dc72bd127
parent1b0261195e3f11932c0f5657a74028f5814168eb
Use search_domain::FUNCTIONS_DOMAIN when setting breakpoints

While working on C++ support for wild matching, I noticed that
attaching to my system's Firefox (which uses .gdb_index), setting a
break at main and bailing, like:

  $ gdb --batch -q -p `pidof firefox` -ex "b main"

would get substancially slower.  It'd take around 20s when currently
it takes 3s.

The problem is that gdb would expand more symtabs than currently,
because Firefox has symbols named like "nsHtml5Atoms::main",
"nsGkAtoms::main", etc., which given wild matching, match.

However, these are not function symbols, [they're "(nsIAtom *)"], so
it seems silly that they'd cause expansion in the first place.

The .gdb_index code (dwarf2read.c:dw2_expand_marked_cus) filters out
symbols matches based on search_domain:

  case VARIABLES_DOMAIN:
    if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE)
      continue;
    break;
  case FUNCTIONS_DOMAIN:
    if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION)
      continue;
    break;
  case TYPES_DOMAIN:
    if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
      continue;
    break;
  default:
    break;

however, we're currently passing down search_domain::ALL_DOMAIN when
we know we're looking for functions, for no good reason.  This patch
fixes that.

It seems like search_domain is underutilized throughout, but I'll
leave using it more for another pass.

gdb/ChangeLog:
2017-11-08  Pedro Alves  <palves@redhat.com>

* linespec.c (iterate_over_all_matching_symtabs): Add
search_domain parameter.  Pass it down to expand_symtabs_matching.
(decode_objc): Request FUNCTIONS_DOMAIN symbols only.
(lookup_prefix_sym): Adjust by passing ALL_DOMAIN as
search_domain.
(add_all_symbol_names_from_pspace): Add search_domain parameter.
Pass it down.
(find_method, find_function_symbols): Request FUNCTIONS_DOMAIN
symbols.
(add_matching_symbols_to_info): Add search_domain parameter.  Pass
it down.
gdb/ChangeLog
gdb/linespec.c