gdb: add an extension language hook for missing debug info
This commit adds a new extension_language_ops hook which allows an
extension to handle the case where GDB can't find a separate debug
information file for a particular objfile.
This commit doesn't actually implement the hook for any of GDB's
extension languages, the next commit will do that. This commit just
adds support for the hook to extension-priv.h and extension.[ch], and
then reworks symfile-debug.c to call the hook.
Right now the hook will always return its default value, which means
GDB should do nothing different. As such, there should be no user
visible changes after this commit.
I'll give a brief description of what the hook does here so that we
can understand the changes in symfile-debug.c. The next commit adds a
Python implementation for this new hook, and gives a fuller
description of the new functionality.
Currently, when looking for separate debug information GDB tries three
things, in this order:
1. Use the build-id to find the required debug information,
2. Check for .gnu_debuglink section and use that to look up the
required debug information,
3. Check with debuginfod to see if it can supply the required
information.
The new extension_language_ops::handle_missing_debuginfo hook is
called if all three steps fail to find any debug information. The
hook has three possible return values:
a. Nothing, no debug information is found, GDB continues without the
debug information for this objfile. This matches the current
behaviour of GDB, and is the default if nothing is implementing this
new hook,
b. Install debug information into a location that step #1 or #2
above would normally check, and then request that GDB repeats steps
#1 and #2 in the hope that GDB will now find the debug information.
If the debug information is still not found then GDB carries on
without the debug information. If the debug information is found
the GDB loads it and carries on,
c. Return a filename for a file containing the required debug
information. GDB loads the contents of this file and carries on.
The changes in this commit mostly involve placing the core of
objfile::find_and_add_separate_symbol_file into a loop which allows
for steps #1 and #2 to be repeated.
We take care to ensure that debuginfod is only queried once, the first
time through. The assumption is that no extension is going to be able
to control the replies from debuginfod, so there's no point making a
second request -- and as these requests go over the network, they
could potentially be slow.
The warnings that find_and_add_separate_symbol_file collects are
displayed only once assuming that no debug information is found. If
debug information is found, even after the extension has operated,
then the warnings are not shown; remember, these are warnings from GDB
about failure to find any suitable debug information, so it makes
sense to hide these if debug information is found.
Approved-By: Tom Tromey <tom@tromey.com>