This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: GDB Python - gdb.execute() - with a timeout?
- From: Duane Ellis <duane at duaneellis dot com>
- To: Ofir Cohen <ofircohenn at gmail dot com>, "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Tue, 28 Jul 2015 05:13:54 -0700
- Subject: Re: GDB Python - gdb.execute() - with a timeout?
- Authentication-results: sourceware.org; auth=none
- References: <10FC35DB-816C-4A6C-A342-ED8E5DAC3E7D at duaneellis dot com> <CAHOBVAe3UMMOXFB5mfAqZm-EUrkdOpNrxf4JHOhi+ps1N3_mAA at mail dot gmail dot com>
> 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.