]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR python/17698 - add Breakpoint.pending
authorTom Tromey <tom@tromey.com>
Thu, 19 May 2016 21:51:00 +0000 (15:51 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 13 Jul 2016 19:21:00 +0000 (13:21 -0600)
This patch adds a "pending" attribute to gdb.Breakpoint.

Built and regtested on x86-64 Fedora 23.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/17698:
* NEWS: Update.
* python/py-breakpoint.c (bppy_get_pending): New function.
(breakpoint_object_getset): Add entry for "pending".
* breakpoint.h (pending_breakpoint_p): Declare.
* breakpoint.c (pending_breakpoint_p): New function.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/17698:
* python.texi (Breakpoints In Python): Document
Breakpoint.pending.

2016-07-13  Tom Tromey  <tom@tromey.com>

PR python/17698:
* gdb.python/py-breakpoint.exp (test_bkpt_basic): Add "pending"
test.
(test_watchpoints): Likewise.
(test_bkpt_pending): New proc.

gdb/ChangeLog
gdb/NEWS
gdb/breakpoint.c
gdb/breakpoint.h
gdb/doc/ChangeLog
gdb/doc/python.texi
gdb/python/py-breakpoint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-breakpoint.exp

index 437f4a5ca7677528d2a9a4de4b2d960346ee7f21..6a426b8bb47c0968163c116b35d6147350b83353 100644 (file)
@@ -1,3 +1,12 @@
+2016-07-13  Tom Tromey  <tom@tromey.com>
+
+       PR python/17698:
+       * NEWS: Update.
+       * python/py-breakpoint.c (bppy_get_pending): New function.
+       (breakpoint_object_getset): Add entry for "pending".
+       * breakpoint.h (pending_breakpoint_p): Declare.
+       * breakpoint.c (pending_breakpoint_p): New function.
+
 2016-07-13  Tom Tromey  <tom@tromey.com>
 
        * python/py-breakpoint.c (bppy_get_visibility)
index 3823f20cbb1cf5102db9766a626bbfdc7b640d97..c29e69af4885cedf240cbb5c32a707751b609410 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -80,6 +80,11 @@ new-ui INTERP TTY
   Start a new user interface instance running INTERP as interpreter,
   using the TTY file for input/output.
 
+* Python Scripting
+
+  ** gdb.Breakpoint objects have a new attribute "pending", which
+     indicates whether the breakpoint is pending.
+
 * Support for tracepoints and fast tracepoints on s390-linux and s390x-linux
   was added in GDBserver, including JIT compiling fast tracepoint's
   conditional expression bytecode into native code.
index 0b29a8ac55199690bc721fcf5587f269b357b261..e4b62c7ffff8cc160381d441e5d454f188c52bc8 100644 (file)
@@ -6815,6 +6815,14 @@ user_breakpoint_p (struct breakpoint *b)
   return b->number > 0;
 }
 
+/* See breakpoint.h.  */
+
+int
+pending_breakpoint_p (struct breakpoint *b)
+{
+  return b->loc == NULL;
+}
+
 /* Print information on user settable breakpoint (watchpoint, etc)
    number BNUM.  If BNUM is -1 print all user-settable breakpoints.
    If ALLFLAG is non-zero, include non-user-settable breakpoints.  If
index 054eab4d75eff2fab5daf12af98bfb76432d7c38..5f06772d6f5dba3e6a66186bb4fd24e2a51a8d72 100644 (file)
@@ -1618,6 +1618,9 @@ extern int pc_at_non_inline_function (struct address_space *aspace,
 
 extern int user_breakpoint_p (struct breakpoint *);
 
+/* Return true if this breakpoint is pending, false if not.  */
+extern int pending_breakpoint_p (struct breakpoint *);
+
 /* Attempt to determine architecture of location identified by SAL.  */
 extern struct gdbarch *get_sal_arch (struct symtab_and_line sal);
 
index 2e0c0bb6267334c435c43d615e2d50a8133c8364..b1ddc289a25b8310325a52a0957680b735356555 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-13  Tom Tromey  <tom@tromey.com>
+
+       PR python/17698:
+       * python.texi (Breakpoints In Python): Document
+       Breakpoint.pending.
+
 2016-07-13  Tom Tromey  <tom@tromey.com>
 
        * python.texi (Breakpoints In Python): Move table of types and
