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.remoteChannel_, None, error)
else:
f = lldb.SBFileSpec()
f.SetFilename(self.executable_)
if self.platform_ == "remote-macosx":
DumperBase.warn("TARGET: %s" % self.target)
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)
self.process = self.target.ConnectRemote(
self.debugger.GetListener(),
"connect://" + self.remoteChannel_, None, error)
DumperBase.warn("TARGET: %s" % self.target)
self.process = self.target.Launch(launchInfo, error)
DumperBase.warn("PROCESS: %s" % self.process)
if self.breakOnMain_:
self.createBreakpointAtMain()
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():
self.report(self.describeError(error))
@@ -1479,8 +1490,9 @@ class Dumper(DumperBase):
self.reportState("stopped")
if self.firstStop_:
self.firstStop_ = False
if self.useTerminal_:
# When using a terminal, the process will be interrupted on startup.
if self.useTerminal_ or self.platform_ == "remote-macosx":
# When using a terminal or remote debugging macosx apps,
# the process will be interrupted on startup.
# We therefore need to continue it here.
self.process.Continue()
else:

View File

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

View File

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