public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Hsiangkai Wang <hsiangkai@gmail.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: GDB Patches <gdb-patches@sourceware.org>,
	Phil Muldoon <pmuldoon@redhat.com>, 	Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH] PR gdb/21698: Fix synchronization problems under python interface
Date: Sat, 21 Apr 2018 23:06:00 -0000	[thread overview]
Message-ID: <CANnyOUpmC5NpsJLKfnOU3rkHbW5KuBfN3=_CeY7Mq2ifvB7ghw@mail.gmail.com> (raw)
In-Reply-To: <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?

      reply	other threads:[~2018-04-21 23:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-03 15:39 Hsiangkai Wang
2017-12-11 12:06 ` Yao Qi
2018-04-21 23:06   ` Hsiangkai Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANnyOUpmC5NpsJLKfnOU3rkHbW5KuBfN3=_CeY7Mq2ifvB7ghw@mail.gmail.com' \
    --to=hsiangkai@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pmuldoon@redhat.com \
    --cc=qiyaoltc@gmail.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).