From patchwork Mon May 23 19:06:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 12480 Received: (qmail 44336 invoked by alias); 23 May 2016 19:07:11 -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 44311 invoked by uid 89); 23 May 2016 19:07:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Screen, Initially, sk:611a41e, Supported X-HELO: gproxy6-pub.mail.unifiedlayer.com Received: from gproxy6-pub.mail.unifiedlayer.com (HELO gproxy6-pub.mail.unifiedlayer.com) (67.222.39.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Mon, 23 May 2016 19:07:00 +0000 Received: (qmail 24810 invoked by uid 0); 23 May 2016 19:06:59 -0000 Received: from unknown (HELO cmgw4) (10.0.90.85) by gproxy6.mail.unifiedlayer.com with SMTP; 23 May 2016 19:06:59 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw4 with id xv6v1s00A2f2jeq01v6zHr; Mon, 23 May 2016 13:06:59 -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=zCQyP7Im9LFKMgBQszEA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from [71.215.116.141] (port=48686 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1b4vBm-0005qN-Sl; Mon, 23 May 2016 13:06:55 -0600 From: Tom Tromey To: Yao Qi Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [RFA] Fix PR python/17981 References: <1463629620-8915-1-git-send-email-tom@tromey.com> <8637p988by.fsf@gmail.com> <87r3csna40.fsf@tromey.com> <864m9o7sqy.fsf@gmail.com> Date: Mon, 23 May 2016 13:06:51 -0600 In-Reply-To: <864m9o7sqy.fsf@gmail.com> (Yao Qi's message of "Mon, 23 May 2016 15:29:09 +0100") Message-ID: <878tz0wq44.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.94 (gnu/linux) MIME-Version: 1.0 X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 71.215.116.141 authed with tom+tromey.com} Yao> Yes, it is correct, but it is better to explicitly document an empty Yao> sequence is returned if there are no breakpoints. Here you go. Tom From 372c5d3e52de3695ca2148eb7683801285072c0c Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 18 May 2016 21:41:28 -0600 Subject: [PATCH] Fix PR python/17981 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. Built and regtested on x86-64 Fedora 23. 2016-05-23 Tom Tromey PR python/17981: * python/py-breakpoint.c (gdbpy_breakpoints): Return a new tuple when there are no breakpoints. 2016-05-23 Tom Tromey * python.texi (Basic Python): Document gdb.breakpoints return. 2016-05-23 Tom Tromey PR python/17981: * gdb.python/py-breakpoint.exp (test_bkpt_basic): Add test for no-breakpoint case. --- gdb/ChangeLog | 6 ++++++ gdb/doc/ChangeLog | 4 ++++ gdb/doc/python.texi | 5 ++++- gdb/python/py-breakpoint.c | 4 ++-- gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.python/py-breakpoint.exp | 5 ++++- 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 07bc5d2..ef25519 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2016-05-23 Tom Tromey + PR python/17981: + * python/py-breakpoint.c (gdbpy_breakpoints): Return a new tuple + when there are no breakpoints. + +2016-05-23 Tom Tromey + PR python/19438, PR python/18393: * python/py-objfile.c (objfpy_initialize): Initialize self->dict. * python/py-progspace.c (pspy_initialize): Initialize self->dict. diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index fe2e3be..3be4a88 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,7 @@ +2016-05-23 Tom Tromey + + * python.texi (Basic Python): Document gdb.breakpoints return. + 2016-05-17 Tom Tromey * gdb.texinfo (Supported Languages): Mention Rust. Update menu. diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index ffbf89a..6623d8e 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -236,7 +236,10 @@ and height, and its pagination will be disabled; @pxref{Screen Size}. @findex gdb.breakpoints @defun gdb.breakpoints () Return a sequence holding all of @value{GDBN}'s breakpoints. -@xref{Breakpoints In Python}, for more information. +@xref{Breakpoints In Python}, for more information. In @value{GDBN} +version 7.11 and earlier, this function returned @code{None} if there +were no breakpoints. This peculiarity was subsequently fixed, and now +@code{gdb.breakpoints} returns an empty sequence in this case. @end defun @findex gdb.parameter 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 1f0e3f9..afa358b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2016-05-23 Tom Tromey + PR python/17981: + * gdb.python/py-breakpoint.exp (test_bkpt_basic): Add test for + no-breakpoint case. + +2016-05-23 Tom Tromey + PR python/19438, PR python/18393: * gdb.python/py-progspace.exp: Add "dir" test. * gdb.python/py-objfile.exp: Add "dir" test. diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index d1d1b22..f501aa9 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\])" \