gdb: Catch exceptions when accessing source cache
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sat, 7 Sep 2019 23:05:22 +0000 (00:05 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 17 Sep 2019 19:53:32 +0000 (15:53 -0400)
commit67f3ed6afef86d08ef9989cc251eac585e9ef9cf
treeb4a93b3ab7485c8f1dbf8b426463f9056502cbf6
parent743321899674e03cf572fcfeb6c7705aded7c9a5
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.
gdb/ChangeLog
gdb/source-cache.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/list-missing-source.exp [new file with mode: 0644]
This page took 0.025881 seconds and 4 git commands to generate.