From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123110 invoked by alias); 28 Jul 2015 12:14:00 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 123100 invoked by uid 89); 28 Jul 2015 12:14:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL,BAYES_20,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 X-HELO: p3plsmtpa08-10.prod.phx3.secureserver.net Received: from p3plsmtpa08-10.prod.phx3.secureserver.net (HELO p3plsmtpa08-10.prod.phx3.secureserver.net) (173.201.193.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 28 Jul 2015 12:13:58 +0000 Received: from [10.75.25.56] ([67.52.130.29]) by p3plsmtpa08-10.prod.phx3.secureserver.net with id xoDu1q00U0eC05P01oDv47; Tue, 28 Jul 2015 05:13:56 -0700 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: GDB Python - gdb.execute() - with a timeout? From: Duane Ellis In-Reply-To: Date: Tue, 28 Jul 2015 12:14:00 -0000 Content-Transfer-Encoding: quoted-printable Message-Id: <7E44F1FD-CC35-419A-BA31-8D0B5D847DEC@duaneellis.com> References: <10FC35DB-816C-4A6C-A342-ED8E5DAC3E7D@duaneellis.com> To: Ofir Cohen , "gdb@sourceware.org" X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00064.txt.bz2 > This is achievable via pexpect wrapper. Thanks for the example but that won=E2=80=99t work for my situation - solut= ion needs to run from within a GUI that has already wrapped GDB/LLDB in som= e form (for example eclipse). The pexpect solution - is external and contro= ls GDB, in my scenario something else is already controlling GDB (i.e.: Ecl= ipse or Emacs-GUD mode) I have an idea - but don=E2=80=99t know how to implement parts of it After (X) timeout period I need to simulate pressing =E2=80=9Ccontrol-C=E2= =80=9D via the gdb_python solution. The idea is that Control_C at the GDB command console will cause GDB =E2=80= =9Ccont=E2=80=9D to stop - and send a =E2=80=9Ctarget halt=E2=80=9D command= and thus the gdb.excute(=E2=80=98cont=E2=80=99) call will finish & return. That would probably be sufficient for my purposes, the idea is sort of this: Mainline thread: Set global =E2=80=9Ctimeout period=E2=80=9D FORK - creating new =E2=80=9Ctimeout thread=E2=80=9D perform gdb.execute(=E2=80=9Ccont=E2=80=9D) *CANCEL* the timeout thread. Meanwhile, timeout thread sleeps for =E2=80=9Ctimeout period=E2=80=9D 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 =E2=80=98event queue=E2=80=99 or =E2=80=98work qu= eue=E2=80=99 (C) As I understand Python threads must =E2=80=9Cpost=E2=80=9D an event = to a GDB event/work queue (D) Eventually when GDB is =E2=80=98safe=E2=80=99 that work item would b= e executed. Assuming that work item is a call to a Python function, I don=E2=80=99t see= how via Python the way to simulate =E2=80=9Ccontrol-C=E2=80=9D at the comm= and console.=20 Am I missing something? Any suggestions? Thanks.