This revision was automatically updated to reflect the committed changes.
Closed by commit rGe3b9bb5a1847: [lldb/bindings] Expose the progress reporting 
machinery to the SWIG interface (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120100/new/

https://reviews.llvm.org/D120100

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/test/API/functionalities/progress_reporting/Makefile
  lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
  lldb/test/API/functionalities/progress_reporting/main.c

Index: lldb/test/API/functionalities/progress_reporting/main.c
===================================================================
--- /dev/null
+++ lldb/test/API/functionalities/progress_reporting/main.c
@@ -0,0 +1,11 @@
+int bar(int b) { return b * b; }
+
+int foo(int f) {
+  int b = bar(f); // break here
+  return b;
+}
+
+int main() {
+  int f = foo(42);
+  return f;
+}
Index: lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
===================================================================
--- /dev/null
+++ lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -0,0 +1,57 @@
+"""
+Test that we are able to broadcast and receive progress events from lldb
+"""
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+import threading
+
+class TestProgressReporting(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    eBroadcastBitStopProgressThread = (1 << 0)
+
+    def setUp(self):
+        TestBase.setUp(self)
+        self.progress_events = []
+
+    def fetch_events(self, test_broadcaster):
+        listener = lldb.SBListener("lldb.progress.listener")
+        listener.StartListeningForEvents(test_broadcaster,
+                                         self.eBroadcastBitStopProgressThread)
+
+        progress_broadcaster = self.dbg.GetBroadcaster()
+        progress_broadcaster.AddListener(listener, lldb.SBDebugger.eBroadcastBitProgress)
+
+        event = lldb.SBEvent()
+
+        done = False
+        while not done:
+            if listener.WaitForEvent(1, event):
+                event_mask = event.GetType();
+                if event.BroadcasterMatchesRef(test_broadcaster):
+                    if event_mask & self.eBroadcastBitStopProgressThread:
+                        done = True;
+                elif event.BroadcasterMatchesRef(progress_broadcaster):
+                    message = lldb.SBDebugger().GetProgressFromEvent(event, 0, 0, 0, False);
+                    if message:
+                        self.progress_events.append((message, event))
+
+    @skipUnlessDarwin
+    def test_dwarf_symbol_loading_progress_report(self):
+        """Test that we are able to fetch dwarf symbol loading progress events"""
+        self.build()
+
+        test_broadcaster = lldb.SBBroadcaster('lldb.broadcaster.test')
+        listener_thread = threading.Thread(target=self.fetch_events,
+                                           args=[test_broadcaster])
+        listener_thread.start()
+
+        lldbutil.run_to_source_breakpoint(self, 'break here', lldb.SBFileSpec('main.c'))
+
+        test_broadcaster.BroadcastEventByType(self.eBroadcastBitStopProgressThread)
+        listener_thread.join()
+
+        self.assertTrue(len(self.progress_events) > 0)
Index: lldb/test/API/functionalities/progress_reporting/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/functionalities/progress_reporting/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
Index: lldb/bindings/interface/SBDebugger.i
===================================================================
--- lldb/bindings/interface/SBDebugger.i
+++ lldb/bindings/interface/SBDebugger.i
@@ -117,6 +117,22 @@
 class SBDebugger
 {
 public:
+    enum
+    {
+        eBroadcastBitProgress = (1 << 0)
+    };
+
+
+    %apply uint64_t& INOUT { uint64_t& progress_id };
+    %apply uint64_t& INOUT { uint64_t& completed };
+    %apply uint64_t& INOUT { uint64_t& total };
+    %apply bool& INOUT { bool& is_debugger_specific };
+    static const char *GetProgressFromEvent(const lldb::SBEvent &event,
+                                        uint64_t &progress_id,
+                                        uint64_t &completed, uint64_t &total,
+                                        bool &is_debugger_specific);
+
+    SBBroadcaster GetBroadcaster();
 
     static void
     Initialize();
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to