From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 8BDCB3858438 for ; Fri, 9 Jun 2023 07:25:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8BDCB3858438 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-out2.suse.de (Postfix) with ESMTPS id ABB361FDF3; Fri, 9 Jun 2023 07:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686295556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0WjzkIyOIXg5XXf5WAzOJYcAsgBPL55Tt5wYW+VcdyQ=; b=1T+F7QlhHcFuD406Ozchpsfo/s8/qe2s85fo3pK3KzQ7gBwpWLDaEmr6yzZLlWusU7xUuy adunYANVslY3Q9xOlhegKPbh+nB59zg/d6Yk1AQYn7RYP0l2s6duv2CZjhIOWkxG4tcRe0 qzxMTVR+GU+ALIW8Sfs662FEeDL6fao= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686295556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0WjzkIyOIXg5XXf5WAzOJYcAsgBPL55Tt5wYW+VcdyQ=; b=r8MSYGFu3aJ5AKlKgwoIrEh+HfgrYmLFbjE5z03YOvREfJoY4ZsKq+jqw3VW6EPNNXeg+D EtezIFoaO/yxr/Dw== 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 89CD7139C8; Fri, 9 Jun 2023 07:25:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OrW3HwTUgmRuRwAAMHmgww (envelope-from ); Fri, 09 Jun 2023 07:25:56 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] [gdb/testsuite] Remove Term::command_no_prompt_prefix Date: Fri, 9 Jun 2023 09:26:05 +0200 Message-Id: <20230609072605.2327-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 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. 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. Fix this by using a new proc gen_prompt, that: - generates a prompt using ^C (though also something like echo \n would work) - consumes the response before the prompt using gdb_expect - consumes the prompt using Term::wait_for "". A fix was necessary to Term::wait_for, to make sure that Term::wait_for "" consumes just one prompt. This allows us to use the regular proc command instead: ... gen_prompt command "tui enable" ... such that we have in tuiterm: ... (gdb) tui enable ... instead of: ... tui enable ... Fix all uses of command_no_prompt_prefix, and remove it. Tested on x86_64-linux. --- .../gdb.python/tui-window-factory.exp | 3 +- gdb/testsuite/gdb.tui/completion.exp | 3 +- gdb/testsuite/gdb.tui/resize-2.exp | 3 +- .../gdb.tui/tui-disasm-long-lines.exp | 3 +- gdb/testsuite/gdb.tui/tui-focus.exp | 6 ++-- .../gdb.tui/tui-layout-asm-short-prog.exp | 3 +- gdb/testsuite/gdb.tui/tui-layout-asm.exp | 3 +- gdb/testsuite/gdb.tui/tui-layout.exp | 3 +- gdb/testsuite/lib/tuiterm.exp | 31 +++++++++++++------ 9 files changed, 40 insertions(+), 18 deletions(-) diff --git a/gdb/testsuite/gdb.python/tui-window-factory.exp b/gdb/testsuite/gdb.python/tui-window-factory.exp index e3b403bdea0..c41e12881e5 100644 --- a/gdb/testsuite/gdb.python/tui-window-factory.exp +++ b/gdb/testsuite/gdb.python/tui-window-factory.exp @@ -53,7 +53,8 @@ gdb_test_no_output "tui new-layout test test_window 1 cmd 1 status 1" # Load the custom window layout and ensure that the correct window # factory was used. with_test_prefix "msg_2" { - Term::command_no_prompt_prefix "layout test" + Term::gen_prompt + Term::command "layout test" Term::check_box_contents "check test_window box" 0 0 80 15 \ "TestWindow \\(msg_2\\)" } diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp index 9cf8dc2ee25..37e9cc93805 100644 --- a/gdb/testsuite/gdb.tui/completion.exp +++ b/gdb/testsuite/gdb.tui/completion.exp @@ -66,7 +66,8 @@ if {![Term::prepare_for_tui]} { return } -Term::command_no_prompt_prefix "layout src" +Term::gen_prompt +Term::command "layout src" Term::command "complete focus " Term::dump_screen Term::check_region_contents "check focus completions" 0 17 80 5 \ diff --git a/gdb/testsuite/gdb.tui/resize-2.exp b/gdb/testsuite/gdb.tui/resize-2.exp index ebe8216c05d..456558abdca 100644 --- a/gdb/testsuite/gdb.tui/resize-2.exp +++ b/gdb/testsuite/gdb.tui/resize-2.exp @@ -31,7 +31,8 @@ if {![Term::prepare_for_tui]} { } # Enter TUI. -Term::command_no_prompt_prefix "layout command-layout" +Term::gen_prompt +Term::command "layout command-layout" proc check_width { what n } { set re "Number of characters $what thinks are in a line is $n" diff --git a/gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp b/gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp index 5d395cd604b..c425df87e67 100644 --- a/gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp +++ b/gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp @@ -41,6 +41,7 @@ if {![Term::prepare_for_tui]} { return } -Term::command_no_prompt_prefix "layout asm" +Term::gen_prompt +Term::command "layout asm" Term::check_box "asm box" 0 0 80 15 Term::check_box_contents "check asm box contents" 0 0 80 15 "
" diff --git a/gdb/testsuite/gdb.tui/tui-focus.exp b/gdb/testsuite/gdb.tui/tui-focus.exp index 72f80523af3..2266f0cc34b 100644 --- a/gdb/testsuite/gdb.tui/tui-focus.exp +++ b/gdb/testsuite/gdb.tui/tui-focus.exp @@ -42,7 +42,8 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \ return } - Term::command_no_prompt_prefix "focus $window" + Term::gen_prompt + Term::command "focus $window" if {$valid_p} { # The 'status' window is special, it's present in the @@ -110,7 +111,8 @@ if {[allow_python_tests]} { # Try to focus using an ambiguous, partial window name. This # should fail as the default layout (src) doesn't include any # windows matching this name. - Term::command_no_prompt_prefix "focus test" + Term::gen_prompt + Term::command "focus test" Term::check_region_contents "check no matching window focus message" \ 0 16 80 1 \ "^No windows matching \"test\" in the current layout\\s*" diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp index 9014622d35c..4347c3b6d3c 100644 --- a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp +++ b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp @@ -41,7 +41,8 @@ if { $gdb_file_cmd_debug_info == "nodebug" } { gdb_test_no_output "maint set tui-left-margin-verbose on" # This puts us into TUI mode, and should display the ASM window. -Term::command_no_prompt_prefix "layout asm" +Term::gen_prompt +Term::command "layout asm" Term::check_box_contents "check asm box contents" 0 0 80 15 "<_start>" # Record the first line of output, we'll need this later. diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm.exp b/gdb/testsuite/gdb.tui/tui-layout-asm.exp index 380477cb457..42f5dbf6a79 100644 --- a/gdb/testsuite/gdb.tui/tui-layout-asm.exp +++ b/gdb/testsuite/gdb.tui/tui-layout-asm.exp @@ -39,7 +39,8 @@ proc count_whitespace { string } { } # This puts us into TUI mode, and should display the ASM window. -Term::command_no_prompt_prefix "layout asm" +Term::gen_prompt +Term::command "layout asm" Term::check_box_contents "check asm box contents" 0 0 ${tui_asm_window_width} 15 "
" # Scroll the ASM window down using the down arrow key. In an ideal diff --git a/gdb/testsuite/gdb.tui/tui-layout.exp b/gdb/testsuite/gdb.tui/tui-layout.exp index 13823387e72..eb0ad1787b8 100644 --- a/gdb/testsuite/gdb.tui/tui-layout.exp +++ b/gdb/testsuite/gdb.tui/tui-layout.exp @@ -68,7 +68,8 @@ proc test_layout_or_focus {layout_name terminal execution} { gdb_test "layout $layout_name" \ "Cannot enable the TUI: terminal doesn't support cursor addressing \\\[TERM=dumb\\\]" } else { - Term::command_no_prompt_prefix "layout $layout_name" + Term::gen_prompt + Term::command "layout $layout_name" if {$layout_name == "asm"} { Term::check_box "asm box" 0 0 80 15 } elseif {$layout_name == "reg"} { diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 171b242aa80..4fac47578f4 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -789,6 +789,10 @@ namespace eval Term { set fn "wait_for" set prompt_wait_for "$gdb_prompt \$" + if { $wait_for == "" } { + set wait_for $prompt_wait_for + } + debug_tui_matching "$fn: regexp: '$wait_for'" while 1 { @@ -871,6 +875,22 @@ namespace eval Term { } } + # Generate prompt on TUIterm. + proc gen_prompt {} { + # Send ^C, generate a prompt. + send_gdb "\003" + + # Drain the output before the prompt. + gdb_expect { + -re "Quit\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 {} { @@ -898,7 +918,8 @@ namespace eval Term { return 0 } - command_no_prompt_prefix "tui enable" + gen_prompt + command "tui enable" return 1 } @@ -913,14 +934,6 @@ namespace eval Term { wait_for $str } - # 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" - } - # Apply the attribute list in ATTRS to attributes array UPVAR_NAME. # Return a string annotating the changed attributes. proc apply_attrs { upvar_name attrs } { base-commit: 30711c89cc7dcd2bd4ea772b2f5dc639c5b1cfcc -- 2.35.3