public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>, Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 1/2] gdb/testsuite: fix readnow detection
Date: Thu,  8 Dec 2022 15:38:32 +0000	[thread overview]
Message-ID: <69eaee80b5b0a72649d6046d9d63d90938e67e14.1670513780.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1670513780.git.aburgess@redhat.com>

The following commit broke the readnow detection in the testsuite:

  commit dfaa040b440084dd73ebd359326752d5f44fc02c
  Date:   Mon Mar 29 18:31:31 2021 -0600

      Remove some "OBJF_READNOW" code from dwarf2_debug_names_index

The testsuite checks if GDB was started with the -readnow flag by
using the 'maintenance print objfiles' command, and looking for the
string 'faked for "readnow"' in the output.  This is implemented in
two helper procs `readnow` (gdb.exp) and `mi_readnow` (mi-support.exp).

The following tests all currently depend on this detection:

  gdb.base/maint.exp
  gdb.cp/nsalias.exp
  gdb.dwarf2/debug-aranges-duplicate-offset-warning.exp
  gdb.dwarf2/dw2-stack-boundary.exp
  gdb.dwarf2/dw2-zero-range.exp
  gdb.dwarf2/gdb-index-nodebug.exp
  gdb.mi/mi-info-sources.exp
  gdb.python/py-symbol.exp
  gdb.rust/traits.exp

The following test also includes detection of 'readnow', but does the
detection itself by checking $::GDBFLAGS for the readnow flag:

  gdb.opt/break-on-_exit.exp

The above commit removed from GDB the code that produced the 'faked
for "readnow"' string, as a consequence the testsuite can no longer
correctly spot when readnow is in use, and many of the above tests
will fail (at least partially).

When looking at the above tests, I noticed that gdb.rust/traits.exp
does call `readnow`, but doesn't actually use the result, so I've
removed the readnow call, this simplifies the next part of this patch
as gdb.rust/traits.exp was the only place an extra regexp was passed
to the readnow call.

Next I have rewritten `readnow` to check the $GDBFLAGS for the
-readnow flag, and removed the `maintenance print objfiles` check.  At
least for all the tests above, when using the readnow board, this is
good enough to get everything passing again.

For the `mi_readnow` proc, I changed this to just call `readnow` from
gdb.exp, I left the mi_readnow name in place - in the future it might
be the case that we want to do some different checks here.

Finally, I updated gdb.opt/break-on-_exit.exp to call the `readnow`
proc.

With these changes, all of the tests listed above now pass correctly
when using the readnow board.
---
 gdb/testsuite/gdb.opt/break-on-_exit.exp |  3 +--
 gdb/testsuite/gdb.rust/traits.exp        |  2 --
 gdb/testsuite/lib/gdb.exp                | 30 ++++--------------------
 gdb/testsuite/lib/mi-support.exp         | 28 ++++------------------
 4 files changed, 10 insertions(+), 53 deletions(-)

diff --git a/gdb/testsuite/gdb.opt/break-on-_exit.exp b/gdb/testsuite/gdb.opt/break-on-_exit.exp
index 7c2fda6af69..3d18cd70bb9 100644
--- a/gdb/testsuite/gdb.opt/break-on-_exit.exp
+++ b/gdb/testsuite/gdb.opt/break-on-_exit.exp
@@ -36,8 +36,7 @@
 standard_testfile
 
 # See if we have target board readnow.exp or similar.
-if { [lsearch -exact $GDBFLAGS -readnow] != -1 \
-	 || [lsearch -exact $GDBFLAGS --readnow] != -1 } {
+if {[readnow]} {
     untested "--readnever not allowed in combination with --readnow"
     return -1
 }
diff --git a/gdb/testsuite/gdb.rust/traits.exp b/gdb/testsuite/gdb.rust/traits.exp
index aa45e64b877..949e7cb919e 100644
--- a/gdb/testsuite/gdb.rust/traits.exp
+++ b/gdb/testsuite/gdb.rust/traits.exp
@@ -43,7 +43,5 @@ if {![runto ${srcfile}:$line]} {
     return -1
 }
 
-set readnow_p [readnow $binfile]
-
 gdb_test "print *td" " = 23.5"
 gdb_test "print *tu" " = 23"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 008f59b9f30..132d538957c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8553,32 +8553,12 @@ gdb_caching_proc supports_fcf_protection {
   } executable "additional_flags=-fcf-protection=full"]
 }
 
