From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id B1D0A3858D26 for ; Mon, 28 Oct 2024 17:49:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1D0A3858D26 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B1D0A3858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137772; cv=none; b=U3RnO7ixUc4yLfcmQWNlweanFB8FWdrDtHdDNmX91tcFs75b8XBG5TEg59C6587dm+pd7AD4ziBGbFRC0EEWOOP8Sgpyd3XKuGbrR87gmrvMKSVZHaxry6uQa6UMHsPC3YWiyq3SvT2uSuabJe79S5fh3jvnDl/MCrBm3zivaYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730137772; c=relaxed/simple; bh=sEloRSQFYp3jn5vwSzlvNZ3j2tMjUDA/iDHmt87dc7I=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=Yzidx3GxEwOF1vAdaiRndr2PWahvv526wgtwgiBnQ5OodBAxQbpMqg3iBHrUlS2X58vWrks1aZXKu3KbNXvJ2ZXPLI84bAvjFHGNUGAIlYHiG4tzmT8jkUIHk+FzQpCkQPBH46+zS07Y3VWRd4D3vbHTGXGdJVTN99GQ3p7RgGo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CA7E521F5F for ; Mon, 28 Oct 2024 17:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zWwt3HkSSSJCwYaTUEtAKxhnmg+m3fgA0UgngtBlNuA=; b=J4v9CliBNso3M14XTkUJ15sVm4AxUeQAGqIeJxsBCyRYajO9oET4DlqYX8ZX81cAHzQIw9 X+UeiRVnjOGkMK87F/oH3AJmwaNbeFOFWSTjxAswmO1WXikWZoesTJGokfkpCS80JiDc+W t4Tpec5tSC9Qbo48gTELkcLUnT69lkE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zWwt3HkSSSJCwYaTUEtAKxhnmg+m3fgA0UgngtBlNuA=; b=Z+uVMT1K6Y+DX63cAx6ehNp8CfqP3L3rp0zs853sJjFDhYAmFqtT8UmeHKp8O1UU6XzR2f W/qTdEhPl/lMNXDQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=J4v9CliB; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Z+uVMT1K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zWwt3HkSSSJCwYaTUEtAKxhnmg+m3fgA0UgngtBlNuA=; b=J4v9CliBNso3M14XTkUJ15sVm4AxUeQAGqIeJxsBCyRYajO9oET4DlqYX8ZX81cAHzQIw9 X+UeiRVnjOGkMK87F/oH3AJmwaNbeFOFWSTjxAswmO1WXikWZoesTJGokfkpCS80JiDc+W t4Tpec5tSC9Qbo48gTELkcLUnT69lkE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1730137768; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zWwt3HkSSSJCwYaTUEtAKxhnmg+m3fgA0UgngtBlNuA=; b=Z+uVMT1K6Y+DX63cAx6ehNp8CfqP3L3rp0zs853sJjFDhYAmFqtT8UmeHKp8O1UU6XzR2f W/qTdEhPl/lMNXDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B2D7B13A82 for ; Mon, 28 Oct 2024 17:49:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AH17KqjOH2ccPQAAD6G6ig (envelope-from ) for ; Mon, 28 Oct 2024 17:49:28 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 3/3] [gdbsupport] Add gdb::wait Date: Mon, 28 Oct 2024 18:49:13 +0100 Message-Id: <20241028174913.27056-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241028174913.27056-1-tdevries@suse.de> References: <20241028174913.27056-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: CA7E521F5F X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.01 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Add gdb::wait, and use it in gdb/procfs.c, making sure that EINTR is handled. Tested on x86_64-linux. --- gdb/procfs.c | 9 +++++---- gdbsupport/eintr.cc | 6 ++++++ gdbsupport/eintr.h | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gdb/procfs.c b/gdb/procfs.c index 22e012f0f31..d5177f3735d 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2062,8 +2062,9 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status, { int wait_retval; - /* /proc file not found; presumably child has terminated. */ - wait_retval = ::wait (&wstat); /* "wait" for the child's exit. */ + /* /proc file not found; presumably child has terminated. Wait + for the child's exit. */ + wait_retval = gdb::wait (&wstat); /* Wrong child? */ if (wait_retval != inf->pid) @@ -2150,7 +2151,7 @@ procfs_target::wait (ptid_t ptid, struct target_waitstatus *status, } else { - int temp = ::wait (&wstat); + int temp = gdb::wait (&wstat); /* FIXME: shouldn't I make sure I get the right event from the right process? If (for @@ -2562,7 +2563,7 @@ unconditionally_kill_inferior (procinfo *pi) ret = gdb::waitpid (pi->pid, &status, 0); #else - wait (NULL); + gdb::wait (NULL); #endif } } diff --git a/gdbsupport/eintr.cc b/gdbsupport/eintr.cc index 7e24fa56224..cb6e45feb3c 100644 --- a/gdbsupport/eintr.cc +++ b/gdbsupport/eintr.cc @@ -33,6 +33,12 @@ extern "C" { return gdb::handle_eintr (-1, ::waitpid, pid, wstatus, options); } + pid_t + wait (int *wstatus) + { + return gdb::handle_eintr (-1, ::wait, wstatus); + } + int open (const char *pathname, int flags) { diff --git a/gdbsupport/eintr.h b/gdbsupport/eintr.h index 3919c9fd930..286da5fc400 100644 --- a/gdbsupport/eintr.h +++ b/gdbsupport/eintr.h @@ -68,6 +68,8 @@ handle_eintr (ErrorValType errval, const Fun &f, const Args &... args) extern "C" { extern pid_t waitpid (pid_t pid, int *wstatus, int options); + extern pid_t wait (int *wstatus); + extern int open (const char *pathname, int flags); extern int close (int fd); extern ssize_t read (int fd, void *buf, size_t count); -- 2.35.3