From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 4DFFD3858D28 for ; Fri, 5 Nov 2021 16:21:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4DFFD3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id E2DAD1E813; Fri, 5 Nov 2021 12:21:23 -0400 (EDT) Subject: Re: [PATCH 2/2] Test case for Bug 28308 To: Kevin Buettner , gdb-patches@sourceware.org References: <20211002010054.1546736-1-kevinb@redhat.com> <20211002010054.1546736-3-kevinb@redhat.com> From: Simon Marchi Message-ID: <63bccc55-dcd0-4a3e-77d8-77ea4bd1971d@simark.ca> Date: Fri, 5 Nov 2021 12:21:23 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211002010054.1546736-3-kevinb@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_NUMSUBJECT, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 05 Nov 2021 16:21:26 -0000 On 2021-10-01 9:00 p.m., Kevin Buettner via Gdb-patches wrote: > +# Make sure that there's no running gdb. It's not clear to me > +# that this is necessary, but a search shows that all other uses of > +# gdb_spawn first do a gdb_exit. > +gdb_exit I'm not sure why that would be necessary here, as there is nothing above your gdb_exit that spawns GDB. If you had used prepare_for_testing instead of build_executable, then that would have started GDB, and your gdb_exit would have been necessary (although I would have told you, don't use prepare_for_testing if you are to exit GDB right after, use build_executable :)). So if things work without this gdb_exit (which I expect), let's just remove it. > +# Create context in which the global, GDBFLAGS, will be restored at > +# the end of the block. All commands run within the block are > +# actually run in the outer context. (This is why 'res' is available > +# outside of the save_vars block.) > +save_vars { GDBFLAGS } { > + # Set flags with which to start GDB. > + append GDBFLAGS " -ex \"set height unlimited\"" > + append GDBFLAGS " -x \"$x_file\"" > + append GDBFLAGS " --args \"$binfile\"" > + > + # Start GDB with above flags. > + set res [gdb_spawn] > +} > + > +set test "Load and run script with -x" Non-capital "l". > +if { $res != 0} { > + fail $test > + return -1 > +} > + > +# The script loaded via -x contains a run command; while running, GDB > +# is expected to print three messages from dprintf breakpoints along > +# with three interspersed messages from an ordinary breakpoint (which > +# was set up with a continue command). Set up pattern D to match > +# output from hitting the dprintf breakpoint and B for the ordinary > +# breakpoint. Then set PAT to contain the entire pattern of expected > +# output from the interspersed dprintf and ordinary breakpoints along > +# with some (additional) expected output from the dprintf breakpoints, > +# i.e. 0, 1, and 2. > +set d "dprintf in increment.., vi=" > +set b "Breakpoint ., inc_vi" > +set pat "${d}0.*?$b.*?${d}1.*?$b.*?${d}2.*?$b.*?" > + > +proc do_test {cmd test} { > + gdb_test_multiple $cmd $test { > + -re "$::pat$::inferior_exited_re normally.*$::gdb_prompt $" { > + pass $test > + } > + -re "Don't know how to run.*$::gdb_prompt $" { > + unsupported $test > + } Given you used target_can_use_run_cmd at the top, when would this unsupported path be taken? > + } > +} > + > +# Check output from running script with -x > +do_test "" $test > + > +# Restart GDB and 'source' the script; this will (still) run the program > +# due to the 'run' command in the script. > +clean_restart $binfile > +do_test "source $x_file" "Load and run script using source command" Non-capital "l". > + > +# This should leave us at the gdb prompt; Run program again using > +# already established breakpoints, i.e. those loaded from the > +# script. Prior to fixing PR 28308, this was the only test that > +# would pass. > +do_test "run" "Run again" Non-capital "r". Simon