From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 4CE2B385842C for ; Mon, 9 Aug 2021 09:45:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4CE2B385842C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x32f.google.com with SMTP id k5-20020a05600c1c85b02902e699a4d20cso457379wms.2 for ; Mon, 09 Aug 2021 02:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Kv9PQ5Y1r4GsDUE+DwTVnkQrAI5NXNtaNnkBh6e0o6c=; b=RWzTxv8Gxycc+yTlZX9ZxIZkWVALhDOiDi/FA8WruiD804SizlNqQcvnXtZVXbaV/b /Vg2CkMFvgnTPskNgqiWT4Qw23cImmJMVkcsADYRDtpg63f3MmLYZQJPr5dgcEhozYu3 YVUPXY6nMXg9o7dkuZ+Olg8Rkjl+ann6FNw+ZOLdpUPCg7CmIw/t8NPnQbtr082uPGUz 62turyTMKf65jC9TNr/QO6hCjNFWzQ34bf3mWkZ5ONYL4CRoiU4y6y0DBH3d8ITtspR6 flB2PwMzliqggQ8MxWDOmm/mH5PxxONufA1qxOVQ85ZD0s/1siOzfSJ4U39eYJdFiMVs SHaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Kv9PQ5Y1r4GsDUE+DwTVnkQrAI5NXNtaNnkBh6e0o6c=; b=UQ2u9L+lvLZv1ySDXivOGCJo2IsDf1W3XFnlSK+Umkvh7LZ48eqnyliL029JiFEwyI TE/bahffhkFd3C1wws3Wkuzkc8LaJACCg5WB41rKxUPhQf0EXg3egAEMbFFEQVg4c4e+ B7pnwFTCbGyT5XIqUTT4NiULbnkuv32SSGgASLpnO7psu5QQO2G/4C7kTcwKwVxj7tq0 Grge95kOlfOXiEOFOk4NNi4ajJdOkxQN/iEVAV7SyT8fPA0XQD+yh+vS+8pS94QjlaHS GwDzS8kZgxrkfk72/FoJ1rwQrknPiGpduivThvBrmAGcG8djvYql4AfRnnBUDjubpHNf tcwQ== X-Gm-Message-State: AOAM533X/d1pVJoXPfmNQ5opZkhZcsKbGPfLZyN3cfN/D8YwqdN70rqz rzDcDQnnV0CQvhD/oBhL6Nt41g== X-Google-Smtp-Source: ABdhPJx3zd/lBJfvTIdhU6UsQzTpSRZsFAdB9OfDR8ndOoN6BR1SYufWd4OOJPKTp+ytjEbgwUF8zg== X-Received: by 2002:a1c:cc05:: with SMTP id h5mr32988570wmb.5.1628502315288; Mon, 09 Aug 2021 02:45:15 -0700 (PDT) Received: from localhost (host86-161-16-194.range86-161.btcentralplus.com. [86.161.16.194]) by smtp.gmail.com with ESMTPSA id f15sm18343109wrp.12.2021.08.09.02.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 02:45:14 -0700 (PDT) Date: Mon, 9 Aug 2021 10:45:13 +0100 From: Andrew Burgess To: Carl Love Cc: gdb-patches@sourceware.org, Rogerio Alves , Ulrich Weigand Subject: Re: [PATCH] Improve forward progress test in gdb.python/python.exp Message-ID: <20210809094513.GE462163@embecosm.com> References: <4fd73f34dd7db949309de791ea5514890a0f9139.camel@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4fd73f34dd7db949309de791ea5514890a0f9139.camel@us.ibm.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 10:38:23 up 7 days, 15:18, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, 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: Mon, 09 Aug 2021 09:45:17 -0000 * Carl Love via Gdb-patches [2021-08-06 15:40:58 -0700]: > GDB maintainers: > > The current gdb.python/python.exp test fails on powerpc. The test > checks to see if the source code line for the function call is less > than the line number after the function call. The issue on powerpc is > the assembly instructions for the branch and the NOP following the > branch map to the same source code line. > > An additional check of the PC before and after the function call is > done if the line number check fails. This additional check takes care > of the case where the call and return locations map to the same source > code line. > > The patch has been run on Powerpc with no regressions. > > Please let me know if the patch is acceptable. Thanks. > > Carl Love > > > -------------------------------------------------------- > > The test steps into func2 and than does an up to get back to the previous > frame. The test checks that the line number you are at after the up command > is greater than the line where the function was called from. The > assembly/codegen for the powerpc target includes a NOP after the > branch-link. > > func2 (); /* Break at func2 call site. / > 10000694: 59 00 00 48 bl 100006ec > 10000698: 00 00 00 60 nop > return 0; / Break to end. */ > 1000069c: 00 00 20 39 li r9,0 > > The PC at the instruction following the branch-link is 0x10000698 which > GDB.find_pc_line() maps to the same line number as the bl instruction. > GDB did move past the branch-link location thus making forward progress. > > The following proposed fix adds an additional PC check to see if forward > progress was made in the case where the original line test fails. > --- > gdb/testsuite/gdb.python/python.exp | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp > index d9fd60f3dd4..4472ed0994f 100644 > --- a/gdb/testsuite/gdb.python/python.exp > +++ b/gdb/testsuite/gdb.python/python.exp > @@ -496,12 +496,32 @@ if ![runto_main] then { > runto [gdb_get_line_number "Break at func2 call site."] > > gdb_py_test_silent_cmd "python line = gdb.selected_frame().find_sal().line" "Get line number of func2 call site" 1 > + > +gdb_py_test_silent_cmd "python pc_call = gdb.selected_frame().pc()" "Get pc at return from func2 location" 1 I find the name for this test a little strange. I'd have expected "Get pc of func2 call site" in order to match the previous test. > + > gdb_test "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line == line)" "True" "test find_pc_line at func2 call site" > > gdb_py_test_silent_cmd "step" "Step into func2" 1 > gdb_py_test_silent_cmd "up" "Step out of func2" 1 > > -gdb_test "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line > line)" "True" "test find_pc_line with resume address" > +gdb_py_test_silent_cmd "python pc_rtn = gdb.selected_frame().pc()" "Get pc at func2 return site" 1 I wonder if we can simplify the logic here? We always expect the pc to be bigger, right? So we can just test that in all cases. Once we know that is being tested, we can make the line number test simpler, like this: gdb_py_test_silent_cmd "python pc_rtn = gdb.selected_frame().pc()" \ "Get pc at func2 return site" 1 gdb_test "python print (pc_rtn > pc_call)" "True" \ "test resume address greater then call address" gdb_test "python print (gdb.find_pc_line(pc_rtn).line >= line)" "True" \ "test find_pc_line with resume address" I wrapped the lines to keep them under 80 characters, which is the correct style where possible. What do you think? Thanks, Andrew > + > +# The point of the following test is to see if gdb has advanced past the > +# location where the branch to a function was made. > +set test_name "test find_pc_line with resume address" > + > +gdb_test_multiple "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line > line)" $test_name { > + -re "True.*" { > + pass $test_name > + } > + -re "False.*" { > + # The instruction at the call-return site may also be associated with > + # the same line that contained the branch. For example, PPC64 puts a > + # NOP after the branch to function. Check if the frame PC has > + # advanced past the call location. > + gdb_test "python print (pc_rtn > pc_call)" "True" "test pc_rtn greater then pc_call" > + } > +} > > gdb_test_no_output "set variable \$cvar1 = 23" "set convenience variable" > gdb_test "python print(gdb.convenience_variable('cvar1'))" "23" > -- > 2.17.1 > >