From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id C04363AA9906 for ; Mon, 18 Jan 2021 10:31:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C04363AA9906 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E2C23AF5B for ; Mon, 18 Jan 2021 10:31:04 +0000 (UTC) Date: Mon, 18 Jan 2021 11:31:03 +0100 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Fix gdb.python/py-finish-breakpoint2.exp with -m32 Message-ID: <20210118103101.GA29963@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-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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, 18 Jan 2021 10:31:07 -0000 Hi, When running test-case gdb.python/py-finish-breakpoint2.exp with target board unix/-m32, we run into: ... (gdb) continue^M Continuing.^M Exception #10^M ^M Breakpoint 3, throw_exception_1 (e=10) at py-finish-breakpoint2.cc:23^M 23 throw new int (e);^M (gdb) FAIL: gdb.python/py-finish-breakpoint2.exp: \ check FinishBreakpoint in catch() ... With -m64, the test passes. Relevant bit of the source: ... 36 try 37 { 38 throw_exception_1 (10); 39 } 40 catch (const int *e) 41 { 42 std::cerr << "Exception #" << *e << std::endl; 43 } 44 i += 1; /* Break after exception 1. */ ... The -m64 scenario in more detail: - the test-case runs to throw_exception_1. - it installs a FinishBreakpoint, which is a temporary breakpoint set at the return address of a frame. - for -m64, that address is: 400c47: 83 45 e4 01 addl $0x1,-0x1c(%rbp) which corresponds the "i += 1 at line 44" - the test-case then continues - an exception is throw in throw_exection_1 - the exception is caught at line 40, and a message is printed - line 44 is executed, and the FinishBreakpoint triggers. With -m32, we have instead: - the address where the finish breakpoint is set is: 8048a0a: 83 c4 10 add $0x10,%esp which is the lasn insn generated for the call at line 38 - the test-case continues - an exception is throw in throw_exection_1 - consequently, the FinishBreakpoint is not triggered. In conclusion, the test worked by accident for -m64, because the first insn after the call to throw_exception_1 is also the first insn after the try. And that just happens to be not the case for -m32. Fix this by removing this part of the test. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/testsuite] Fix gdb.python/py-finish-breakpoint2.exp with -m32 gdb/testsuite/ChangeLog: 2021-01-18 Tom de Vries * gdb.python/py-finish-breakpoint2.exp: Remove part of test that works by accident. --- gdb/testsuite/gdb.python/py-finish-breakpoint2.exp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp index 10c4b6e81b8..4193f073996 100644 --- a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp @@ -46,12 +46,6 @@ gdb_test "source $pyfile" ".*Python script imported.*" \ gdb_breakpoint "throw_exception_1" gdb_test "continue" "Breakpoint .*throw_exception_1.*" "run to exception 1" - -gdb_test "python print (len(gdb.breakpoints()))" "3" "check BP count" -gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" "init ExceptionFinishBreakpoint" "set FinishBP after the exception" -gdb_test "continue" ".*stopped at ExceptionFinishBreakpoint.*" "check FinishBreakpoint in catch()" -gdb_test "python print (len(gdb.breakpoints()))" "3" "check finish BP removal" - gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" "continue to second exception" gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" "init ExceptionFinishBreakpoint" "set FinishBP after the exception" gdb_test "continue" ".*exception did not finish.*" "FinishBreakpoint with exception thrown not caught"