From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id imqdI5VRXGErGQAAWB0awg (envelope-from ) for ; Tue, 05 Oct 2021 09:22:29 -0400 Received: by simark.ca (Postfix, from userid 112) id 8225B1EE1B; Tue, 5 Oct 2021 09:22:29 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 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 950C81E813 for ; Tue, 5 Oct 2021 09:22:28 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 370BB385AC19 for ; Tue, 5 Oct 2021 13:22:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 370BB385AC19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633440148; bh=rrZTkwXw+K6zlupz+olvLLz9MauM6n8MfQMZPOJmti8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=vaxHioH7HKQN4qP0NaGZeK24nUCD+6z52jnxfa9zwGxJkgyru8c3sBa/GkE9Egwxz 1Ne7nUdaEYItRgaUKXxhQSXV2Fyjjq3tmS7JVJCEWFFfSddWSVymy4qdToIROIIMmu iX9tkhcj2zYImF9O8VD6RLKFTnCMeka/fN4ik3JY= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 31D55385840B for ; Tue, 5 Oct 2021 13:22:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 31D55385840B 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 6416C1FE4D; Tue, 5 Oct 2021 13:22:09 +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 4AF2713C6B; Tue, 5 Oct 2021 13:22:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id vEwlEYFRXGFWCQAAMHmgww (envelope-from ); Tue, 05 Oct 2021 13:22:09 +0000 Date: Tue, 5 Oct 2021 15:22:07 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Add Term::dump_box in lib/tuiterm.exp Message-ID: <20211005132206.GA19271@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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" Hi, Factor out new proc Term::get_region and use it to implement a new proc Term::dump_box, similar to Term::dump_screen. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/testsuite] Add Term::dump_box in lib/tuiterm.exp --- gdb/testsuite/lib/tuiterm.exp | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 222583f291f..a0197402b1f 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -772,28 +772,38 @@ namespace eval Term { } } - # Check that the region of the screen described by X, Y, WIDTH, - # 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 } { + # Get the region of the screen described by X, Y, WIDTH, + # and HEIGHT, and separate the lines using SEP. + proc get_region { x y width height sep } { variable _chars - # Now grab the contents of the box, join each line together - # with a '\r\n' sequence and match against REGEXP. + # Grab the contents of the box, join each line together + # using $sep. set result "" for {set yy $y} {$yy < [expr {$y + $height}]} {incr yy} { if {$yy > $y} { # Add the end of line sequence only if this isn't the # first line. - append result "\r\n" + append result $sep } for {set xx $x} {$xx < [expr {$x + $width}]} {incr xx} { append result [lindex $_chars($xx,$yy) 0] } } + return $result + } + + # Check that the region of the screen described by X, Y, WIDTH, + # 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 } { + variable _chars + # 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"] if {![gdb_assert {[regexp -- $regexp $result]} $test_name]} { dump_screen } @@ -831,6 +841,20 @@ namespace eval Term { } } + # A debugging function to dump a box from the current screen, with line + # numbers. + proc dump_box { x y width height } { + verbose -log "Box Dump ($width x $height) @ ($x, $y):" + set region [get_region $x $y $width $height "\n"] + set lines [split $region "\n"] + set nr $y + foreach line $lines { + set fmt [format %5d $nr] + verbose -log "$fmt $line" + incr nr + } + } + # Resize the terminal. proc _do_resize {rows cols} { variable _chars