From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0AO9LceZ5WHbCgAAWB0awg (envelope-from ) for ; Mon, 17 Jan 2022 11:31:03 -0500 Received: by simark.ca (Postfix, from userid 112) id B830C1F34E; Mon, 17 Jan 2022 11:31:03 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 573601EAA4 for ; Mon, 17 Jan 2022 11:31:03 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1820385843B for ; Mon, 17 Jan 2022 16:31:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1820385843B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1642437062; bh=KxL4ZLwpQxFs/cMMdO7Z4jZkJbTIP6Wina37Lz8jtQs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ydq1TQyc1+p2PaBCjy2ptRagLtBvcqh1uyVCk+huuSDxloTZTmAwiu0/J3Rk7Xz3I x6cBklbZ4TaONGIZo1/5ImkjjcC3jvkBw6f78/9xTF2mhTnRW7aZRPtpAMV4/0fRcM NN+gtLWdS3lv4+WEG1X7qpwM3PruYzVUMkONLGNs= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id EC4D73858022 for ; Mon, 17 Jan 2022 16:28:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC4D73858022 X-ASG-Debug-ID: 1642436863-0c856e06ab1223b0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 55CfaxtRkYXrXmL0 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 17 Jan 2022 11:27:43 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 0857A441B21; Mon, 17 Jan 2022 11:27:43 -0500 (EST) X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 0/8] Some fixes for handling vfork by multi-threaded programs Date: Mon, 17 Jan 2022 11:27:34 -0500 X-ASG-Orig-Subj: [PATCH 0/8] Some fixes for handling vfork by multi-threaded programs Message-Id: <20220117162742.524350-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1642436863 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2953 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.95393 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Someone reported to me a while ago that stepping in a multi-threaded program where some threads sometimes call vfork would make GDB behave erratically. Some "step"s or "next"s would land in the wrong place, or just behave as "continue". After a bit of investigation, I realized that GDB didn't handle vforks by multi-threaded program correctly. See patch "fix handling of vfork by multi-threaded program" for an in-depth explanation. While working on this, I tried to fix all combinations of target-non-stop, non-stop, schedule-multiple, detach-on-fork and follow-fork-mode. However, I was not seeing the end of it and it was making me a bit crazy. So I chose to only focus on the "default" case of detach-on-fork=on and follow-fork-mode=parent for now. It will probably make it easier for the reviewers too. Simon Marchi (8): gdb/infrun: add reason parameter to stop_all_threads gdb/linux-nat: remove check based on current_inferior in linux_handle_extended_wait gdb: replace inferior::waiting_for_vfork_done with inferior::thread_waiting_for_vfork_done gdb/infrun: add inferior parameters to stop_all_threads and restart_threads gdb/infrun: add logging statement to do_target_resume gdb: fix handling of vfork by multi-threaded program (follow-fork-mode=parent, detach-on-fork=on) gdbserver: report correct status in thread stop race condition gdb: resume ongoing step after handling fork or vfork gdb/infcmd.c | 2 +- gdb/inferior.h | 8 +- gdb/infrun.c | 210 ++++++++++++++++-- gdb/infrun.h | 14 +- gdb/linux-nat.c | 17 +- gdb/remote.c | 2 +- .../gdb.threads/next-fork-other-thread.c | 86 +++++++ .../gdb.threads/next-fork-other-thread.exp | 116 ++++++++++ .../gdb.threads/vfork-multi-inferior-sleep.c | 25 +++ .../gdb.threads/vfork-multi-inferior.c | 55 +++++ .../gdb.threads/vfork-multi-inferior.exp | 115 ++++++++++ .../gdb.threads/vfork-multi-thread.c | 74 ++++++ .../gdb.threads/vfork-multi-thread.exp | 96 ++++++++ gdbserver/linux-low.cc | 60 +++-- 14 files changed, 801 insertions(+), 79 deletions(-) create mode 100644 gdb/testsuite/gdb.threads/next-fork-other-thread.c create mode 100644 gdb/testsuite/gdb.threads/next-fork-other-thread.exp create mode 100644 gdb/testsuite/gdb.threads/vfork-multi-inferior-sleep.c create mode 100644 gdb/testsuite/gdb.threads/vfork-multi-inferior.c create mode 100644 gdb/testsuite/gdb.threads/vfork-multi-inferior.exp create mode 100644 gdb/testsuite/gdb.threads/vfork-multi-thread.c create mode 100644 gdb/testsuite/gdb.threads/vfork-multi-thread.exp base-commit: 1adce770ea443ec73c8af29618c504495893d0b8 -- 2.34.1