Skip to content
Closed
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
2 changes: 1 addition & 1 deletion lldb/include/lldb/Host/ProcessLaunchInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ProcessLaunchInfo : public ProcessInfo {

bool MonitorProcess() const;

PseudoTerminal &GetPTY() { return *m_pty; }
std::shared_ptr<PseudoTerminal> GetPTY() const { return m_pty; }

void SetLaunchEventData(const char *data) { m_event_data.assign(data); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ PlatformAppleSimulator::DebugProcess(ProcessLaunchInfo &launch_info,
// been used where the secondary side was given as the file to open for
// stdin/out/err after we have already opened the primary so we can
// read/write stdin/out/err.
int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
int pty_fd = launch_info.GetPTY()->ReleasePrimaryFileDescriptor();
if (pty_fd != PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,18 @@ static Status HandleFileAction(ProcessLaunchInfo &launch_info,
case FileAction::eFileActionOpen: {
FileSpec file_spec = file_action->GetFileSpec();
if (file_spec) {
const int primary_fd = launch_info.GetPTY().GetPrimaryFileDescriptor();
const int primary_fd = launch_info.GetPTY()->GetPrimaryFileDescriptor();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like a worse API than before. The call sites now look like they forgot to check for a nullptr.
Could we keep the old API and have some callers use shared_froom_this()? Or have both APIs?

if (primary_fd != PseudoTerminal::invalid_fd) {
// Check in case our file action open wants to open the secondary
FileSpec secondary_spec(launch_info.GetPTY().GetSecondaryName());
FileSpec secondary_spec(launch_info.GetPTY()->GetSecondaryName());
if (file_spec == secondary_spec) {
int secondary_fd =
launch_info.GetPTY().GetSecondaryFileDescriptor();
launch_info.GetPTY()->GetSecondaryFileDescriptor();
if (secondary_fd == PseudoTerminal::invalid_fd) {
if (llvm::Error Err = launch_info.GetPTY().OpenSecondary(O_RDWR))
if (llvm::Error Err = launch_info.GetPTY()->OpenSecondary(O_RDWR))
return Status::FromError(std::move(Err));
}
secondary_fd = launch_info.GetPTY().GetSecondaryFileDescriptor();
secondary_fd = launch_info.GetPTY()->GetSecondaryFileDescriptor();
assert(secondary_fd != PseudoTerminal::invalid_fd);
[options setValue:[NSNumber numberWithInteger:secondary_fd]
forKey:key];
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ lldb::ProcessSP PlatformPOSIX::DebugProcess(ProcessLaunchInfo &launch_info,
if (error.Success()) {
// Hook up process PTY if we have one (which we should for local debugging
// with llgs).
int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
int pty_fd = launch_info.GetPTY()->ReleasePrimaryFileDescriptor();
if (pty_fd != PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
LLDB_LOG(log, "hooked up STDIO pty to process");
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ lldb::ProcessSP PlatformQemuUser::DebugProcess(ProcessLaunchInfo &launch_info,
if (error.Fail())
return nullptr;

if (launch_info.GetPTY().GetPrimaryFileDescriptor() !=
if (launch_info.GetPTY()->GetPrimaryFileDescriptor() !=
PseudoTerminal::invalid_fd)
process_sp->SetSTDIOFileDescriptor(
launch_info.GetPTY().ReleasePrimaryFileDescriptor());
launch_info.GetPTY()->ReleasePrimaryFileDescriptor());

return process_sp;
}
Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info,
LLDB_LOG(log, "inferior started, now in stopped state");

return std::unique_ptr<NativeProcessAIX>(new NativeProcessAIX(
pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate,
HostInfo::GetArchitecture(HostInfo::eArchKind64), *this, {pid}));
pid, launch_info.GetPTY()->ReleasePrimaryFileDescriptor(),
native_delegate, HostInfo::GetArchitecture(HostInfo::eArchKind64), *this,
{pid}));
}

llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ NativeProcessFreeBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
Info.GetArchitecture().GetArchitectureName());

std::unique_ptr<NativeProcessFreeBSD> process_up(new NativeProcessFreeBSD(
pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate,
Info.GetArchitecture(), m_mainloop));
pid, launch_info.GetPTY()->ReleasePrimaryFileDescriptor(),
native_delegate, Info.GetArchitecture(), m_mainloop));

status = process_up->SetupTrace();
if (status.Fail())
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ NativeProcessLinux::Manager::Launch(ProcessLaunchInfo &launch_info,
return arch_or.takeError();

return std::unique_ptr<NativeProcessLinux>(new NativeProcessLinux(
pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate,
*arch_or, *this, {pid}));
pid, launch_info.GetPTY()->ReleasePrimaryFileDescriptor(),
native_delegate, *arch_or, *this, {pid}));
}

llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ NativeProcessNetBSD::Manager::Launch(ProcessLaunchInfo &launch_info,
Info.GetArchitecture().GetArchitectureName());

std::unique_ptr<NativeProcessNetBSD> process_up(new NativeProcessNetBSD(
pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate,
Info.GetArchitecture(), m_mainloop));
pid, launch_info.GetPTY()->ReleasePrimaryFileDescriptor(),
native_delegate, Info.GetArchitecture(), m_mainloop));

status = process_up->SetupTrace();
if (status.Fail())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ namespace lldb_private {
NativeProcessWindows::NativeProcessWindows(ProcessLaunchInfo &launch_info,
NativeDelegate &delegate,
llvm::Error &E)
: NativeProcessProtocol(LLDB_INVALID_PROCESS_ID,
launch_info.GetPTY().ReleasePrimaryFileDescriptor(),
delegate),
: NativeProcessProtocol(
LLDB_INVALID_PROCESS_ID,
launch_info.GetPTY()->ReleasePrimaryFileDescriptor(), delegate),
ProcessDebugger(), m_arch(launch_info.GetArchitecture()) {
ErrorAsOutParameter EOut(&E);
DebugDelegateSP delegate_sp(new NativeDebugDelegate(*this));
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Target/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ lldb::ProcessSP Platform::DebugProcess(ProcessLaunchInfo &launch_info,
// been used where the secondary side was given as the file to open for
// stdin/out/err after we have already opened the primary so we can
// read/write stdin/out/err.
int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
int pty_fd = launch_info.GetPTY()->ReleasePrimaryFileDescriptor();
if (pty_fd != PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
}
Expand Down
Loading