Skip to content

Commit 353aac7

Browse files
committed
Fix swig interfaces, and the emitter class
1 parent ec90252 commit 353aac7

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
%extend lldb::SBProgress {
2+
#ifdef SWIGPYTHON
3+
%pythoncode %{
4+
def __enter__(self):
5+
'''No-op for with statement'''
6+
pass
7+
8+
def __exit__(self, exc_type, exc_value, traceback):
9+
'''Finalize the progress object'''
10+
self.Finalize()
11+
%}
12+
#endif
13+
}

lldb/bindings/interfaces.swig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
%include "./interface/SBModuleSpecExtensions.i"
201201
%include "./interface/SBModuleSpecListExtensions.i"
202202
%include "./interface/SBProcessExtensions.i"
203+
%include "./interface/SBProgressExtensions.i"
203204
%include "./interface/SBProcessInfoListExtensions.i"
204205
%include "./interface/SBQueueItemExtensions.i"
205206
%include "./interface/SBScriptObjectExtensions.i"

lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@ def get_short_help(self):
6767
def get_long_help(self):
6868
return self.help_string
6969

70-
def __get__progress(self, debugger, total):
71-
if total is None:
72-
progress = lldb.SBProgress(
73-
"Progress tester", "Initial Indeterminate Detail", debugger
74-
)
75-
else:
76-
progress = lldb.SBProgress(
77-
"Progress tester", "Initial Detail", total, debugger
78-
)
79-
8070
def __init__(self, debugger, unused):
8171
self.parser = self.create_options()
8272
self.help_string = self.parser.format_help()
@@ -90,9 +80,17 @@ def __call__(self, debugger, command, exe_ctx, result):
9080
return
9181

9282
total = cmd_options.total
83+
if total is None:
84+
progress = lldb.SBProgress(
85+
"Progress tester", "Initial Indeterminate Detail", debugger
86+
)
87+
else:
88+
progress = lldb.SBProgress(
89+
"Progress tester", "Initial Detail", total, debugger
90+
)
9391
# Check to see if total is set to None to indicate an indeterminate progress
9492
# then default to 10 steps.
95-
with self.__get_progress(debugger, total) as progress:
93+
with progress:
9694
if total is None:
9795
total = 10
9896

@@ -103,9 +101,6 @@ def __call__(self, debugger, command, exe_ctx, result):
103101
progress.Increment(1, f"Step {i}")
104102
time.sleep(cmd_options.seconds)
105103

106-
# Not required for deterministic progress, but required for indeterminate progress.
107-
progress.Finalize()
108-
109104

110105
def __lldb_init_module(debugger, dict):
111106
# Register all classes that have a register_lldb_command method

0 commit comments

Comments
 (0)