Files
qt-creator/src/plugins/debugger/lldb/lldbenginehost.cpp

112 lines
3.4 KiB
C++
Raw Normal View History

2010-10-08 12:14:51 +02:00
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#define QT_NO_CAST_FROM_ASCII
#include "lldbenginehost.h"
#include "debuggeractions.h"
#include "debuggerconstants.h"
#include "debuggerdialogs.h"
#include "debuggerplugin.h"
#include "debuggerstringutils.h"
2010-11-10 11:11:07 +10:00
#include "coreplugin/icore.h"
2010-10-08 12:14:51 +02:00
#include "breakhandler.h"
#include "breakpoint.h"
#include "moduleshandler.h"
#include "registerhandler.h"
#include "stackhandler.h"
#include "watchhandler.h"
#include "watchutils.h"
#include "threadshandler.h"
#include "debuggeragents.h"
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QProcess>
#include <QtCore/QFileInfo>
#include <QtCore/QThread>
#include <QtCore/QCoreApplication>
#include <QtNetwork/QLocalSocket>
#include <QtNetwork/QLocalServer>
namespace Debugger {
namespace Internal {
2010-11-26 10:10:00 +01:00
LldbEngineHost::LldbEngineHost(const DebuggerStartParameters &startParameters)
2010-10-08 12:14:51 +02:00
:IPCEngineHost(startParameters)
{
QLocalServer *s = new QLocalServer(this);
2010-11-26 10:10:00 +01:00
s->removeServer(QLatin1String("/tmp/qtcreator-debuggeripc"));
s->listen(QLatin1String("/tmp/qtcreator-debuggeripc"));
2010-10-08 12:14:51 +02:00
2010-11-26 10:10:00 +01:00
m_guestProcess = new QProcess(this);
m_guestProcess->setProcessChannelMode(QProcess::ForwardedChannels);
2010-10-08 12:14:51 +02:00
2010-11-26 10:10:00 +01:00
connect(m_guestProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(finished(int, QProcess::ExitStatus)));
2010-10-08 12:14:51 +02:00
2010-11-26 10:10:00 +01:00
QString a = Core::ICore::instance()->resourcePath() + QLatin1String("/qtcreator-lldb");
m_guestProcess->start(a, QStringList());
2010-10-08 12:14:51 +02:00
2010-11-26 10:10:00 +01:00
if (!m_guestProcess->waitForStarted()) {
2010-10-08 12:14:51 +02:00
showStatusMessage(tr("lldb failed to start"));
notifyEngineIll();
return;
}
s->waitForNewConnection(-1);
QLocalSocket *f = s->nextPendingConnection();
s->close(); // wtf race in accept
setGuestDevice(f);
}
2010-11-26 10:10:00 +01:00
LldbEngineHost::~LldbEngineHost()
2010-10-08 12:14:51 +02:00
{
2010-11-26 10:10:00 +01:00
disconnect(m_guestProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
2010-10-08 12:14:51 +02:00
this, SLOT(finished (int, QProcess::ExitStatus)));
2010-11-26 10:10:00 +01:00
m_guestProcess->terminate();
m_guestProcess->kill();
2010-10-08 12:14:51 +02:00
}
2010-11-26 10:10:00 +01:00
void LldbEngineHost::finished(int, QProcess::ExitStatus)
2010-10-08 12:14:51 +02:00
{
showStatusMessage(QLatin1String("lldb crashed"));
notifyEngineIll();
}
2010-11-26 10:10:00 +01:00
DebuggerEngine *createLldbEngine(const DebuggerStartParameters &startParameters)
2010-10-08 12:14:51 +02:00
{
2010-11-26 10:10:00 +01:00
return new LldbEngineHost(startParameters);
2010-10-08 12:14:51 +02:00
}
} // namespace Internal
} // namespace Debugger