Re: GDB Python - gdb.execute() - with a timeout?
Duane Ellis <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <[email protected]> |
> This is achievable via pexpect wrapper.
Thanks for the example but that won’t work for my situation - solution needs to run from within a GUI that has already wrapped GDB/LLDB in some form (for example eclipse). The pexpect solution - is external and controls GDB, in my scenario something else is already controlling GDB (i.e.: Eclipse or Emacs-GUD mode)
I have an idea - but don’t know how to implement parts of it
After (X) timeout period I need to simulate pressing “control-C” via the gdb_python solution.
The idea is that Control_C at the GDB command console will cause GDB “cont” to stop - and send a “target halt” command and thus the gdb.excute(‘cont’) call will finish & return.
That would probably be sufficient for my purposes, the idea is sort of this:
Mainline thread:
Set global “timeout period”
FORK - creating new “timeout thread”
perform gdb.execute(“cont”)
*CANCEL* the timeout thread.
Meanwhile, timeout thread
sleeps for “timeout period”
After timeout period - ?? somehow ?? Simulate human pressing Control-C at the GDB console window
Some notes:
(A) I know that GDB is single threaded
(B) I know there is an ‘event queue’ or ‘work queue’
(C) As I understand Python threads must “post” an event to a GDB event/work queue
(D) Eventually when GDB is ‘safe’ that work item would be executed.
Assuming that work item is a call to a Python function, I don’t see how via Python the way to simulate “control-C” at the command console.
Am I missing something? Any suggestions?
Thanks.