Skip to content

Commit 211e0e2

Browse files
committed
[lldb][target] Add progress report for wait-attaching to process
This commit adds a progress report when wait-attaching to a process as well as a test for this.
1 parent a027eb4 commit 211e0e2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lldb/source/Target/Target.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3546,6 +3546,8 @@ llvm::Expected<TraceSP> Target::GetTraceOrCreate() {
35463546
}
35473547

35483548
Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) {
3549+
std::unique_ptr<Progress> attach_progress;
3550+
attach_progress = std::make_unique<Progress>("Waiting to attach to process");
35493551
m_stats.SetLaunchOrAttachTime();
35503552
auto state = eStateInvalid;
35513553
auto process_sp = GetProcessSP();

lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Test that we are able to broadcast and receive progress events from lldb
33
"""
44
import lldb
5+
import threading
56

67
import lldbsuite.test.lldbutil as lldbutil
78

@@ -16,6 +17,37 @@ def setUp(self):
1617
self.broadcaster, lldb.SBDebugger.eBroadcastBitProgress
1718
)
1819

20+
def test_wait_attach_progress_reporting(self):
21+
"""Test that progress reports for wait attaching work as intended."""
22+
self.build()
23+
target = self.dbg.CreateTarget(None)
24+
25+
# Wait attach to a process, then check to see that a progress report was created
26+
# and that its message is correct for waiting to attach to a process.
27+
class AttachThread(threading.Thread):
28+
def __init__(self, target):
29+
threading.Thread.__init__(self)
30+
self.target = target
31+
32+
def run(self):
33+
self.target.AttachToProcessWithName(
34+
lldb.SBListener(), "a.out", True, lldb.SBError()
35+
)
36+
37+
thread = AttachThread(target)
38+
thread.start()
39+
40+
event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
41+
progress_data = lldb.SBDebugger.GetProgressDataFromEvent(event)
42+
message = progress_data.GetValueForKey("message").GetStringValue(100)
43+
self.assertGreater(len(message), 0)
44+
self.assertEqual(message, "Waiting to attach to process")
45+
46+
# Interrupt the process attach to keep the test from stalling.
47+
target.process.SendAsyncInterrupt()
48+
49+
thread.join()
50+
1951
def test_dwarf_symbol_loading_progress_report(self):
2052
"""Test that we are able to fetch dwarf symbol loading progress events"""
2153
self.build()

0 commit comments

Comments
 (0)