aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport/observable.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-04-24 19:26:04 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-04-24 19:26:41 -0400
commitc90e7d6352b2e16ac007d08b2e03ae10081147b5 (patch)
tree2ca6bb8a1d338ff48f2eed24dcb25300e4204f54 /gdbsupport/observable.h
parentec098003e27d67bca9e9880320e26ab8ad30fe31 (diff)
downloadfsf-binutils-gdb-c90e7d6352b2e16ac007d08b2e03ae10081147b5.zip
fsf-binutils-gdb-c90e7d6352b2e16ac007d08b2e03ae10081147b5.tar.gz
fsf-binutils-gdb-c90e7d6352b2e16ac007d08b2e03ae10081147b5.tar.bz2
gdbsupport, gdb: give names to observers
Give a name to each observer, this will help produce more meaningful debug message. gdbsupport/ChangeLog: * observable.h (class observable) <struct observer> <observer>: Add name parameter. <name>: New field. <attach>: Add name parameter, update all callers. Change-Id: Ie0cc4664925215b8d2b09e026011b7803549fba0
Diffstat (limited to 'gdbsupport/observable.h')
-rw-r--r--gdbsupport/observable.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/gdbsupport/observable.h b/gdbsupport/observable.h
index 1d19429..5e7846f 100644
--- a/gdbsupport/observable.h
+++ b/gdbsupport/observable.h
@@ -61,12 +61,13 @@ public:
private:
struct observer
{
- observer (const struct token *token, func_type func)
- : token (token), func (func)
+ observer (const struct token *token, func_type func, const char *name)
+ : token (token), func (func), name (name)
{}
const struct token *token;
func_type func;
+ const char *name;
};
public:
@@ -78,17 +79,23 @@ public:
DISABLE_COPY_AND_ASSIGN (observable);
/* Attach F as an observer to this observable. F cannot be
- detached. */
- void attach (const func_type &f)
+ detached.
+
+ NAME is the name of the observer, used for debug output purposes. Its
+ lifetime must be at least as long as the observer is attached. */
+ void attach (const func_type &f, const char *name)
{
- m_observers.emplace_back (nullptr, f);
+ m_observers.emplace_back (nullptr, f, name);
}
/* Attach F as an observer to this observable. T is a reference to
- a token that can be used to later remove F. */
- void attach (const func_type &f, const token &t)
+ a token that can be used to later remove F.
+
+ NAME is the name of the observer, used for debug output purposes. Its
+ lifetime must be at least as long as the observer is attached. */
+ void attach (const func_type &f, const token &t, const char *name)
{
- m_observers.emplace_back (&t, f);
+ m_observers.emplace_back (&t, f, name);
}
/* Remove observers associated with T from this observable. T is