Debugger: Fix remote debugging macosx apps

Change-Id: I5328069ba9b82bb66dfa2c1e0d148a717d594a4b
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-06-21 16:38:41 +02:00
parent 26ef870761
commit 31c6ff495a
3 changed files with 39 additions and 18 deletions

View File

@@ -971,20 +971,31 @@ class Dumper(DumperBase):
self.debugger.GetListener(), self.debugger.GetListener(),
self.remoteChannel_, None, error) self.remoteChannel_, None, error)
else: else:
f = lldb.SBFileSpec() if self.platform_ == "remote-macosx":
f.SetFilename(self.executable_) DumperBase.warn("TARGET: %s" % self.target)
launchInfo = lldb.SBLaunchInfo(self.processArgs_) self.process = self.target.ConnectRemote(
#launchInfo.SetWorkingDirectory(self.workingDirectory_) self.debugger.GetListener(),
launchInfo.SetWorkingDirectory('/tmp') "connect://" + self.remoteChannel_, None, error)
if self.platform_ == 'remote-android':
launchInfo.SetWorkingDirectory('/data/local/tmp')
launchInfo.SetEnvironmentEntries(self.environment_, False)
launchInfo.SetExecutableFile(f, True)
DumperBase.warn("TARGET: %s" % self.target) if self.breakOnMain_:
self.process = self.target.Launch(launchInfo, error) self.createBreakpointAtMain()
DumperBase.warn("PROCESS: %s" % self.process)
DumperBase.warn("PROCESS: %s" % self.process)
else:
f = lldb.SBFileSpec()
f.SetFilename(self.executable_)
launchInfo = lldb.SBLaunchInfo(self.processArgs_)
#launchInfo.SetWorkingDirectory(self.workingDirectory_)
launchInfo.SetWorkingDirectory('/tmp')
if self.platform_ == 'remote-android':
launchInfo.SetWorkingDirectory('/data/local/tmp')
launchInfo.SetEnvironmentEntries(self.environment_, False)
launchInfo.SetExecutableFile(f, True)
DumperBase.warn("TARGET: %s" % self.target)
self.process = self.target.Launch(launchInfo, error)
DumperBase.warn("PROCESS: %s" % self.process)
if not error.Success(): if not error.Success():
self.report(self.describeError(error)) self.report(self.describeError(error))
@@ -1479,8 +1490,9 @@ class Dumper(DumperBase):
self.reportState("stopped") self.reportState("stopped")
if self.firstStop_: if self.firstStop_:
self.firstStop_ = False self.firstStop_ = False
if self.useTerminal_: if self.useTerminal_ or self.platform_ == "remote-macosx":
# When using a terminal, the process will be interrupted on startup. # When using a terminal or remote debugging macosx apps,
# the process will be interrupted on startup.
# We therefore need to continue it here. # We therefore need to continue it here.
self.process.Continue() self.process.Continue()
else: else:

View File

@@ -1069,9 +1069,13 @@ DebugServerRunner::DebugServerRunner(RunControl *runControl, DebugServerPortsGat
cmd.addArg(QString("*:%1").arg(portsGatherer->gdbServer().port())); cmd.addArg(QString("*:%1").arg(portsGatherer->gdbServer().port()));
cmd.addArg("--server"); cmd.addArg("--server");
} else if (cmd.executable().baseName() == "debugserver") { } else if (cmd.executable().baseName() == "debugserver") {
cmd.addArg(QString("*:%1").arg(portsGatherer->gdbServer().port())); const QString ipAndPort("`echo $SSH_CLIENT | cut -d ' ' -f 1`:%1");
cmd.addArg("--attach"); cmd.addArgs(ipAndPort.arg(portsGatherer->gdbServer().port()), CommandLine::Raw);
cmd.addArg(QString::number(m_pid.pid()));
if (m_pid.isValid())
cmd.addArgs({"--attach", QString::number(m_pid.pid())});
else
cmd.addCommandLineAsArgs(runControl->runnable().command);
} else { } else {
// Something resembling gdbserver // Something resembling gdbserver
if (m_useMulti) if (m_useMulti)

View File

@@ -5,6 +5,7 @@
#include "remotelinux_constants.h" #include "remotelinux_constants.h"
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/runconfigurationaspects.h>
@@ -37,7 +38,11 @@ public:
setStartMode(AttachToRemoteServer); setStartMode(AttachToRemoteServer);
setCloseMode(KillAndExitMonitorAtClose); setCloseMode(KillAndExitMonitorAtClose);
setUseExtendedRemote(true); setUseExtendedRemote(true);
setLldbPlatform("remote-linux");
if (runControl->device()->osType() == Utils::OsTypeMac)
setLldbPlatform("remote-macosx");
else
setLldbPlatform("remote-linux");
} }
}; };