index 69134d4ac9fc61e3ecff329ada44baf5994e0d5d..e00bc2a7046e59301b99188bd18460a66dc2b40f 100644 (file)
@@ -4685,6 +4685,12 @@ first command is @code{silent}.  This is not reported by the
 @code{silent} attribute.
 @end defvar
 
+@defvar Breakpoint.pending
+This attribute is @code{True} if the breakpoint is pending, and
+@code{False} otherwise.  @xref{Set Breaks}.  This attribute is
+read-only.
+@end defvar
+
 @anchor{python_breakpoint_thread}
 @defvar Breakpoint.thread
 If the breakpoint is thread-specific, this attribute holds the
index 513a02d08f261a101d6409310061c7e1862930d1..f2d4385c84e0309ddce23707732565a2d16a66cf 100644 (file)
@@ -563,6 +563,24 @@ bppy_get_temporary (PyObject *self, void *closure)
   Py_RETURN_FALSE;
 }
 
+/* Python function to determine if the breakpoint is a pending
+   breakpoint.  */
+
+static PyObject *
+bppy_get_pending (PyObject *self, void *closure)
+{
+  gdbpy_breakpoint_object *self_bp = (gdbpy_breakpoint_object *) self;
+
+  BPPY_REQUIRE_VALID (self_bp);
+
+  if (is_watchpoint (self_bp->bp))
+    Py_RETURN_FALSE;
+  if (pending_breakpoint_p (self_bp->bp))
+    Py_RETURN_TRUE;
+
+  Py_RETURN_FALSE;
+}
+
 /* Python function to get the breakpoint's number.  */
 static PyObject *
 bppy_get_number (PyObject *self, void *closure)
@@ -1054,6 +1072,8 @@ or None if no condition set."},
     "Whether the breakpoint is visible to the user."},
   { "temporary", bppy_get_temporary, NULL,
     "Whether this breakpoint is a temporary breakpoint."},
+  { "pending", bppy_get_pending, NULL,
+    "Whether this breakpoint is a pending breakpoint."},
   { NULL }  /* Sentinel.  */
 };
 
index b404db4443d5c52c741b8550ac4bfccab9b202e7..79a3dd7c39c7a0d254b08d3583f8af260102acbb 100644 (file)
@@ -1,3 +1,11 @@
+2016-07-13  Tom Tromey  <tom@tromey.com>
+
+       PR python/17698:
+       * gdb.python/py-breakpoint.exp (test_bkpt_basic): Add "pending"
+       test.
+       (test_watchpoints): Likewise.
+       (test_bkpt_pending): New proc.
+
 2016-07-13  Tom Tromey  <tom@tromey.com>
 
        PR cli/18053:
index f501aa91d8a4231366d56d80691f958d445a179d..eb8ec8866921f18be5abc5c937d119f330d4ff5e 100644 (file)
@@ -49,6 +49,8 @@ proc test_bkpt_basic { } {
            "<gdb.Breakpoint object at $hex>" "Check obj exists @main"
        gdb_test "python print (blist\[0\].location)" \
            "main." "Check breakpoint location @main"
+       gdb_test "python print (blist\[0\].pending)" "False" \
+           "Check pending status of main breakpoint"
 
        set mult_line [gdb_get_line_number "Break at multiply."]
        gdb_breakpoint ${mult_line}
@@ -267,6 +269,7 @@ proc test_watchpoints { } {
 
        gdb_py_test_silent_cmd  "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE )" \
            "Set watchpoint" 0
+       gdb_test "python print (wp1.pending)" "False"
        gdb_test "continue" \
            ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*main.*" \
            "Test watchpoint write"
@@ -497,6 +500,13 @@ proc test_bkpt_address {} {
        ".*Breakpoint ($decimal)+ at .*$srcfile, line ($decimal)+\."
 }
 
+proc test_bkpt_pending {} {
+    delete_breakpoints
+    gdb_breakpoint "nosuchfunction" allow-pending
+    gdb_test "python print (gdb.breakpoints()\[0\].pending)" "True" \
+       "Check pending status of pending breakpoint"
+}
+
 test_bkpt_basic
 test_bkpt_deletion
 test_bkpt_cond_and_cmds
@@ -506,3 +516,4 @@ test_bkpt_internal
 test_bkpt_eval_funcs
 test_bkpt_temporary
 test_bkpt_address
+test_bkpt_pending