Skip to content

Reland "[lldb][target] Add progress report for wait-attaching to proc… #145111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3546,6 +3546,7 @@ llvm::Expected<TraceSP> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Test that we are able to broadcast and receive progress events from lldb
"""
import lldb
import threading

import lldbsuite.test.lldbutil as lldbutil

Expand All @@ -16,6 +17,38 @@ 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)

# Wait attach to a process, then check to see that a progress report was created
# and that its message is correct for waiting to attach to a process.
class AttachThread(threading.Thread):
def __init__(self, target):
threading.Thread.__init__(self)
self.target = target

def run(self):
self.target.AttachToProcessWithName(
lldb.SBListener(),
"wait-attach-progress-report",
True,
lldb.SBError(),
)

thread = AttachThread(target)
thread.start()

event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
progress_data = lldb.SBDebugger.GetProgressDataFromEvent(event)
message = progress_data.GetValueForKey("message").GetStringValue(100)
self.assertEqual(message, "Waiting to attach to process")

# Interrupt the process attach to keep the test from stalling.
target.process.SendAsyncInterrupt()

thread.join()

def test_dwarf_symbol_loading_progress_report(self):
"""Test that we are able to fetch dwarf symbol loading progress events"""
self.build()
Expand Down
Loading