Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion lldb/source/API/SBProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ SBProgress::~SBProgress() = default;
void SBProgress::Increment(uint64_t amount, const char *description) {
LLDB_INSTRUMENT_VA(amount, description);

m_opaque_up->Increment(amount, description);
std::optional<std::string> description_opt;
if (description && description[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

So this only calls increment if there is a non-null and non-empty description. Is that the correct behavior? Or should we still be calling increment with a nullopt in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No we only set the value of the description optional if non-null, non-empty description. So Increment(1, NULL/None in Python) will bump the count by one but send no message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yeah, I read that wrong. Thanks for confirming.

description_opt = description;
m_opaque_up->Increment(amount, description_opt);
}

lldb_private::Progress &SBProgress::ref() const { return *m_opaque_up; }
12 changes: 12 additions & 0 deletions lldb/test/API/python_api/sbprogress/TestSBProgress.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ def test_without_external_bit_set(self):
expected_string = "Test progress first increment"
progress.Increment(1, expected_string)
self.assertFalse(listener.PeekAtNextEvent(event))

def test_with_external_bit_set(self):
"""Test SBProgress can handle null events."""

progress = lldb.SBProgress("Test SBProgress", "Test progress", self.dbg)
listener = lldb.SBListener("Test listener")
broadcaster = self.dbg.GetBroadcaster()
broadcaster.AddListener(listener, lldb.eBroadcastBitExternalProgress)
event = lldb.SBEvent()

progress.Increment(1, None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would progress.Increment(1, "") map to the case where description[0] == '\0'? If so seems like a cheap test to add.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good callout, I expanded the test case.

self.assertTrue(listener.PeekAtNextEvent(event))