public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>, Tom Tromey <tom@tromey.com>
Subject: [PATCH][gdb/symtab] Recognize .gdb_index symbol table with empty entries as empty
Date: Sun, 1 Aug 2021 20:04:02 +0200	[thread overview]
Message-ID: <20210801180400.GA9164@delia> (raw)

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 } {

             reply	other threads:[~2021-08-01 18:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-01 18:04 Tom de Vries [this message]
2021-08-02 13:29 ` Simon Marchi
2021-08-02 14:15 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210801180400.GA9164@delia \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).