[Lldb-commits] [PATCH] D157556: Replace the singleton "ShadowListener" with a primary and N secondary listeners

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 9 15:40:39 PDT 2023


jingham created this revision.
jingham added reviewers: mib, bulbazord, clayborg, JDevlieghere.
Herald added a project: All.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Allow a Broadcaster to have one "Primary" listener, and potentially many secondary Listeners.  The primary listener is guaranteed to run the DoOnRemoval first, and only when that is complete will secondary Listeners receive the event.

Prior to Ismail's addition of the notion of a "Secondary" listener, you could only safely observe process events from the Listener you passed in to the Process creation.  That was because the act of pulling the process event off the event queue triggered the change of the public state of the process (thus keeping the event stream and the state in sync).

Ismail added a privileged "shadow listener" that could also be informed of the event.  That wasn't quite the right model, however, because the real singleton is the primary listener.

That's what this patch implements.

This isn't quite the full solution for the Process Listener.  The goal is that the primary Process Listener not only gets to drive the event stream, but that the primary listener gets to react to each event before any other Listener can hear about it.  That will allow the process execution logic to run before any other agent gets a chance to change the process state out from under it.  For that, I'll need to add a receipt mechanism to the event delivery, and have the forwarding to the pending listeners happen only after the receipt is acknowledged.  But that will be a follow on patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157556

Files:
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Utility/Broadcaster.h
  lldb/include/lldb/Utility/Event.h
  lldb/source/Target/Process.cpp
  lldb/source/Utility/Broadcaster.cpp
  lldb/source/Utility/Event.cpp
  lldb/source/Utility/Listener.cpp
  lldb/test/API/functionalities/interactive_scripted_process/TestInteractiveScriptedProcess.py
  lldb/test/API/python_api/event/TestEvents.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157556.548786.patch
Type: text/x-patch
Size: 21404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230809/7d9928ca/attachment-0001.bin>


More information about the lldb-commits mailing list