forked from qt-creator/qt-creator
Debugger: Modernize lldbengine.cpp
Change-Id: I4d2c7b51cc4beb3edebf6995df1ce269f9c2c8db Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -50,25 +50,26 @@
|
|||||||
#include <debugger/watchhandler.h>
|
#include <debugger/watchhandler.h>
|
||||||
#include <debugger/watchutils.h>
|
#include <debugger/watchutils.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
#include <utils/savedaction.h>
|
|
||||||
#include <utils/qtcprocess.h>
|
|
||||||
|
|
||||||
#include <texteditor/texteditor.h>
|
|
||||||
#include <coreplugin/messagebox.h>
|
#include <coreplugin/messagebox.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <texteditor/texteditor.h>
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/savedaction.h>
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QToolTip>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <QApplication>
|
using namespace Core;
|
||||||
#include <QToolTip>
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
@@ -91,25 +92,25 @@ LldbEngine::LldbEngine(const DebuggerStartParameters &startParameters)
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Windows up to xp needs a workaround for attaching to freshly started processes. see proc_stub_win
|
// Windows up to xp needs a workaround for attaching to freshly started processes. see proc_stub_win
|
||||||
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
||||||
m_stubProc.setMode(Utils::ConsoleProcess::Suspend);
|
m_stubProc.setMode(ConsoleProcess::Suspend);
|
||||||
else
|
else
|
||||||
m_stubProc.setMode(Utils::ConsoleProcess::Debug);
|
m_stubProc.setMode(ConsoleProcess::Debug);
|
||||||
#else
|
#else
|
||||||
m_stubProc.setMode(Utils::ConsoleProcess::Debug);
|
m_stubProc.setMode(ConsoleProcess::Debug);
|
||||||
m_stubProc.setSettings(Core::ICore::settings());
|
m_stubProc.setSettings(ICore::settings());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(action(AutoDerefPointers), SIGNAL(valueChanged(QVariant)),
|
connect(action(AutoDerefPointers), &SavedAction::valueChanged,
|
||||||
SLOT(updateLocals()));
|
this, &LldbEngine::updateLocals);
|
||||||
connect(action(CreateFullBacktrace), SIGNAL(triggered()),
|
connect(action(CreateFullBacktrace), &QAction::triggered,
|
||||||
SLOT(createFullBacktrace()));
|
this, &LldbEngine::createFullBacktrace);
|
||||||
connect(action(UseDebuggingHelpers), SIGNAL(valueChanged(QVariant)),
|
connect(action(UseDebuggingHelpers), &SavedAction::valueChanged,
|
||||||
SLOT(updateLocals()));
|
this, &LldbEngine::updateLocals);
|
||||||
connect(action(UseDynamicType), SIGNAL(valueChanged(QVariant)),
|
connect(action(UseDynamicType), &SavedAction::valueChanged,
|
||||||
SLOT(updateLocals()));
|
this, &LldbEngine::updateLocals);
|
||||||
connect(action(IntelFlavor), SIGNAL(valueChanged(QVariant)),
|
connect(action(IntelFlavor), &SavedAction::valueChanged,
|
||||||
SLOT(updateAll()));
|
this, &LldbEngine::updateAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
LldbEngine::~LldbEngine()
|
LldbEngine::~LldbEngine()
|
||||||
@@ -174,9 +175,9 @@ bool LldbEngine::prepareCommand()
|
|||||||
DebuggerStartParameters &sp = startParameters();
|
DebuggerStartParameters &sp = startParameters();
|
||||||
QtcProcess::SplitError perr;
|
QtcProcess::SplitError perr;
|
||||||
sp.processArgs = QtcProcess::prepareArgs(sp.processArgs, &perr,
|
sp.processArgs = QtcProcess::prepareArgs(sp.processArgs, &perr,
|
||||||
Utils::HostOsInfo::hostOs(),
|
HostOsInfo::hostOs(),
|
||||||
&sp.environment, &sp.workingDirectory).toWindowsArgs();
|
&sp.environment, &sp.workingDirectory).toWindowsArgs();
|
||||||
if (perr != Utils::QtcProcess::SplitOk) {
|
if (perr != QtcProcess::SplitOk) {
|
||||||
// perr == BadQuoting is never returned on Windows
|
// perr == BadQuoting is never returned on Windows
|
||||||
// FIXME? QTCREATORBUG-2809
|
// FIXME? QTCREATORBUG-2809
|
||||||
notifyEngineSetupFailed();
|
notifyEngineSetupFailed();
|
||||||
@@ -207,9 +208,9 @@ void LldbEngine::setupEngine()
|
|||||||
// Set environment + dumper preload.
|
// Set environment + dumper preload.
|
||||||
m_stubProc.setEnvironment(startParameters().environment);
|
m_stubProc.setEnvironment(startParameters().environment);
|
||||||
|
|
||||||
connect(&m_stubProc, SIGNAL(processError(QString)), SLOT(stubError(QString)));
|
connect(&m_stubProc, &ConsoleProcess::processError, this, &LldbEngine::stubError);
|
||||||
connect(&m_stubProc, SIGNAL(processStarted()), SLOT(stubStarted()));
|
connect(&m_stubProc, &ConsoleProcess::processStarted, this, &LldbEngine::stubStarted);
|
||||||
connect(&m_stubProc, SIGNAL(stubStopped()), SLOT(stubExited()));
|
connect(&m_stubProc, &ConsoleProcess::stubStopped, this, &LldbEngine::stubExited);
|
||||||
// FIXME: Starting the stub implies starting the inferior. This is
|
// FIXME: Starting the stub implies starting the inferior. This is
|
||||||
// fairly unclean as far as the state machine and error reporting go.
|
// fairly unclean as far as the state machine and error reporting go.
|
||||||
|
|
||||||
@@ -233,21 +234,21 @@ void LldbEngine::setupEngine()
|
|||||||
void LldbEngine::startLldb()
|
void LldbEngine::startLldb()
|
||||||
{
|
{
|
||||||
m_lldbCmd = startParameters().debuggerCommand;
|
m_lldbCmd = startParameters().debuggerCommand;
|
||||||
connect(&m_lldbProc, SIGNAL(error(QProcess::ProcessError)),
|
connect(&m_lldbProc, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error),
|
||||||
SLOT(handleLldbError(QProcess::ProcessError)));
|
this, &LldbEngine::handleLldbError);
|
||||||
connect(&m_lldbProc, SIGNAL(finished(int,QProcess::ExitStatus)),
|
connect(&m_lldbProc, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||||
SLOT(handleLldbFinished(int,QProcess::ExitStatus)));
|
this, &LldbEngine::handleLldbFinished);
|
||||||
connect(&m_lldbProc, SIGNAL(readyReadStandardOutput()),
|
connect(&m_lldbProc, &QProcess::readyReadStandardOutput,
|
||||||
SLOT(readLldbStandardOutput()));
|
this, &LldbEngine::readLldbStandardOutput);
|
||||||
connect(&m_lldbProc, SIGNAL(readyReadStandardError()),
|
connect(&m_lldbProc, &QProcess::readyReadStandardError,
|
||||||
SLOT(readLldbStandardError()));
|
this, &LldbEngine::readLldbStandardError);
|
||||||
|
|
||||||
connect(this, SIGNAL(outputReady(QByteArray)),
|
connect(this, &LldbEngine::outputReady,
|
||||||
SLOT(handleResponse(QByteArray)), Qt::QueuedConnection);
|
this, &LldbEngine::handleResponse, Qt::QueuedConnection);
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append(_("-i"));
|
args.append(_("-i"));
|
||||||
args.append(Core::ICore::resourcePath() + _("/debugger/lldbbridge.py"));
|
args.append(ICore::resourcePath() + _("/debugger/lldbbridge.py"));
|
||||||
args.append(m_lldbCmd);
|
args.append(m_lldbCmd);
|
||||||
showMessage(_("STARTING LLDB: python ") + args.join(QLatin1Char(' ')));
|
showMessage(_("STARTING LLDB: python ") + args.join(QLatin1Char(' ')));
|
||||||
m_lldbProc.setEnvironment(startParameters().environment.toStringList());
|
m_lldbProc.setEnvironment(startParameters().environment.toStringList());
|
||||||
@@ -262,7 +263,7 @@ void LldbEngine::startLldb()
|
|||||||
notifyEngineSetupFailed();
|
notifyEngineSetupFailed();
|
||||||
showMessage(_("ADAPTER START FAILED"));
|
showMessage(_("ADAPTER START FAILED"));
|
||||||
if (!msg.isEmpty())
|
if (!msg.isEmpty())
|
||||||
Core::ICore::showWarningWithOptions(tr("Adapter start failed."), msg);
|
ICore::showWarningWithOptions(tr("Adapter start failed."), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,9 +292,9 @@ void LldbEngine::setupInferior()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString executable;
|
QString executable;
|
||||||
Utils::QtcProcess::Arguments args;
|
QtcProcess::Arguments args;
|
||||||
Utils::QtcProcess::prepareCommand(QFileInfo(sp.executable).absoluteFilePath(),
|
QtcProcess::prepareCommand(QFileInfo(sp.executable).absoluteFilePath(),
|
||||||
sp.processArgs, &executable, &args);
|
sp.processArgs, &executable, &args);
|
||||||
|
|
||||||
Command cmd("setupInferior");
|
Command cmd("setupInferior");
|
||||||
cmd.arg("executable", executable);
|
cmd.arg("executable", executable);
|
||||||
@@ -952,8 +953,7 @@ void LldbEngine::handleLldbError(QProcess::ProcessError error)
|
|||||||
default:
|
default:
|
||||||
//setState(EngineShutdownRequested, true);
|
//setState(EngineShutdownRequested, true);
|
||||||
m_lldbProc.kill();
|
m_lldbProc.kill();
|
||||||
Core::AsynchronousMessageBox::critical(tr("LLDB I/O Error"),
|
AsynchronousMessageBox::critical(tr("LLDB I/O Error"), errorMessage(error));
|
||||||
errorMessage(error));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1309,7 +1309,7 @@ void LldbEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result
|
|||||||
showMessage(_("ADAPTER START FAILED"));
|
showMessage(_("ADAPTER START FAILED"));
|
||||||
if (!result.reason.isEmpty()) {
|
if (!result.reason.isEmpty()) {
|
||||||
const QString title = tr("Adapter start failed");
|
const QString title = tr("Adapter start failed");
|
||||||
Core::ICore::showWarningWithOptions(title, result.reason);
|
ICore::showWarningWithOptions(title, result.reason);
|
||||||
}
|
}
|
||||||
notifyEngineSetupFailed();
|
notifyEngineSetupFailed();
|
||||||
return;
|
return;
|
||||||
@@ -1442,7 +1442,7 @@ void LldbEngine::stubStarted()
|
|||||||
|
|
||||||
void LldbEngine::stubError(const QString &msg)
|
void LldbEngine::stubError(const QString &msg)
|
||||||
{
|
{
|
||||||
Core::AsynchronousMessageBox::critical(tr("Debugger Error"), msg);
|
AsynchronousMessageBox::critical(tr("Debugger Error"), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LldbEngine::stubExited()
|
void LldbEngine::stubExited()
|
||||||
|
Reference in New Issue
Block a user