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: Ofir Cohen <ofircohenn at gmail dot com>
- To: Duane Ellis <duane at duaneellis dot com>
- Cc: "gdb at sourceware dot org" <gdb at sourceware dot org>
- Date: Tue, 28 Jul 2015 13:09:38 +0300
- 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>
Hi,
This is achievable via pexpect wrapper.
You can take a look at this example:
http://opensource.apple.com/source/lldb/lldb-76/utils/test/disasm.py
The pexpect.spawn receives timeout as a parameter, so you could adapt it
to your needs.
I don't think this is achievable directly in gdb, i.e. w/o wrappers.
Most of the gdb code _once executed_ is synchronous and doesn't allow timeouts
or that sort of thing.
Correct me if I'm wrong.
- Ofir
On 27 July 2015 at 15:23, Duane Ellis <duane@duaneellis.com> wrote:
> Hi, am trying to script some times using GDB/Python specifically some test cases
>
> The general format of my GDB_PY scripts are:
>
> import gdb
> gdb.execute(âload foobarâ)
>
> gdb.execute(âbreak test_breakpointâ)
>
> gdb.execute(ârunâ)
> gdb.execute(âset test_flag=0x1234â)
>
> gdb.execute(âcontâ) <â HERE Is where I want a timeout
>
> # At this point, we should eventually hit the âtest_breakpointâ
> # However in some cases we do not.
>
> the timeout needs to be âreasonably programableâ - i.e.: 1 second, 10 seconds, an hour would in some use cases be reasonable.
>
> In other words, if my test case is running properly - I should hit the breakpoint.
>
> I need a means to detect when things go wrong.
>
> This problem is *NOT* limited to the TEST case
>
> Is there some way to do this?
>
> Thanks.
>