public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Patrick Monnerat <patrick@monnerat.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Replace deprecated_target_wait_hook by observers
Date: Tue, 7 Sep 2021 11:08:03 -0400	[thread overview]
Message-ID: <8240f04b-eef9-f14b-1d1f-18b2a187cc65@polymtl.ca> (raw)
In-Reply-To: <20210826144044.146397-1-patrick@monnerat.net>

> diff --git a/gdb/target.c b/gdb/target.c
> index ae2d659583e..22e58484a18 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -26,6 +26,7 @@
>  #include "symtab.h"
>  #include "inferior.h"
>  #include "infrun.h"
> +#include "observable.h"
>  #include "bfd.h"
>  #include "symfile.h"
>  #include "objfiles.h"
> @@ -2591,12 +2592,45 @@ target_disconnect (const char *args, int from_tty)
>    current_inferior ()->top_target ()->disconnect (args, from_tty);
>  }
>  
> +/* RAII class to handle target_wait observers.
> +   These observers allow the Insight GUI to monitor user interaction while
> +   waiting on the target. */
> +
> +class scoped_target_wait
> +{
> +public:
> +  explicit scoped_target_wait (ptid_t ptid)
> +  {
> +    m_event_ptid = null_ptid;
> +    gdb::observers::target_pre_wait.notify (ptid);
> +  }
> +
> +  ~scoped_target_wait ()
> +  {
> +    gdb::observers::target_post_wait.notify (m_event_ptid);

The only dangerous things about this is if an observer throws an
exception, an exception will exit the destructor, and that aborts the
process.

Maybe something safer in that regard would be:

try
  {
    gdb::observers::target_pre_wait.notify (ptid);
    ptid_t event_ptid = target_wait (...);
    gdb::observers::target_post_wait.notify (event_ptid);
    return event_ptid;
  }
catch
  {
    gdb::observers::target_post_wait.notify (null_ptid);
    throw;
  }

Simon

  parent reply	other threads:[~2021-09-07 15:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 14:40 Patrick Monnerat
2021-09-04 11:58 ` [PING] " Patrick Monnerat
2021-09-07 15:08 ` Simon Marchi [this message]
2021-09-23 20:10   ` [PATCH] " Tom Tromey
2021-10-25 19:02     ` Simon Marchi
2021-10-27 18:39       ` Tom Tromey
2022-03-12 12:41 patrick
2022-03-14 13:53 ` Tom Tromey
2022-03-14 14:16   ` Patrick Monnerat

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=8240f04b-eef9-f14b-1d1f-18b2a187cc65@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=patrick@monnerat.net \
    /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).