Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lldb/bindings/interface/SBProgressDocstrings.i
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ Non-deterministic progresses behave the same, but omit the total in the construc
# Explicitly send a progressEnd, otherwise this will be sent
# when the python runtime cleans up this object.
non_deterministic_progress.Finalize()

Additionally for Python, progress is supported in a with statement. ::
with lldb.SBProgress('Non deterministic progress, 'Detail', lldb.SBDebugger) as progress:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit, the string in the first argument is not terminated:

with lldb.SBProgress('Non deterministic progress', 'Detail', lldb.SBDebugger) as progress:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's copied from above, and that was also unescaped, good catch

for i in range(10):
progress.Increment(1)
# The progress object is automatically finalized when the with statement

") lldb::SBProgress;

%feature("docstring",
Expand Down
13 changes: 13 additions & 0 deletions lldb/bindings/interface/SBProgressExtensions.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
%extend lldb::SBProgress {
#ifdef SWIGPYTHON
%pythoncode %{
def __enter__(self):
'''No-op for with statement'''
pass

def __exit__(self, exc_type, exc_value, traceback):
'''Finalize the progress object'''
self.Finalize()
%}
#endif
}
1 change: 1 addition & 0 deletions lldb/bindings/interfaces.swig
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
%include "./interface/SBModuleSpecExtensions.i"
%include "./interface/SBModuleSpecListExtensions.i"
%include "./interface/SBProcessExtensions.i"
%include "./interface/SBProgressExtensions.i"
%include "./interface/SBProcessInfoListExtensions.i"
%include "./interface/SBQueueItemExtensions.i"
%include "./interface/SBScriptObjectExtensions.i"
Expand Down
23 changes: 10 additions & 13 deletions lldb/test/API/tools/lldb-dap/progress/Progress_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,18 @@ def __call__(self, debugger, command, exe_ctx, result):
progress = lldb.SBProgress(
"Progress tester", "Initial Detail", total, debugger
)

# Check to see if total is set to None to indicate an indeterminate progress
# then default to 10 steps.
if total is None:
total = 10

for i in range(1, total):
if cmd_options.no_details:
progress.Increment(1)
else:
progress.Increment(1, f"Step {i}")
time.sleep(cmd_options.seconds)

# Not required for deterministic progress, but required for indeterminate progress.
progress.Finalize()
with progress:
if total is None:
total = 10

for i in range(1, total):
if cmd_options.no_details:
progress.Increment(1)
else:
progress.Increment(1, f"Step {i}")
time.sleep(cmd_options.seconds)


def __lldb_init_module(debugger, dict):
Expand Down