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 71DBA3858D35 for ; Wed, 10 Nov 2021 23:17:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 71DBA3858D35 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 9C1ED212C6; Wed, 10 Nov 2021 23:17:37 +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 76DA313D1D; Wed, 10 Nov 2021 23:17:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IGBNGxFTjGG/JAAAMHmgww (envelope-from ); Wed, 10 Nov 2021 23:17:37 +0000 Subject: Re: [PATCH] Fix for the gdb.base/sigstep.exp test. To: Carl Love , gdb-patches@sourceware.org, Will Schmidt , Rogerio Alves References: <0a9375881ccc306f3e66d83ff5206594d53fed0e.camel@us.ibm.com> From: Tom de Vries Message-ID: Date: Thu, 11 Nov 2021 00:17:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <0a9375881ccc306f3e66d83ff5206594d53fed0e.camel@us.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, SPF_HELO_NONE, 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: Wed, 10 Nov 2021 23:17:40 -0000 On 11/8/21 7:26 PM, Carl Love via Gdb-patches wrote: > > > > GDB maintainers: > > The gdb.base/sigstep.exp has 6 fails on the PowerPC platforms. Th > following patch fixes the minor differences of how the test runs on > PowerPC versus X86. The differences have to do with the number of > assembly instructions generated for the two systems and where gdb stops > at the beginning of a function. On PowerPC, gdb stops in the prolog > rather than at the first line of code. > > The fix adds an addtional stepi in one case and an additional step in > the other case to get to the expected location in the code. > > The patch only consists of changes to the test. No GDB internal > changes are made. > > The patch was also tested on X86 with no regression failures. > > Please let me know if the patch is acceptable for mainline. Thanks. > > Carl Love > > --------------------------------------------------------------------- > I ran the test-case on ppc64le-linux, and got 6 FAILs as well: ... FAIL: gdb.base/sigstep.exp: stepi to handler, nothing in handler, step from handler: leave handler FAIL: gdb.base/sigstep.exp: stepi to handler, nothing in handler, next from handler: leave handler FAIL: gdb.base/sigstep.exp: stepi to handler, nothing in handler, continue from handler: break clear done (got interactive prompt) FAIL: gdb.base/sigstep.exp: nexti to handler, nothing in handler, step from handler: leave handler FAIL: gdb.base/sigstep.exp: nexti to handler, nothing in handler, next from handler: leave handler FAIL: gdb.base/sigstep.exp: nexti to handler, nothing in handler, continue from handler: break clear done (got interactive prompt) ... The first FAIL looks like this: ... (gdb) PASS: gdb.base/sigstep.exp: stepi to handler, nothing in handler, step from handler: continue to signal stepi^M ^M 1: x/i $pc^M => 0x7ffff7f804c0 <__kernel_start_sigtramp_rt64>: bctrl^M (gdb) PASS: gdb.base/sigstep.exp: stepi to handler, nothing in handler, step from handler: stepi to handler delete breakpoints^M Delete all breakpoints? (y or n) y^M (gdb) info breakpoints^M No breakpoints or watchpoints.^M (gdb) step^M handler (sig=1685382480) at /suse/tdevries/gdb/src/gdb/testsuite/gdb.base/sigstep.c:32^M 32 {^M 1: x/i $pc^M => 0x1000081c : lis r2,4098^M (gdb) FAIL: gdb.base/sigstep.exp: stepi to handler, nothing in handler, step from handler: leave handler ... The first difference with x86_64 though is where the first stepi gets us. On x86_64-linux, it's: ... gdb) PASS: gdb.base/sigstep.exp: stepi to handler, nothing in handler, step from handler: continue to signal stepi^M handler (sig=0) at /home/vries/gdb_versions/devel/src/gdb/testsuite/gdb.base/sigstep.c:32^M 32 {^M 1: x/i $pc^M => 0x400657 : push %rbp^M (gdb) PASS: gdb.base/sigstep.exp: stepi to handler, nothing in handler, step from handler: stepi to handler ... while on ppc it gets us "". > This patch fixes the test for a few differences in how the test runs on > PPC. The firs fix adds a gdb_test_multiple to check for PPC. The assembly > sequence on PPC reqires two stepi commands to get into the handler where as > it only takes one stepi on x86. The description here does not tell us why two stepi commands are required, while its obvious if you show it. I'd include the relevant part of the gdb log in the commit message to clarify why you're making the change. Anyway, using this change all 6 FAILs disappear. > > The second change in proc advance is due to gdb stopping int the prolog of > the function on PPC. Specificially it stops at the opening brace for the > function not with the first line of code. The patch adds an extra step for > PPC to get gdb to the expected location. Do you really need this bit? If so, can you show why? > --- > gdb/testsuite/gdb.base/sigstep.exp | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.base/sigstep.exp b/gdb/testsuite/gdb.base/sigstep.exp > index ea254af5297..dca9d39d1b6 100644 > --- a/gdb/testsuite/gdb.base/sigstep.exp > +++ b/gdb/testsuite/gdb.base/sigstep.exp > @@ -93,7 +93,17 @@ proc advance { enter_cmd in_handler_prefix in_handler exit_cmd } { > gdb_test "handle SIGVTALRM print pass stop" > gdb_test "continue" "Program received signal.*" "continue to signal" > } > - gdb_test "$enter_cmd" ".*handler .*" "$enter_cmd to handler" > + > + set test_cmd ".*handler .*" The second parameter of gdb_test is a regexp, not a command. > + gdb_test_multiple "$enter_cmd" "$enter_cmd to handler" { > + -re "handler .*sig=.*" { Both regexps are missing a -wrap, otherwise you're not consuming the prompt. > + pass "$test_cmd" The name of the test is "$enter_cmd to handler", and it's available as $gdb_test_name. > + } > + -re ".*signal handler called.*" { > + #ppc is at branch instruction, need one more stepi to get to handler > + gdb_test "$enter_cmd" ".*handler .*" "$enter_cmd to handler ppc" > + } > + } [ Missing indentation. ] I guess it's easier to reuse the first regexp using exp_continue rather than using another gdb_test. If not, you can also assign the regexp to a variable, and use that one twice. So, this is what I got: ... diff --git a/gdb/testsuite/gdb.base/sigstep.exp b/gdb/testsuite/gdb.base/sigstep.exp index ea254af5297..176918b67d6 100644 --- a/gdb/testsuite/gdb.base/sigstep.exp +++ b/gdb/testsuite/gdb.base/sigstep.exp @@ -79,6 +79,7 @@ validate_backtrace proc advance { enter_cmd in_handler_prefix in_handler exit_cmd } { global gdb_prompt inferior_exited_re global clear_done other_handler_location + global decimal set prefix "$enter_cmd to handler, $in_handler_prefix in handler, $exit_cmd from handler" @@ -93,7 +94,16 @@ proc advance { enter_cmd in_handler_prefix in_handler exit_cmd } { gdb_test "handle SIGVTALRM print pass stop" gdb_test "continue" "Program received signal.*" "continue to signal" } - gdb_test "$enter_cmd" ".*handler .*" "$enter_cmd to handler" + + gdb_test_multiple "$enter_cmd" "$enter_cmd to handler" { + -re -wrap "\r\n.*" { + send_gdb "$enter_cmd\n" + exp_continue + } + -re -wrap "\r\n(Breakpoint $decimal, )?handler \\(sig=.*" { + pass $gdb_test_name + } + } delete_breakpoints ... Thanks, - Tom