summaryrefslogtreecommitdiff
path: root/src/plugins/ios/iosdebugsupport.cpp
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@digia.com>2013-10-10 15:15:49 +0200
committerhjk <hjk121@nokiamail.com>2013-10-29 14:03:58 +0100
commitc162ba1391674fe942ff7449a81a64ecfc31e421 (patch)
tree2405502654e8dc5a74d62cfc429f9fa6392e377a /src/plugins/ios/iosdebugsupport.cpp
parentdc5ba1127dc67c848a8be46b4b42a3d0d5e99851 (diff)
downloadqt-creator-c162ba1391674fe942ff7449a81a64ecfc31e421.tar.gz
ios simulator debugging
Change-Id: Ieee4a509b46da937c3bce21f72c77685946db4dd Reviewed-by: hjk <hjk121@nokiamail.com>
Diffstat (limited to 'src/plugins/ios/iosdebugsupport.cpp')
-rw-r--r--src/plugins/ios/iosdebugsupport.cpp84
1 files changed, 75 insertions, 9 deletions
diff --git a/src/plugins/ios/iosdebugsupport.cpp b/src/plugins/ios/iosdebugsupport.cpp
index a2890c84ef..d9ea84ac15 100644
--- a/src/plugins/ios/iosdebugsupport.cpp
+++ b/src/plugins/ios/iosdebugsupport.cpp
@@ -37,7 +37,8 @@
#include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerrunner.h>
#include <debugger/debuggerstartparameters.h>
-
+#include <debugger/debuggerrunconfigurationaspect.h>
+#include <projectexplorer/toolchain.h>
#include <projectexplorer/target.h>
#include <qt4projectmanager/qmakebuildconfiguration.h>
#include <qt4projectmanager/qmakenodes.h>
@@ -45,6 +46,11 @@
#include <qtsupport/qtkitinformation.h>
#include <QDir>
+#include <QTcpServer>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
using namespace Debugger;
using namespace ProjectExplorer;
@@ -56,14 +62,46 @@ namespace Internal {
RunControl *IosDebugSupport::createDebugRunControl(IosRunConfiguration *runConfig,
QString *errorMessage)
{
- //Target *target = runConfig->target();
- //Qt4Project *project = static_cast<Qt4Project *>(target->project());
+ Target *target = runConfig->target();
+ if (!target)
+ return 0;
+ ProjectExplorer::IDevice::ConstPtr device = DeviceKitInformation::device(target->kit());
+ if (device.isNull())
+ return 0;
+ Qt4Project *project = static_cast<Qt4Project *>(target->project());
DebuggerStartParameters params;
- params.startMode = AttachToRemoteServer;
- //params.displayName = IosManager::packageName(target);
+ if (device->type() == Core::Id(Ios::Constants::IOS_DEVICE_TYPE))
+ params.startMode = AttachToRemoteProcess;
+ else
+ params.startMode = AttachExternal;
+ params.displayName = runConfig->appName();
params.remoteSetupNeeded = true;
+ Debugger::DebuggerRunConfigurationAspect *aspect
+ = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
+ if (aspect->useCppDebugger()) {
+ params.languages |= CppLanguage;
+ Kit *kit = target->kit();
+ params.sysRoot = SysRootKitInformation::sysRoot(kit).toString();
+ params.debuggerCommand = DebuggerKitInformation::debuggerCommand(kit).toString();
+ if (ToolChain *tc = ToolChainKitInformation::toolChain(kit))
+ params.toolChainAbi = tc->targetAbi();
+ params.executable = runConfig->exePath().toString();
+ }
+ if (aspect->useQmlDebugger()) {
+ params.languages |= QmlLanguage;
+ QTcpServer server;
+ QTC_ASSERT(server.listen(QHostAddress::LocalHost)
+ || server.listen(QHostAddress::LocalHostIPv6), return 0);
+ params.qmlServerAddress = server.serverAddress().toString();
+ params.remoteSetupNeeded = true;
+ //TODO: Not sure if these are the right paths.
+ params.projectSourceDirectory = project->projectDirectory();
+ params.projectSourceFiles = project->files(Qt4Project::ExcludeGeneratedFiles);
+ params.projectBuildDirectory = project->rootQt4ProjectNode()->buildDir();
+ }
+
DebuggerRunControl * const debuggerRunControl
= DebuggerPlugin::createDebugger(params, runConfig, errorMessage);
new IosDebugSupport(runConfig, debuggerRunControl);
@@ -74,7 +112,7 @@ IosDebugSupport::IosDebugSupport(IosRunConfiguration *runConfig,
DebuggerRunControl *runControl)
: QObject(runControl), m_runControl(runControl),
m_runner(new IosRunner(this, runConfig, true)),
- m_gdbServerPort(0), m_qmlPort(0)
+ m_gdbServerFd(0), m_qmlPort(0)
{
connect(m_runControl->engine(), SIGNAL(requestRemoteSetup()),
@@ -84,6 +122,8 @@ IosDebugSupport::IosDebugSupport(IosRunConfiguration *runConfig,
connect(m_runner, SIGNAL(gotGdbSocket(int)),
SLOT(handleGdbServerFd(int)));
+ connect(m_runner, SIGNAL(gotInferiorPid(Q_PID)),
+ SLOT(handleGotInferiorPid(Q_PID)));
connect(m_runner, SIGNAL(finished(bool)),
SLOT(handleRemoteProcessFinished(bool)));
@@ -93,17 +133,43 @@ IosDebugSupport::IosDebugSupport(IosRunConfiguration *runConfig,
SLOT(handleRemoteOutput(QString)));
}
+IosDebugSupport::~IosDebugSupport()
+{
+ if (m_gdbServerFd > 0)
+ close(m_gdbServerFd);
+}
+
void IosDebugSupport::handleGdbServerFd(int gdbServerFd)
{
- Q_UNUSED(gdbServerFd);
- QTC_CHECK(false); // to do transfer fd to debugger
- //m_runControl->engine()->notifyEngineRemoteSetupDone(gdbServerPort, qmlPort);
+ if (m_gdbServerFd > 0) {
+ close(m_gdbServerFd);
+ m_gdbServerFd = 0;
+ }
+ if (gdbServerFd > 0) {
+ m_runControl->engine()->notifyEngineRemoteSetupDone(m_gdbServerFd, m_qmlPort);
+ } else {
+ m_runControl->engine()->notifyEngineRemoteSetupFailed(
+ tr("Could not get debug server file descriptor."));
+ }
+}
+
+void IosDebugSupport::handleGotInferiorPid(Q_PID pid)
+{
+ if (pid > 0) {
+ //m_runControl->engine()->notifyInferiorPid(pid);
+ m_runControl->engine()->notifyEngineRemoteSetupDone(int(pid), m_qmlPort);
+ } else {
+ m_runControl->engine()->notifyEngineRemoteSetupFailed(
+ tr("Got an invalid process id."));
+ }
}
void IosDebugSupport::handleRemoteProcessFinished(bool cleanEnd)
{
if (!cleanEnd && m_runControl)
m_runControl->showMessage(tr("Run failed unexpectedly."), AppStuff);
+ //m_runControl->engine()->notifyInferiorIll();
+ m_runControl->engine()->abortDebugger();
}
void IosDebugSupport::handleRemoteOutput(const QString &output)