This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] PR gdb/21698: Fix synchronization problems under python interface
- From: Hsiangkai Wang <hsiangkai at gmail dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>, Phil Muldoon <pmuldoon at redhat dot com>, Tom Tromey <tom at tromey dot com>
- Date: Sun, 22 Apr 2018 07:06:47 +0800
- Subject: Re: [PATCH] PR gdb/21698: Fix synchronization problems under python interface
- References: <1504453086-9952-1-git-send-email-Hsiangkai@gmail.com> <CAH=s-PMabUvUWiM=GwfREJejjab_C782N3iogHXeEM6HWVCLig@mail.gmail.com>
On Mon, Dec 11, 2017 at 8:06 PM, Yao Qi <qiyaoltc@gmail.com> wrote:
> On Sun, Sep 3, 2017 at 4:38 PM, Hsiangkai Wang <Hsiangkai@gmail.com> wrote:
>
> [This patch was not reviewed, and my Arm colleague reminds me
> taking a look at this patch, because ARM embedded toolchain needs
> this fix]
>
>> When executing multiple steppings through gdb.post_event(), prompt will
>> show first and current_ui->prompt_state will be changed to PROMPTED.
>> There is no chance to switch prompt_state to PROMPT_NEEDED or
>> PROMPT_BLOCK. So, synchronous commands will behave like asynchronous
>> commands under gdb.post_event(). In addition, GDB will raise an
>> exception while checking thread state in ensure_not_running() and GDB
>> will hang.
>>
>> I propose a solution to initialize current_ui->prompt_state to
>> PROMPT_NEEDED in execute_gdb_command() to ensure synchronous commands
>> will behave as expected.
>>
>
> The fix is not my area, so I took some time to understand it.
> However, when I read the test below, I start to wonder whether it is a
> right way to use python API gdb.post_event.
>
>> diff --git a/gdb/testsuite/gdb.python/step.py b/gdb/testsuite/gdb.python/step.py
>> new file mode 100644
>> index 0000000..c8cb866
>> --- /dev/null
>> +++ b/gdb/testsuite/gdb.python/step.py
>> @@ -0,0 +1,7 @@
>> +def test_steps():
>> + for _ in range(6):
>> + gdb.execute("si")
>> +
>> + print("Stepping successful.")
>> +
>> +gdb.post_event(test_steps)
>
> Phil and Tom,
> Is it the expected way to use this python interface? It is quite
> ambiguous to me in this case, that is, the callable is called in
> event processing, but the callable has side-effect which causes
> inferior running, and generating more events.
If it is not the expected way to use post_event(), is there any
suggestions to execute multiple steps in Python scripts?