gdb/testsuite: fix gdb.base/with.exp failure with, native-extended-gdbserver (was: New FAIL on gdb.base/with.exp on native-extended-gdbserver)

Message ID 0761e02d-dd1c-22fe-3d10-4ae5849cdd73@simark.ca
State New
Headers show
Series
  • gdb/testsuite: fix gdb.base/with.exp failure with, native-extended-gdbserver (was: New FAIL on gdb.base/with.exp on native-extended-gdbserver)
Related show

Commit Message

Simon Marchi May 11, 2020, 2:54 p.m.
On 2019-08-02 7:24 p.m., Sergio Durigan Junior wrote:
> On Wednesday, July 03 2019, Pedro Alves wrote:

> 

>> On 6/18/19 1:38 AM, Pedro Alves wrote:

>>>

>>>  (gdb) help with

>>>  Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.

>>>  Usage: with SETTING [VALUE] [-- COMMAND]

>>>  Usage: w SETTING [VALUE] [-- COMMAND]

>>>  With no COMMAND, repeats the last executed command.

>>>  SETTING is any setting settable with the "set" command.

>>>  E.g.:

>>>    with language pascal -- print obj

>>>    with print elements unlimited -- print obj

>>>

>>

>> I've merged this in now.

> 

> Hi Pedro,

> 

> First of all, thanks for the nice feature.

> 

> BuildBot has unfortunately caught a new failure on gdb.base/with.exp

> when run agains native-extended-gdbserver:

> 

>   https://sourceware.org/ml/gdb-testers/2019-q3/msg00213.html

> 

>   new FAIL: gdb.base/with.exp: repeat: reinvoke with no previous command to relaunch

> 

> I've also found it here when preparing a new Fedora GDB release.

> 

> Thanks,


Here's a patch for this

From 4927107e4d99cc81e36c699d5716ea8d76fb7101 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@efficios.com>

Date: Mon, 11 May 2020 10:17:38 -0400
Subject: [PATCH] gdb/testsuite: fix gdb.base/with.exp failure with
 native-extended-gdbserver

I see this failure when running:

    $ make check TESTS="gdb.base/with.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver"
    FAIL: gdb.base/with.exp: repeat: reinvoke with no previous command to relaunch

This test issues `with language ada` and expects GDB to complain that
there is no command to repeat (either because the history is empty or
the previous command is non-repeatable).  However, with the
native-extended-gdbserver board, the `set remote exec-file` command is
issued during `clean_restart`, and it is a repeatable command, so GDB
doesn't print the expected message:

    (gdb) set remote exec-file /home/smarchi/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/with/with^M
    (gdb) with language ada^M
    (gdb) FAIL: gdb.base/with.exp: repeat: reinvoke with no previous command to relaunch

Fix it by using gdb_spawn instead of clean_restart.  gdb_spawn fires up
GDB and does not issue any command, not even `set height` and `set
width`.

I've also added a separate test for trying to repeat a non-repeatable
command, since that's a slightly different case than trying to repeat
without history.

gdb/testsuite/ChangeLog:

	* gdb.base/with.exp: Start GDB with gdb_spawn for repeat test.
	Add test for trying to repeat a non-repeatable command.
---
 gdb/testsuite/gdb.base/with.exp | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

-- 
2.26.2

Patch

diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp
index a60ccf307468..e86e49618a7f 100644
--- a/gdb/testsuite/gdb.base/with.exp
+++ b/gdb/testsuite/gdb.base/with.exp
@@ -175,15 +175,22 @@  with_test_prefix "user-defined" {

 # Check repeating.
 with_test_prefix "repeat" {
-    clean_restart $binfile
+    # Start GDB like this (as opposed to gdb_start/clean_restart) for the first
+    # test to make sure no command is issued after starting the GDB process.
+    gdb_exit
+    gdb_spawn
+    gdb_test "" "" "wait for initial prompt"

-    # "with" with no command reinvokes the previous command.
+    # "with" with no command in the history.
     gdb_test "with language ada" \
 	"No previous command to relaunch" \
 	"reinvoke with no previous command to relaunch"

-    gdb_test "print g_s" " = {a = 1, b = 2, c = 3}"
+    # For the rest of this scope we need to have the binary loaded.
+    clean_restart $binfile

+    # "with" with no command reinvokes the previous command.
+    gdb_test "print g_s" " = {a = 1, b = 2, c = 3}"
     gdb_test "with language ada" \
 	" = \\(a => 1, b => 2, c => 3\\)" \
 	"reinvoke with language"
@@ -202,6 +209,12 @@  with_test_prefix "repeat" {
 	    pass $test
 	}
     }
+
+    # "with" after a non-repeatable command.
+    gdb_test "display 123" "1: 123 = 123"
+    gdb_test "with language ada" \
+	"No previous command to relaunch" \
+	"reinvoke after a non-repeatable command"
 }

 # Basic run control.