From: Joel Brobecker <brobecker@gnat.com>
To: Andrew Cagney <ac131313@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Re-initializing a list after the control returns to gdb...
Date: Tue, 25 Feb 2003 01:37:00 -0000 [thread overview]
Message-ID: <20030225013722.GM910@gnat.com> (raw)
In-Reply-To: <3E53EA7A.8070001@redhat.com>
[Sorry for answering late, got preempted...]
> In hindsite, it needs to be converted to an observer model (or a new
> observer model introduced and the current gdb-hooks changed to one of
> the many observers).
One model that works extremely well is the signals system implemented in
glib. I find it very nicely done. It would be nice if we could reuse
this, but this is a very very complex machinery doing probably way too
much for what we need in GDB.
I would instead suggest something much more simple, like this:
enum notice_kinds
{
breakpoint_created_notice,
breakpoint_deleted_notice,
...
invalid_last_notice, /* Should always be last. */
};
typedef void (notice_ftype) (void *args, void *data);
typedef void (free_notice_data) (void *data);
/* Registers NOTICE_CALLBACK for notification when NOTICE_KIND
events occur. Returns an id of the registration, which can be
used later to unregister. DATA needs to be allocated on the heap,
as it will be passed to NOTICE_CALLBACK when called.
If FREE_NOTICE_DATA is not null, then this function will be called
to free DATA when unsubscribing. */
int notices_subscribe (enum notice_kinds notice_kind,
notice_ftype *notice_callback,
void *data,
void *free_notice_data);
/* Equivalent of:
notices_subscribe (notice_kind, notice_callback, NULL, NULL).
FIXME: This is just a convenience function. Do we want to keep it? */
int notices_subscribe_no_data (enum notice_kinds notice_kind,
notice_ftype *notice_callback);
/* Unregister an observer. */
void notices_unsubscribe (enum notice_kinds notice_kind, int notice_id);
/* Send a notice to all the observers who subscribed for the given
NOTICE_KIND. ARGS is given to the notice callback who should
not how to decipher it. */
void notices_send (enum notice_kinds notice_kind, void *args);
The notices would be more or less implemented as an array of linked
lists of observers.
The DATA parameter is not strictly need in any of the forms of hooks
or events that I have seen so far in GDB's code. This might prove useful
in the future, but we can certainly do without.
This should be fairly easy to implement, and should address all our
current needs. Shall I go ahead and do that?
--
Joel (who must have placed his finger at the wrong spot, all I wanted was
to add a hook, but suddently I found myself swallowed in something a
bit bigger :-).
next prev parent reply other threads:[~2003-02-25 1:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-19 2:01 Joel Brobecker
2003-02-19 12:47 ` Andrew Cagney
2003-02-19 16:05 ` Joel Brobecker
2003-02-19 16:49 ` Andrew Cagney
2003-02-19 17:46 ` Joel Brobecker
2003-02-19 17:01 ` Andrew Cagney
2003-02-19 17:50 ` Joel Brobecker
2003-02-19 18:05 ` Andrew Cagney
2003-02-19 19:24 ` Joel Brobecker
2003-02-19 20:30 ` Andrew Cagney
2003-02-25 1:37 ` Joel Brobecker [this message]
2003-02-26 15:57 ` Andrew Cagney
2003-02-27 7:13 ` Joel Brobecker
2003-02-27 18:44 ` Andrew Cagney
2003-02-28 7:42 ` Joel Brobecker
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=20030225013722.GM910@gnat.com \
--to=brobecker@gnat.com \
--cc=ac131313@redhat.com \
--cc=gdb-patches@sources.redhat.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