diff options
author | Matheus Branco Borella <dark.ryu.550@gmail.com> | 2023-10-10 10:26:40 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-10-10 10:26:40 +0200 |
commit | 8b9c08eddac038663b8f5ede4b4d24e441a6d8a3 (patch) | |
tree | 828d9bed8c1ee0e66bec726788ce2c3fab520063 /gdb/doc | |
parent | d883c61283a547788292f94633799303fd34080c (diff) | |
download | gdb-8b9c08eddac038663b8f5ede4b4d24e441a6d8a3.zip gdb-8b9c08eddac038663b8f5ede4b4d24e441a6d8a3.tar.gz gdb-8b9c08eddac038663b8f5ede4b4d24e441a6d8a3.tar.bz2 |
[gdb/symtab] Add name_of_main and language_of_main to the DWARF index
This patch adds a new section to the DWARF index containing the name
and the language of the main function symbol, gathered from
`cooked_index::get_main`, if available. Currently, for lack of a better name,
this section is called the "shortcut table". The way this name is both saved and
applied upon an index being loaded in mirrors how it is done in
`cooked_index_functions`, more specifically, the full name of the main function
symbol is saved and `set_objfile_main_name` is used to apply it after it is
loaded.
The main use case for this patch is in improving startup times when dealing with
large binaries. Currently, when an index is used, GDB has to expand symtabs
until it finds out what the language of the main function symbol is. For some
large executables, this may take a considerable amount of time to complete,
slowing down startup. This patch bypasses that operation by having both the name
and language of the main function symbol be provided ahead of time by the index.
In my testing (a binary with about 1.8GB worth of DWARF data) this change brings
startup time down from about 34 seconds to about 1.5 seconds.
When testing the patch with target board cc-with-gdb-index, test-case
gdb.fortran/nested-funcs-2.exp starts failing, but this is due to a
pre-existing issue, filed as PR symtab/30946.
Tested on x86_64-linux, with target board unix and cc-with-gdb-index.
PR symtab/24549
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24549
Approved-By: Tom de Vries <tdevries@suse.de>
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/gdb.texinfo | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 4932e49..db1a82e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -49663,13 +49663,14 @@ unless otherwise noted: @enumerate @item -The version number, currently 8. Versions 1, 2 and 3 are obsolete. +The version number, currently 9. Versions 1, 2 and 3 are obsolete. Version 4 uses a different hashing function from versions 5 and 6. Version 6 includes symbols for inlined functions, whereas versions 4 and 5 do not. Version 7 adds attributes to the CU indices in the symbol table. Version 8 specifies that symbols from DWARF type units (@samp{DW_TAG_type_unit}) refer to the type unit's symbol table and not the -compilation unit (@samp{DW_TAG_comp_unit}) using the type. +compilation unit (@samp{DW_TAG_comp_unit}) using the type. Version 9 adds +the name and the language of the main function to the index. @value{GDBN} will only read version 4, 5, or 6 indices by specifying @code{set use-deprecated-index-sections on}. @@ -49691,6 +49692,9 @@ The offset, from the start of the file, of the address area. The offset, from the start of the file, of the symbol table. @item +The offset, from the start of the file, of the shortcut table. + +@item The offset, from the start of the file, of the constant pool. @end enumerate @@ -49766,6 +49770,21 @@ don't currently have a simple description of the canonicalization algorithm; if you intend to create new index sections, you must read the code. +@item The shortcut table +This is a data structure with the following fields: + +@table @asis +@item Language of main +An @code{offset_type} value indicating the language of the main function as a +@code{DW_LANG_} constant. This value will be zero if main function information +is not present. + +@item Name of main +An @code{offset_type} value indicating the offset of the main function's name +in the constant pool. This value must be ignored if the value for the language +of main is zero. +@end table + @item The constant pool. This is simply a bunch of bytes. It is organized so that alignment is correct: CU vectors are stored first, followed by |