[PATCH][gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty

Simon Marchi simon.marchi@polymtl.ca
Mon Aug 2 13:29:47 GMT 2021


On 2021-08-01 2:04 p.m., Tom de Vries wrote:
> Hi,
> 
> When reading a .gdb_index that contains a non-empty symbol table with only
> empty entries, gdb doesn't recognize it as empty.
> 
> Fix this by recognizing that the constant pool is empty, and then setting the
> symbol table to empty.
> 
> Tested on x86_64-linux.
> 
> Any comments?
> 
> I don't see the need to propagate to gdb-11-branch, but perhaps I'm wrong there?
> 
> Thanks,
> - Tom
> 
> [gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty
> 
> gdb/ChangeLog:
> 
> 2021-08-01  Tom de Vries  <tdevries@suse.de>
> 
> 	PR symtab/28159
> 	* dwarf2/read.c (read_gdb_index_from_buffer): Handle symbol table
> 	filled with empty entries.
> 
> gdb/testsuite/ChangeLog:
> 
> 2021-08-01  Tom de Vries  <tdevries@suse.de>
> 
> 	PR symtab/28159
> 	* gdb.dwarf2/dw2-zero-range.exp: Remove kfail.
> 
> ---
>  gdb/dwarf2/read.c                           |  7 +++++++
>  gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp | 22 ++--------------------
>  2 files changed, 9 insertions(+), 20 deletions(-)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index de84c47b626..a937fbef1cc 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -2777,6 +2777,13 @@ to use the section anyway."),
>    ++i;
>    map->constant_pool = buffer.slice (metadata[i]);
>  
> +  if (map->constant_pool.empty () && !map->symbol_table.empty ())
> +    {
> +      map->symbol_table
> +	= offset_view (gdb::array_view<const gdb_byte> (symbol_table,
> +							symbol_table));
> +    }

That probably warrants a little comment.

Otherwise, LGTM.

Simon


More information about the Gdb-patches mailing list