Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 8/8] gdb: resume ongoing step after handling fork or vfork
Date: Thu, 31 Mar 2022 19:22:53 +0100	[thread overview]
Message-ID: <7c2c3635-3b05-e3f8-05a3-c15bd6771a5c@palves.net> (raw)
In-Reply-To: <20220117162742.524350-9-simon.marchi@polymtl.ca>

On 2022-01-17 16:27, Simon Marchi via Gdb-patches wrote:
> From: Simon Marchi <simon.marchi@efficios.com>
> 
> The test introduced by this patch would fail in this configuration, with
> the native-gdbserver or native-extended-gdbserver boards:
> 
>     FAIL: gdb.threads/next-fork-other-thread.exp: fork_func=fork: target-non-stop=auto: non-stop=off: displaced-stepping=auto: i=2: next to for loop
> 
> The problem is that the step operation is forgotten when handling the
> fork/vfork.  With "debug infrun" and "debug remote", it looks like this
> (some lines omitted for brevity).  We do the next:
> 
>     [infrun] proceed: enter
>       [infrun] proceed: addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT
>       [infrun] resume_1: step=1, signal=GDB_SIGNAL_0, trap_expected=0, current thread [4154304.4154304.0] at 0x5555555553bf
>       [infrun] do_target_resume: resume_ptid=4154304.0.0, step=1, sig=GDB_SIGNAL_0
>       [remote] Sending packet: $vCont;r5555555553bf,5555555553c4:p3f63c0.3f63c0;c:p3f63c0.-1#cd
>     [infrun] proceed: exit
> 
> We then handle a fork event:
> 
>     [infrun] fetch_inferior_event: enter
>       [remote] wait: enter
>         [remote] Packet received: T05fork:p3f63ee.3f63ee;06:0100000000000000;07:b08e59f6ff7f0000;10:bf60e8f7ff7f0000;thread:p3f63c0.3f63c6;core:17;
>       [remote] wait: exit
>       [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status) =
>       [infrun] print_target_wait_results:   4154304.4154310.0 [Thread 4154304.4154310],
>       [infrun] print_target_wait_results:   status->kind = FORKED, child_ptid = 4154350.4154350.0
>       [infrun] handle_inferior_event: status->kind = FORKED, child_ptid = 4154350.4154350.0
>       [remote] Sending packet: $D;3f63ee#4b
>       [infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [4154304.4154310.0] at 0x7ffff7e860bf
>       [infrun] do_target_resume: resume_ptid=4154304.0.0, step=0, sig=GDB_SIGNAL_0
>       [remote] Sending packet: $vCont;c:p3f63c0.-1#73
>     [infrun] fetch_inferior_event: exit
> 
> In the first snippet, we resume the stepping thread with the range-stepping (r)
> vCont command.  But after handling the fork (detaching the fork child), we
> resumed the whole process freely.  The stepping thread, which was paused by
> GDBserver while reporting the fork event, was therefore resumed freely, instead
> of confined to the addresses of the stepped line.  Note that since this
> is a "next", it could be that we have entered a function, installed a
> step-resume breakpoint, and it's ok to continue freely the stepping
> thread, but that's not the case here.  The two snippets shown above were
> next to each other in the logs.
> 
> For the fork case, we can resume stepping right after handling the
> event.
> 
> However, for the vfork case, where we are waiting for the
> external child process to exec or exit, we only resume the thread that
> called vfork, and keep the others stopped (see patch "gdb: fix handling of
> vfork by multi-threaded program" prior in this series).  So we can't
> resume the stepping thread right now.  Instead, do it after handling the
> vfork-done event.

Also OK.

Thanks for doing all this.

  reply	other threads:[~2022-03-31 18:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 16:27 [PATCH 0/8] Some fixes for handling vfork by multi-threaded programs Simon Marchi via Gdb-patches
2022-01-17 16:27 ` [PATCH 1/8] gdb/infrun: add reason parameter to stop_all_threads Simon Marchi via Gdb-patches
2022-03-31 15:05   ` Pedro Alves
2022-03-31 15:35     ` Simon Marchi via Gdb-patches
2022-01-17 16:27 ` [PATCH 2/8] gdb/linux-nat: remove check based on current_inferior in linux_handle_extended_wait Simon Marchi via Gdb-patches
2022-03-31 16:12   ` Pedro Alves
2022-03-31 17:06     ` Simon Marchi via Gdb-patches
2022-01-17 16:27 ` [PATCH 3/8] gdb: replace inferior::waiting_for_vfork_done with inferior::thread_waiting_for_vfork_done Simon Marchi via Gdb-patches
2022-03-31 18:17   ` Pedro Alves
2022-04-01 14:25     ` Simon Marchi via Gdb-patches
2022-01-17 16:27 ` [PATCH 4/8] gdb/infrun: add inferior parameters to stop_all_threads and restart_threads Simon Marchi via Gdb-patches
2022-03-31 18:17   ` Pedro Alves
2022-01-17 16:27 ` [PATCH 5/8] gdb/infrun: add logging statement to do_target_resume Simon Marchi via Gdb-patches
2022-03-31 18:18   ` Pedro Alves
2022-01-17 16:27 ` [PATCH 6/8] gdb: fix handling of vfork by multi-threaded program (follow-fork-mode=parent, detach-on-fork=on) Simon Marchi via Gdb-patches
2022-03-31 18:21   ` Pedro Alves
2022-04-01 17:28     ` Simon Marchi via Gdb-patches
2022-01-17 16:27 ` [PATCH 7/8] gdbserver: report correct status in thread stop race condition Simon Marchi via Gdb-patches
2022-03-31 18:21   ` Pedro Alves
2022-01-17 16:27 ` [PATCH 8/8] gdb: resume ongoing step after handling fork or vfork Simon Marchi via Gdb-patches
2022-03-31 18:22   ` Pedro Alves [this message]
2022-03-31 18:28   ` Pedro Alves
2022-04-01 18:42     ` Simon Marchi via Gdb-patches

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=7c2c3635-3b05-e3f8-05a3-c15bd6771a5c@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=simon.marchi@polymtl.ca \
    /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