From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id C32563858D35 for ; Wed, 21 Jun 2023 13:31:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C32563858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E3CAF21D3A for ; Wed, 21 Jun 2023 13:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687354318; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=asCogU99TpxqmRmQE2PBnTa7DEnr3NIsFhYpz7TNeyw=; b=p7MHqTquW5tf1plVm1rwK6I4fT2qaSTrXQy6kJNrvNNB3FbXnYWUiaBrUZQ++SaoyjQlqL jbB28pQwRjNdFX0CKpuUHuBbw8zFpHJ7eN7Os+WZxPvFDg5FUi3SE7yhPE6n2W48Te2OQ6 5HFPw4UT3qt1T6kHcv7e3DVZs13qIQ4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687354318; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=asCogU99TpxqmRmQE2PBnTa7DEnr3NIsFhYpz7TNeyw=; b=P/znbksoghdL2d2OvAkht1lWMMLkx4G2Vis2rXgMirndPilPXpnbWpIhT9f0m/GR41nwKe x9JpzTrZH8upFNAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D0A72134B1 for ; Wed, 21 Jun 2023 13:31:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GB/dMc77kmRBagAAMHmgww (envelope-from ) for ; Wed, 21 Jun 2023 13:31:58 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [pushed 2/2] [gdb/testsuite] Reimplement Term::command_no_prompt_prefix Date: Wed, 21 Jun 2023 15:32:00 +0200 Message-Id: <20230621133200.25576-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230621133200.25576-1-tdevries@suse.de> References: <20230621133200.25576-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Say we run test-case gdb.tui/basic.exp. It calls Term::enter_tui, which does: ... command_no_prompt_prefix "tui enable" ... The proc command_no_prompt_prefix is documented as: ... # As proc command, but don't wait for an initial prompt. This is used for # initial terminal commands, where there's no prompt yet. ... Indeed, before the "tui enable" command, the tuiterm is empty, so there is no prompt and just before switching to TUI we have in the tuiterm: ... tui enable ... The reason that there is no prompt, is that: - in order for tuiterm to show something, its input processing procs need to be called, and - the initial gdb prompt, and subsequent prompts generated by gdb_test-style procs, are all consumed by those procs instead. This is in principle not a problem, but the absence of a prompt makes a tuiterm session look less like a session on an actual xterm. Add a new proc gen_prompt, that: - generates a prompt using echo - consumes the response before the prompt using gdb_expect - consumes the prompt using Term::wait_for "". This allows us to reimplement Term::command_no_prompt_prefix using Term::command, and just before switching to TUI we have in the tuiterm: ... (gdb) tui enable ... Tested on x86_64-linux. --- gdb/testsuite/lib/tuiterm.exp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 41fa554aa09..598c1f8cbdf 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -875,6 +875,21 @@ namespace eval Term { } } + # Generate prompt on TUIterm. + proc gen_prompt {} { + # Generate a prompt. + send_gdb "echo\n" + + # Drain the output before the prompt. + gdb_expect { + -re "echo\r\n" { + } + } + + # Interpret prompt using TUIterm. + wait_for "" + } + # Setup ready for starting the tui, but don't actually start it. # Returns 1 on success, 0 if TUI tests should be skipped. proc prepare_for_tui {} { @@ -920,9 +935,8 @@ namespace eval Term { # As proc command, but don't wait for an initial prompt. This is used for # initial terminal commands, where there's no prompt yet. proc command_no_prompt_prefix {cmd} { - send_gdb "$cmd\n" - set str [string_to_regexp $cmd] - wait_for "^$str" + gen_prompt + command $cmd } # Apply the attribute list in ATTRS to attributes array UPVAR_NAME. -- 2.35.3