This is the mail archive of the gdb-patches@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: [PATCH] PR gdb/21698: Fix synchronization problems under python interface


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.

-- 
Yao (齐尧)


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