From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id DCF973858D39 for ; Tue, 28 Mar 2023 17:57:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DCF973858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4PmHT05Vqtz3kTt for ; Tue, 28 Mar 2023 17:57:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PmHT03zMsz3s01 for ; Tue, 28 Mar 2023 17:57:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680026244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rt6O0umD9RpWRJYPHx2VCrqxhI0wVKb+3ya+vsKRzGM=; b=rHMyMUXuIxO4AgC80iJSxunJVMdNwp31M+gXpuAnWh+9mkwJUyLbdbQ5xqcporwhKbuqXq MuYiQIJyN7Fl+x9jD0jSLLB2oADuy0a95LJ3gJ/GAgkZg0V7CEChGYGSubYqb75jNpJWOg II8RzmDh6QMb/vvTpGvrOLaqmznDdRemYKkW2Owvyz9D6az3Mz/ZE45Su7VBQMmnGA3ixa /hYVh1LhuA8jm2Fxg5kWBdgg7cBllnz82LxHGHLoZt4ntYCoZuMCrWMxxnc3jsLgCnEh1S kGeVyHYGoIsenOSLh6sqW7j9Q0vSl9zUPqFARavHcfE5vznrDs16yOHqZd9VSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680026244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rt6O0umD9RpWRJYPHx2VCrqxhI0wVKb+3ya+vsKRzGM=; b=tqTvtF9WcTLYuKklhOYqWAb2HZHSgny5uM8AM0QdR4huaRv8kgqUbgeDX/0CVrTafuk0Gm CAs3Aq3mwUnOubfsCanWNysT1WUXoLsBsu66R84nckC74k2aL8FHYoa+lFF/W2wXB6VVhp HpyoY5MDcFbLg4FOujUHYALVJv00w7KXyemGfSQzSbRh/Hs4/QXI1INSAYvHCDWVj1drlm tlIkConu7N10aCDqAhvqUXNdYCOj241cCXsYxEEXv3VJDS/zMwJwylfGFhdVUXt5OGQFZ9 g1Q5ldiwKtdsKqVLn6Vw4gSOap9M2s7NAakn6WUn51pnVFIhQorGkXpRF1q8hQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680026244; a=rsa-sha256; cv=none; b=FEc5EqlKjeXhmvVbFRGepHJkiSOfBt+SGXIkA42Yc/HpxXOVtJ5yzLDXsS48R4wIWuP/r5 B1Li+eHATktKKg7mkAay0ANiioR+i2bZo3Xwq/3vhRIYnJ/VPteeut6tfjVSne/g0NnovA Jq2R4O17oJzI9CkYC8yrOVsL8bzua0CAxrtSNSgxD8V+iACPLhITcS78mefglAm5IwKaVK wZoqG0RlTxDF3LSvtTo+hN3V01GAl5z30a2RsdRin7ewEIHDitNHGoPx94NiZXoowyy1T0 /aYPJA64fQOQX34vbNHT/5dLtS+pxrOaWzc14XlOnShdG9gXZHUI0XGePe1PEg== Received: from [IPV6:2601:648:8680:16b0:2d4e:165:cff:1385] (unknown [IPv6:2601:648:8680:16b0:2d4e:165:cff:1385]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PmHT01fHfzjtJ for ; Tue, 28 Mar 2023 17:57:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <20187516-da6d-17f3-30c1-5d5b360d36f2@FreeBSD.org> Date: Tue, 28 Mar 2023 10:57:23 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] gdb: fix -Wdeprecated-declarations on macOS Content-Language: en-US To: gdb-patches@sourceware.org References: <6379554d-4e45-0ff8-a972-47596ea83b90@simark.ca> <7657bb99-0319-ed79-fe2a-fb74a3876798@FreeBSD.org> <4d64a51b-4a3b-2949-84cd-bbdb528b971e@simark.ca> From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,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: On 3/28/23 10:52 AM, John Baldwin wrote: > On 3/28/23 9:01 AM, Simon Marchi wrote: >> On 3/28/23 11:10, John Baldwin wrote: >>> On 3/28/23 7:55 AM, Simon Marchi via Gdb-patches wrote: >>>> On 3/28/23 10:16, Enze Li via Gdb-patches wrote: >>>>> I noticed that there are some issues when compiling on macOS. There are >>>>> a few places where errors like the following are reported, >>>>> >>>>> ====== >>>>> CXX cli/cli-cmds.o >>>>> cli/cli-cmds.c:929:14: error: 'vfork' is deprecated: Use posix_spawn or fork [-Werror,-Wdeprecated-declarations] >>>>> if ((pid = vfork ()) == 0) >>>>> ^ >>>>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:604:1: note: 'vfork' has been explicitly marked deprecated here >>>>> __deprecated_msg("Use posix_spawn or fork") >>>>> ^ >>>>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:208:48: note: expanded from macro '__deprecated_msg' >>>>> #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg))) >>>>> ^ >>>>> 1 error generated. >>>>> ====== >>>>> >>>>> This patch is only available for the macOS platform. This is done by >>>>> using macros to differentiate between specific platforms. >>>>> >>>>> Tested by rebuilding both on x86_64 linux and macOS Big Sur. >>>> >>>> Any idea why vfork is deprecated on macOS? I can't find any answer >>>> online. >>>> >>>> I think it would be good to have a gdb_ util function with the ifdef at >>>> a single place, with an appropriate comment. I don't know how to call >>>> this function though. Would calling it gdb_vfork be misleading, because >>>> it won't always vfork? >>> >>> Even if vfork is deprecated, you still want to use it instead of fork I think >>> as long as it exists. The real fix is to add a patch to use posix_spawn >>> to fork the shell instead of vfork when posix_spawn exists. posix_spawn is >>> just a wrapper around vfork + execve on FreeBSD's libc for example (I haven't >>> looked to see what it is on Linux but suspect it is similar). >> >> I guess that using posix_spawn would require some very significant >> architectural changes? Right now, we fork (or vfork), do some cleanup / >> prep work, and then exec. How do you do that with posix_spawn? > > Hummm, it depends on the prep work. If you are shuffling things like > fd's you do that as actions you pass to posix_spawn. However, Tom's > point about PTRACE_ME is true that I don't know if any systems have > a posix_spawn extension to do that operation. In theory it wouldn't > be hard to add such a thing to posix_spawn, but it's not there today. > If MacOS does support attaching the debugger for its posix_spawn it > might still be better to use posix_spawn on MacOS, but if not I guess > we are stuck with plain fork. Ah, MacOS does support such an extension via an OS-specific flag passed to posix_spawnattr_setflags: POSIX_SPAWN_START_SUSPENDED Apple Extension: If this bit is set, then the child process will be created as if it immediately received a SIGSTOP signal, per- mitting debuggers, profilers, and other pro- grams to manipulate the process before it begins execution in user space. This per- mits, for example, obtaining exact instruc- tion counts, or debugging very early in dyld(1). To resume the child process, it must be sent a SIGCONT signal. -- John Baldwin