diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-04-24 19:26:04 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-04-24 19:26:41 -0400 |
commit | c90e7d6352b2e16ac007d08b2e03ae10081147b5 (patch) | |
tree | 2ca6bb8a1d338ff48f2eed24dcb25300e4204f54 /gdbsupport | |
parent | ec098003e27d67bca9e9880320e26ab8ad30fe31 (diff) | |
download | gdb-c90e7d6352b2e16ac007d08b2e03ae10081147b5.zip gdb-c90e7d6352b2e16ac007d08b2e03ae10081147b5.tar.gz 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')
-rw-r--r-- | gdbsupport/ChangeLog | 7 | ||||
-rw-r--r-- | gdbsupport/observable.h | 23 |
2 files changed, 22 insertions, 8 deletions
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog index bfbd152..0f3de6d 100644 --- a/gdbsupport/ChangeLog +++ b/gdbsupport/ChangeLog @@ -1,5 +1,12 @@ 2021-04-24 Simon Marchi <simon.marchi@polymtl.ca> + * observable.h (class observable) <struct observer> <observer>: + Add name parameter. + <name>: New field. + <attach>: Add name parameter, update all callers. + +2021-04-24 Simon Marchi <simon.marchi@polymtl.ca> + * observable.h (class observable) <struct observer>: New. <detach, notify>: Update. <m_observers>: Change type to vector of observers. 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 |