public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: Lancelot SIX <lsix@lancelotsix.com>
Cc: Tom Tromey <tromey@adacore.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH 1/5] Rewrite final cleanups
Date: Mon, 26 Feb 2024 11:53:35 -0700	[thread overview]
Message-ID: <87msrnvyz4.fsf@tromey.com> (raw)
In-Reply-To: <20240225223034.l6gnzbamvivyzuyu@octopus> (Lancelot SIX's message of "Sun, 25 Feb 2024 22:30:34 +0000")

>>>>> "Lancelot" == Lancelot SIX <lsix@lancelotsix.com> writes:

>> tempdir_name = 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 = concat ("rm -rf ", tempdir_name, (char *) NULL);
>> +      wstat = system (zap);
>> +      if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 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 address by
Lancelot> another patch, but in the way to c++ification, this could be replaced
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 callbacks to
Lancelot> never throw (unfortunately, we can’t have use std::function<void ()
Lancelot> noexcept> to have this in the type system).  If we accept that callbacks
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

  reply	other threads:[~2024-02-26 18:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 21:11 [PATCH 0/5] Restore DAP 'quit' request Tom Tromey
2024-02-23 21:11 ` [PATCH 1/5] Rewrite final cleanups Tom Tromey
2024-02-25 22:30   ` Lancelot SIX
2024-02-26 18:53     ` Tom Tromey [this message]
2024-02-27 14:03       ` Lancelot SIX
2024-02-27 17:27         ` Tom Tromey
2024-02-27 17:36           ` Tom Tromey
2024-03-03 16:50           ` Lancelot SIX
2024-02-23 21:11 ` [PATCH 2/5] Add extension_language_ops::shutdown Tom Tromey
2024-02-23 21:11 ` [PATCH 3/5] Change finalize_values into a final cleanup Tom Tromey
2024-02-23 21:11 ` [PATCH 4/5] Add final cleanup for runnables Tom Tromey
2024-02-23 21:11 ` [PATCH 5/5] Explicitly quit gdb from DAP server thread Tom Tromey

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=87msrnvyz4.fsf@tromey.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).