2013-03-22 10:28:49 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2013-03-22 10:28:49 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-03-22 10:28:49 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-03-22 10:28:49 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2013-03-22 10:28:49 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "lldbengine.h"
|
|
|
|
|
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/debuggeractions.h>
|
|
|
|
|
#include <debugger/debuggercore.h>
|
|
|
|
|
#include <debugger/debuggerdialogs.h>
|
2013-10-10 15:15:49 +02:00
|
|
|
#include <debugger/debuggerinternalconstants.h>
|
2013-11-08 16:11:01 +01:00
|
|
|
#include <debugger/debuggermainwindow.h>
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/debuggerprotocol.h>
|
|
|
|
|
#include <debugger/debuggerstartparameters.h>
|
|
|
|
|
#include <debugger/debuggerstringutils.h>
|
|
|
|
|
#include <debugger/debuggertooltipmanager.h>
|
2013-03-22 10:28:49 +01:00
|
|
|
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/breakhandler.h>
|
|
|
|
|
#include <debugger/disassemblerlines.h>
|
|
|
|
|
#include <debugger/moduleshandler.h>
|
|
|
|
|
#include <debugger/registerhandler.h>
|
|
|
|
|
#include <debugger/stackhandler.h>
|
|
|
|
|
#include <debugger/sourceutils.h>
|
|
|
|
|
#include <debugger/threadshandler.h>
|
|
|
|
|
#include <debugger/watchhandler.h>
|
|
|
|
|
#include <debugger/watchutils.h>
|
2013-03-22 10:28:49 +01:00
|
|
|
|
2014-11-25 13:08:18 +01:00
|
|
|
#include <coreplugin/messagebox.h>
|
2013-03-22 10:28:49 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
2015-01-23 15:53:09 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#include <utils/savedaction.h>
|
|
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
2013-03-22 10:28:49 +01:00
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QToolTip>
|
2015-01-23 15:53:09 +01:00
|
|
|
#include <QVariant>
|
2013-03-22 10:28:49 +01:00
|
|
|
|
2015-01-23 15:53:09 +01:00
|
|
|
using namespace Core;
|
2014-03-03 16:59:56 +01:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-03-05 10:41:16 +01:00
|
|
|
static int ¤tToken()
|
|
|
|
|
{
|
|
|
|
|
static int token = 0;
|
|
|
|
|
return token;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// LldbEngine
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
LldbEngine::LldbEngine(const DebuggerRunParameters &startParameters)
|
2013-11-19 10:45:00 +01:00
|
|
|
: DebuggerEngine(startParameters), m_continueAtNextSpontaneousStop(false)
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
2013-05-07 08:46:51 +02:00
|
|
|
m_lastAgentId = 0;
|
2013-03-22 10:28:49 +01:00
|
|
|
setObjectName(QLatin1String("LldbEngine"));
|
2013-05-29 14:54:47 +02:00
|
|
|
|
2014-03-03 16:59:56 +01:00
|
|
|
if (startParameters.useTerminal) {
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
// Windows up to xp needs a workaround for attaching to freshly started processes. see proc_stub_win
|
|
|
|
|
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
2015-01-23 15:53:09 +01:00
|
|
|
m_stubProc.setMode(ConsoleProcess::Suspend);
|
2014-03-03 16:59:56 +01:00
|
|
|
else
|
2015-01-23 15:53:09 +01:00
|
|
|
m_stubProc.setMode(ConsoleProcess::Debug);
|
2014-03-03 16:59:56 +01:00
|
|
|
#else
|
2015-01-23 15:53:09 +01:00
|
|
|
m_stubProc.setMode(ConsoleProcess::Debug);
|
|
|
|
|
m_stubProc.setSettings(ICore::settings());
|
2014-03-03 16:59:56 +01:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-23 15:53:09 +01:00
|
|
|
connect(action(AutoDerefPointers), &SavedAction::valueChanged,
|
|
|
|
|
this, &LldbEngine::updateLocals);
|
|
|
|
|
connect(action(CreateFullBacktrace), &QAction::triggered,
|
2015-09-09 16:34:09 +02:00
|
|
|
this, &LldbEngine::fetchFullBacktrace);
|
2015-01-23 15:53:09 +01:00
|
|
|
connect(action(UseDebuggingHelpers), &SavedAction::valueChanged,
|
|
|
|
|
this, &LldbEngine::updateLocals);
|
|
|
|
|
connect(action(UseDynamicType), &SavedAction::valueChanged,
|
|
|
|
|
this, &LldbEngine::updateLocals);
|
|
|
|
|
connect(action(IntelFlavor), &SavedAction::valueChanged,
|
|
|
|
|
this, &LldbEngine::updateAll);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LldbEngine::~LldbEngine()
|
2014-03-03 16:59:56 +01:00
|
|
|
{
|
|
|
|
|
m_stubProc.disconnect(); // Avoid spurious state transitions from late exiting stub
|
2015-03-03 18:05:00 +01:00
|
|
|
m_lldbProc.disconnect();
|
2014-03-03 16:59:56 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-07 16:43:20 +02:00
|
|
|
void LldbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages)
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
2015-02-05 14:39:59 +01:00
|
|
|
DebuggerCommand cmd("executeDebuggerCommand");
|
|
|
|
|
cmd.arg("command", command);
|
|
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-05 10:41:16 +01:00
|
|
|
void LldbEngine::runCommand(const DebuggerCommand &command_)
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_lldbProc.state() == QProcess::Running, notifyEngineIll());
|
2015-03-05 10:41:16 +01:00
|
|
|
const int tok = ++currentToken();
|
|
|
|
|
DebuggerCommand command = command_;
|
|
|
|
|
command.arg("token", tok);
|
|
|
|
|
QByteArray token = QByteArray::number(tok);
|
2015-01-30 12:36:04 +01:00
|
|
|
QByteArray cmd = command.function + "({" + command.args + "})";
|
|
|
|
|
showMessage(_(token + cmd + '\n'), LogInput);
|
2015-09-09 16:34:09 +02:00
|
|
|
m_commandForToken[currentToken()] = command;
|
2015-02-13 10:02:35 +01:00
|
|
|
m_lldbProc.write("script theDumper." + cmd + "\n");
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-09 15:37:04 +01:00
|
|
|
void LldbEngine::debugLastCommand()
|
|
|
|
|
{
|
|
|
|
|
runCommand(m_lastDebuggableCommand);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
void LldbEngine::shutdownInferior()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
|
2015-02-02 12:47:51 +01:00
|
|
|
runCommand(DebuggerCommand("shutdownInferior"));
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::shutdownEngine()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state());
|
|
|
|
|
m_lldbProc.kill();
|
2015-05-27 13:59:56 +02:00
|
|
|
if (runParameters().useTerminal)
|
2014-03-03 16:59:56 +01:00
|
|
|
m_stubProc.stop();
|
2014-03-25 16:56:37 +01:00
|
|
|
notifyEngineShutdownOk();
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-06 14:23:08 +01:00
|
|
|
void LldbEngine::abortDebugger()
|
|
|
|
|
{
|
|
|
|
|
if (targetState() == DebuggerFinished) {
|
|
|
|
|
// We already tried. Try harder.
|
|
|
|
|
showMessage(_("ABORTING DEBUGGER. SECOND TIME."));
|
|
|
|
|
m_lldbProc.kill();
|
|
|
|
|
} else {
|
|
|
|
|
// Be friendly the first time. This will change targetState().
|
|
|
|
|
showMessage(_("ABORTING DEBUGGER. FIRST TIME."));
|
|
|
|
|
quitDebugger();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-03 16:59:56 +01:00
|
|
|
// FIXME: Merge with GdbEngine/QtcProcess
|
|
|
|
|
bool LldbEngine::prepareCommand()
|
|
|
|
|
{
|
|
|
|
|
if (HostOsInfo::isWindowsHost()) {
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerRunParameters &rp = runParameters();
|
2014-03-03 16:59:56 +01:00
|
|
|
QtcProcess::SplitError perr;
|
2015-05-27 13:59:56 +02:00
|
|
|
rp.processArgs = QtcProcess::prepareArgs(rp.processArgs, &perr,
|
2015-01-23 15:53:09 +01:00
|
|
|
HostOsInfo::hostOs(),
|
2015-07-15 10:38:15 +03:00
|
|
|
nullptr, &rp.workingDirectory).toWindowsArgs();
|
2015-01-23 15:53:09 +01:00
|
|
|
if (perr != QtcProcess::SplitOk) {
|
2014-03-03 16:59:56 +01:00
|
|
|
// perr == BadQuoting is never returned on Windows
|
|
|
|
|
// FIXME? QTCREATORBUG-2809
|
|
|
|
|
notifyEngineSetupFailed();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
void LldbEngine::setupEngine()
|
|
|
|
|
{
|
2015-05-27 13:59:56 +02:00
|
|
|
if (runParameters().useTerminal) {
|
2014-03-03 16:59:56 +01:00
|
|
|
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
|
|
|
|
showMessage(_("TRYING TO START ADAPTER"));
|
|
|
|
|
|
|
|
|
|
// Currently, adapters are not re-used
|
|
|
|
|
// // We leave the console open, so recycle it now.
|
|
|
|
|
// m_stubProc.blockSignals(true);
|
|
|
|
|
// m_stubProc.stop();
|
|
|
|
|
// m_stubProc.blockSignals(false);
|
|
|
|
|
|
|
|
|
|
if (!prepareCommand()) {
|
|
|
|
|
notifyEngineSetupFailed();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
m_stubProc.setWorkingDirectory(runParameters().workingDirectory);
|
2014-03-03 16:59:56 +01:00
|
|
|
// Set environment + dumper preload.
|
2015-05-27 13:59:56 +02:00
|
|
|
m_stubProc.setEnvironment(runParameters().environment);
|
2014-03-03 16:59:56 +01:00
|
|
|
|
2015-01-23 15:53:09 +01:00
|
|
|
connect(&m_stubProc, &ConsoleProcess::processError, this, &LldbEngine::stubError);
|
|
|
|
|
connect(&m_stubProc, &ConsoleProcess::processStarted, this, &LldbEngine::stubStarted);
|
|
|
|
|
connect(&m_stubProc, &ConsoleProcess::stubStopped, this, &LldbEngine::stubExited);
|
2014-03-03 16:59:56 +01:00
|
|
|
// FIXME: Starting the stub implies starting the inferior. This is
|
|
|
|
|
// fairly unclean as far as the state machine and error reporting go.
|
|
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
if (!m_stubProc.start(runParameters().executable,
|
|
|
|
|
runParameters().processArgs)) {
|
2014-03-03 16:59:56 +01:00
|
|
|
// Error message for user is delivered via a signal.
|
|
|
|
|
//handleAdapterStartFailed(QString());
|
|
|
|
|
notifyEngineSetupFailed();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
2015-05-27 13:59:56 +02:00
|
|
|
if (runParameters().remoteSetupNeeded)
|
2014-03-03 16:59:56 +01:00
|
|
|
notifyEngineRequestRemoteSetup();
|
|
|
|
|
else
|
|
|
|
|
startLldb();
|
|
|
|
|
}
|
2013-10-10 15:15:49 +02:00
|
|
|
}
|
2013-03-22 10:28:49 +01:00
|
|
|
|
2013-10-10 15:15:49 +02:00
|
|
|
void LldbEngine::startLldb()
|
|
|
|
|
{
|
2015-05-27 13:59:56 +02:00
|
|
|
m_lldbCmd = runParameters().debuggerCommand;
|
2015-01-23 15:53:09 +01:00
|
|
|
connect(&m_lldbProc, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error),
|
|
|
|
|
this, &LldbEngine::handleLldbError);
|
|
|
|
|
connect(&m_lldbProc, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
|
|
|
|
this, &LldbEngine::handleLldbFinished);
|
|
|
|
|
connect(&m_lldbProc, &QProcess::readyReadStandardOutput,
|
|
|
|
|
this, &LldbEngine::readLldbStandardOutput);
|
|
|
|
|
connect(&m_lldbProc, &QProcess::readyReadStandardError,
|
|
|
|
|
this, &LldbEngine::readLldbStandardError);
|
|
|
|
|
|
|
|
|
|
connect(this, &LldbEngine::outputReady,
|
|
|
|
|
this, &LldbEngine::handleResponse, Qt::QueuedConnection);
|
2013-03-22 10:28:49 +01:00
|
|
|
|
2015-01-30 12:36:04 +01:00
|
|
|
showMessage(_("STARTING LLDB: ") + m_lldbCmd);
|
2015-06-05 12:31:39 +02:00
|
|
|
m_lldbProc.setEnvironment(runParameters().environment);
|
2015-05-27 13:59:56 +02:00
|
|
|
if (!runParameters().workingDirectory.isEmpty())
|
|
|
|
|
m_lldbProc.setWorkingDirectory(runParameters().workingDirectory);
|
2013-10-20 21:45:47 +02:00
|
|
|
|
2015-06-05 12:31:39 +02:00
|
|
|
m_lldbProc.setCommand(m_lldbCmd, QString());
|
|
|
|
|
m_lldbProc.start();
|
2013-03-22 10:28:49 +01:00
|
|
|
|
|
|
|
|
if (!m_lldbProc.waitForStarted()) {
|
2013-10-24 12:16:26 +02:00
|
|
|
const QString msg = tr("Unable to start LLDB \"%1\": %2")
|
2013-05-16 15:09:24 +02:00
|
|
|
.arg(m_lldbCmd, m_lldbProc.errorString());
|
2013-03-22 10:28:49 +01:00
|
|
|
notifyEngineSetupFailed();
|
|
|
|
|
showMessage(_("ADAPTER START FAILED"));
|
2013-04-30 10:46:48 +02:00
|
|
|
if (!msg.isEmpty())
|
2015-01-23 15:53:09 +01:00
|
|
|
ICore::showWarningWithOptions(tr("Adapter start failed."), msg);
|
2015-03-09 13:30:22 +01:00
|
|
|
return;
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
2015-03-09 13:30:22 +01:00
|
|
|
m_lldbProc.waitForReadyRead(1000);
|
|
|
|
|
m_lldbProc.write("sc print('@\\nlldbstartupok@\\n')\n");
|
|
|
|
|
}
|
2015-01-30 12:36:04 +01:00
|
|
|
|
2015-03-09 13:30:22 +01:00
|
|
|
// FIXME: splitting of startLldb() necessary to support LLDB <= 310 - revert asap
|
|
|
|
|
void LldbEngine::startLldbStage2()
|
|
|
|
|
{
|
2015-01-30 12:36:04 +01:00
|
|
|
showMessage(_("ADAPTER STARTED"));
|
|
|
|
|
showStatusMessage(tr("Setting up inferior..."));
|
|
|
|
|
|
|
|
|
|
const QByteArray dumperSourcePath =
|
|
|
|
|
ICore::resourcePath().toLocal8Bit() + "/debugger/";
|
|
|
|
|
|
2015-02-13 10:02:35 +01:00
|
|
|
m_lldbProc.write("script sys.path.insert(1, '" + dumperSourcePath + "')\n");
|
|
|
|
|
m_lldbProc.write("script from lldbbridge import *\n");
|
|
|
|
|
m_lldbProc.write("script print(dir())\n");
|
|
|
|
|
m_lldbProc.write("script theDumper = Dumper()\n"); // This triggers reportState("enginesetupok")
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::setupInferior()
|
|
|
|
|
{
|
2015-07-16 11:12:43 +02:00
|
|
|
Environment sysEnv = Environment::systemEnvironment();
|
|
|
|
|
Environment runEnv = runParameters().environment;
|
|
|
|
|
foreach (const EnvironmentItem &item, sysEnv.diff(runEnv)) {
|
|
|
|
|
DebuggerCommand cmd("executeDebuggerCommand");
|
|
|
|
|
if (item.unset)
|
|
|
|
|
cmd.arg("command", "settings remove target.env-vars " + item.name.toUtf8());
|
|
|
|
|
else
|
|
|
|
|
cmd.arg("command", "settings set target.env-vars " + item.name.toUtf8() + '=' + item.value.toUtf8());
|
|
|
|
|
runCommand(cmd);
|
2015-07-15 10:38:15 +03:00
|
|
|
}
|
|
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
const QString path = stringSetting(ExtraDumperFile);
|
2015-06-22 08:00:47 +03:00
|
|
|
if (!path.isEmpty() && QFileInfo(path).isReadable()) {
|
2015-02-11 12:20:21 +01:00
|
|
|
DebuggerCommand cmd("addDumperModule");
|
2015-01-28 17:17:31 +01:00
|
|
|
cmd.arg("path", path.toUtf8());
|
|
|
|
|
runCommand(cmd);
|
2014-06-23 16:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-28 14:23:52 +02:00
|
|
|
const QString commands = stringSetting(ExtraDumperCommands);
|
2014-06-23 16:33:19 +02:00
|
|
|
if (!commands.isEmpty()) {
|
2015-02-02 12:47:51 +01:00
|
|
|
DebuggerCommand cmd("executeDebuggerCommand");
|
2015-07-16 12:03:11 +02:00
|
|
|
cmd.arg("command", commands.toUtf8());
|
2014-06-23 16:33:19 +02:00
|
|
|
runCommand(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-18 16:48:57 +01:00
|
|
|
DebuggerCommand cmd1("loadDumpers");
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd1.callback = [this](const DebuggerResponse &response) {
|
|
|
|
|
watchHandler()->addDumpers(response.data);
|
|
|
|
|
};
|
2015-01-23 19:09:08 +01:00
|
|
|
runCommand(cmd1);
|
2015-03-09 13:30:22 +01:00
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
const DebuggerRunParameters &rp = runParameters();
|
2015-01-23 19:09:08 +01:00
|
|
|
|
2014-02-04 13:32:17 +01:00
|
|
|
QString executable;
|
2015-01-23 15:53:09 +01:00
|
|
|
QtcProcess::Arguments args;
|
2015-05-27 13:59:56 +02:00
|
|
|
QtcProcess::prepareCommand(QFileInfo(rp.executable).absoluteFilePath(),
|
|
|
|
|
rp.processArgs, &executable, &args);
|
2014-02-04 13:32:17 +01:00
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd2("setupInferior");
|
|
|
|
|
cmd2.arg("executable", executable);
|
|
|
|
|
cmd2.arg("breakOnMain", rp.breakOnMain);
|
|
|
|
|
cmd2.arg("useTerminal", rp.useTerminal);
|
|
|
|
|
cmd2.arg("startMode", rp.startMode);
|
2015-01-30 12:36:04 +01:00
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd2.beginList("processArgs");
|
2014-02-05 10:43:21 +01:00
|
|
|
foreach (const QString &arg, args.toUnixArgs())
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd2.arg(arg.toUtf8().toHex());
|
|
|
|
|
cmd2.endList();
|
2013-11-19 10:45:00 +01:00
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
if (rp.useTerminal) {
|
2014-03-03 16:59:56 +01:00
|
|
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
|
|
|
|
const qint64 attachedPID = m_stubProc.applicationPID();
|
|
|
|
|
const qint64 attachedMainThreadID = m_stubProc.applicationMainThreadID();
|
|
|
|
|
const QString msg = (attachedMainThreadID != -1)
|
|
|
|
|
? QString::fromLatin1("Attaching to %1 (%2)").arg(attachedPID).arg(attachedMainThreadID)
|
|
|
|
|
: QString::fromLatin1("Attaching to %1").arg(attachedPID);
|
|
|
|
|
showMessage(msg, LogMisc);
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd2.arg("attachPid", attachedPID);
|
2014-03-03 16:59:56 +01:00
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd2.arg("startMode", rp.startMode);
|
2014-03-03 16:59:56 +01:00
|
|
|
// it is better not to check the start mode on the python sid (as we would have to duplicate the
|
2015-05-27 13:59:56 +02:00
|
|
|
// enum values), and thus we assume that if the rp.attachPID is valid we really have to attach
|
|
|
|
|
QTC_CHECK(rp.attachPID <= 0 || (rp.startMode == AttachCrashedExternal
|
|
|
|
|
|| rp.startMode == AttachExternal));
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd2.arg("attachPid", rp.attachPID);
|
|
|
|
|
cmd2.arg("sysRoot", rp.deviceSymbolsRoot.isEmpty() ? rp.sysRoot : rp.deviceSymbolsRoot);
|
|
|
|
|
cmd2.arg("remoteChannel", ((rp.startMode == AttachToRemoteProcess
|
2015-05-27 13:59:56 +02:00
|
|
|
|| rp.startMode == AttachToRemoteServer)
|
|
|
|
|
? rp.remoteChannel : QString()));
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd2.arg("platform", rp.platform);
|
2015-05-27 13:59:56 +02:00
|
|
|
QTC_CHECK(!rp.continueAfterAttach || (rp.startMode == AttachToRemoteProcess
|
|
|
|
|
|| rp.startMode == AttachExternal
|
|
|
|
|
|| rp.startMode == AttachToRemoteServer));
|
2014-03-03 16:59:56 +01:00
|
|
|
m_continueAtNextSpontaneousStop = false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd2.callback = [this](const DebuggerResponse &response) {
|
|
|
|
|
bool success = response.data["success"].toInt();
|
|
|
|
|
if (success) {
|
|
|
|
|
foreach (Breakpoint bp, breakHandler()->unclaimedBreakpoints()) {
|
|
|
|
|
if (acceptsBreakpoint(bp)) {
|
|
|
|
|
bp.setEngine(this);
|
|
|
|
|
insertBreakpoint(bp);
|
|
|
|
|
} else {
|
|
|
|
|
showMessage(_("BREAKPOINT %1 IN STATE %2 IS NOT ACCEPTABLE")
|
|
|
|
|
.arg(bp.id().toString()).arg(bp.state()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
notifyInferiorSetupOk();
|
|
|
|
|
} else {
|
|
|
|
|
notifyInferiorSetupFailed();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
runCommand(cmd2);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::runEngine()
|
|
|
|
|
{
|
2015-05-27 13:59:56 +02:00
|
|
|
const DebuggerRunParameters &rp = runParameters();
|
2015-01-30 12:36:04 +01:00
|
|
|
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state(); return);
|
2013-03-22 10:28:49 +01:00
|
|
|
showStatusMessage(tr("Running requested..."), 5000);
|
2015-02-27 11:56:03 +01:00
|
|
|
DebuggerCommand cmd("runEngine");
|
2015-09-09 16:34:09 +02:00
|
|
|
if (rp.startMode == AttachCore)
|
2015-05-27 13:59:56 +02:00
|
|
|
cmd.arg("coreFile", rp.coreFile);
|
2015-02-27 11:56:03 +01:00
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::interruptInferior()
|
|
|
|
|
{
|
|
|
|
|
showStatusMessage(tr("Interrupt requested..."), 5000);
|
2013-05-07 12:34:10 +02:00
|
|
|
runCommand("interruptInferior");
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-09 10:59:36 +02:00
|
|
|
void LldbEngine::executeStep()
|
|
|
|
|
{
|
|
|
|
|
notifyInferiorRunRequested();
|
2013-05-07 12:34:10 +02:00
|
|
|
runCommand("executeStep");
|
2013-04-09 10:59:36 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
void LldbEngine::executeStepI()
|
|
|
|
|
{
|
|
|
|
|
notifyInferiorRunRequested();
|
2013-05-07 12:34:10 +02:00
|
|
|
runCommand("executeStepI");
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::executeStepOut()
|
|
|
|
|
{
|
|
|
|
|
notifyInferiorRunRequested();
|
2013-05-07 12:34:10 +02:00
|
|
|
runCommand("executeStepOut");
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::executeNext()
|
|
|
|
|
{
|
|
|
|
|
notifyInferiorRunRequested();
|
2013-05-07 12:34:10 +02:00
|
|
|
runCommand("executeNext");
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::executeNextI()
|
|
|
|
|
{
|
|
|
|
|
notifyInferiorRunRequested();
|
2013-05-07 12:34:10 +02:00
|
|
|
runCommand("executeNextI");
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::continueInferior()
|
|
|
|
|
{
|
|
|
|
|
notifyInferiorRunRequested();
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd("continueInferior");
|
|
|
|
|
cmd.callback = [this](const DebuggerResponse &response) {
|
|
|
|
|
if (response.resultClass == ResultError)
|
|
|
|
|
notifyEngineIll();
|
|
|
|
|
};
|
|
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-11 17:06:17 +02:00
|
|
|
void LldbEngine::handleResponse(const QByteArray &response)
|
2013-04-09 10:59:36 +02:00
|
|
|
{
|
2013-04-30 10:46:48 +02:00
|
|
|
GdbMi all;
|
|
|
|
|
all.fromStringMultiple(response);
|
2013-04-10 15:54:04 +02:00
|
|
|
|
2013-05-02 14:31:35 +02:00
|
|
|
foreach (const GdbMi &item, all.children()) {
|
|
|
|
|
const QByteArray name = item.name();
|
2015-09-09 16:34:09 +02:00
|
|
|
if (name == "result") {
|
|
|
|
|
QString msg = item["status"].toUtf8();
|
2014-02-06 16:47:07 +01:00
|
|
|
if (msg.size())
|
|
|
|
|
msg[0] = msg.at(0).toUpper();
|
|
|
|
|
showStatusMessage(msg);
|
2013-05-02 14:31:35 +02:00
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
int token = item["token"].toInt();
|
|
|
|
|
showMessage(QString::fromLatin1("%1^").arg(token), LogOutput);
|
|
|
|
|
if (m_commandForToken.contains(token)) {
|
|
|
|
|
DebuggerCommand cmd = m_commandForToken.take(token);
|
|
|
|
|
DebuggerResponse response;
|
|
|
|
|
response.token = token;
|
|
|
|
|
response.data = item;
|
|
|
|
|
if (cmd.callback)
|
|
|
|
|
cmd.callback(response);
|
|
|
|
|
}
|
|
|
|
|
} else if (name == "state")
|
|
|
|
|
handleStateNotification(item);
|
|
|
|
|
else if (name == "location")
|
|
|
|
|
handleLocationNotification(item);
|
|
|
|
|
else if (name == "output")
|
|
|
|
|
handleOutputNotification(item);
|
2015-02-24 11:33:25 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
void LldbEngine::executeRunToLine(const ContextData &data)
|
|
|
|
|
{
|
2013-04-10 15:54:04 +02:00
|
|
|
notifyInferiorRunRequested();
|
2015-02-02 12:47:51 +01:00
|
|
|
DebuggerCommand cmd("executeRunToLocation");
|
2014-02-06 16:47:07 +01:00
|
|
|
cmd.arg("file", data.fileName);
|
|
|
|
|
cmd.arg("line", data.lineNumber);
|
|
|
|
|
cmd.arg("address", data.address);
|
|
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::executeRunToFunction(const QString &functionName)
|
|
|
|
|
{
|
2013-04-10 15:54:04 +02:00
|
|
|
notifyInferiorRunRequested();
|
2015-02-05 14:39:59 +01:00
|
|
|
DebuggerCommand cmd("executeRunToFunction");
|
|
|
|
|
cmd.arg("function", functionName);
|
|
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::executeJumpToLine(const ContextData &data)
|
|
|
|
|
{
|
2015-02-02 12:47:51 +01:00
|
|
|
DebuggerCommand cmd("executeJumpToLocation");
|
2014-02-06 15:40:23 +01:00
|
|
|
cmd.arg("file", data.fileName);
|
|
|
|
|
cmd.arg("line", data.lineNumber);
|
|
|
|
|
cmd.arg("address", data.address);
|
|
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::activateFrame(int frameIndex)
|
|
|
|
|
{
|
|
|
|
|
if (state() != InferiorStopOk && state() != InferiorUnrunnable)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-02-27 16:53:48 +01:00
|
|
|
StackHandler *handler = stackHandler();
|
2015-09-09 16:34:09 +02:00
|
|
|
if (frameIndex == handler->stackSize()) {
|
|
|
|
|
fetchStack(handler->stackSize() * 10 + 3);
|
2014-04-09 13:16:27 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2014-02-03 13:47:26 +01:00
|
|
|
|
2015-02-27 16:53:48 +01:00
|
|
|
QTC_ASSERT(frameIndex < handler->stackSize(), return);
|
|
|
|
|
handler->setCurrentIndex(frameIndex);
|
|
|
|
|
gotoLocation(handler->currentFrame());
|
|
|
|
|
|
2015-02-02 12:47:51 +01:00
|
|
|
DebuggerCommand cmd("activateFrame");
|
2014-02-03 13:47:26 +01:00
|
|
|
cmd.arg("index", frameIndex);
|
|
|
|
|
cmd.arg("thread", threadsHandler()->currentThread().raw());
|
|
|
|
|
runCommand(cmd);
|
2015-09-09 16:34:09 +02:00
|
|
|
|
|
|
|
|
updateLocals();
|
|
|
|
|
reloadRegisters();
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::selectThread(ThreadId threadId)
|
|
|
|
|
{
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd("selectThread");
|
|
|
|
|
cmd.arg("id", threadId.raw());
|
|
|
|
|
cmd.callback = [this](const DebuggerResponse &) {
|
|
|
|
|
DebuggerCommand cmd("fetchStack");
|
|
|
|
|
cmd.arg("nativeMixed", isNativeMixedActive());
|
|
|
|
|
cmd.arg("stacklimit", action(MaximalStackDepth)->value().toInt());
|
|
|
|
|
runCommand(cmd);
|
|
|
|
|
updateLocals();
|
|
|
|
|
};
|
2015-02-05 14:39:59 +01:00
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-02 13:48:33 +01:00
|
|
|
bool LldbEngine::stateAcceptsBreakpointChanges() const
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
2015-02-02 13:48:33 +01:00
|
|
|
switch (state()) {
|
|
|
|
|
case InferiorSetupRequested:
|
|
|
|
|
case InferiorRunRequested:
|
|
|
|
|
case InferiorRunOk:
|
|
|
|
|
case InferiorStopRequested:
|
|
|
|
|
case InferiorStopOk:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-02 13:48:33 +01:00
|
|
|
bool LldbEngine::acceptsBreakpoint(Breakpoint bp) const
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
2015-05-27 13:59:56 +02:00
|
|
|
if (runParameters().startMode == AttachCore)
|
2015-02-02 13:48:33 +01:00
|
|
|
return false;
|
|
|
|
|
// We handle QML breakpoint unless specifically disabled.
|
2015-05-27 13:59:56 +02:00
|
|
|
if (isNativeMixedEnabled() && !(runParameters().languages & QmlLanguage))
|
2015-02-02 13:48:33 +01:00
|
|
|
return true;
|
|
|
|
|
return bp.parameters().isCppBreakpoint();
|
|
|
|
|
}
|
2013-03-22 10:28:49 +01:00
|
|
|
|
2015-02-02 13:48:33 +01:00
|
|
|
void LldbEngine::insertBreakpoint(Breakpoint bp)
|
|
|
|
|
{
|
|
|
|
|
DebuggerCommand cmd("insertBreakpoint");
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.callback = [this, bp](const DebuggerResponse &response) {
|
|
|
|
|
QTC_CHECK(bp.state() == BreakpointInsertProceeding);
|
|
|
|
|
updateBreakpointData(bp, response.data, true);
|
|
|
|
|
};
|
2015-02-04 16:27:46 +01:00
|
|
|
bp.addToCommand(&cmd);
|
2015-02-02 13:48:33 +01:00
|
|
|
bp.notifyBreakpointInsertProceeding();
|
2015-02-04 16:27:46 +01:00
|
|
|
runCommand(cmd);
|
2013-04-12 14:41:05 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-02 13:48:33 +01:00
|
|
|
void LldbEngine::changeBreakpoint(Breakpoint bp)
|
2013-04-12 14:41:05 +02:00
|
|
|
{
|
2015-02-02 13:48:33 +01:00
|
|
|
const BreakpointResponse &response = bp.response();
|
|
|
|
|
DebuggerCommand cmd("changeBreakpoint");
|
2015-02-04 16:27:46 +01:00
|
|
|
cmd.arg("lldbid", response.id.toByteArray());
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.callback = [this, bp](const DebuggerResponse &response) {
|
|
|
|
|
QTC_CHECK(!bp.isValid() || bp.state() == BreakpointChangeProceeding);
|
|
|
|
|
updateBreakpointData(bp, response.data, false);
|
|
|
|
|
};
|
2015-02-04 16:27:46 +01:00
|
|
|
bp.addToCommand(&cmd);
|
2015-02-02 13:48:33 +01:00
|
|
|
bp.notifyBreakpointChangeProceeding();
|
|
|
|
|
runCommand(cmd);
|
|
|
|
|
}
|
2013-04-09 10:59:36 +02:00
|
|
|
|
2015-02-02 13:48:33 +01:00
|
|
|
void LldbEngine::removeBreakpoint(Breakpoint bp)
|
|
|
|
|
{
|
|
|
|
|
const BreakpointResponse &response = bp.response();
|
2015-09-09 16:34:09 +02:00
|
|
|
if (response.id.isValid()) {
|
|
|
|
|
DebuggerCommand cmd("removeBreakpoint");
|
|
|
|
|
cmd.arg("lldbid", response.id.toByteArray());
|
|
|
|
|
cmd.callback = [this, bp](const DebuggerResponse &) {
|
|
|
|
|
QTC_CHECK(bp.state() == BreakpointRemoveProceeding);
|
|
|
|
|
Breakpoint bp0 = bp;
|
|
|
|
|
bp0.notifyBreakpointRemoveOk();
|
|
|
|
|
};
|
|
|
|
|
bp.notifyBreakpointRemoveProceeding();
|
|
|
|
|
runCommand(cmd);
|
|
|
|
|
}
|
2013-04-09 10:59:36 +02:00
|
|
|
}
|
2013-03-22 10:28:49 +01:00
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool added)
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
|
|
|
|
BreakHandler *handler = breakHandler();
|
2014-03-05 19:06:24 +01:00
|
|
|
BreakpointResponseId rid = BreakpointResponseId(bkpt["lldbid"].data());
|
2015-01-10 01:07:01 +01:00
|
|
|
if (!bp.isValid())
|
|
|
|
|
bp = handler->findBreakpointByResponseId(rid);
|
|
|
|
|
BreakpointResponse response = bp.response();
|
2013-04-09 10:59:36 +02:00
|
|
|
if (added)
|
|
|
|
|
response.id = rid;
|
|
|
|
|
QTC_CHECK(response.id == rid);
|
|
|
|
|
response.address = 0;
|
2013-05-07 12:09:54 +02:00
|
|
|
response.enabled = bkpt["enabled"].toInt();
|
|
|
|
|
response.ignoreCount = bkpt["ignorecount"].toInt();
|
2013-06-14 15:15:09 +02:00
|
|
|
response.condition = QByteArray::fromHex(bkpt["condition"].data());
|
2013-05-07 12:09:54 +02:00
|
|
|
response.hitCount = bkpt["hitcount"].toInt();
|
2014-03-05 19:06:24 +01:00
|
|
|
response.fileName = bkpt["file"].toUtf8();
|
|
|
|
|
response.lineNumber = bkpt["line"].toInt();
|
|
|
|
|
|
|
|
|
|
GdbMi locations = bkpt["locations"];
|
2015-02-19 16:44:58 +01:00
|
|
|
const int numChild = int(locations.children().size());
|
2014-03-05 19:06:24 +01:00
|
|
|
if (numChild > 1) {
|
|
|
|
|
foreach (const GdbMi &location, locations.children()) {
|
|
|
|
|
const int locid = location["locid"].toInt();
|
|
|
|
|
BreakpointResponse sub;
|
|
|
|
|
sub.id = BreakpointResponseId(rid.majorPart(), locid);
|
|
|
|
|
sub.type = response.type;
|
|
|
|
|
sub.address = location["addr"].toAddress();
|
|
|
|
|
sub.functionName = location["func"].toUtf8();
|
|
|
|
|
sub.fileName = location["file"].toUtf8();
|
|
|
|
|
sub.lineNumber = location["line"].toInt();
|
2015-01-10 01:07:01 +01:00
|
|
|
bp.insertSubBreakpoint(sub);
|
2013-04-09 10:59:36 +02:00
|
|
|
}
|
2014-03-05 19:06:24 +01:00
|
|
|
} else if (numChild == 1) {
|
|
|
|
|
const GdbMi location = locations.childAt(0);
|
|
|
|
|
response.address = location["addr"].toAddress();
|
|
|
|
|
response.functionName = location["func"].toUtf8();
|
2013-04-09 10:59:36 +02:00
|
|
|
} else {
|
2014-11-17 13:09:36 +01:00
|
|
|
// This can happen for pending breakpoints.
|
|
|
|
|
showMessage(_("NO LOCATIONS (YET) FOR BP %1").arg(response.toString()));
|
2013-04-09 10:59:36 +02:00
|
|
|
}
|
2015-01-10 01:07:01 +01:00
|
|
|
bp.setResponse(response);
|
2014-03-05 19:06:24 +01:00
|
|
|
if (added)
|
2015-01-10 01:07:01 +01:00
|
|
|
bp.notifyBreakpointInsertOk();
|
2014-03-05 19:06:24 +01:00
|
|
|
else
|
2015-01-10 01:07:01 +01:00
|
|
|
bp.notifyBreakpointChangeOk();
|
2013-04-09 10:59:36 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
void LldbEngine::handleOutputNotification(const GdbMi &output)
|
2013-05-29 12:14:49 +02:00
|
|
|
{
|
|
|
|
|
QByteArray channel = output["channel"].data();
|
|
|
|
|
QByteArray data = QByteArray::fromHex(output["data"].data());
|
|
|
|
|
LogChannel ch = AppStuff;
|
|
|
|
|
if (channel == "stdout")
|
|
|
|
|
ch = AppOutput;
|
|
|
|
|
else if (channel == "stderr")
|
|
|
|
|
ch = AppError;
|
|
|
|
|
showMessage(QString::fromUtf8(data), ch);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
void LldbEngine::loadSymbols(const QString &moduleName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(moduleName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::loadAllSymbols()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::reloadModules()
|
|
|
|
|
{
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd("fetchModules");
|
|
|
|
|
cmd.callback = [this](const DebuggerResponse &response) {
|
|
|
|
|
const GdbMi &modules = response.data["modules"];
|
|
|
|
|
ModulesHandler *handler = modulesHandler();
|
|
|
|
|
handler->beginUpdateAll();
|
|
|
|
|
foreach (const GdbMi &item, modules.children()) {
|
|
|
|
|
Module module;
|
|
|
|
|
module.modulePath = item["file"].toUtf8();
|
|
|
|
|
module.moduleName = item["name"].toUtf8();
|
|
|
|
|
module.symbolsRead = Module::UnknownReadState;
|
|
|
|
|
module.startAddress = item["loaded_addr"].toAddress();
|
|
|
|
|
module.endAddress = 0; // FIXME: End address not easily available.
|
|
|
|
|
handler->updateModule(module);
|
|
|
|
|
}
|
|
|
|
|
handler->endUpdateAll();
|
|
|
|
|
};
|
|
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::requestModuleSymbols(const QString &moduleName)
|
|
|
|
|
{
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd("fetchSymbols");
|
2015-02-05 14:39:59 +01:00
|
|
|
cmd.arg("module", moduleName);
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.callback = [this, moduleName](const DebuggerResponse &response) {
|
|
|
|
|
const GdbMi &symbols = response.data["symbols"];
|
|
|
|
|
QString moduleName = response.data["module"].toUtf8();
|
|
|
|
|
Symbols syms;
|
|
|
|
|
foreach (const GdbMi &item, symbols.children()) {
|
|
|
|
|
Symbol symbol;
|
|
|
|
|
symbol.address = item["address"].toUtf8();
|
|
|
|
|
symbol.name = item["name"].toUtf8();
|
|
|
|
|
symbol.state = item["state"].toUtf8();
|
|
|
|
|
symbol.section = item["section"].toUtf8();
|
|
|
|
|
symbol.demangled = item["demangled"].toUtf8();
|
|
|
|
|
syms.append(symbol);
|
|
|
|
|
}
|
|
|
|
|
Internal::showModuleSymbols(moduleName, syms);
|
|
|
|
|
};
|
2015-02-05 14:39:59 +01:00
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-10 15:54:04 +02:00
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Tooltip specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2015-06-08 18:07:11 +02:00
|
|
|
bool LldbEngine::canHandleToolTip(const DebuggerToolTipContext &context) const
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
2015-06-08 18:07:11 +02:00
|
|
|
return state() == InferiorStopOk && context.isCppEditor;
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-29 14:54:47 +02:00
|
|
|
void LldbEngine::updateAll()
|
|
|
|
|
{
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd("fetchThreads");
|
|
|
|
|
cmd.callback = [this](const DebuggerResponse &response) {
|
|
|
|
|
threadsHandler()->updateThreads(response.data);
|
|
|
|
|
fetchStack(action(MaximalStackDepth)->value().toInt());
|
|
|
|
|
reloadRegisters();
|
|
|
|
|
};
|
2014-04-09 13:16:27 +02:00
|
|
|
runCommand(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-24 11:33:25 +01:00
|
|
|
void LldbEngine::reloadFullStack()
|
2014-04-09 13:16:27 +02:00
|
|
|
{
|
2015-09-09 16:34:09 +02:00
|
|
|
fetchStack(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::fetchStack(int limit)
|
|
|
|
|
{
|
|
|
|
|
DebuggerCommand cmd("fetchStack");
|
2015-02-05 14:19:32 +01:00
|
|
|
cmd.arg("nativeMixed", isNativeMixedActive());
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.arg("stacklimit", limit);
|
|
|
|
|
cmd.callback = [this](const DebuggerResponse &response) {
|
|
|
|
|
const GdbMi &stack = response.data["stack"];
|
|
|
|
|
StackHandler *handler = stackHandler();
|
|
|
|
|
StackFrames frames;
|
|
|
|
|
foreach (const GdbMi &item, stack["frames"].children()) {
|
|
|
|
|
StackFrame frame;
|
|
|
|
|
frame.level = item["level"].toInt();
|
|
|
|
|
frame.file = item["file"].toUtf8();
|
|
|
|
|
frame.function = item["func"].toUtf8();
|
|
|
|
|
frame.from = item["func"].toUtf8();
|
|
|
|
|
frame.line = item["line"].toInt();
|
|
|
|
|
frame.address = item["addr"].toAddress();
|
|
|
|
|
GdbMi usable = item["usable"];
|
|
|
|
|
if (usable.isValid())
|
|
|
|
|
frame.usable = usable.data().toInt();
|
|
|
|
|
else
|
|
|
|
|
frame.usable = QFileInfo(frame.file).isReadable();
|
|
|
|
|
if (item["language"].data() == "js"
|
|
|
|
|
|| frame.file.endsWith(QLatin1String(".js"))
|
|
|
|
|
|| frame.file.endsWith(QLatin1String(".qml"))) {
|
|
|
|
|
frame.language = QmlLanguage;
|
|
|
|
|
frame.fixQmlFrame(runParameters());
|
|
|
|
|
}
|
|
|
|
|
frames.append(frame);
|
|
|
|
|
}
|
|
|
|
|
bool canExpand = stack["hasmore"].toInt();
|
|
|
|
|
action(ExpandStack)->setEnabled(canExpand);
|
|
|
|
|
handler->setFrames(frames, canExpand);
|
|
|
|
|
|
|
|
|
|
updateLocals();
|
|
|
|
|
};
|
2014-04-09 13:16:27 +02:00
|
|
|
runCommand(cmd);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Watch specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2015-03-19 12:42:53 +01:00
|
|
|
void LldbEngine::assignValueInDebugger(WatchItem *,
|
2013-05-30 15:35:52 +02:00
|
|
|
const QString &expression, const QVariant &value)
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
2015-02-02 12:47:51 +01:00
|
|
|
DebuggerCommand cmd("assignValue");
|
2013-05-30 15:35:52 +02:00
|
|
|
cmd.arg("exp", expression.toLatin1().toHex());
|
|
|
|
|
cmd.arg("value", value.toString().toLatin1().toHex());
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.callback = [this](const DebuggerResponse &) { updateLocals(); };
|
2013-05-30 15:35:52 +02:00
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-08 18:07:11 +02:00
|
|
|
void LldbEngine::doUpdateLocals(const UpdateParameters ¶ms)
|
2013-05-29 14:54:47 +02:00
|
|
|
{
|
2015-02-27 08:15:18 +01:00
|
|
|
if (stackHandler()->stackSize() == 0) {
|
|
|
|
|
showMessage(_("SKIPPING LOCALS DUE TO EMPTY STACK"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-06 09:46:08 +02:00
|
|
|
watchHandler()->notifyUpdateStarted(params.partialVariables());
|
2015-06-16 16:38:14 +02:00
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd("fetchLocals");
|
2015-02-05 14:19:32 +01:00
|
|
|
cmd.arg("nativeMixed", isNativeMixedActive());
|
2015-02-12 11:31:02 +01:00
|
|
|
watchHandler()->appendFormatRequests(&cmd);
|
2015-09-14 12:53:35 +02:00
|
|
|
watchHandler()->appendWatchersAndTooltipRequests(&cmd);
|
2013-05-24 12:54:09 +02:00
|
|
|
|
|
|
|
|
const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty();
|
2013-06-05 11:26:46 +02:00
|
|
|
cmd.arg("passexceptions", alwaysVerbose);
|
2014-07-28 14:23:52 +02:00
|
|
|
cmd.arg("fancy", boolSetting(UseDebuggingHelpers));
|
|
|
|
|
cmd.arg("autoderef", boolSetting(AutoDerefPointers));
|
|
|
|
|
cmd.arg("dyntype", boolSetting(UseDynamicType));
|
2015-03-26 13:03:38 +01:00
|
|
|
cmd.arg("partialVariable", params.partialVariable);
|
2015-05-29 08:23:52 +02:00
|
|
|
cmd.arg("sortStructMembers", boolSetting(SortStructMembers));
|
2013-11-05 09:45:38 +01:00
|
|
|
|
2013-05-24 12:54:09 +02:00
|
|
|
//cmd.arg("resultvarname", m_resultVarName);
|
|
|
|
|
|
2014-01-09 15:37:04 +01:00
|
|
|
m_lastDebuggableCommand = cmd;
|
|
|
|
|
m_lastDebuggableCommand.args.replace("\"passexceptions\":0", "\"passexceptions\":1");
|
|
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.callback = [this](const DebuggerResponse &response) {
|
|
|
|
|
updateLocalsView(response.data);
|
|
|
|
|
watchHandler()->notifyUpdateFinished();
|
|
|
|
|
};
|
2013-11-08 16:11:01 +01:00
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
runCommand(cmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::handleLldbError(QProcess::ProcessError error)
|
|
|
|
|
{
|
2015-03-05 11:11:32 +01:00
|
|
|
showMessage(_("LLDB PROCESS ERROR: %1").arg(error));
|
2013-03-22 10:28:49 +01:00
|
|
|
switch (error) {
|
|
|
|
|
case QProcess::Crashed:
|
|
|
|
|
break; // will get a processExited() as well
|
|
|
|
|
// impossible case QProcess::FailedToStart:
|
|
|
|
|
case QProcess::ReadError:
|
|
|
|
|
case QProcess::WriteError:
|
|
|
|
|
case QProcess::Timedout:
|
|
|
|
|
default:
|
|
|
|
|
//setState(EngineShutdownRequested, true);
|
|
|
|
|
m_lldbProc.kill();
|
2015-01-23 15:53:09 +01:00
|
|
|
AsynchronousMessageBox::critical(tr("LLDB I/O Error"), errorMessage(error));
|
2013-03-22 10:28:49 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString LldbEngine::errorMessage(QProcess::ProcessError error) const
|
|
|
|
|
{
|
|
|
|
|
switch (error) {
|
|
|
|
|
case QProcess::FailedToStart:
|
2013-10-11 12:45:42 +02:00
|
|
|
return tr("The LLDB process failed to start. Either the "
|
2013-10-24 12:16:26 +02:00
|
|
|
"invoked program \"%1\" is missing, or you may have insufficient "
|
2013-03-22 10:28:49 +01:00
|
|
|
"permissions to invoke the program.")
|
2013-05-16 15:09:24 +02:00
|
|
|
.arg(m_lldbCmd);
|
2013-03-22 10:28:49 +01:00
|
|
|
case QProcess::Crashed:
|
2013-10-11 12:45:42 +02:00
|
|
|
return tr("The LLDB process crashed some time after starting "
|
2013-03-22 10:28:49 +01:00
|
|
|
"successfully.");
|
|
|
|
|
case QProcess::Timedout:
|
|
|
|
|
return tr("The last waitFor...() function timed out. "
|
|
|
|
|
"The state of QProcess is unchanged, and you can try calling "
|
|
|
|
|
"waitFor...() again.");
|
|
|
|
|
case QProcess::WriteError:
|
|
|
|
|
return tr("An error occurred when attempting to write "
|
2013-10-11 12:45:42 +02:00
|
|
|
"to the LLDB process. For example, the process may not be running, "
|
2013-03-22 10:28:49 +01:00
|
|
|
"or it may have closed its input channel.");
|
|
|
|
|
case QProcess::ReadError:
|
|
|
|
|
return tr("An error occurred when attempting to read from "
|
|
|
|
|
"the Lldb process. For example, the process may not be running.");
|
|
|
|
|
default:
|
2013-11-06 09:30:36 +01:00
|
|
|
return tr("An unknown error in the LLDB process occurred.") + QLatin1Char(' ');
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-05 11:11:32 +01:00
|
|
|
void LldbEngine::handleLldbFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
2015-03-05 11:11:32 +01:00
|
|
|
notifyDebuggerProcessFinished(exitCode, exitStatus, QLatin1String("LLDB"));
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::readLldbStandardError()
|
|
|
|
|
{
|
|
|
|
|
QByteArray err = m_lldbProc.readAllStandardError();
|
2014-11-15 10:10:51 +01:00
|
|
|
qDebug() << "\nLLDB STDERR UNEXPECTED: " << err;
|
|
|
|
|
showMessage(_("Lldb stderr: " + err), LogError);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::readLldbStandardOutput()
|
|
|
|
|
{
|
|
|
|
|
QByteArray out = m_lldbProc.readAllStandardOutput();
|
2015-09-04 08:48:53 +02:00
|
|
|
out.replace("\r\n", "\n");
|
2015-09-09 16:34:09 +02:00
|
|
|
showMessage(_(out), LogOutput);
|
2013-04-30 10:46:48 +02:00
|
|
|
m_inbuffer.append(out);
|
2013-03-22 10:28:49 +01:00
|
|
|
while (true) {
|
2013-11-01 10:32:37 +01:00
|
|
|
int pos = m_inbuffer.indexOf("@\n");
|
2013-03-22 10:28:49 +01:00
|
|
|
if (pos == -1)
|
|
|
|
|
break;
|
|
|
|
|
QByteArray response = m_inbuffer.left(pos).trimmed();
|
2013-11-01 10:32:37 +01:00
|
|
|
m_inbuffer = m_inbuffer.mid(pos + 2);
|
2015-03-09 13:30:22 +01:00
|
|
|
if (response == "lldbstartupok")
|
|
|
|
|
startLldbStage2();
|
|
|
|
|
else
|
|
|
|
|
emit outputReady(response);
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
void LldbEngine::handleStateNotification(const GdbMi &reportedState)
|
2013-04-10 15:54:04 +02:00
|
|
|
{
|
2013-05-02 14:31:35 +02:00
|
|
|
QByteArray newState = reportedState.data();
|
|
|
|
|
if (newState == "running")
|
|
|
|
|
notifyInferiorRunOk();
|
|
|
|
|
else if (newState == "inferiorrunfailed")
|
|
|
|
|
notifyInferiorRunFailed();
|
2013-11-19 10:45:00 +01:00
|
|
|
else if (newState == "stopped") {
|
2013-05-02 14:31:35 +02:00
|
|
|
notifyInferiorSpontaneousStop();
|
2013-11-19 10:45:00 +01:00
|
|
|
if (m_continueAtNextSpontaneousStop) {
|
|
|
|
|
m_continueAtNextSpontaneousStop = false;
|
|
|
|
|
continueInferior();
|
2014-03-11 15:49:34 +01:00
|
|
|
} else {
|
|
|
|
|
updateAll();
|
2013-11-19 10:45:00 +01:00
|
|
|
}
|
2015-03-25 16:34:03 +01:00
|
|
|
} else if (newState == "inferiorstopok") {
|
2013-05-02 14:31:35 +02:00
|
|
|
notifyInferiorStopOk();
|
2015-03-25 16:34:03 +01:00
|
|
|
updateAll();
|
|
|
|
|
} else if (newState == "inferiorstopfailed")
|
2013-05-02 14:31:35 +02:00
|
|
|
notifyInferiorStopFailed();
|
2014-06-02 16:45:12 +02:00
|
|
|
else if (newState == "inferiorill")
|
|
|
|
|
notifyInferiorIll();
|
2013-05-02 14:31:35 +02:00
|
|
|
else if (newState == "enginesetupok")
|
|
|
|
|
notifyEngineSetupOk();
|
|
|
|
|
else if (newState == "enginesetupfailed")
|
|
|
|
|
notifyEngineSetupFailed();
|
2013-11-11 16:16:58 +01:00
|
|
|
else if (newState == "enginerunfailed")
|
|
|
|
|
notifyEngineRunFailed();
|
2013-11-19 10:45:00 +01:00
|
|
|
else if (newState == "enginerunandinferiorrunok") {
|
2015-05-27 13:59:56 +02:00
|
|
|
if (runParameters().continueAfterAttach)
|
2013-11-19 10:45:00 +01:00
|
|
|
m_continueAtNextSpontaneousStop = true;
|
2013-05-02 14:31:35 +02:00
|
|
|
notifyEngineRunAndInferiorRunOk();
|
2013-11-19 10:45:00 +01:00
|
|
|
} else if (newState == "enginerunandinferiorstopok")
|
2013-05-22 14:30:36 +02:00
|
|
|
notifyEngineRunAndInferiorStopOk();
|
2015-02-27 11:56:03 +01:00
|
|
|
else if (newState == "enginerunokandinferiorunrunnable")
|
|
|
|
|
notifyEngineRunOkAndInferiorUnrunnable();
|
2013-05-29 15:38:49 +02:00
|
|
|
else if (newState == "inferiorshutdownok")
|
|
|
|
|
notifyInferiorShutdownOk();
|
|
|
|
|
else if (newState == "inferiorshutdownfailed")
|
|
|
|
|
notifyInferiorShutdownFailed();
|
|
|
|
|
else if (newState == "engineshutdownok")
|
|
|
|
|
notifyEngineShutdownOk();
|
|
|
|
|
else if (newState == "engineshutdownfailed")
|
|
|
|
|
notifyEngineShutdownFailed();
|
2013-05-22 14:30:36 +02:00
|
|
|
else if (newState == "inferiorexited")
|
|
|
|
|
notifyInferiorExited();
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
void LldbEngine::handleLocationNotification(const GdbMi &reportedLocation)
|
2013-04-10 17:49:35 +02:00
|
|
|
{
|
2014-11-15 13:13:29 +01:00
|
|
|
qulonglong addr = reportedLocation["addr"].toAddress();
|
|
|
|
|
QString file = reportedLocation["file"].toUtf8();
|
|
|
|
|
int line = reportedLocation["line"].toInt();
|
|
|
|
|
Location loc = Location(file, line);
|
|
|
|
|
if (boolSetting(OperateByInstruction) || !QFileInfo::exists(file) || line <= 0) {
|
|
|
|
|
loc = Location(addr);
|
2013-06-11 18:07:59 +02:00
|
|
|
loc.setNeedsMarker(true);
|
2014-11-15 13:13:29 +01:00
|
|
|
loc.setUseAssembler(true);
|
2013-06-11 18:07:59 +02:00
|
|
|
}
|
2014-11-15 13:13:29 +01:00
|
|
|
gotoLocation(loc);
|
2013-04-10 17:49:35 +02:00
|
|
|
}
|
|
|
|
|
|
2013-04-30 10:46:48 +02:00
|
|
|
void LldbEngine::reloadRegisters()
|
|
|
|
|
{
|
2015-09-09 16:34:09 +02:00
|
|
|
if (!Internal::isDockVisible(QLatin1String(DOCKWIDGET_REGISTER)))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DebuggerCommand cmd("fetchRegisters");
|
|
|
|
|
cmd.callback = [this](const DebuggerResponse &response) {
|
|
|
|
|
RegisterHandler *handler = registerHandler();
|
|
|
|
|
GdbMi regs = response.data["registers"];
|
|
|
|
|
foreach (const GdbMi &item, regs.children()) {
|
|
|
|
|
Register reg;
|
|
|
|
|
reg.name = item["name"].data();
|
|
|
|
|
reg.value.fromByteArray(item["value"].data(), HexadecimalFormat);
|
|
|
|
|
reg.size = item["size"].data().toInt();
|
|
|
|
|
reg.reportedType = item["type"].data();
|
|
|
|
|
if (reg.reportedType.startsWith("unsigned"))
|
|
|
|
|
reg.kind = IntegerRegister;
|
|
|
|
|
handler->updateRegister(reg);
|
|
|
|
|
}
|
|
|
|
|
handler->commitUpdates();
|
|
|
|
|
};
|
|
|
|
|
runCommand(cmd);
|
2013-04-30 10:46:48 +02:00
|
|
|
}
|
|
|
|
|
|
2015-03-18 16:48:57 +01:00
|
|
|
void LldbEngine::reloadDebuggingHelpers()
|
|
|
|
|
{
|
|
|
|
|
runCommand("reloadDumpers");
|
|
|
|
|
updateAll();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-03 17:18:07 +02:00
|
|
|
void LldbEngine::fetchDisassembler(DisassemblerAgent *agent)
|
|
|
|
|
{
|
2013-05-07 08:46:51 +02:00
|
|
|
QPointer<DisassemblerAgent> p(agent);
|
|
|
|
|
int id = m_disassemblerAgents.value(p, -1);
|
|
|
|
|
if (id == -1) {
|
|
|
|
|
id = ++m_lastAgentId;
|
|
|
|
|
m_disassemblerAgents.insert(p, id);
|
|
|
|
|
}
|
2014-03-06 12:04:47 +01:00
|
|
|
const Location &loc = agent->location();
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd("fetchDisassembler");
|
2014-03-06 12:04:47 +01:00
|
|
|
cmd.arg("address", loc.address());
|
|
|
|
|
cmd.arg("function", loc.functionName());
|
2014-07-28 14:23:52 +02:00
|
|
|
cmd.arg("flavor", boolSetting(IntelFlavor) ? "intel" : "att");
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.callback = [this, id](const DebuggerResponse &response) {
|
|
|
|
|
DisassemblerLines result;
|
|
|
|
|
QPointer<DisassemblerAgent> agent = m_disassemblerAgents.key(id);
|
|
|
|
|
if (!agent.isNull()) {
|
|
|
|
|
foreach (const GdbMi &line, response.data["lines"].children()) {
|
|
|
|
|
DisassemblerLine dl;
|
|
|
|
|
dl.address = line["address"].toAddress();
|
|
|
|
|
//dl.data = line["data"].toUtf8();
|
|
|
|
|
//dl.rawData = line["rawdata"].data();
|
|
|
|
|
dl.data = line["rawdata"].toUtf8();
|
|
|
|
|
if (!dl.data.isEmpty())
|
|
|
|
|
dl.data += QString(30 - dl.data.size(), QLatin1Char(' '));
|
|
|
|
|
dl.data += line["data"].toUtf8();
|
|
|
|
|
dl.offset = line["offset"].toInt();
|
|
|
|
|
dl.lineNumber = line["line"].toInt();
|
|
|
|
|
dl.fileName = line["file"].toUtf8();
|
|
|
|
|
dl.function = line["function"].toUtf8();
|
|
|
|
|
dl.hunk = line["hunk"].toInt();
|
|
|
|
|
QByteArray comment = line["comment"].data();
|
|
|
|
|
if (!comment.isEmpty())
|
|
|
|
|
dl.data += QString::fromUtf8(" # " + comment);
|
|
|
|
|
result.appendLine(dl);
|
|
|
|
|
}
|
|
|
|
|
agent->setContents(result);
|
|
|
|
|
}
|
|
|
|
|
};
|
2014-03-06 12:04:47 +01:00
|
|
|
runCommand(cmd);
|
2013-05-07 08:46:51 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-09 16:34:09 +02:00
|
|
|
void LldbEngine::fetchFullBacktrace()
|
2014-03-11 16:40:07 +01:00
|
|
|
{
|
2015-09-09 16:34:09 +02:00
|
|
|
DebuggerCommand cmd("fetchFullBacktrace");
|
|
|
|
|
cmd.callback = [](const DebuggerResponse &response) {
|
|
|
|
|
Internal::openTextEditor(_("Backtrace $"),
|
|
|
|
|
QString::fromUtf8(QByteArray::fromHex(response.data.data())));
|
|
|
|
|
};
|
|
|
|
|
runCommand("fetchFullBacktrace");
|
2014-03-11 16:40:07 +01:00
|
|
|
}
|
2013-05-07 08:46:51 +02:00
|
|
|
|
|
|
|
|
void LldbEngine::fetchMemory(MemoryAgent *agent, QObject *editorToken,
|
|
|
|
|
quint64 addr, quint64 length)
|
|
|
|
|
{
|
|
|
|
|
int id = m_memoryAgents.value(agent, -1);
|
|
|
|
|
if (id == -1) {
|
|
|
|
|
id = ++m_lastAgentId;
|
|
|
|
|
m_memoryAgents.insert(agent, id);
|
|
|
|
|
}
|
2013-10-31 09:35:05 +01:00
|
|
|
m_memoryAgentTokens.insert(id, editorToken);
|
2015-09-09 16:34:09 +02:00
|
|
|
|
2015-02-02 12:47:51 +01:00
|
|
|
DebuggerCommand cmd("fetchMemory");
|
2014-03-06 12:04:47 +01:00
|
|
|
cmd.arg("address", addr);
|
|
|
|
|
cmd.arg("length", length);
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.callback = [this, id](const DebuggerResponse &response) {
|
|
|
|
|
qulonglong addr = response.data["address"].toAddress();
|
|
|
|
|
QPointer<MemoryAgent> agent = m_memoryAgents.key(id);
|
|
|
|
|
if (!agent.isNull()) {
|
|
|
|
|
QPointer<QObject> token = m_memoryAgentTokens.value(id);
|
|
|
|
|
QTC_ASSERT(!token.isNull(), return);
|
|
|
|
|
QByteArray ba = QByteArray::fromHex(response.data["contents"].data());
|
|
|
|
|
agent->addLazyData(token.data(), addr, ba);
|
|
|
|
|
}
|
|
|
|
|
};
|
2014-03-06 12:04:47 +01:00
|
|
|
runCommand(cmd);
|
2013-05-07 08:46:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::changeMemory(MemoryAgent *agent, QObject *editorToken,
|
|
|
|
|
quint64 addr, const QByteArray &data)
|
|
|
|
|
{
|
|
|
|
|
int id = m_memoryAgents.value(agent, -1);
|
|
|
|
|
if (id == -1) {
|
|
|
|
|
id = ++m_lastAgentId;
|
|
|
|
|
m_memoryAgents.insert(agent, id);
|
|
|
|
|
m_memoryAgentTokens.insert(id, editorToken);
|
|
|
|
|
}
|
2015-02-02 12:47:51 +01:00
|
|
|
DebuggerCommand cmd("writeMemory");
|
2014-03-06 12:04:47 +01:00
|
|
|
cmd.arg("address", addr);
|
|
|
|
|
cmd.arg("data", data.toHex());
|
2015-09-09 16:34:09 +02:00
|
|
|
cmd.callback = [this, id](const DebuggerResponse &response) { Q_UNUSED(response); };
|
2014-03-06 12:04:47 +01:00
|
|
|
runCommand(cmd);
|
2013-05-03 17:18:07 +02:00
|
|
|
}
|
|
|
|
|
|
2014-12-17 13:14:29 +01:00
|
|
|
void LldbEngine::setRegisterValue(const QByteArray &name, const QString &value)
|
2013-05-07 08:46:51 +02:00
|
|
|
{
|
2015-02-05 14:39:59 +01:00
|
|
|
DebuggerCommand cmd("setRegister");
|
|
|
|
|
cmd.arg("name", name);
|
|
|
|
|
cmd.arg("value", value);
|
|
|
|
|
runCommand(cmd);
|
2013-05-07 08:46:51 +02:00
|
|
|
}
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
bool LldbEngine::hasCapability(unsigned cap) const
|
|
|
|
|
{
|
2013-04-12 16:58:25 +02:00
|
|
|
if (cap & (ReverseSteppingCapability
|
|
|
|
|
| AutoDerefPointersCapability
|
|
|
|
|
| DisassemblerCapability
|
|
|
|
|
| RegisterCapability
|
|
|
|
|
| ShowMemoryCapability
|
|
|
|
|
| JumpToLineCapability
|
|
|
|
|
| ReloadModuleCapability
|
|
|
|
|
| ReloadModuleSymbolsCapability
|
|
|
|
|
| BreakOnThrowAndCatchCapability
|
|
|
|
|
| BreakConditionCapability
|
|
|
|
|
| TracePointCapability
|
|
|
|
|
| ReturnFromFunctionCapability
|
|
|
|
|
| CreateFullBacktraceCapability
|
|
|
|
|
| WatchpointByAddressCapability
|
|
|
|
|
| WatchpointByExpressionCapability
|
|
|
|
|
| AddWatcherCapability
|
|
|
|
|
| WatchWidgetsCapability
|
|
|
|
|
| ShowModuleSymbolsCapability
|
|
|
|
|
| ShowModuleSectionsCapability
|
|
|
|
|
| CatchCapability
|
|
|
|
|
| OperateByInstructionCapability
|
|
|
|
|
| RunToLineCapability
|
|
|
|
|
| WatchComplexExpressionsCapability
|
|
|
|
|
| MemoryAddressCapability))
|
|
|
|
|
return true;
|
|
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
if (runParameters().startMode == AttachCore)
|
2013-04-12 16:58:25 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
//return cap == SnapshotCapability;
|
|
|
|
|
return false;
|
2013-03-22 10:28:49 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-27 13:59:56 +02:00
|
|
|
DebuggerEngine *createLldbEngine(const DebuggerRunParameters &startParameters)
|
2013-03-22 10:28:49 +01:00
|
|
|
{
|
|
|
|
|
return new LldbEngine(startParameters);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-18 19:21:27 +02:00
|
|
|
void LldbEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result)
|
2013-10-10 15:15:49 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
2014-09-18 19:21:27 +02:00
|
|
|
DebuggerEngine::notifyEngineRemoteSetupFinished(result);
|
2013-10-10 15:15:49 +02:00
|
|
|
|
2014-09-18 20:01:19 +02:00
|
|
|
if (result.success) {
|
|
|
|
|
startLldb();
|
|
|
|
|
} else {
|
2014-09-18 19:21:27 +02:00
|
|
|
showMessage(_("ADAPTER START FAILED"));
|
|
|
|
|
if (!result.reason.isEmpty()) {
|
|
|
|
|
const QString title = tr("Adapter start failed");
|
2015-01-23 15:53:09 +01:00
|
|
|
ICore::showWarningWithOptions(title, result.reason);
|
2014-09-18 19:21:27 +02:00
|
|
|
}
|
|
|
|
|
notifyEngineSetupFailed();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-10-10 15:15:49 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-03 16:59:56 +01:00
|
|
|
void LldbEngine::stubStarted()
|
|
|
|
|
{
|
|
|
|
|
startLldb();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::stubError(const QString &msg)
|
|
|
|
|
{
|
2015-01-23 15:53:09 +01:00
|
|
|
AsynchronousMessageBox::critical(tr("Debugger Error"), msg);
|
2014-03-03 16:59:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LldbEngine::stubExited()
|
|
|
|
|
{
|
|
|
|
|
if (state() == EngineShutdownRequested || state() == DebuggerFinished) {
|
|
|
|
|
showMessage(_("STUB EXITED EXPECTEDLY"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
showMessage(_("STUB EXITED"));
|
|
|
|
|
notifyEngineIll();
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 10:28:49 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|