[Lldb-commits] [lldb] 34bd157 - [lldb/test] Update lldbutil.fetch_next_event to match broadcaster class
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 25 15:04:31 PDT 2023
Author: Med Ismail Bennani
Date: 2023-04-25T15:03:45-07:00
New Revision: 34bd15798ede2bc003783ed61d08f8d6c74c38f9
URL: https://github.com/llvm/llvm-project/commit/34bd15798ede2bc003783ed61d08f8d6c74c38f9
DIFF: https://github.com/llvm/llvm-project/commit/34bd15798ede2bc003783ed61d08f8d6c74c38f9.diff
LOG: [lldb/test] Update lldbutil.fetch_next_event to match broadcaster class
This patch updates the `lldbutil.fetch_next_event` helper function to
either match a specific broadcaster or match a whole broadcaster class.
This is very handy when testing process events for interactive scripted
process debugging.
This also fixes a bug in the failing case, where `SBEvent.GetDescription`
expects a `SBStream` argument. We never took that code path in the
original implementation so we didn't hit that bug.
Differential Revision: https://reviews.llvm.org/D149175
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Added:
Modified:
lldb/packages/Python/lldbsuite/test/lldbutil.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index d174c5af069b8..309b51baae9be 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1202,18 +1202,25 @@ def start_listening_from(broadcaster, event_mask):
broadcaster.AddListener(listener, event_mask)
return listener
-def fetch_next_event(test, listener, broadcaster, timeout=10):
+def fetch_next_event(test, listener, broadcaster, match_class=False, timeout=10):
"""Fetch one event from the listener and return it if it matches the provided broadcaster.
+ If `match_class` is set to True, this will match an event with an entire broadcaster class.
Fails otherwise."""
event = lldb.SBEvent()
if listener.WaitForEvent(timeout, event):
- if event.BroadcasterMatchesRef(broadcaster):
- return event
+ if match_class:
+ if event.GetBroadcasterClass() == broadcaster:
+ return event
+ else:
+ if event.BroadcasterMatchesRef(broadcaster):
+ return event
+ stream = lldb.SBStream()
+ event.GetDescription(stream)
test.fail("received event '%s' from unexpected broadcaster '%s'." %
- (event.GetDescription(), event.GetBroadcaster().GetName()))
+ (stream.GetData(), event.GetBroadcaster().GetName()))
test.fail("couldn't fetch an event before reaching the timeout.")
More information about the lldb-commits
mailing list