diff options
author | Tom Tromey <tromey@adacore.com> | 2019-07-22 14:31:43 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-08-06 08:04:33 -0600 |
commit | cb44333d99548bbbf7be06387a31877ee9322ab4 (patch) | |
tree | 8ac25ea16ebbc5556d5f1e24940e729169d08bb8 /gdb/symtab.h | |
parent | 872dceaaff9b54764b8f510b549497b9d904b136 (diff) | |
download | binutils-gdb-cb44333d99548bbbf7be06387a31877ee9322ab4.tar.gz |
Add file offsets to the source cache
Currently, gdb stores the number of lines and an array of file offsets
for the start of each line in struct symtab. This patch moves this
information to the source cache. This has two benefits.
First, it allows gdb to read a source file less frequently.
Currently, a source file may be read multiple times: once when
computing the file offsets, once when highlighting, and then pieces
may be read again while printing source lines. With this change, the
file is read once for its source text and file offsets; and then
perhaps read again if it is evicted from the cache.
Second, if multiple symtabs cover the same source file, then this will
share the file offsets between them. I'm not sure whether this
happens in practice.
gdb/ChangeLog
2019-08-06 Tom Tromey <tromey@adacore.com>
* annotate.c (annotate_source_line): Use g_source_cache.
* source-cache.c (source_cache::get_plain_source_lines): Change
parameters. Populate m_offset_cache.
(source_cache::ensure): New method.
(source_cache::get_line_charpos): New method.
(extract_lines): Move lower. Change parameters.
(source_cache::get_source_lines): Move lower.
* source-cache.h (class source_cache): Update comment.
<get_line_charpos>: New method.
<get_source_lines>: Update comment.
<clear>: Clear m_offset_cache.
<get_plain_source_lines>: Change parameters.
<ensure>: New method
<m_offset_cache>: New member.
* source.c (forget_cached_source_info_for_objfile): Update.
(info_source_command): Use g_source_cache.
(find_source_lines, open_source_file_with_line_charpos): Remove.
(print_source_lines_base, search_command_helper): Use g_source_cache.
* source.h (open_source_file_with_line_charpos): Don't declare.
* symtab.h (struct symtab) <nlines, line_charpos>: Remove.
* tui/tui-source.c (tui_source_window::do_scroll_vertical):
Use g_source_cache.
Diffstat (limited to 'gdb/symtab.h')
-rw-r--r-- | gdb/symtab.h | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/gdb/symtab.h b/gdb/symtab.h index 9880ecc4c53..f2d59a9f90b 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1321,16 +1321,6 @@ struct symtab const char *filename; - /* Total number of lines found in source file. */ - - int nlines; - - /* line_charpos[N] is the position of the (N-1)th line of the - source file. "position" means something we can lseek() to; it - is not guaranteed to be useful any other way. */ - - int *line_charpos; - /* Language of this source file. */ enum language language; |