* How to loop in python extension while accepting mi-commands?
@ 2022-03-10 19:40 Simon Sobisch
0 siblings, 0 replies; only message in thread
From: Simon Sobisch @ 2022-03-10 19:40 UTC (permalink / raw)
To: GDB Mailing list
I've created an auto-step command (something like that in-built would be
quite nice), both the "easy" and "nearly full" implementation can be
found with some explanation at https://stackoverflow.com/a/67470615/5027456
At its core the command does:
# recognize the kind of stop via stop_handler_auto_step
last_stop_was_simple = True
# actual auto-stepping
# we just quit the loop as requested
# pass keyboard and user errors unchanged
except (KeyboardInterrupt, gdb.GdbError):
with a handler of
# check the type of stop, the following is the common one after
# step/next, a more complex one would be a subclass (for example
# breakpoint or signal)
if not type(event) is gdb.StopEvent:
last_stop_was_simple = False
This works in general on the console, steps with a pause as setup and
you can follow the code execution.
It stops on breakpoints and other "events" and when issuing CTRL-C the
code receives the KeyboardInterrupt and is stopped, too.
The problem with this code: while an application can send
-exec-interrupt 10 times GDB seems to queue that because the
user-command is still active.
After the loop is ended, for example by a breakpoint, the MI-side
receives 10 times a "done" response - so there's more than guessing that
GDB seems to queue the commands.
I've tried to move the loop into a python thread via
"thread.start_new_thread(loop_func(sleep_time)" and while the stepping
worked the -exec-interrupt was still not received.
gdb (in this case 9.2 but similar was seen in newer versions) was
started with "-iex set pagination off -iex set mi-async on".
* Is there a way to accept mi-commands while running in Python extension
* Is there a better approach for the auto-step than a loop like the one
above, ending depending on KeyboardInterrupt or a gdb event happens?
* Is there any chance that a command like can be added into GDB? If yes:
would it be helpful to send the "full" python extension script to
Thanks for any comments,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-10 19:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 19:40 How to loop in python extension while accepting mi-commands? Simon Sobisch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).