This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GDB Python - gdb.execute() - with a timeout?


> 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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]