diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 45a9e1196a049..8f8d2ef21cc5f 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3546,6 +3546,7 @@ llvm::Expected Target::GetTraceOrCreate() { } Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) { + Progress attach_progress("Waiting to attach to process"); m_stats.SetLaunchOrAttachTime(); auto state = eStateInvalid; auto process_sp = GetProcessSP(); diff --git a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py index 9af53845ca1b7..583e187cb6d3a 100644 --- a/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py +++ b/lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py @@ -16,6 +16,28 @@ def setUp(self): self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress ) + def test_wait_attach_progress_reporting(self): + """Test that progress reports for wait attaching work as intended.""" + target = self.dbg.CreateTarget(None) + + # The waiting to attach progress message will get emitted upon + # trying to attach, but it's not going to be the event picked + # up by checking with fetch_next_event, so go through all emitted + # progress events and check that the waiting to attach one was emitted at all. + target.AttachToProcessWithName( + self.listener, + "wait-attach-progress-report", + False, + lldb.SBError(), + ) + event = lldb.SBEvent() + events = [] + while self.listener.GetNextEventForBroadcaster(self.broadcaster, event): + progress_data = lldb.SBDebugger.GetProgressDataFromEvent(event) + message = progress_data.GetValueForKey("message").GetStringValue(100) + events.append(message) + self.assertTrue("Waiting to attach to process" in events) + def test_dwarf_symbol_loading_progress_report(self): """Test that we are able to fetch dwarf symbol loading progress events""" self.build()