gdb: change default objfile iteration order to start with current objfile

The current default objfile search strategy, defined both in
solib_ops::iterate_over_objfiles_in_search_order (when the solib_ops
hasn't overridden it) and in
program_space::iterate_over_objfiles_in_search_order (when there is no
solib_ops in the program space, for some reason), is to scan the objfile
list linearly.

program_space::iterate_over_objfiles_in_search_order:

    for (auto &objfile : this->objfiles ())
      if (cb (&objfile))
        return;

solib_ops::iterate_over_objfiles_in_search_order:

    for (objfile &objfile : m_pspace->objfiles ())
      if (cb (&objfile))
        return;

The following patch adds support for multiple concurrent solib_ops in a
program space.  Everything that deals with an solib_ops needs to be
adapted to deal with multiple solib_ops, including
program_space::iterate_over_objfiles_in_search_order.  What I came up
with for that method introduces a change in behavior where the current
objfile will always be searched first.  Rather than hide the change in
behavior in that big patch, do it in this preparatory patch, in the hope
that any potential problems it causes can be more easily bisected and
analyzed.

Concretely, the change is to check the current objfile first, in the two
spots:

    if (current_objfile != nullptr && cb (current_objfile))
      return;

This happens to be what windows_solib_ops did, so remove that
specialization.

svr4_solib_ops already has its own iterate_over_objfiles_in_search_order
that conditionally checks the current objfile first, based on the
DT_SYMBOLIC dynamic tag.  So it is not affected by this change.

The solib_ops potentially affected by this change are (we know that
rocm_solib_ops doesn't care):

 - frv_solib_ops
 - target_solib_ops
 - darwin_solib_ops
 - dsbt_solib_ops
 - aix_solib_ops

I don't really know if searching objfiles in order (so, main objfile
first typically) is essential for any of these solib_ops.
Intuitively, searching the current objfile first makes sense, unless
there is some fancy symbol interposition happening, in which case that
solib_ops should probably implement a custom
iterate_over_objfiles_in_search_order.

Change-Id: I58195af6b53ca202e6061a5f36d5f74e1a0d5c17
Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17003
3 files changed