PR python/13598 - add before_prompt event
This adds an event that is emitted just before GDB presents a prompt to the user. This provides Python code a way to react to whatever changes might have been made by the previous command. For example, in my GUI I use this to track changes to the selected frame and reflect them in the UI. Built and regtested on x86-64 Fedora 23. gdb/ChangeLog 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. gdb/doc/ChangeLog 2017-02-14 Tom Tromey <tom@tromey.com> PR python/13598: * python.texi (Events In Python): Document events.before_prompt. gdb/testsuite/ChangeLog 2017-02-14 Tom Tromey <tom@tromey.com> PR python/13598: * gdb.python/py-events.exp: Add before_prompt event tests.
This commit is contained in:
parent
075beec08a
commit
3f77c7691f
8 changed files with 57 additions and 0 deletions
|
@ -53,6 +53,7 @@ typedef struct
|
|||
eventregistry_object *breakpoint_created;
|
||||
eventregistry_object *breakpoint_deleted;
|
||||
eventregistry_object *breakpoint_modified;
|
||||
eventregistry_object *before_prompt;
|
||||
|
||||
PyObject *module;
|
||||
|
||||
|
|
|
@ -100,6 +100,9 @@ gdbpy_initialize_py_events (void)
|
|||
"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)
|
||||
|
|
|
@ -100,6 +100,7 @@ const struct extension_language_defn extension_language_python =
|
|||
#include "interps.h"
|
||||
#include "event-top.h"
|
||||
#include "py-ref.h"
|
||||
#include "py-event.h"
|
||||
|
||||
/* True if Python has been successfully initialized, false
|
||||
otherwise. */
|
||||
|
@ -969,6 +970,10 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang,
|
|||
|
||||
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"))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue