+2017-02-14 Tom Tromey <tom@tromey.com>
+
+ PR python/13598:
+ * python/python.c (gdbpy_before_prompt_hook): Emit before_prompt
+ event.
+ * python/py-evts.c (gdbpy_initialize_py_events): Add
+ before_prompt registry.
+ * python/py-events.h (events_object) <before_prompt>: New field.
+
2017-02-14 Markus Metzger <markus.t.metzger@intel.com>
* btrace.c (ftrace_new_switch): Preserve up link and flags.
+2017-02-14 Tom Tromey <tom@tromey.com>
+
+ PR python/13598:
+ * python.texi (Events In Python): Document events.before_prompt.
+
2017-02-13 Luis Machado <lgustavo@codesourcery.com>
* gdb.texinfo (Target Commands): Document the optional offset
invalid state; that is, the @code{is_valid} method will return
@code{False}.
+@item events.before_prompt
+This event carries no payload. It is emitted each time @value{GDBN}
+presents a prompt to the user.
+
@end table
@node Threads In Python
eventregistry_object *breakpoint_created;
eventregistry_object *breakpoint_deleted;
eventregistry_object *breakpoint_modified;
+ eventregistry_object *before_prompt;
PyObject *module;
"breakpoint_modified") < 0)
return -1;
+ if (add_new_registry (&gdb_py_events.before_prompt, "before_prompt") < 0)
+ return -1;
+
if (gdb_pymodule_addobject (gdb_module,
"events",
(PyObject *) gdb_py_events.module) < 0)
#include "interps.h"
#include "event-top.h"
#include "py-ref.h"
+#include "py-event.h"
/* True if Python has been successfully initialized, false
otherwise. */
gdbpy_enter enter_py (get_current_arch (), current_language);
+ if (!evregpy_no_listeners_p (gdb_py_events.before_prompt)
+ && evpy_emit_event (NULL, gdb_py_events.before_prompt) < 0)
+ return EXT_LANG_RC_ERROR;
+
if (gdb_python_module
&& PyObject_HasAttrString (gdb_python_module, "prompt_hook"))
{
+2017-02-14 Tom Tromey <tom@tromey.com>
+
+ PR python/13598:
+ * gdb.python/py-events.exp: Add before_prompt event tests.
+
2017-02-14 Andreas Arnez <arnez@linux.vnet.ibm.com>
* gdb.dwarf2/implptrpiece.exp: Fix check for big-endian targets.
.*exit code: 12.*
.*exit inf: 2.*
dir ok: True.*" "Inferior 2 terminated."
+
+
+# Test before_prompt event.
+gdb_py_test_multiple "define new user command" \
+ "define xxz" "End with a line saying just .end.." \
+ "set variable \$x = 72" "" \
+ "set variable \$y = 93" "" \
+ "end" ""
+
+gdb_py_test_multiple "add before_prompt listener" \
+ "python" "" \
+ "count = 0" "" \
+ "def listener():" "" \
+ " global count" "" \
+ " count = count + 1" "" \
+ "gdb.events.before_prompt.connect(listener)" "" \
+ "end" ""
+
+gdb_test_no_output "set variable \$x = 32" "do something"
+# Result is due to one emitted before "set var" and one emitted before
+# this command.
+gdb_test "python print(count)" 2 "check for before_prompt event"
+
+gdb_test_no_output "xxz" "run a canned sequence"
+gdb_test "python print(count)" 4 "check for before_prompt event"