/* GDB Notifications to Observers.
- Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011
+ Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* An observer is an entity who is interested in being notified when GDB
- reaches certain states, or certain events occur in GDB. The entity being
- observed is called the Subject. To receive notifications, the observer
- attaches a callback to the subject. One subject can have several
+ reaches certain states, or certain events occur in GDB. The entity being
+ observed is called the Subject. To receive notifications, the observer
+ attaches a callback to the subject. One subject can have several
observers.
This file implements an internal generic low-level event notification
for all possible notifications.
The current implementation of the generic observer provides support
- for contextual data. This contextual data is given to the subject
- when attaching the callback. In return, the subject will provide
+ for contextual data. This contextual data is given to the subject
+ when attaching the callback. In return, the subject will provide
this contextual data back to the observer as a parameter of the
callback.
FIXME: The current support for the contextual data is only partial,
as it lacks a mechanism that would deallocate this data when the
- callback is detached. This is not a problem so far, as this contextual
- data is only used internally to hold a function pointer. Later on,
+ callback is detached. This is not a problem so far, as this contextual
+ data is only used internally to hold a function pointer. Later on,
if a certain observer needs to provide support for user-level
contextual data, then the generic notification mechanism will need
need to be enhanced to allow the observer to provide a routine to
xalloc_observer_list_node (void)
{
struct observer_list *node = XMALLOC (struct observer_list);
+
node->observer = XMALLOC (struct observer);
return node;
}
int observer_test_third_observer = 0;
void
-observer_test_first_notification_function (struct bpstats *bs)
+observer_test_first_notification_function (int arg)
{
observer_test_first_observer++;
}
void
-observer_test_second_notification_function (struct bpstats *bs)
+observer_test_second_notification_function (int arg)
{
observer_test_second_observer++;
}
void
-observer_test_third_notification_function (struct bpstats *bs)
+observer_test_third_notification_function (int arg)
{
observer_test_third_observer++;
}