[Lldb-commits] [lldb] e3b9bb5 - [lldb/bindings] Expose the progress reporting machinery to the SWIG interface
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 18 14:16:39 PST 2022
Author: Med Ismail Bennani
Date: 2022-02-18T14:16:09-08:00
New Revision: e3b9bb5a1847483338190c82ee63a962e82696fd
URL: https://github.com/llvm/llvm-project/commit/e3b9bb5a1847483338190c82ee63a962e82696fd
DIFF: https://github.com/llvm/llvm-project/commit/e3b9bb5a1847483338190c82ee63a962e82696fd.diff
LOG: [lldb/bindings] Expose the progress reporting machinery to the SWIG interface
This patch defines the SBDebugger::eBroadcastBitProgress enum in the SWIG
interface and exposes the SBDebugger::{GetProgressFromEvent,GetBroadcaster}
methods as well.
This allows to exercise the API from the script interpreter using python.
Differential Revision: https://reviews.llvm.org/D120100
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Added:
lldb/test/API/functionalities/progress_reporting/Makefile
lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
lldb/test/API/functionalities/progress_reporting/main.c
Modified:
lldb/bindings/interface/SBDebugger.i
Removed:
################################################################################
diff --git a/lldb/bindings/interface/SBDebugger.i b/lldb/bindings/interface/SBDebugger.i
index f21e60d62873..3790857b8ab6 100644
--- a/lldb/bindings/interface/SBDebugger.i
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -117,6 +117,22 @@ or the equivalent arguments for :py:class:`SBTarget.AttachToProcessWithID` .") S
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();
diff --git a/lldb/test/API/functionalities/progress_reporting/Makefile b/lldb/test/API/functionalities/progress_reporting/Makefile
new file mode 100644
index 000000000000..10495940055b
--- /dev/null
+++ b/lldb/test/API/functionalities/progress_reporting/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
new file mode 100644
index 000000000000..b9d9953539c1
--- /dev/null
+++ b/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)
diff --git a/lldb/test/API/functionalities/progress_reporting/main.c b/lldb/test/API/functionalities/progress_reporting/main.c
new file mode 100644
index 000000000000..3ebd6282aa95
--- /dev/null
+++ b/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;
+}
More information about the lldb-commits
mailing list