ios simulator debugging

Change-Id: Ieee4a509b46da937c3bce21f72c77685946db4dd
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Fawzi Mohamed
2013-10-10 15:15:49 +02:00
committed by hjk
parent dc5ba1127d
commit c162ba1391
12 changed files with 213 additions and 28 deletions

View File

@@ -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)