From patchwork Thu May 19 03:47:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 12368 Received: (qmail 59947 invoked by alias); 19 May 2016 03:47:31 -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 58236 invoked by uid 89); 19 May 2016 03:47:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, FSL_HELO_HOME, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=H*m:tromey, Initially, H*MI:tom X-HELO: gproxy8-pub.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8-pub.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Thu, 19 May 2016 03:47:13 +0000 Received: (qmail 32360 invoked by uid 0); 19 May 2016 03:47:10 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy8.mail.unifiedlayer.com with SMTP; 19 May 2016 03:47:10 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id w3n61s00g2f2jeq013n9AB; Wed, 18 May 2016 21:47:10 -0600 X-Authority-Analysis: v=2.1 cv=EftbHpWC c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=_v2sUkyEFrwA:10 a=yrkiwgmsf1kA:10 a=zstS-IiYAAAA:8 a=0FD05c-RAAAA:8 a=-Tw2qtJ8SvaZbl0imiQA:9 a=4G6NA9xxw8l3yy4pmD5M:22 a=l1rpMCqCXRGZwUSuRcM3:22 Received: from [71.215.116.141] (port=40808 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1b3EvS-0006ea-M6; Wed, 18 May 2016 21:47:06 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Fix PR python/17981 Date: Wed, 18 May 2016 21:47:00 -0600 Message-Id: <1463629620-8915-1-git-send-email-tom@tromey.com> X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 71.215.116.141 authed with tom+tromey.com} PR python/17981 notes that gdb.breakpoints() returns None when there are no breakpoints; whereas an empty list or tuple would be more in keeping with Python and the documentation. This patch fixes the bug by changing the no-breakpoint return to make an empty tuple. It's arguable whether this should be changed. On the one hand, it may mean some script has to adapt. On the other hand, it's clearly better this way. Built and regtested on x86-64 Fedora 23. 2016-05-18 Tom Tromey PR python/17981: * python/py-breakpoint.c (gdbpy_breakpoints): Return a new tuple when there are no breakpoints. 2016-05-18 Tom Tromey PR python/17981: * gdb.python/py-breakpoint.exp (test_bkpt_basic): Add test for no-breakpoint case. --- gdb/ChangeLog | 6 ++++++ gdb/python/py-breakpoint.c | 4 ++-- gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.python/py-breakpoint.exp | 5 ++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 92024b6..53b11c0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2016-05-18 Tom Tromey + PR python/17981: + * python/py-breakpoint.c (gdbpy_breakpoints): Return a new tuple + when there are no breakpoints. + +2016-05-18 Tom Tromey + * rust-lang.c (rust_subscript): Initialize "high". 2016-05-17 Simon Marchi diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 611a41e..ed9cae6 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -746,13 +746,13 @@ gdbpy_breakpoints (PyObject *self, PyObject *args) PyObject *list, *tuple; if (bppy_live == 0) - Py_RETURN_NONE; + return PyTuple_New (0); list = PyList_New (0); if (!list) return NULL; - /* If iteratre_over_breakpoints returns non NULL it signals an error + /* If iterate_over_breakpoints returns non NULL it signals an error condition. In that case abandon building the list and return NULL. */ if (iterate_over_breakpoints (build_bp_list, list) != NULL) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a773c63..c09e858 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-05-18 Tom Tromey + + PR python/17981: + * gdb.python/py-breakpoint.exp (test_bkpt_basic): Add test for + no-breakpoint case. + 2016-05-18 Simon Marchi * gdb.mi/mi-threads-interrupt.c: New file. diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index d1d1b22..0116705 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -34,12 +34,15 @@ proc test_bkpt_basic { } { # Start with a fresh gdb. clean_restart ${testfile} + # We should start with no breakpoints. + gdb_test "python print gdb.breakpoints()" "\\(\\)" + if ![runto_main] then { fail "Cannot run to main." return 0 } - # Initially there should be one breakpoint: main. + # Now there should be one breakpoint: main. gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \ "Get Breakpoint List" 0 gdb_test "python print (blist\[0\])" \