From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA] Fix PR python/17981
Date: Thu, 19 May 2016 03:47:00 -0000 [thread overview]
Message-ID: <1463629620-8915-1-git-send-email-tom@tromey.com> (raw)
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 <tom@tromey.com>
PR python/17981:
* python/py-breakpoint.c (gdbpy_breakpoints): Return a new tuple
when there are no breakpoints.
2016-05-18 Tom Tromey <tom@tromey.com>
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 <tom@tromey.com>
+ PR python/17981:
+ * python/py-breakpoint.c (gdbpy_breakpoints): Return a new tuple
+ when there are no breakpoints.
+
+2016-05-18 Tom Tromey <tom@tromey.com>
+
* rust-lang.c (rust_subscript): Initialize "high".
2016-05-17 Simon Marchi <simon.marchi@ericsson.com>
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 <tom@tromey.com>
+
+ PR python/17981:
+ * gdb.python/py-breakpoint.exp (test_bkpt_basic): Add test for
+ no-breakpoint case.
+
2016-05-18 Simon Marchi <simon.marchi@ericsson.com>
* 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\])" \
--
2.5.5
next reply other threads:[~2016-05-19 3:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 3:47 Tom Tromey [this message]
2016-05-23 8:52 ` Yao Qi
2016-05-23 14:05 ` Tom Tromey
2016-05-23 14:29 ` Yao Qi
2016-05-23 19:07 ` Tom Tromey
2016-05-23 19:15 ` Eli Zaretskii
2016-05-23 19:07 ` Tom Tromey
2016-05-24 8:38 ` Yao Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463629620-8915-1-git-send-email-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox