2008-12-02 12:01:29 +01:00
|
|
|
/***************************************************************************
|
|
|
|
**
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
**
|
2009-01-13 19:21:51 +01:00
|
|
|
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
|
|
|
** Non-Open Source Usage
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
** Licensees may use this file in accordance with the Qt Beta Version
|
|
|
|
** License Agreement, Agreement version 2.2 provided with the Software or,
|
|
|
|
** alternatively, in accordance with the terms contained in a written
|
2008-12-02 14:17:16 +01:00
|
|
|
** agreement between you and Nokia.
|
|
|
|
**
|
|
|
|
** GNU General Public License Usage
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
** Public License versions 2.0 or 3.0 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
|
|
|
** of this file. Please review the following information to ensure GNU
|
|
|
|
** General Public Licensing requirements will be met:
|
|
|
|
**
|
|
|
|
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
|
|
|
** http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
**
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2008-12-02 14:17:16 +01:00
|
|
|
** rights. These rights are described in the Nokia Qt GPL Exception
|
2008-12-16 17:20:00 +01:00
|
|
|
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
|
|
|
***************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef DEBUGGER_GDBENGINE_H
|
|
|
|
#define DEBUGGER_GDBENGINE_H
|
|
|
|
|
2008-12-09 12:27:55 +01:00
|
|
|
#include "idebuggerengine.h"
|
|
|
|
#include "gdbmi.h"
|
2009-01-15 14:47:14 +01:00
|
|
|
#include "outputcollector.h"
|
2008-12-09 12:27:55 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QByteArray>
|
|
|
|
#include <QtCore/QHash>
|
|
|
|
#include <QtCore/QMap>
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtCore/QProcess>
|
|
|
|
#include <QtCore/QPoint>
|
2009-01-15 14:47:14 +01:00
|
|
|
#include <QtCore/QTextCodec>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QVariant>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QAction;
|
|
|
|
class QAbstractItemModel;
|
|
|
|
class QWidget;
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
class DebuggerManager;
|
|
|
|
class IDebuggerManagerAccessForEngines;
|
|
|
|
class GdbResultRecord;
|
|
|
|
class GdbMi;
|
|
|
|
|
|
|
|
class WatchData;
|
|
|
|
class BreakpointData;
|
|
|
|
|
|
|
|
struct GdbCookie
|
|
|
|
{
|
|
|
|
GdbCookie() : type(0), synchronized(false) {}
|
|
|
|
|
|
|
|
QString command;
|
|
|
|
int type;
|
|
|
|
bool synchronized;
|
|
|
|
QVariant cookie;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DataDumperState
|
|
|
|
{
|
|
|
|
DataDumperUninitialized,
|
|
|
|
DataDumperLoadTried,
|
|
|
|
DataDumperAvailable,
|
|
|
|
DataDumperUnavailable,
|
|
|
|
};
|
|
|
|
|
2008-12-11 14:01:53 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class GdbEngine : public IDebuggerEngine
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
GdbEngine(DebuggerManager *parent);
|
|
|
|
~GdbEngine();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void gdbResponseAvailable();
|
|
|
|
void gdbInputAvailable(const QString &prefix, const QString &msg);
|
|
|
|
void gdbOutputAvailable(const QString &prefix, const QString &msg);
|
2009-01-15 14:30:49 +01:00
|
|
|
void applicationOutputAvailable(const QString &output);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
//
|
|
|
|
// IDebuggerEngine implementation
|
|
|
|
//
|
|
|
|
void stepExec();
|
|
|
|
void stepOutExec();
|
|
|
|
void nextExec();
|
|
|
|
void stepIExec();
|
|
|
|
void nextIExec();
|
|
|
|
|
|
|
|
void shutdown();
|
|
|
|
void setToolTipExpression(const QPoint &pos, const QString &exp);
|
|
|
|
bool startDebugger();
|
|
|
|
void exitDebugger();
|
|
|
|
|
|
|
|
void continueInferior();
|
|
|
|
void interruptInferior();
|
|
|
|
|
|
|
|
void runToLineExec(const QString &fileName, int lineNumber);
|
|
|
|
void runToFunctionExec(const QString &functionName);
|
|
|
|
void jumpToLineExec(const QString &fileName, int lineNumber);
|
|
|
|
|
|
|
|
void activateFrame(int index);
|
|
|
|
void selectThread(int index);
|
|
|
|
|
|
|
|
Q_SLOT void attemptBreakpointSynchronization();
|
|
|
|
|
|
|
|
void loadSessionData() {}
|
|
|
|
void saveSessionData() {}
|
|
|
|
|
|
|
|
void assignValueInDebugger(const QString &expr, const QString &value);
|
|
|
|
void executeDebuggerCommand(const QString & command);
|
|
|
|
|
|
|
|
void loadSymbols(const QString &moduleName);
|
|
|
|
void loadAllSymbols();
|
|
|
|
|
2009-01-27 15:53:50 +01:00
|
|
|
void setDebugDumpers(bool on);
|
|
|
|
void setUseCustomDumpers(bool on);
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
//
|
|
|
|
// Own stuff
|
|
|
|
//
|
|
|
|
int currentFrame() const;
|
|
|
|
QString currentWorkingDirectory() const { return m_pwd; }
|
|
|
|
|
|
|
|
bool supportsThreads() const;
|
|
|
|
|
2009-02-13 13:50:50 +01:00
|
|
|
void initializeConnections();
|
|
|
|
void initializeVariables();
|
2008-12-02 12:01:29 +01:00
|
|
|
void queryFullName(const QString &fileName, QString *fullName);
|
|
|
|
QString fullName(const QString &fileName);
|
|
|
|
QString shortName(const QString &fullName);
|
|
|
|
// get one usable name out of these, try full names first
|
|
|
|
QString fullName(const QStringList &candidates);
|
|
|
|
|
|
|
|
void handleResult(const GdbResultRecord &, int type, const QVariant &);
|
|
|
|
|
|
|
|
// type and cookie are sender-internal data, opaque for the "event
|
|
|
|
// queue". resultNeeded == true increments m_pendingResults on
|
|
|
|
// send and decrements on receipt, effectively preventing
|
|
|
|
// watch model updates before everything is finished.
|
2009-02-16 18:28:15 +01:00
|
|
|
enum StopNeeded { DoesNotNeedStop, NeedsStop };
|
|
|
|
enum Synchronization { NotSynchronized, Synchronized };
|
|
|
|
void sendCommand(const QString &command,
|
2008-12-02 12:01:29 +01:00
|
|
|
int type = 0, const QVariant &cookie = QVariant(),
|
2009-02-16 18:28:15 +01:00
|
|
|
StopNeeded needStop = DoesNotNeedStop,
|
|
|
|
Synchronization synchronized = NotSynchronized);
|
2008-12-02 12:01:29 +01:00
|
|
|
void sendSynchronizedCommand(const QString & command,
|
|
|
|
int type = 0, const QVariant &cookie = QVariant(),
|
2009-02-16 18:28:15 +01:00
|
|
|
StopNeeded needStop = DoesNotNeedStop);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
void setTokenBarrier();
|
|
|
|
|
|
|
|
void updateLocals();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleResponse();
|
|
|
|
|
|
|
|
void gdbProcError(QProcess::ProcessError error);
|
|
|
|
void readGdbStandardOutput();
|
|
|
|
void readGdbStandardError();
|
2009-01-15 14:47:14 +01:00
|
|
|
void readDebugeeOutput(const QByteArray &data);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
int terminationIndex(const QByteArray &buffer, int &length);
|
2009-02-12 13:31:19 +01:00
|
|
|
void handleStart(const GdbResultRecord &response);
|
2009-02-18 15:27:56 +01:00
|
|
|
void handleAttach();
|
|
|
|
void handleAqcuiredInferior();
|
2008-12-02 12:01:29 +01:00
|
|
|
void handleAsyncOutput2(const GdbMi &data);
|
|
|
|
void handleAsyncOutput(const GdbMi &data);
|
|
|
|
void handleResultRecord(const GdbResultRecord &response);
|
|
|
|
void handleFileExecAndSymbols(const GdbResultRecord &response);
|
|
|
|
void handleExecRun(const GdbResultRecord &response);
|
|
|
|
void handleExecJumpToLine(const GdbResultRecord &response);
|
|
|
|
void handleExecRunToFunction(const GdbResultRecord &response);
|
|
|
|
void handleInfoShared(const GdbResultRecord &response);
|
|
|
|
void handleInfoProc(const GdbResultRecord &response);
|
2009-02-13 17:11:34 +01:00
|
|
|
void handleInfoThreads(const GdbResultRecord &response);
|
2008-12-02 12:01:29 +01:00
|
|
|
void handleShowVersion(const GdbResultRecord &response);
|
|
|
|
void handleQueryPwd(const GdbResultRecord &response);
|
|
|
|
void handleQuerySources(const GdbResultRecord &response);
|
2009-02-16 13:29:57 +01:00
|
|
|
void debugMessage(const QString &msg);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-15 14:47:14 +01:00
|
|
|
OutputCollector m_outputCollector;
|
|
|
|
QTextCodec *m_outputCodec;
|
|
|
|
QTextCodec::ConverterState m_outputCodecState;
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QByteArray m_inbuffer;
|
|
|
|
|
|
|
|
QProcess m_gdbProc;
|
|
|
|
|
|
|
|
QHash<int, GdbCookie> m_cookieForToken;
|
|
|
|
QHash<int, QByteArray> m_customOutputForToken;
|
|
|
|
|
|
|
|
QByteArray m_pendingConsoleStreamOutput;
|
|
|
|
QByteArray m_pendingTargetStreamOutput;
|
|
|
|
QByteArray m_pendingLogStreamOutput;
|
|
|
|
QString m_pwd;
|
|
|
|
|
|
|
|
// contains the first token number for the current round
|
|
|
|
// of evaluation. Responses with older tokens are considers
|
|
|
|
// out of date and discarded.
|
|
|
|
int m_oldestAcceptableToken;
|
|
|
|
|
|
|
|
int m_gdbVersion; // 6.8.0 is 680
|
2009-02-23 16:06:23 +01:00
|
|
|
int m_gdbBuildVersion; // MAC only?
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
// awful hack to keep track of used files
|
2009-02-17 14:08:49 +01:00
|
|
|
QMap<QString, QString> m_shortToFullName;
|
|
|
|
QMap<QString, QString> m_fullToShortName;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Breakpoint specific stuff
|
|
|
|
//
|
|
|
|
void handleBreakList(const GdbResultRecord &record);
|
|
|
|
void handleBreakList(const GdbMi &table);
|
|
|
|
void handleBreakIgnore(const GdbResultRecord &record, int index);
|
|
|
|
void handleBreakInsert(const GdbResultRecord &record, int index);
|
|
|
|
void handleBreakInsert1(const GdbResultRecord &record, int index);
|
|
|
|
void handleBreakCondition(const GdbResultRecord &record, int index);
|
|
|
|
void handleBreakInfo(const GdbResultRecord &record, int index);
|
|
|
|
void extractDataFromInfoBreak(const QString &output, BreakpointData *data);
|
|
|
|
void breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt);
|
|
|
|
void sendInsertBreakpoint(int index);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Disassembler specific stuff
|
|
|
|
//
|
|
|
|
void handleDisassemblerList(const GdbResultRecord &record,
|
|
|
|
const QString &cookie);
|
|
|
|
void reloadDisassembler();
|
|
|
|
QString m_address;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Modules specific stuff
|
|
|
|
//
|
|
|
|
void reloadModules();
|
|
|
|
void handleModulesList(const GdbResultRecord &record);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Register specific stuff
|
|
|
|
//
|
|
|
|
void reloadRegisters();
|
|
|
|
void handleRegisterListNames(const GdbResultRecord &record);
|
|
|
|
void handleRegisterListValues(const GdbResultRecord &record);
|
|
|
|
|
2009-02-17 14:08:49 +01:00
|
|
|
//
|
|
|
|
// Source file specific stuff
|
|
|
|
//
|
|
|
|
void reloadSourceFiles();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Stack specific stuff
|
|
|
|
//
|
|
|
|
void handleStackListFrames(const GdbResultRecord &record);
|
|
|
|
void handleStackSelectThread(const GdbResultRecord &record, int cookie);
|
|
|
|
void handleStackListThreads(const GdbResultRecord &record, int cookie);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Tooltip specific stuff
|
|
|
|
//
|
|
|
|
void sendToolTipCommand(const QString &command, const QString &cookie);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Watch specific stuff
|
|
|
|
//
|
|
|
|
// FIXME: BaseClass. called to improve situation for a watch item
|
|
|
|
void updateSubItem(const WatchData &data);
|
|
|
|
|
|
|
|
void updateWatchModel();
|
|
|
|
Q_SLOT void updateWatchModel2();
|
|
|
|
|
|
|
|
void insertData(const WatchData &data);
|
|
|
|
void sendWatchParameters(const QByteArray ¶ms0);
|
|
|
|
void createGdbVariable(const WatchData &data);
|
|
|
|
|
|
|
|
void handleTypeContents(const QString &output);
|
|
|
|
void maybeHandleInferiorPidChanged(const QString &pid);
|
|
|
|
|
|
|
|
void tryLoadCustomDumpers();
|
|
|
|
void runCustomDumper(const WatchData &data, bool dumpChildren);
|
|
|
|
bool isCustomValueDumperAvailable(const QString &type) const;
|
|
|
|
|
|
|
|
void handleVarListChildren(const GdbResultRecord &record,
|
|
|
|
const WatchData &cookie);
|
|
|
|
void handleVarCreate(const GdbResultRecord &record,
|
|
|
|
const WatchData &cookie);
|
|
|
|
void handleVarAssign();
|
|
|
|
void handleEvaluateExpression(const GdbResultRecord &record,
|
|
|
|
const WatchData &cookie);
|
|
|
|
void handleToolTip(const GdbResultRecord &record,
|
|
|
|
const QString &cookie);
|
|
|
|
void handleDumpCustomValue1(const GdbResultRecord &record,
|
|
|
|
const WatchData &cookie);
|
|
|
|
void handleQueryDataDumper1(const GdbResultRecord &record);
|
|
|
|
void handleQueryDataDumper2(const GdbResultRecord &record);
|
|
|
|
void handleDumpCustomValue2(const GdbResultRecord &record,
|
|
|
|
const WatchData &cookie);
|
|
|
|
void handleDumpCustomEditValue(const GdbResultRecord &record);
|
|
|
|
void handleDumpCustomSetup(const GdbResultRecord &record);
|
|
|
|
void handleStackListLocals(const GdbResultRecord &record);
|
|
|
|
void handleStackListArguments(const GdbResultRecord &record);
|
|
|
|
void handleVarListChildrenHelper(const GdbMi &child,
|
|
|
|
const WatchData &parent);
|
|
|
|
void setWatchDataType(WatchData &data, const GdbMi &mi);
|
2008-12-03 16:51:56 +01:00
|
|
|
void setLocals(const QList<GdbMi> &locals);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
QString m_editedData;
|
|
|
|
int m_pendingRequests;
|
|
|
|
|
|
|
|
QStringList m_availableSimpleDumpers;
|
|
|
|
QString m_namespace; // namespace used in "namespaced Qt";
|
2009-01-07 15:03:49 +01:00
|
|
|
int m_qtVersion; // Qt version used in the debugged program
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
DataDumperState m_dataDumperState; // state of qt creator dumpers
|
|
|
|
QList<GdbMi> m_currentFunctionArgs;
|
|
|
|
QString m_currentFrame;
|
|
|
|
QMap<QString, QString> m_varToType;
|
|
|
|
|
2009-02-13 12:34:10 +01:00
|
|
|
bool m_waitingForBreakpointSynchronizationToContinue;
|
2009-02-13 16:55:24 +01:00
|
|
|
bool m_waitingForFirstBreakpointToBeHit;
|
2009-02-13 13:50:50 +01:00
|
|
|
bool m_modulesListOutdated;
|
2009-02-13 12:34:10 +01:00
|
|
|
|
2009-02-16 18:28:15 +01:00
|
|
|
QList<GdbCookie> m_commandsToRunOnTemporaryBreak;
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
DebuggerManager *q;
|
|
|
|
IDebuggerManagerAccessForEngines *qq;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
#endif // DEBUGGER_GDBENGINE_H
|