From patchwork Wed Sep 28 08:59:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 16106 Received: (qmail 2282 invoked by alias); 28 Sep 2016 08:59:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 2257 invoked by uid 89); 28 Sep 2016 08:59:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=unwinder, his X-HELO: emailserver1.aplushosting.com Received: from emailserver1.asdf456.com (HELO emailserver1.aplushosting.com) (72.18.207.136) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Wed, 28 Sep 2016 08:59:41 +0000 Received: (qmail 3040 invoked by uid 0); 28 Sep 2016 08:59:39 -0000 Received: from unknown (HELO pinnacle.lan) (70.176.31.165) by emailserver1.asdf456.com with SMTP; Wed, 28 Sep 2016 08:59:39 +0000 Date: Wed, 28 Sep 2016 01:59:38 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH 4/4] py-unwind-maint.exp: Allow unwinders to be called during python import Message-ID: <20160928015938.2e0b2461@pinnacle.lan> In-Reply-To: <20160928014455.438266a2@pinnacle.lan> References: <20160928014455.438266a2@pinnacle.lan> MIME-Version: 1.0 py-unwind-maint.exp: Allow unwinders to be called during python import In his commit of "Fix PR19927: Avoid unwinder recursion if sniffer uses calls parse_and_eval", Pedro updated the py-unwind-maint.exp test to account for different behavior in GDB caused by his changes to frame.c. This patch changes py-unwind-maint.exp so that either behavior is acceptable. Regardless of which path is taken, the number of PASSes and the names of the tests are the same. gdb/testsuite/ChangeLog: * gdb.python/py-unwind-maint.exp: Adjust tests to allow for unwinders to be called as a side effect of "source" and "disable unwinder" commands. If these side effects don't occur, detect that behavior and run slightly different tests which are also considered to be correct behavior. --- gdb/testsuite/gdb.python/py-unwind-maint.exp | 59 ++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.exp b/gdb/testsuite/gdb.python/py-unwind-maint.exp index 1253057..91b1fdf 100644 --- a/gdb/testsuite/gdb.python/py-unwind-maint.exp +++ b/gdb/testsuite/gdb.python/py-unwind-maint.exp @@ -34,13 +34,49 @@ if ![runto_main ] then { return -1 } -gdb_test "source ${pyfile}" "Python script imported" \ - "import python scripts" -gdb_test_sequence "frame" "All unwinders enabled" { - "py_unwind_maint_ps_unwinder called" - "global_unwinder called" - "#0 main" +send_gdb "source ${pyfile}\n" +gdb_expect { + -re "Python script imported\r\n$gdb_prompt $" { + set unwinder_called_on_import false + } + -re ".*$gdb_prompt $" { + set unwinder_called_on_import true + } + timeout { + fail "Can't source python script" + return -1 + } +} + +clean_restart ${testfile} + +if ![runto_main ] then { + fail "Can't run to main" + return -1 +} + +if { $unwinder_called_on_import } { + gdb_test_sequence "source ${pyfile}" "import python scripts" { + "Python script imported" + "py_unwind_maint_ps_unwinder called" + "global_unwinder called" + } + # The unwinders were called above. We keep the name of the + # test the same so that it matches the case below and so that + # we have no greater or fewer passes regardless which path + # is taken. + gdb_test_sequence "frame" "All unwinders enabled" { + "#0 main" + } +} else { + gdb_test "source ${pyfile}" "Python script imported" \ + "import python scripts" + gdb_test_sequence "frame" "All unwinders enabled" { + "py_unwind_maint_ps_unwinder called" + "global_unwinder called" + "#0 main" + } } gdb_test_sequence "info unwinder" "Show all unwinders" { @@ -57,8 +93,15 @@ gdb_test_sequence "continue" "Unwinders called" { "global_unwinder called" } -gdb_test_sequence "disable unwinder global .*" "Unwinder disabled" { - "1 unwinder disabled" +if { $unwinder_called_on_import } { + gdb_test_sequence "disable unwinder global .*" "Unwinder disabled" { + "1 unwinder disabled" + "py_unwind_maint_ps_unwinder called" + } +} else { + gdb_test_sequence "disable unwinder global .*" "Unwinder disabled" { + "1 unwinder disabled" + } } gdb_test_sequence "info unwinder" "Show with global unwinder disabled" {