From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0EVeO3wCeGIWHwUAWB0awg (envelope-from ) for ; Sun, 08 May 2022 13:48:44 -0400 Received: by simark.ca (Postfix, from userid 112) id EEB3B1E21F; Sun, 8 May 2022 13:48:44 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ekchm7P2; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4B5951E143 for ; Sun, 8 May 2022 13:48:44 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 807083857415 for ; Sun, 8 May 2022 17:48:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 807083857415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1652032123; bh=c/dEMtNqNy6oJOv76n28DkP4B0AFTTcJ9RHB6RjOw4s=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ekchm7P2cNTZTz9M/j29ytv9crDIPlV15HnsrA1A+m4gTJ3cDfv3im+sbYbCBQ2jm 0C2jO8Xwrh4nxRfsD2JMMbkoMmhwhSrwqBb4rQQdzkMfStNVp6R2u5tvlkPikBcsrO vCgHY4QGNTSNutZ2cOB/zBOcR+e6V/hxQlxi2x4A= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id A1FFC3858405 for ; Sun, 8 May 2022 17:48:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A1FFC3858405 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 B4FF01F9E5; Sun, 8 May 2022 17:48:22 +0000 (UTC) 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 9A96B13A97; Sun, 8 May 2022 17:48:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id q7NRJGYCeGLIJQAAMHmgww (envelope-from ); Sun, 08 May 2022 17:48:22 +0000 Message-ID: <3c72428e-b3d5-e4f8-d325-75584d29bede@suse.de> Date: Sun, 8 May 2022 19:48:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: [committed][gdb/testsuite] Fix gdb.tui/scroll.exp with read1 Content-Language: en-US To: gdb-patches@sourceware.org References: <20220412141524.GA6848@delia.home> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 4/30/22 13:42, Tom de Vries wrote: > On 4/12/22 16:15, Tom de Vries wrote: >> Hi, >> >> When running test-case gdb.tui/scroll.exp, I get: >> ... >> Box Dump (80 x 8) @ (0, 0): >>      0 $17 = 16 >>      1 (gdb) p 17 >>      2 $18 = 17 >>      3 (gdb) p 18 >>      4 $19 = 18 >>      5 (gdb) p 19 >>      6 $20 = 19 >>      7 (gdb) >> PASS: gdb.tui/scroll.exp: check cmd window in flip layout >> ... >> but with check-read1 I get instead: >> ... >> Box Dump (80 x 8) @ (0, 0): >>      0 (gdb) 15 >>      1 (gdb) p 16 >>      2 $17 = 16 >>      3 (gdb) p 17 >>      4 $18 = 17 >>      5 (gdb) p 18 >>      6 $19 = 18 >>      7 (gdb) p 19 >> FAIL: gdb.tui/scroll.exp: check cmd window in flip layout >> ... >> >> The "p 19" command is handled by Term::command, which sends the >> command and then >> does Term::wait_for "^$gdb_prompt [string_to_regexp $cmd]", which: >> - matches the line with "(gdb) p 19", and >> - tries to match the following prompt "(gdb) " >> >> The problem is that scrolling results in reissuing output before the >> "(gdb) p >> 19", and the second matching triggers on that.  Consequently, wait_for no >> longer translates gdb output into screen actions, and the screen does not >> reflect the result of "p 19". >> >> Fix this by using a new proc wait_for_region_contents, which in >> contrast to >> wait_for can handle a multi-line regexp. >> >> Tested on x86_64-linux with make targets check and check-read1. >> >> Any comments? >> > > Ping. > Committed. Thanks, - Tom >> [gdb/testsuite] Fix gdb.tui/scroll.exp with read1 >> >> --- >>   gdb/testsuite/gdb.tui/scroll.exp |  8 +++- >>   gdb/testsuite/lib/tuiterm.exp    | 99 >> +++++++++++++++++++++++++++------------- >>   2 files changed, 74 insertions(+), 33 deletions(-) >> >> diff --git a/gdb/testsuite/gdb.tui/scroll.exp >> b/gdb/testsuite/gdb.tui/scroll.exp >> index c23cd2b9abf..f34f8fddc68 100644 >> --- a/gdb/testsuite/gdb.tui/scroll.exp >> +++ b/gdb/testsuite/gdb.tui/scroll.exp >> @@ -60,7 +60,13 @@ Term::command "winheight cmd 8" >>   Term::check_box "src window after resize" 0 8 80 16 >>   for {set i 10} {$i < 20} {incr i 1} { >> -    Term::command "p $i" >> +    set cmd "p $i" >> +    send_gdb "$cmd\n" >> +    Term::wait_for_region_contents 0 0 80 8 \ >> +    [multi_line \ >> +         "$gdb_prompt [string_to_regexp $cmd]\\s+" \ >> +         "\\\$\\d+ = $i\\s+" \ >> +         "$gdb_prompt "] >>   } >>   # Now check that the contents of the command window are as expected. >> diff --git a/gdb/testsuite/lib/tuiterm.exp >> b/gdb/testsuite/lib/tuiterm.exp >> index e660840eed9..bf094131eac 100644 >> --- a/gdb/testsuite/lib/tuiterm.exp >> +++ b/gdb/testsuite/lib/tuiterm.exp >> @@ -663,11 +663,47 @@ namespace eval Term { >>       _clear_lines 0 $_rows >>       } >> +    # Accept some output from gdb and update the screen. >> +    # Return 1 if successful, or 0 if a timeout occurred. >> +    proc accept_gdb_output { } { >> +    global expect_out >> +    gdb_expect { >> +        -re "^\[\x07\x08\x0a\x0d\]" { >> +        scan $expect_out(0,string) %c val >> +        set hexval [format "%02x" $val] >> +        _log "wait_for: _ctl_0x${hexval}" >> +        _ctl_0x${hexval} >> +        } >> +        -re "^\x1b(\[0-9a-zA-Z\])" { >> +        _log "wait_for: unsupported escape" >> +        error "unsupported escape" >> +        } >> +        -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@\])" { >> +        set cmd $expect_out(2,string) >> +        set params [split $expect_out(1,string) ";"] >> +        _log "wait_for: _csi_$cmd <<<$expect_out(1,string)>>>" >> +        eval _csi_$cmd $params >> +        } >> +        -re "^\[^\x07\x08\x0a\x0d\x1b\]+" { >> +        _insert $expect_out(0,string) >> +        variable _last_char >> +        set _last_char [string index $expect_out(0,string) end] >> +        } >> + >> +        timeout { >> +        # Assume a timeout means we somehow missed the >> +        # expected result, and carry on. >> +        return 0 >> +        } >> +    } >> + >> +    return 1 >> +    } >> + >>       # Accept some output from gdb and update the screen.  WAIT_FOR is >>       # a regexp matching the line to wait for.  Return 0 on timeout, 1 >>       # on success. >>       proc wait_for {wait_for} { >> -    global expect_out >>       global gdb_prompt >>       variable _cur_col >>       variable _cur_row >> @@ -675,34 +711,8 @@ namespace eval Term { >>       set prompt_wait_for "$gdb_prompt \$" >>       while 1 { >> -        gdb_expect { >> -        -re "^\[\x07\x08\x0a\x0d\]" { >> -            scan $expect_out(0,string) %c val >> -            set hexval [format "%02x" $val] >> -            _log "wait_for: _ctl_0x${hexval}" >> -            _ctl_0x${hexval} >> -        } >> -        -re "^\x1b(\[0-9a-zA-Z\])" { >> -            _log "wait_for: unsupported escape" >> -            error "unsupported escape" >> -        } >> -        -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@\])" { >> -            set cmd $expect_out(2,string) >> -            set params [split $expect_out(1,string) ";"] >> -            _log "wait_for: _csi_$cmd <<<$expect_out(1,string)>>>" >> -            eval _csi_$cmd $params >> -        } >> -        -re "^\[^\x07\x08\x0a\x0d\x1b\]+" { >> -            _insert $expect_out(0,string) >> -            variable _last_char >> -            set _last_char [string index $expect_out(0,string) end] >> -        } >> - >> -        timeout { >> -            # Assume a timeout means we somehow missed the >> -            # expected result, and carry on. >> -            return 0 >> -        } >> +        if { [accept_gdb_output] == 0 } { >> +        return 0 >>           } >>           # If the cursor appears just after the prompt, return.  It >> @@ -724,6 +734,23 @@ namespace eval Term { >>       return 1 >>       } >> +    # Accept some output from gdb and update the screen.  Wait for >> the screen >> +    # region X/Y/WIDTH/HEIGTH to matches REGEXP.  Return 0 on >> timeout, 1 on >> +    # success. >> +    proc wait_for_region_contents {x y width height regexp} { >> +    while 1 { >> +        if { [accept_gdb_output] == 0 } { >> +        return 0 >> +        } >> + >> +        if { [check_region_contents_p $x $y $width $height $regexp] } { >> +        break >> +        } >> +    } >> + >> +    return 1 >> +    } >> + >>       # Like ::clean_restart, but ensures that gdb starts in an >>       # environment where the TUI can work.  ROWS and COLS are the size >>       # of the terminal.  EXECUTABLE, if given, is passed to >> @@ -940,15 +967,23 @@ namespace eval Term { >>       # and HEIGHT match REGEXP.  This is like check_contents except >>       # only part of the screen is checked.  This can be used to check >>       # the contents within a box (though check_box_contents is a better >> -    # choice for boxes with a border). >> -    proc check_region_contents { test_name x y width height regexp } { >> +    # choice for boxes with a border).  Return 1 if check succeeded. >> +    proc check_region_contents_p { x y width height regexp } { >>       variable _chars >>       dump_box $x $y $width $height >>       # Now grab the contents of the box, join each line together >>       # with a '\r\n' sequence and match against REGEXP. >>       set result [get_region $x $y $width $height "\r\n"] >> -    gdb_assert {[regexp -- $regexp $result]} $test_name >> +    return [regexp -- $regexp $result] >> +    } >> + >> +    # Check that the region of the screen described by X, Y, WIDTH, >> +    # and HEIGHT match REGEXP.  As check_region_contents_p, but produce >> +    # a pass/fail message. >> +    proc check_region_contents { test_name x y width height regexp } { >> +    set ok [check_region_contents_p $x $y $width $height $regexp] >> +    gdb_assert {$ok} $test_name >>       } >>       # Check the contents of a box on the screen.  This is a little