public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty
@ 2021-08-01 18:04 Tom de Vries
  2021-08-02 13:29 ` Simon Marchi
  2021-08-02 14:15 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Tom de Vries @ 2021-08-01 18:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi, Tom Tromey

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));
+    }
+
   return 1;
 }
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
index 7b46c93d9b5..c3ae7537346 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
@@ -148,16 +148,7 @@ foreach_with_prefix ranges_sect {ranges rnglists} {
 	    }
 	}
 
-	if { $have_complaint } {
-	    pass $test
-	} else {
-	    set index [have_index $lib1]
-	    if { $index == "gdb_index" } {
-		kfail symtab/28159 $test
-	    } else {
-		fail $test
-	    }
-	}
+	gdb_assert { $have_complaint } $test
     }
 
     if { ! $readnow_p } {
@@ -173,16 +164,7 @@ foreach_with_prefix ranges_sect {ranges rnglists} {
 	gdb_load $lib1
 	set test "Zero address complaint - unrelocated - psymtab"
 	set have_complaint [regexp $re.* $gdb_file_cmd_msg]
-	if { $have_complaint } {
-	    pass $test
-	} else {
-	    set index [have_index $lib1]
-	    if { $index == "gdb_index" } {
-		kfail symtab/28159 $test
-	    } else {
-		fail $test
-	    }
-	}
+	gdb_assert { $have_complaint } $test
     }
 
     if { ! $readnow_p } {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty
  2021-08-01 18:04 [PATCH][gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty Tom de Vries
@ 2021-08-02 13:29 ` Simon Marchi
  2021-08-02 14:15 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2021-08-02 13:29 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches; +Cc: Tom Tromey

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty
  2021-08-01 18:04 [PATCH][gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty Tom de Vries
  2021-08-02 13:29 ` Simon Marchi
@ 2021-08-02 14:15 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2021-08-02 14:15 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gdb-patches, Simon Marchi, Tom Tromey

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> I don't see the need to propagate to gdb-11-branch, but perhaps I'm
Tom> wrong there?

It doesn't seem to be a regression, or a common situation, so I think
it's fine to leave it out.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-02 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-01 18:04 [PATCH][gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty Tom de Vries
2021-08-02 13:29 ` Simon Marchi
2021-08-02 14:15 ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).