gdb: Catch exceptions when accessing source cache
The source_cache::get_line_charpos function can currently throw an
exception if the source file is missing, which doesn't match the
expected behaviour documented in the functions header file. The
documented behaviour is to return false on failure, and this is how
the function appears to be used throughout GDB.
I spotted this in the 'info source' command, currently for a missing
source file you'll see something like this:
(gdb) info source
Current source file is /path/to/src/file.c
Compilation directory is /path/to/build/
/path/to/src/file.c: No such file or directory.
(gdb)
After this patch we see this:
(gdb) info source
Current source file is /path/to/src/file.c
Compilation directory is /path/to/build/
Source language is c.
Producer is COMPILER VERSION AND FLAGS.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.
We don't currently indicate that the source file can't be found, and
maybe that would be something worth adding in the future.
gdb/ChangeLog:
* source-cache.c (source_cache::get_line_charpos): Catch
exceptions and return false, this matches the behaviour documented
in the header file.
gdb/testsuite/ChangeLog:
* gdb.base/list-missing-source.exp: New file.