From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id hUKHEUre3GUgyi0AWB0awg (envelope-from ) for ; Mon, 26 Feb 2024 13:54:02 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=VBs6JUtH; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 368E31E0D2; Mon, 26 Feb 2024 13:54:02 -0500 (EST) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C90551E030 for ; Mon, 26 Feb 2024 13:53:59 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14D0D3858C98 for ; Mon, 26 Feb 2024 18:53:59 +0000 (GMT) Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 1113F3858CDB for ; Mon, 26 Feb 2024 18:53:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1113F3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1113F3858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708973621; cv=none; b=Y6c9Etpn8Ra9T+zZq/5x4ut1zSgHK5m3lhGDzyM7+mKJw7TWdkEYuU9a1RMUMAUIhlvjZh4ZDAM8TZ6bA1Dl7+BLpiBYwP7+u2ULOE8ALQQJG1rSdMwXhcyg+3bdVW9VdiQaic1JvjAfFIA/qqn44lWbzFve3EleWQxxRwKFzUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708973621; c=relaxed/simple; bh=wfIlhbv+ybznDc3iDkOAq5y+aI2FtwfmwtlPllpPqJ8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e6XG2ycRJw64UYVEvJ9w1K2PQDaS6pAkjNGjF+HuZurRYDKhHeJtM32xyyMjuL12mNu6NrhqhFNBpUnkhqPLD5UiqWIX+quOjkpvt8CgNVJpSzXT45u41bL/INE62NxGbCnGac/ndu6UVKvgqG8GrwuDDwl88T9utJUvTQUqn04= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-3657c437835so5662745ab.2 for ; Mon, 26 Feb 2024 10:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1708973617; x=1709578417; darn=sourceware.org; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=iPVBHWXe8FHAZG1VxvvFiJGvVY1XGxJSLexF3gs+rWA=; b=VBs6JUtHwfV2gt5SilApyejeMJ84VACsCm5PO1sAWW+aTRzAAAfxurScpVLFKB1mc6 uwauTJTqm0LyyMgX+ZCqpkp2FM9VcHo9TmEEPHqKar0yHBNpeEypWCyQciIhdu/IzZts mtXVA7mGPVoODRn8yRqMdzyXXvmVc1VsLIVRaDy+MfMSPzYfFapbKfXM+1mSh8liXOqW P0PlGRmAVqnmkHF9M6CxGb2juHx+bFoV+YnGoNEZhsw2rm9mVjcteUI0rRuNp9D4yCP/ EKu99AmdScfXadeh4KDEiEYcQdyTuNMzG8XtE6XXFnp2fdWom864T7qId6vnOSgegush tPYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708973617; x=1709578417; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=iPVBHWXe8FHAZG1VxvvFiJGvVY1XGxJSLexF3gs+rWA=; b=vqJdonqb5f6PY5+Mzzv/vcylzDzCrpXY13hYny/amiwVYMx+K6P23p9g3zlTMGqwEV EORMEYeupUxhHjoSJh6gsgyaR/Pc7YqZ6CWDRPpuK43qnGc7dhyhkveWuKB2YKa/MZV+ jLi0Gq3+CFroVCBdmhKNwKiCr11BaQsuCEko6smhq0ullTYQpkGPSE73eMyWfqNe8GI+ RYNyXcTDQmEDMSsEog2++OTkm6foAkeQBeV2bwE6Rm278kxJlbMfCEwchEiqPuUOB2AC KHcVtNhazSe8R3il78RI/MFkxD5IxOXhm86puUiMEL7v0Ebmt952JAVEjHsL8u6ASa3Y tWiQ== X-Forwarded-Encrypted: i=1; AJvYcCWe3+BHaGlRsrfPt/vqqC7jk4sVYL2jdosGPSh5tIjIxNb52DE26HXecWxLxR7hHegega6g2K11a2U3PYdMRXCJ678b4rUZ+6loxg== X-Gm-Message-State: AOJu0YyDRcYS3vDYuNq62SFdZI28JPREu7upg+LyBhzQBhxeNOuh8Ufw xIbn25EiA1w8BVMQCrUTkyoohsZkZxE4fmW4bRB6Lg7zF8eHSjUTx/qXTFeAwA== X-Google-Smtp-Source: AGHT+IF9AN977uzc5li9i6Oe0J9ejiyRUVT1yqRpVvwF98FovBNKBJTnDmnBzh6OYFJbc4db8tXWNw== X-Received: by 2002:a05:6e02:d0b:b0:365:1403:8b8d with SMTP id g11-20020a056e020d0b00b0036514038b8dmr6597320ilj.30.1708973617132; Mon, 26 Feb 2024 10:53:37 -0800 (PST) Received: from murgatroyd (71-211-170-195.hlrn.qwest.net. [71.211.170.195]) by smtp.gmail.com with ESMTPSA id y14-20020a92c74e000000b00364f35b5546sm1683565ilp.28.2024.02.26.10.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 10:53:36 -0800 (PST) From: Tom Tromey To: Lancelot SIX Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [PATCH 1/5] Rewrite final cleanups References: <20240223-final-cleanups-v1-0-84d5271e9979@adacore.com> <20240223-final-cleanups-v1-1-84d5271e9979@adacore.com> <20240225223034.l6gnzbamvivyzuyu@octopus> X-Attribution: Tom Date: Mon, 26 Feb 2024 11:53:35 -0700 In-Reply-To: <20240225223034.l6gnzbamvivyzuyu@octopus> (Lancelot SIX's message of "Sun, 25 Feb 2024 22:30:34 +0000") Message-ID: <87msrnvyz4.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org >>>>> "Lancelot" =3D=3D Lancelot SIX writes: >> tempdir_name =3D xstrdup (tempdir_name); >> - make_final_cleanup (do_rmdir, tempdir_name); >> + add_final_cleanup ([] () >> + { >> + char *zap; >> + int wstat; >> + >> + gdb_assert (startswith (tempdir_name, TMP_PREFIX)); >> + zap =3D concat ("rm -rf ", tempdir_name, (char *) NULL); >> + wstat =3D system (zap); >> + if (wstat =3D=3D -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) = !=3D 0) >> + warning (_("Could not remove temporary directory %s"), tempdir_name); >> + XDELETEVEC (zap); Lancelot> I am aware that this is orthogonal to this patch and can be addre= ss by Lancelot> another patch, but in the way to c++ification, this could be repl= aced Lancelot> with: Lancelot> std::filesystem::remove_all (tempdir_name); Yeah, I think it's better to do this kind of thing as a separate cleanup. Also I wonder if all the compilers we support ship std::filesystem. (I have no idea.) >> void >> do_final_cleanups () >> { >> - do_my_cleanups (&final_cleanup_chain, SENTINEL_CLEANUP); >> + for (auto &func : all_cleanups) >> + func (); >> + all_cleanups.clear (); Lancelot> I am wondering if we want special handling if one of the cleanup Lancelot> function ever throws. It is probably acceptable to expect callba= cks to Lancelot> never throw (unfortunately, we can=E2=80=99t have use std::functi= on noexcept> to have this in the type system). If we accept that ca= llbacks Lancelot> can throw, is it OK to skip pending cleanup functions? We could catch and ignore exceptions here. I'm not sure how important this really is. The current code has ignored it for decades. Tom