summaryrefslogtreecommitdiff
path: root/lldb/packages
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2023-04-25 11:24:02 -0700
committerMed Ismail Bennani <medismail.bennani@gmail.com>2023-04-25 15:03:45 -0700
commit34bd15798ede2bc003783ed61d08f8d6c74c38f9 (patch)
treea4d3a9495509f8befd36522a5e34a13ff16ef0c4 /lldb/packages
parente31d0c20e411f22a943f1ed5f8b618c529436c59 (diff)
downloadllvm-34bd15798ede2bc003783ed61d08f8d6c74c38f9.tar.gz
[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@gmail.com>
Diffstat (limited to 'lldb/packages')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbutil.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index d174c5af069b..309b51baae9b 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.")