2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-04-23 12:12:22 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2010-04-23 12:12:22 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-04-23 12:12:22 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2010-04-23 12:12:22 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2012-10-02 09:12:39 +02: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
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
#include "pdbengine.h"
|
|
|
|
|
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/debuggeractions.h>
|
|
|
|
|
#include <debugger/debuggercore.h>
|
|
|
|
|
#include <debugger/debuggerdialogs.h>
|
|
|
|
|
#include <debugger/debuggerplugin.h>
|
|
|
|
|
#include <debugger/debuggerprotocol.h>
|
|
|
|
|
#include <debugger/debuggerstartparameters.h>
|
|
|
|
|
#include <debugger/debuggerstringutils.h>
|
|
|
|
|
#include <debugger/debuggertooltipmanager.h>
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/breakhandler.h>
|
|
|
|
|
#include <debugger/moduleshandler.h>
|
|
|
|
|
#include <debugger/registerhandler.h>
|
|
|
|
|
#include <debugger/stackhandler.h>
|
|
|
|
|
#include <debugger/sourceutils.h>
|
|
|
|
|
#include <debugger/watchhandler.h>
|
|
|
|
|
#include <debugger/watchutils.h>
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-04-23 12:12:22 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/texteditor.h>
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2010-04-23 12:12:22 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2014-11-25 13:08:18 +01:00
|
|
|
#include <coreplugin/messagebox.h>
|
2010-04-23 12:12:22 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QVariant>
|
2010-04-23 12:12:22 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QToolTip>
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DEBUG_SCRIPT 1
|
|
|
|
|
#if DEBUG_SCRIPT
|
|
|
|
|
# define SDEBUG(s) qDebug() << s
|
|
|
|
|
#else
|
|
|
|
|
# define SDEBUG(s)
|
|
|
|
|
#endif
|
|
|
|
|
# define XSDEBUG(s) qDebug() << s
|
|
|
|
|
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
#define CB(callback) [this](const DebuggerResponse &r) { callback(r); }
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// PdbEngine
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
PdbEngine::PdbEngine(const DebuggerStartParameters &startParameters)
|
2012-08-14 17:54:01 +02:00
|
|
|
: DebuggerEngine(startParameters)
|
2010-08-24 15:35:46 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("PdbEngine"));
|
|
|
|
|
}
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
PdbEngine::~PdbEngine()
|
|
|
|
|
{}
|
|
|
|
|
|
2012-04-10 09:36:15 +02:00
|
|
|
void PdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2012-04-10 09:36:15 +02:00
|
|
|
if (!(languages & CppLanguage))
|
|
|
|
|
return;
|
2010-07-23 16:05:56 +02:00
|
|
|
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
|
|
|
//XSDEBUG("PdbEngine::executeDebuggerCommand:" << command);
|
2010-04-23 12:12:22 +02:00
|
|
|
if (state() == DebuggerNotReady) {
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(_("PDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + command);
|
2010-04-23 12:12:22 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2010-07-23 16:05:56 +02:00
|
|
|
QTC_ASSERT(m_pdbProc.state() == QProcess::Running, notifyEngineIll());
|
|
|
|
|
postCommand(command.toLatin1(), CB(handleExecuteDebuggerCommand));
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::handleExecuteDebuggerCommand(const DebuggerResponse &response)
|
2010-07-23 16:05:56 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::postDirectCommand(const QByteArray &command)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_pdbProc.state() == QProcess::Running, notifyEngineIll());
|
|
|
|
|
showMessage(_(command), LogInput);
|
2011-02-23 15:28:39 +01:00
|
|
|
m_pdbProc.write(command + '\n');
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::postCommand(const QByteArray &command, DebuggerCommand::Callback callback)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2010-07-23 16:05:56 +02:00
|
|
|
QTC_ASSERT(m_pdbProc.state() == QProcess::Running, notifyEngineIll());
|
2015-02-13 12:03:30 +01:00
|
|
|
DebuggerCommand cmd;
|
|
|
|
|
cmd.function = command;
|
2010-04-23 12:12:22 +02:00
|
|
|
cmd.callback = callback;
|
|
|
|
|
m_commands.enqueue(cmd);
|
2015-02-13 12:03:30 +01:00
|
|
|
qDebug() << "ENQUEUE: " << cmd.function;
|
|
|
|
|
showMessage(_(cmd.function), LogInput);
|
|
|
|
|
m_pdbProc.write(cmd.function + '\n');
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
void PdbEngine::shutdownInferior()
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
|
|
|
|
|
notifyInferiorShutdownOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
void PdbEngine::shutdownEngine()
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state());
|
2010-04-23 12:12:22 +02:00
|
|
|
m_pdbProc.kill();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:10:50 +02:00
|
|
|
void PdbEngine::setupEngine()
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
2010-04-23 12:12:22 +02:00
|
|
|
|
2010-07-23 16:05:56 +02:00
|
|
|
m_pdb = _("python");
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(_("STARTING PDB ") + m_pdb);
|
2010-04-23 12:12:22 +02:00
|
|
|
|
2015-02-05 12:26:16 +01:00
|
|
|
connect(&m_pdbProc, static_cast<void(QProcess::*)(QProcess::ProcessError)>(&QProcess::error),
|
|
|
|
|
this, &PdbEngine::handlePdbError);
|
|
|
|
|
connect(&m_pdbProc, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished),
|
|
|
|
|
this, &PdbEngine::handlePdbFinished);
|
|
|
|
|
connect(&m_pdbProc, &QProcess::readyReadStandardOutput,
|
|
|
|
|
this, &PdbEngine::readPdbStandardOutput);
|
|
|
|
|
connect(&m_pdbProc, &QProcess::readyReadStandardError,
|
|
|
|
|
this, &PdbEngine::readPdbStandardError);
|
|
|
|
|
|
|
|
|
|
connect(this, &PdbEngine::outputReady,
|
|
|
|
|
this, &PdbEngine::handleOutput2, Qt::QueuedConnection);
|
2010-07-23 16:05:56 +02:00
|
|
|
|
2010-10-30 21:54:23 +02:00
|
|
|
// We will stop immediately, so setup a proper callback.
|
2015-02-13 12:03:30 +01:00
|
|
|
DebuggerCommand cmd;
|
2015-02-13 11:53:37 +01:00
|
|
|
cmd.callback = CB(handleFirstCommand);
|
2010-04-23 12:12:22 +02:00
|
|
|
m_commands.enqueue(cmd);
|
|
|
|
|
|
2010-07-23 16:05:56 +02:00
|
|
|
m_pdbProc.start(m_pdb, QStringList() << _("-i"));
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
if (!m_pdbProc.waitForStarted()) {
|
2014-04-17 14:09:47 +02:00
|
|
|
const QString msg = tr("Unable to start pdb \"%1\": %2")
|
2010-04-23 12:12:22 +02:00
|
|
|
.arg(m_pdb, m_pdbProc.errorString());
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyEngineSetupFailed();
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(_("ADAPTER START FAILED"));
|
2010-04-23 12:12:22 +02:00
|
|
|
if (!msg.isEmpty()) {
|
|
|
|
|
const QString title = tr("Adapter start failed");
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::ICore::showWarningWithOptions(title, msg);
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
2010-07-09 08:48:33 +02:00
|
|
|
notifyEngineSetupFailed();
|
2010-04-23 12:12:22 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2010-07-09 08:48:33 +02:00
|
|
|
notifyEngineSetupOk();
|
2010-07-08 18:10:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::setupInferior()
|
|
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
2010-04-23 12:12:22 +02:00
|
|
|
|
2015-02-13 09:18:27 +01:00
|
|
|
QString fileName = mainPythonFile();
|
2010-07-23 16:05:56 +02:00
|
|
|
QFile scriptFile(fileName);
|
|
|
|
|
if (!scriptFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
2014-11-25 13:08:18 +01:00
|
|
|
Core::AsynchronousMessageBox::critical(tr("Python Error"),
|
2010-07-23 16:05:56 +02:00
|
|
|
_("Cannot open script file %1:\n%2").
|
|
|
|
|
arg(fileName, scriptFile.errorString()));
|
|
|
|
|
notifyInferiorSetupFailed();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
notifyInferiorSetupOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-13 09:18:27 +01:00
|
|
|
QString PdbEngine::mainPythonFile() const
|
|
|
|
|
{
|
|
|
|
|
return QFileInfo(startParameters().processArgs).absoluteFilePath();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:10:50 +02:00
|
|
|
void PdbEngine::runEngine()
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2010-07-23 16:05:56 +02:00
|
|
|
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
2010-07-08 18:10:50 +02:00
|
|
|
showStatusMessage(tr("Running requested..."), 5000);
|
2010-07-23 16:05:56 +02:00
|
|
|
const QByteArray dumperSourcePath =
|
2013-09-25 18:22:01 +02:00
|
|
|
Core::ICore::resourcePath().toLocal8Bit() + "/debugger/";
|
2010-07-23 16:05:56 +02:00
|
|
|
postDirectCommand("import sys");
|
2015-02-13 09:18:27 +01:00
|
|
|
postDirectCommand("sys.argv.append('" + mainPythonFile().toLocal8Bit() + "')");
|
2010-07-23 16:05:56 +02:00
|
|
|
postDirectCommand("execfile('/usr/bin/pdb')");
|
2015-02-13 09:18:27 +01:00
|
|
|
postDirectCommand("execfile('" + dumperSourcePath + "pdbbridge.py')");
|
2010-07-23 16:05:56 +02:00
|
|
|
attemptBreakpointSynchronization();
|
|
|
|
|
notifyEngineRunAndInferiorStopOk();
|
|
|
|
|
continueInferior();
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::interruptInferior()
|
|
|
|
|
{
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorStopOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::executeStep()
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
resetLocation();
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
postCommand("step", CB(handleUpdateAll));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::executeStepI()
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
resetLocation();
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
postCommand("step", CB(handleUpdateAll));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::executeStepOut()
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
resetLocation();
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
postCommand("finish", CB(handleUpdateAll));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::executeNext()
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
resetLocation();
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
postCommand("next", CB(handleUpdateAll));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::executeNextI()
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
resetLocation();
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
postCommand("next", CB(handleUpdateAll));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::continueInferior()
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
resetLocation();
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
// Callback will be triggered e.g. when breakpoint is hit.
|
|
|
|
|
postCommand("continue", CB(handleUpdateAll));
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-23 10:16:11 +01:00
|
|
|
void PdbEngine::executeRunToLine(const ContextData &data)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2011-02-23 10:16:11 +01:00
|
|
|
Q_UNUSED(data)
|
2010-04-23 12:12:22 +02:00
|
|
|
SDEBUG("FIXME: PdbEngine::runToLineExec()");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::executeRunToFunction(const QString &functionName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(functionName)
|
|
|
|
|
XSDEBUG("FIXME: PdbEngine::runToFunctionExec()");
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-23 10:16:11 +01:00
|
|
|
void PdbEngine::executeJumpToLine(const ContextData &data)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2011-02-23 10:16:11 +01:00
|
|
|
Q_UNUSED(data)
|
2010-04-23 12:12:22 +02:00
|
|
|
XSDEBUG("FIXME: PdbEngine::jumpToLineExec()");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::activateFrame(int frameIndex)
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
resetLocation();
|
2010-07-09 17:07:59 +02:00
|
|
|
if (state() != InferiorStopOk && state() != InferiorUnrunnable)
|
2010-04-23 12:12:22 +02:00
|
|
|
return;
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
StackHandler *handler = stackHandler();
|
|
|
|
|
int oldIndex = handler->currentIndex();
|
2010-04-23 12:12:22 +02:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
//if (frameIndex == handler->stackSize()) {
|
2010-04-23 12:12:22 +02:00
|
|
|
// reloadFullStack();
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
QTC_ASSERT(frameIndex < handler->stackSize(), return);
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
if (oldIndex != frameIndex) {
|
|
|
|
|
// Assuming the command always succeeds this saves a roundtrip.
|
|
|
|
|
// Otherwise the lines below would need to get triggered
|
|
|
|
|
// after a response to this -stack-select-frame here.
|
2010-06-16 11:08:54 +02:00
|
|
|
handler->setCurrentIndex(frameIndex);
|
2010-04-23 12:12:22 +02:00
|
|
|
//postCommand("-stack-select-frame " + QByteArray::number(frameIndex),
|
|
|
|
|
// CB(handleStackSelectFrame));
|
|
|
|
|
}
|
2010-12-16 19:06:33 +01:00
|
|
|
gotoLocation(handler->currentFrame());
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
void PdbEngine::selectThread(ThreadId threadId)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2012-10-19 16:37:57 +02:00
|
|
|
Q_UNUSED(threadId)
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-10 01:07:01 +01:00
|
|
|
bool PdbEngine::acceptsBreakpoint(Breakpoint bp) const
|
2010-11-25 14:33:13 +01:00
|
|
|
{
|
2015-01-10 01:07:01 +01:00
|
|
|
const QString fileName = bp.fileName();
|
2010-11-25 14:33:13 +01:00
|
|
|
return fileName.endsWith(QLatin1String(".py"));
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-10 01:07:01 +01:00
|
|
|
void PdbEngine::insertBreakpoint(Breakpoint bp)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2015-01-10 01:07:01 +01:00
|
|
|
QTC_CHECK(bp.state() == BreakpointInsertRequested);
|
|
|
|
|
bp.notifyBreakpointInsertProceeding();
|
2010-11-25 14:33:13 +01:00
|
|
|
|
|
|
|
|
QByteArray loc;
|
2015-01-10 01:07:01 +01:00
|
|
|
if (bp.type() == BreakpointByFunction)
|
|
|
|
|
loc = bp.functionName().toLatin1();
|
2010-11-25 14:33:13 +01:00
|
|
|
else
|
2015-01-10 01:07:01 +01:00
|
|
|
loc = bp.fileName().toLocal8Bit() + ':'
|
|
|
|
|
+ QByteArray::number(bp.lineNumber());
|
2010-11-25 14:33:13 +01:00
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
postCommand("break " + loc, [this, bp](const DebuggerResponse &r) { handleBreakInsert(r, bp); });
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::handleBreakInsert(const DebuggerResponse &response, Breakpoint bp)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
|
|
|
|
//qDebug() << "BP RESPONSE: " << response.data;
|
|
|
|
|
// "Breakpoint 1 at /pdb/math.py:10"
|
2015-02-13 11:53:37 +01:00
|
|
|
QTC_ASSERT(response.logStreamOutput.startsWith("Breakpoint "), return);
|
|
|
|
|
int pos1 = response.logStreamOutput.indexOf(" at ");
|
2010-04-23 12:12:22 +02:00
|
|
|
QTC_ASSERT(pos1 != -1, return);
|
2015-02-13 11:53:37 +01:00
|
|
|
QByteArray bpnr = response.logStreamOutput.mid(11, pos1 - 11);
|
|
|
|
|
int pos2 = response.logStreamOutput.lastIndexOf(':');
|
|
|
|
|
QByteArray file = response.logStreamOutput.mid(pos1 + 4, pos2 - pos1 - 4);
|
|
|
|
|
QByteArray line = response.logStreamOutput.mid(pos2 + 1);
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakpointResponse br;
|
2011-06-24 16:25:30 +02:00
|
|
|
br.id = BreakpointResponseId(bpnr);
|
2010-11-15 17:04:29 +01:00
|
|
|
br.fileName = _(file);
|
|
|
|
|
br.lineNumber = line.toInt();
|
2015-01-10 01:07:01 +01:00
|
|
|
bp.setResponse(br);
|
|
|
|
|
QTC_CHECK(!bp.needsChange());
|
|
|
|
|
bp.notifyBreakpointInsertOk();
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-10 01:07:01 +01:00
|
|
|
void PdbEngine::removeBreakpoint(Breakpoint bp)
|
2010-11-25 14:33:13 +01:00
|
|
|
{
|
2015-01-10 01:07:01 +01:00
|
|
|
QTC_CHECK(bp.state() == BreakpointRemoveRequested);
|
|
|
|
|
bp.notifyBreakpointRemoveProceeding();
|
|
|
|
|
BreakpointResponse br = bp.response();
|
|
|
|
|
showMessage(_("DELETING BP %1 IN %2").arg(br.id.toString()).arg(bp.fileName()));
|
2011-06-21 16:45:23 +02:00
|
|
|
postCommand("clear " + br.id.toByteArray());
|
2010-11-25 14:33:13 +01:00
|
|
|
// Pretend it succeeds without waiting for response.
|
2015-01-10 01:07:01 +01:00
|
|
|
bp.notifyBreakpointRemoveOk();
|
2010-11-25 14:33:13 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-23 12:12:22 +02:00
|
|
|
void PdbEngine::loadSymbols(const QString &moduleName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(moduleName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::loadAllSymbols()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::reloadModules()
|
|
|
|
|
{
|
2010-07-23 16:05:56 +02:00
|
|
|
//postCommand("qdebug('listmodules')", CB(handleListModules));
|
2010-05-03 19:12:52 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::handleListModules(const DebuggerResponse &response)
|
2010-05-03 19:12:52 +02:00
|
|
|
{
|
|
|
|
|
GdbMi out;
|
2015-02-13 11:53:37 +01:00
|
|
|
out.fromString(response.logStreamOutput.trimmed());
|
2015-01-13 22:42:30 +01:00
|
|
|
ModulesHandler *handler = modulesHandler();
|
|
|
|
|
handler->beginUpdateAll();
|
2010-05-03 19:12:52 +02:00
|
|
|
foreach (const GdbMi &item, out.children()) {
|
|
|
|
|
Module module;
|
2013-05-03 18:26:10 +02:00
|
|
|
module.moduleName = _(item["name"].data());
|
|
|
|
|
QString path = _(item["value"].data());
|
2010-05-03 19:12:52 +02:00
|
|
|
int pos = path.indexOf(_("' from '"));
|
|
|
|
|
if (pos != -1) {
|
|
|
|
|
path = path.mid(pos + 8);
|
|
|
|
|
if (path.size() >= 2)
|
|
|
|
|
path.chop(2);
|
|
|
|
|
} else if (path.startsWith(_("<module '"))
|
|
|
|
|
&& path.endsWith(_("' (built-in)>"))) {
|
|
|
|
|
path = _("(builtin)");
|
|
|
|
|
}
|
|
|
|
|
module.modulePath = path;
|
2015-01-13 22:42:30 +01:00
|
|
|
handler->updateModule(module);
|
2010-05-03 19:12:52 +02:00
|
|
|
}
|
2015-01-13 22:42:30 +01:00
|
|
|
handler->endUpdateAll();
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2010-05-03 19:12:52 +02:00
|
|
|
void PdbEngine::requestModuleSymbols(const QString &moduleName)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2010-05-03 19:12:52 +02:00
|
|
|
postCommand("qdebug('listsymbols','" + moduleName.toLatin1() + "')",
|
2015-02-13 11:53:37 +01:00
|
|
|
[this, moduleName](const DebuggerResponse &r) { handleListSymbols(r, moduleName); });
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::handleListSymbols(const DebuggerResponse &response, const QString &moduleName)
|
2010-05-03 19:12:52 +02:00
|
|
|
{
|
|
|
|
|
GdbMi out;
|
2015-02-13 11:53:37 +01:00
|
|
|
out.fromString(response.logStreamOutput.trimmed());
|
2010-06-15 11:14:44 +02:00
|
|
|
Symbols symbols;
|
2010-05-03 19:12:52 +02:00
|
|
|
foreach (const GdbMi &item, out.children()) {
|
|
|
|
|
Symbol symbol;
|
2013-05-03 18:26:10 +02:00
|
|
|
symbol.name = _(item["name"].data());
|
2010-05-03 19:12:52 +02:00
|
|
|
symbols.append(symbol);
|
|
|
|
|
}
|
2014-10-22 13:04:47 +02:00
|
|
|
Internal::showModuleSymbols(moduleName, symbols);
|
2010-05-03 19:12:52 +02:00
|
|
|
}
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Tooltip specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static WatchData m_toolTip;
|
|
|
|
|
static QPoint m_toolTipPos;
|
|
|
|
|
static QHash<QString, WatchData> m_toolTipCache;
|
|
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
bool PdbEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
|
2014-07-08 18:16:54 +02:00
|
|
|
const DebuggerToolTipContext &ctx)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
if (state() != InferiorStopOk) {
|
2010-04-23 12:12:22 +02:00
|
|
|
//SDEBUG("SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED");
|
2011-02-17 10:08:57 +01:00
|
|
|
return false;
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
// Check mime type and get expression (borrowing some C++ - functions)
|
2014-09-19 15:26:41 +02:00
|
|
|
const QString javaPythonMimeType = QLatin1String("application/javascript");
|
|
|
|
|
if (editorWidget->textDocument()->mimeType() != javaPythonMimeType)
|
2011-02-17 10:08:57 +01:00
|
|
|
return false;
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
int line;
|
|
|
|
|
int column;
|
2014-09-19 15:26:41 +02:00
|
|
|
QString exp = cppExpressionAt(editorWidget, ctx.position, &line, &column);
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
QToolTip::hideText();
|
|
|
|
|
if (exp.isEmpty() || exp.startsWith(QLatin1Char('#'))) {
|
|
|
|
|
QToolTip::hideText();
|
2011-02-17 10:08:57 +01:00
|
|
|
return false;
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hasLetterOrNumber(exp)) {
|
2014-04-17 14:09:47 +02:00
|
|
|
QToolTip::showText(m_toolTipPos, tr("\"%1\" contains no identifier").arg(exp));
|
2011-02-17 10:08:57 +01:00
|
|
|
return true;
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exp.startsWith(QLatin1Char('"')) && exp.endsWith(QLatin1Char('"'))) {
|
|
|
|
|
QToolTip::showText(m_toolTipPos, tr("String literal %1").arg(exp));
|
2011-02-17 10:08:57 +01:00
|
|
|
return true;
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (exp.startsWith(QLatin1String("++")) || exp.startsWith(QLatin1String("--")))
|
|
|
|
|
exp.remove(0, 2);
|
|
|
|
|
|
|
|
|
|
if (exp.endsWith(QLatin1String("++")) || exp.endsWith(QLatin1String("--")))
|
|
|
|
|
exp.remove(0, 2);
|
|
|
|
|
|
|
|
|
|
if (exp.startsWith(QLatin1Char('<')) || exp.startsWith(QLatin1Char('[')))
|
2011-02-17 10:08:57 +01:00
|
|
|
return false;
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
if (hasSideEffects(exp)) {
|
|
|
|
|
QToolTip::showText(m_toolTipPos,
|
2014-04-17 14:09:47 +02:00
|
|
|
tr("Cowardly refusing to evaluate expression \"%1\" "
|
2010-04-23 12:12:22 +02:00
|
|
|
"with potential side effects").arg(exp));
|
2011-02-17 10:08:57 +01:00
|
|
|
return true;
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
2010-07-09 17:07:59 +02:00
|
|
|
//if (status() != InferiorStopOk)
|
2010-04-23 12:12:22 +02:00
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
// FIXME: 'exp' can contain illegal characters
|
|
|
|
|
m_toolTip = WatchData();
|
|
|
|
|
m_toolTip.exp = exp;
|
|
|
|
|
m_toolTip.name = exp;
|
|
|
|
|
m_toolTip.iname = tooltipIName;
|
|
|
|
|
insertData(m_toolTip);
|
|
|
|
|
#endif
|
2011-02-17 10:08:57 +01:00
|
|
|
return false;
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Watch specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-09-23 13:22:08 +02:00
|
|
|
void PdbEngine::assignValueInDebugger(const Internal::WatchData *, const QString &expression, const QVariant &value)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(expression);
|
|
|
|
|
Q_UNUSED(value);
|
2010-09-23 13:22:08 +02:00
|
|
|
SDEBUG("ASSIGNING: " << (expression + QLatin1Char('=') + value.toString()));
|
2010-04-23 12:12:22 +02:00
|
|
|
#if 0
|
2010-09-23 13:22:08 +02:00
|
|
|
m_scriptEngine->evaluate(expression + QLatin1Char('=') + value.toString());
|
2010-04-23 12:12:22 +02:00
|
|
|
updateLocals();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-09-13 08:32:12 +02:00
|
|
|
void PdbEngine::updateWatchData(const WatchData &data, const WatchUpdateFlags &flags)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(data);
|
2010-09-13 10:26:56 +02:00
|
|
|
Q_UNUSED(flags);
|
2010-04-23 12:12:22 +02:00
|
|
|
updateAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::handlePdbError(QProcess::ProcessError error)
|
|
|
|
|
{
|
2010-07-23 16:05:56 +02:00
|
|
|
qDebug() << "HANDLE PDB ERROR";
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(_("HANDLE PDB ERROR"));
|
2010-04-23 12:12:22 +02: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:
|
2010-07-12 15:34:05 +02:00
|
|
|
//setState(EngineShutdownRequested, true);
|
2010-04-23 12:12:22 +02:00
|
|
|
m_pdbProc.kill();
|
2014-11-25 13:08:18 +01:00
|
|
|
Core::AsynchronousMessageBox::critical(tr("Pdb I/O Error"),
|
|
|
|
|
errorMessage(error));
|
2010-04-23 12:12:22 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString PdbEngine::errorMessage(QProcess::ProcessError error) const
|
|
|
|
|
{
|
|
|
|
|
switch (error) {
|
|
|
|
|
case QProcess::FailedToStart:
|
|
|
|
|
return tr("The Pdb process failed to start. Either the "
|
2014-04-17 14:09:47 +02:00
|
|
|
"invoked program \"%1\" is missing, or you may have insufficient "
|
2010-04-23 12:12:22 +02:00
|
|
|
"permissions to invoke the program.")
|
|
|
|
|
.arg(m_pdb);
|
|
|
|
|
case QProcess::Crashed:
|
|
|
|
|
return tr("The Pdb process crashed some time after starting "
|
|
|
|
|
"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 "
|
|
|
|
|
"to the Pdb process. For example, the process may not be running, "
|
|
|
|
|
"or it may have closed its input channel.");
|
|
|
|
|
case QProcess::ReadError:
|
|
|
|
|
return tr("An error occurred when attempting to read from "
|
|
|
|
|
"the Pdb process. For example, the process may not be running.");
|
|
|
|
|
default:
|
2013-10-17 14:52:10 +02:00
|
|
|
return tr("An unknown error in the Pdb process occurred.") + QLatin1Char(' ');
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::handlePdbFinished(int code, QProcess::ExitStatus type)
|
|
|
|
|
{
|
2010-07-23 16:05:56 +02:00
|
|
|
qDebug() << "PDB FINISHED";
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(_("PDB PROCESS FINISHED, status %1, code %2").arg(type).arg(code));
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyEngineSpontaneousShutdown();
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::readPdbStandardError()
|
|
|
|
|
{
|
|
|
|
|
QByteArray err = m_pdbProc.readAllStandardError();
|
2010-07-23 16:05:56 +02:00
|
|
|
qDebug() << "\nPDB STDERR" << err;
|
|
|
|
|
//qWarning() << "Unexpected pdb stderr:" << err;
|
|
|
|
|
//showMessage(_("Unexpected pdb stderr: " + err));
|
|
|
|
|
//handleOutput(err);
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::readPdbStandardOutput()
|
|
|
|
|
{
|
2010-07-23 16:05:56 +02:00
|
|
|
QByteArray out = m_pdbProc.readAllStandardOutput();
|
|
|
|
|
qDebug() << "\nPDB STDOUT" << out;
|
|
|
|
|
handleOutput(out);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::handleOutput(const QByteArray &data)
|
|
|
|
|
{
|
|
|
|
|
//qDebug() << "READ: " << data;
|
|
|
|
|
m_inbuffer.append(data);
|
2012-08-22 11:58:33 +02:00
|
|
|
qDebug() << "BUFFER FROM: '" << m_inbuffer << '\'';
|
2010-07-23 16:05:56 +02:00
|
|
|
while (true) {
|
|
|
|
|
int pos = m_inbuffer.indexOf("(Pdb)");
|
|
|
|
|
if (pos == -1)
|
|
|
|
|
pos = m_inbuffer.indexOf(">>>");
|
|
|
|
|
if (pos == -1)
|
|
|
|
|
break;
|
|
|
|
|
QByteArray response = m_inbuffer.left(pos).trimmed();
|
2010-04-23 12:12:22 +02:00
|
|
|
m_inbuffer = m_inbuffer.mid(pos + 6);
|
2010-07-23 16:05:56 +02:00
|
|
|
emit outputReady(response);
|
|
|
|
|
}
|
2012-08-22 11:58:33 +02:00
|
|
|
qDebug() << "BUFFER LEFT: '" << m_inbuffer << '\'';
|
2010-07-23 16:05:56 +02:00
|
|
|
//m_inbuffer.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PdbEngine::handleOutput2(const QByteArray &data)
|
|
|
|
|
{
|
2015-02-13 11:53:37 +01:00
|
|
|
DebuggerResponse response;
|
|
|
|
|
response.logStreamOutput = data;
|
2010-07-23 16:05:56 +02:00
|
|
|
showMessage(_(data));
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(!m_commands.isEmpty(), qDebug() << "RESPONSE: " << data; return);
|
2015-02-13 12:03:30 +01:00
|
|
|
DebuggerCommand cmd = m_commands.dequeue();
|
|
|
|
|
qDebug() << "DEQUE: " << cmd.function;
|
2010-07-23 16:05:56 +02:00
|
|
|
if (cmd.callback) {
|
|
|
|
|
//qDebug() << "EXECUTING CALLBACK " << cmd.callbackName
|
|
|
|
|
// << " RESPONSE: " << response.data;
|
2015-02-13 11:53:37 +01:00
|
|
|
cmd.callback(response);
|
2010-07-23 16:05:56 +02:00
|
|
|
} else {
|
2015-02-13 11:53:37 +01:00
|
|
|
qDebug() << "NO CALLBACK FOR RESPONSE: " << response.logStreamOutput;
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
2010-07-23 16:05:56 +02:00
|
|
|
/*
|
2010-04-23 12:12:22 +02:00
|
|
|
void PdbEngine::handleResponse(const QByteArray &response0)
|
|
|
|
|
{
|
|
|
|
|
QByteArray response = response0;
|
|
|
|
|
qDebug() << "RESPONSE: '" << response << "'";
|
|
|
|
|
if (response.startsWith("--Call--")) {
|
|
|
|
|
qDebug() << "SKIPPING '--Call--' MARKER";
|
|
|
|
|
response = response.mid(9);
|
|
|
|
|
}
|
|
|
|
|
if (response.startsWith("--Return--")) {
|
|
|
|
|
qDebug() << "SKIPPING '--Return--' MARKER";
|
|
|
|
|
response = response.mid(11);
|
|
|
|
|
}
|
|
|
|
|
if (response.startsWith("> ")) {
|
|
|
|
|
int pos1 = response.indexOf('(');
|
|
|
|
|
int pos2 = response.indexOf(')', pos1);
|
|
|
|
|
if (pos1 != -1 && pos2 != -1) {
|
|
|
|
|
int lineNumber = response.mid(pos1 + 1, pos2 - pos1 - 1).toInt();
|
|
|
|
|
QByteArray fileName = response.mid(2, pos1 - 2);
|
2010-07-23 16:05:56 +02:00
|
|
|
qDebug() << " " << pos1 << pos2 << lineNumber << fileName
|
2010-04-23 12:12:22 +02:00
|
|
|
<< response.mid(pos1 + 1, pos2 - pos1 - 1);
|
|
|
|
|
StackFrame frame;
|
|
|
|
|
frame.file = _(fileName);
|
|
|
|
|
frame.line = lineNumber;
|
|
|
|
|
if (frame.line > 0 && QFileInfo(frame.file).exists()) {
|
2010-12-16 19:06:33 +01:00
|
|
|
gotoLocation(frame);
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorSpontaneousStop();
|
2010-04-23 12:12:22 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
qDebug() << "COULD NOT PARSE RESPONSE: '" << response << "'";
|
|
|
|
|
}
|
2010-07-23 16:05:56 +02:00
|
|
|
*/
|
2010-04-23 12:12:22 +02:00
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::handleFirstCommand(const DebuggerResponse &response)
|
2010-07-08 18:10:50 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(response);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::handleUpdateAll(const DebuggerResponse &response)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(response);
|
2010-07-12 15:34:05 +02:00
|
|
|
notifyInferiorSpontaneousStop();
|
2010-04-23 12:12:22 +02:00
|
|
|
updateAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::updateAll()
|
2010-07-23 16:05:56 +02:00
|
|
|
{
|
|
|
|
|
postCommand("bt", CB(handleBacktrace));
|
|
|
|
|
//updateLocals();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdbEngine::updateLocals()
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
|
|
|
|
QByteArray watchers;
|
|
|
|
|
//if (!m_toolTipExpression.isEmpty())
|
|
|
|
|
// watchers += m_toolTipExpression.toLatin1()
|
|
|
|
|
// + '#' + tooltipINameForExpression(m_toolTipExpression.toLatin1());
|
|
|
|
|
|
2012-05-18 02:28:41 +02:00
|
|
|
WatchHandler *handler = watchHandler();
|
2010-04-23 12:12:22 +02:00
|
|
|
QHash<QByteArray, int> watcherNames = handler->watcherNames();
|
|
|
|
|
QHashIterator<QByteArray, int> it(watcherNames);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
if (!watchers.isEmpty())
|
|
|
|
|
watchers += "##";
|
2010-07-23 18:20:13 +02:00
|
|
|
watchers += it.key() + "#watch." + QByteArray::number(it.value());
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray options;
|
2014-07-28 14:23:52 +02:00
|
|
|
if (boolSetting(UseDebuggingHelpers))
|
2010-04-23 12:12:22 +02:00
|
|
|
options += "fancy,";
|
2014-07-28 14:23:52 +02:00
|
|
|
if (boolSetting(AutoDerefPointers))
|
2010-04-23 12:12:22 +02:00
|
|
|
options += "autoderef,";
|
|
|
|
|
if (options.isEmpty())
|
|
|
|
|
options += "defaults,";
|
|
|
|
|
options.chop(1);
|
|
|
|
|
|
|
|
|
|
postCommand("qdebug('" + options + "','"
|
2015-02-12 11:31:02 +01:00
|
|
|
// + handler->expansionRequests() + "','"
|
2010-04-23 12:12:22 +02:00
|
|
|
+ handler->typeFormatRequests() + "','"
|
|
|
|
|
+ handler->individualFormatRequests() + "','"
|
|
|
|
|
+ watchers.toHex() + "')", CB(handleListLocals));
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::handleBacktrace(const DebuggerResponse &response)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
|
|
|
|
//qDebug() << " BACKTRACE: '" << response.data << "'";
|
|
|
|
|
// " /usr/lib/python2.6/bdb.py(368)run()"
|
|
|
|
|
// "-> exec cmd in globals, locals"
|
|
|
|
|
// " <string>(1)<module>()"
|
|
|
|
|
// " /python/math.py(19)<module>()"
|
|
|
|
|
// "-> main()"
|
|
|
|
|
// " /python/math.py(14)main()"
|
|
|
|
|
// "-> print cube(3)"
|
|
|
|
|
// " /python/math.py(7)cube()"
|
|
|
|
|
// "-> x = square(a)"
|
|
|
|
|
// "> /python/math.py(2)square()"
|
|
|
|
|
// "-> def square(a):"
|
|
|
|
|
|
|
|
|
|
// Populate stack view.
|
2010-06-15 11:14:44 +02:00
|
|
|
StackFrames stackFrames;
|
2010-04-23 12:12:22 +02:00
|
|
|
int level = 0;
|
|
|
|
|
int currentIndex = -1;
|
2015-02-13 11:53:37 +01:00
|
|
|
foreach (const QByteArray &line, response.logStreamOutput.split('\n')) {
|
2010-04-23 12:12:22 +02:00
|
|
|
//qDebug() << " LINE: '" << line << "'";
|
|
|
|
|
if (line.startsWith("> ") || line.startsWith(" ")) {
|
|
|
|
|
int pos1 = line.indexOf('(');
|
|
|
|
|
int pos2 = line.indexOf(')', pos1);
|
|
|
|
|
if (pos1 != -1 && pos2 != -1) {
|
|
|
|
|
int lineNumber = line.mid(pos1 + 1, pos2 - pos1 - 1).toInt();
|
|
|
|
|
QByteArray fileName = line.mid(2, pos1 - 2);
|
2010-07-23 16:05:56 +02:00
|
|
|
//qDebug() << " " << pos1 << pos2 << lineNumber << fileName
|
2010-04-23 12:12:22 +02:00
|
|
|
// << line.mid(pos1 + 1, pos2 - pos1 - 1);
|
|
|
|
|
StackFrame frame;
|
|
|
|
|
frame.file = _(fileName);
|
|
|
|
|
frame.line = lineNumber;
|
|
|
|
|
frame.function = _(line.mid(pos2 + 1));
|
2012-02-24 01:30:11 +01:00
|
|
|
frame.usable = QFileInfo(frame.file).isReadable();
|
2014-10-24 10:28:28 +02:00
|
|
|
if (frame.line > 0 && QFileInfo::exists(frame.file)) {
|
2010-04-23 12:12:22 +02:00
|
|
|
if (line.startsWith("> "))
|
|
|
|
|
currentIndex = level;
|
|
|
|
|
frame.level = level;
|
|
|
|
|
stackFrames.prepend(frame);
|
|
|
|
|
++level;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const int frameCount = stackFrames.size();
|
2010-07-23 16:05:56 +02:00
|
|
|
for (int i = 0; i != frameCount; ++i)
|
|
|
|
|
stackFrames[i].level = frameCount - stackFrames[i].level - 1;
|
2010-06-16 11:08:54 +02:00
|
|
|
stackHandler()->setFrames(stackFrames);
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
// Select current frame.
|
|
|
|
|
if (currentIndex != -1) {
|
|
|
|
|
currentIndex = frameCount - currentIndex - 1;
|
2010-06-16 11:08:54 +02:00
|
|
|
stackHandler()->setCurrentIndex(currentIndex);
|
2010-12-16 19:06:33 +01:00
|
|
|
gotoLocation(stackFrames.at(currentIndex));
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
2010-07-23 16:05:56 +02:00
|
|
|
|
|
|
|
|
updateLocals();
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-13 11:53:37 +01:00
|
|
|
void PdbEngine::handleListLocals(const DebuggerResponse &response)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
|
|
|
|
//qDebug() << " LOCALS: '" << response.data << "'";
|
2015-02-13 11:53:37 +01:00
|
|
|
QByteArray out = response.logStreamOutput.trimmed();
|
2010-04-23 12:12:22 +02:00
|
|
|
|
|
|
|
|
GdbMi all;
|
|
|
|
|
all.fromStringMultiple(out);
|
|
|
|
|
//qDebug() << "ALL: " << all.toString();
|
|
|
|
|
|
|
|
|
|
//GdbMi data = all.findChild("data");
|
2010-06-16 11:08:54 +02:00
|
|
|
WatchHandler *handler = watchHandler();
|
2015-01-29 12:24:40 +01:00
|
|
|
|
|
|
|
|
QSet<QByteArray> toDelete;
|
|
|
|
|
foreach (WatchItem *item, handler->model()->treeLevelItems<WatchItem *>(2))
|
|
|
|
|
toDelete.insert(item->d.iname);
|
|
|
|
|
|
2010-04-23 12:12:22 +02:00
|
|
|
foreach (const GdbMi &child, all.children()) {
|
2015-01-29 13:53:15 +01:00
|
|
|
WatchItem *item = new WatchItem(child);
|
2015-01-29 12:24:40 +01:00
|
|
|
handler->insertItem(item);
|
|
|
|
|
toDelete.remove(item->d.iname);
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
2015-01-29 12:24:40 +01:00
|
|
|
|
|
|
|
|
handler->purgeOutdatedItems(toDelete);
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-12 20:28:17 +01:00
|
|
|
bool PdbEngine::hasCapability(unsigned cap) const
|
2010-05-03 19:12:52 +02:00
|
|
|
{
|
2012-01-12 20:28:17 +01:00
|
|
|
return cap & (ReloadModuleCapability|BreakConditionCapability);
|
2010-05-03 19:12:52 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
DebuggerEngine *createPdbEngine(const DebuggerStartParameters &startParameters)
|
2010-04-23 12:12:22 +02:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
return new PdbEngine(startParameters);
|
2010-04-23 12:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|