forked from OSchip/llvm-project
Reland "[lldb/test] Fix TestProgressReporting.py race issue with the event listener"
This patch relands commit 3e3e79a9e4
, and
fixes the memory sanitizer issue described in D120284, by removing the
output arguments from the LLDB_INSTRUMENT_VA invocation.
Differential Revision: https://reviews.llvm.org/D120599
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
parent
badb6e2730
commit
425880ed35
|
@ -123,14 +123,11 @@ public:
|
|||
};
|
||||
|
||||
|
||||
%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);
|
||||
uint64_t &OUTPUT,
|
||||
uint64_t &OUTPUT,
|
||||
uint64_t &OUTPUT,
|
||||
bool &OUTPUT);
|
||||
|
||||
SBBroadcaster GetBroadcaster();
|
||||
|
||||
|
|
|
@ -151,8 +151,7 @@ const char *SBDebugger::GetProgressFromEvent(const lldb::SBEvent &event,
|
|||
uint64_t &completed,
|
||||
uint64_t &total,
|
||||
bool &is_debugger_specific) {
|
||||
LLDB_INSTRUMENT_VA(event, progress_id, completed, total,
|
||||
is_debugger_specific);
|
||||
LLDB_INSTRUMENT_VA(event);
|
||||
const Debugger::ProgressEventData *progress_data =
|
||||
Debugger::ProgressEventData::GetEventDataFromEvent(event.get());
|
||||
if (progress_data == nullptr)
|
||||
|
|
|
@ -17,41 +17,42 @@ class TestProgressReporting(TestBase):
|
|||
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)
|
||||
|
||||
def fetch_events(self):
|
||||
event = lldb.SBEvent()
|
||||
|
||||
done = False
|
||||
while not done:
|
||||
if listener.WaitForEvent(1, event):
|
||||
if self.listener.WaitForEvent(1, event):
|
||||
event_mask = event.GetType();
|
||||
if event.BroadcasterMatchesRef(test_broadcaster):
|
||||
if event.BroadcasterMatchesRef(self.test_broadcaster):
|
||||
if event_mask & self.eBroadcastBitStopProgressThread:
|
||||
done = True;
|
||||
elif event.BroadcasterMatchesRef(progress_broadcaster):
|
||||
message = lldb.SBDebugger().GetProgressFromEvent(event, 0, 0, 0, False);
|
||||
elif event.BroadcasterMatchesRef(self.progress_broadcaster):
|
||||
ret_args = lldb.SBDebugger().GetProgressFromEvent(event);
|
||||
self.assertGreater(len(ret_args), 1)
|
||||
|
||||
message = ret_args[0]
|
||||
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])
|
||||
self.listener = lldb.SBListener("lldb.progress.listener")
|
||||
self.test_broadcaster = lldb.SBBroadcaster('lldb.broadcaster.test')
|
||||
self.listener.StartListeningForEvents(self.test_broadcaster,
|
||||
self.eBroadcastBitStopProgressThread)
|
||||
|
||||
self.progress_broadcaster = self.dbg.GetBroadcaster()
|
||||
self.progress_broadcaster.AddListener(self.listener, lldb.SBDebugger.eBroadcastBitProgress)
|
||||
|
||||
listener_thread = threading.Thread(target=self.fetch_events)
|
||||
listener_thread.start()
|
||||
|
||||
lldbutil.run_to_source_breakpoint(self, 'break here', lldb.SBFileSpec('main.c'))
|
||||
|
||||
test_broadcaster.BroadcastEventByType(self.eBroadcastBitStopProgressThread)
|
||||
self.test_broadcaster.BroadcastEventByType(self.eBroadcastBitStopProgressThread)
|
||||
listener_thread.join()
|
||||
|
||||
self.assertTrue(len(self.progress_events) > 0)
|
||||
self.assertGreater(len(self.progress_events), 0)
|
||||
|
|
Loading…
Reference in New Issue