diff options
author | Tom Tromey <tom@tromey.com> | 2015-04-29 09:44:24 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-02-14 10:38:56 -0700 |
commit | 3f77c7691fc5ff92eef90f39bb972f25c7422fb0 (patch) | |
tree | 99e0da3d325474407055aee6a389eacec702623e /gdb/testsuite | |
parent | 075beec08ae857d918890c30d290863abb3f7f57 (diff) | |
download | gdb-3f77c7691fc5ff92eef90f39bb972f25c7422fb0.zip gdb-3f77c7691fc5ff92eef90f39bb972f25c7422fb0.tar.gz gdb-3f77c7691fc5ff92eef90f39bb972f25c7422fb0.tar.bz2 |
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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-events.exp | 25 |
2 files changed, 30 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a54eb67..a67a69c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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. diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index 16ea110..8ec2dd1 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -210,3 +210,28 @@ gdb_test "continue" ".*event type: continue.* .*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" |