-# Return 1 if symbols were read in using -readnow.  Otherwise, return 0.
+# Return true if symbols were read in using -readnow.  Otherwise,
+# return false.
 
-proc readnow { args } {
-    if { [llength $args] == 1 } {
-	set re [lindex $args 0]
-    } else {
-	set re ""
-    }
-
-    set readnow_p 0
-    # Given the listing from the following command can be very verbose, match
-    # the patterns line-by-line.  This prevents timeouts from waiting for
-    # too much data to come at once.
-    set cmd "maint print objfiles $re"
-    gdb_test_multiple $cmd "" -lbl {
-	-re "\r\n.gdb_index: faked for \"readnow\"" {
-	    # Record the we've seen the above pattern.
-	    set readnow_p 1
-	    exp_continue
-	}
-	-re -wrap "" {
-	    # We don't care about any other input.
-	}
-    }
-
-    return $readnow_p
+proc readnow { } {
+    return [expr {[lsearch -exact $::GDBFLAGS -readnow] != -1
+		  || [lsearch -exact $::GDBFLAGS --readnow] != -1}]
 }
 
 # Return index name if symbols were read in using an index.
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 18a2a04def8..2dccb8924b1 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -671,32 +671,12 @@ proc mi_gdb_load { arg } {
     return 0
 }
 
-# Return 1 if symbols were read in using -readnow.  Otherwise, return 0.
-# Based on readnow from lib/gdb.exp.
+# Return true if symbols were read in using -readnow.  Otherwise,
+# return false.
 
 proc mi_readnow { args } {
-    global mi_gdb_prompt
-
-    if { [llength $args] == 1 } {
-	set re [lindex $args 0]
-    } else {
-	set re ""
-    }
-
-    set readnow_p 0
-    set cmd "maint print objfiles $re"
-    send_gdb "$cmd\n"
-    gdb_expect {
-	-re ".gdb_index: faked for ..readnow.." {
-	    # Record that we've seen the above pattern.
-	    set readnow_p 1
-	    exp_continue
-	}
-	-re "\\^done\r\n$mi_gdb_prompt$" {
-	}
-    }
-
-    return $readnow_p
+    # Just defer to gdb.exp.
+    return [readnow]
 }
 
 # mi_gdb_test COMMAND [PATTERN [MESSAGE [IPATTERN]]] -- send a command to gdb;
-- 
2.25.4


  reply	other threads:[~2022-12-08 15:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08 15:38 [PATCH 0/2] New test for slow DWARF reader issue Andrew Burgess
2022-12-08 15:38 ` Andrew Burgess [this message]
2022-12-08 15:38 ` [PATCH 2/2] gdb/testsuite: new test for recent dwarf " Andrew Burgess
2022-12-09 18:18   ` Tom Tromey
2022-12-09 19:24     ` Andrew Burgess
2022-12-14 14:47       ` Luis Machado
2022-12-15 11:22         ` Andrew Burgess
2022-12-19 13:20           ` Luis Machado
2022-12-19 13:52             ` Andrew Burgess
2022-12-20  8:43               ` tdevries
2022-12-20 10:32                 ` Andrew Burgess
2022-12-20 13:20                   ` Andrew Burgess
2022-12-20 14:04                     ` Luis Machado
2022-12-20 14:54                     ` tdevries
2022-12-24 16:05                       ` Andrew Burgess
2022-12-09 18:18 ` [PATCH 0/2] New test for slow DWARF " Tom Tromey
2022-12-14 10:25   ` Andrew Burgess

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=69eaee80b5b0a72649d6046d9d63d90938e67e14.1670513780.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --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).