work save: debugger
This commit is contained in:
parent
84ba68f1b9
commit
a87ef64a1c
|
@ -17,6 +17,7 @@ SOURCES += \
|
|||
compiler/filecompiler.cpp \
|
||||
compiler/stdincompiler.cpp \
|
||||
cpudialog.cpp \
|
||||
debugger.cpp \
|
||||
editor.cpp \
|
||||
editorlist.cpp \
|
||||
iconsmanager.cpp \
|
||||
|
@ -67,6 +68,7 @@ HEADERS += \
|
|||
compiler/filecompiler.h \
|
||||
compiler/stdincompiler.h \
|
||||
cpudialog.h \
|
||||
debugger.h \
|
||||
editor.h \
|
||||
editorlist.h \
|
||||
iconsmanager.h \
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
#include "debugger.h"
|
||||
|
||||
Debugger::Debugger(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DebugReader::DebugReader(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DebugReader::clearCmdQueue()
|
||||
{
|
||||
QMutexLocker locker(&mMutex);
|
||||
mCmdQueue.clear();
|
||||
while (mUpdateCount>0) {
|
||||
//WatchView.Items.EndUpdate();
|
||||
mUpdateCount--;
|
||||
}
|
||||
}
|
||||
|
||||
bool DebugReader::findAnnotation(AnnotationType annotation)
|
||||
{
|
||||
AnnotationType NextAnnotation;
|
||||
do {
|
||||
NextAnnotation = getNextAnnotation();
|
||||
if (NextAnnotation == AnnotationType::TEOF)
|
||||
return false;
|
||||
} while (NextAnnotation != annotation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AnnotationType DebugReader::getAnnotation(const QString &s)
|
||||
{
|
||||
if (s == "pre-prompt") {
|
||||
return AnnotationType::TPrePrompt;
|
||||
} else if (s == "prompt") {
|
||||
return AnnotationType::TPrompt;
|
||||
} else if (s == "post-prompt") {
|
||||
AnnotationType result = AnnotationType::TPostPrompt;
|
||||
|
||||
int IndexBackup = mIndex;
|
||||
QString t = GetNextFilledLine();
|
||||
int mIndex = IndexBackup;
|
||||
|
||||
//hack to catch local
|
||||
if ((mCurrentCmd) && (mCurrentCmd->command == "info locals")) {
|
||||
result = AnnotationType::TLocal;
|
||||
} else if ((mCurrentCmd) && (mCurrentCmd->command == "info args")) {
|
||||
//hack to catch params
|
||||
result = AnnotationType::TParam;
|
||||
} else if (t.startsWith("rax ") || t.startsWith("eax ")) {
|
||||
// Hack fix to catch register dump
|
||||
result = AnnotationType::TInfoReg;
|
||||
} else {
|
||||
// Another hack to catch assembler
|
||||
if (t.startsWith("Dump of assembler code for function "))
|
||||
result = AnnotationType::TInfoAsm;
|
||||
}
|
||||
return result;
|
||||
} else if (s == "error-begin") {
|
||||
return AnnotationType::TErrorBegin;
|
||||
} else if (s == "error-end") {
|
||||
return AnnotationType::TErrorEnd;
|
||||
} else if (s == "display-begin") {
|
||||
return AnnotationType::TDisplayBegin;
|
||||
} else if (s == "display-expression") {
|
||||
return AnnotationType::TDisplayExpression;
|
||||
} else if (s == "display-end") {
|
||||
return AnnotationType::TDisplayEnd;
|
||||
} else if (s == "frame-source-begin") {
|
||||
return AnnotationType::TFrameSourceBegin;
|
||||
} else if (s == "frame-source-file") {
|
||||
return AnnotationType::TFrameSourceFile;
|
||||
} else if (s == "frame-source-line") {
|
||||
return AnnotationType::TFrameSourceLine;
|
||||
} else if (s == "frame-function-name") {
|
||||
return AnnotationType::TFrameFunctionName;
|
||||
} else if (s == "frame-args") {
|
||||
return AnnotationType::TFrameArgs;
|
||||
} else if (s == "frame-begin") {
|
||||
return AnnotationType::TFrameBegin;
|
||||
} else if (s == "frame-end") {
|
||||
return AnnotationType::TFrameEnd;
|
||||
} else if (s == "frame-where") {
|
||||
return AnnotationType::TFrameWhere;
|
||||
} else if (s == "source") {
|
||||
return AnnotationType::TSource;
|
||||
} else if (s == "exited") {
|
||||
return AnnotationType::TExit;
|
||||
} else if (s == "arg-begin") {
|
||||
return AnnotationType::TArgBegin;
|
||||
} else if (s == "arg-name-end") {
|
||||
return AnnotationType::TArgNameEnd;
|
||||
} else if (s == "arg-value") {
|
||||
return AnnotationType::TArgValue;
|
||||
} else if (s == "arg-end") {
|
||||
return AnnotationType::TArgEnd;
|
||||
} else if (s == "array-section-begin") {
|
||||
return AnnotationType::TArrayBegin;
|
||||
} else if (s == "array-section-end") {
|
||||
return AnnotationType::TArrayEnd;
|
||||
} else if (s == "elt") {
|
||||
return AnnotationType::TElt;
|
||||
} else if (s == "elt-rep") {
|
||||
return AnnotationType::TEltRep;
|
||||
} else if (s == "elt-rep-end") {
|
||||
return AnnotationType::TEltRepEnd;
|
||||
} else if (s == "field-begin") {
|
||||
return AnnotationType::TFieldBegin;
|
||||
} else if (s == "field-name-end") {
|
||||
return AnnotationType::TFieldNameEnd;
|
||||
} else if (s == "field-value") {
|
||||
return AnnotationType::TFieldValue;
|
||||
} else if (s == "field-end") {
|
||||
return AnnotationType::TFieldEnd;
|
||||
} else if (s == "value-history-value") {
|
||||
return AnnotationType::TValueHistoryValue;
|
||||
} else if (s == "value-history-begin") {
|
||||
return AnnotationType::TValueHistoryBegin;
|
||||
} else if (s == "value-history-end") {
|
||||
return AnnotationType::TValueHistoryEnd;
|
||||
} else if (s == "signal") {
|
||||
return AnnotationType::TSignal;
|
||||
} else if (s == "signal-name") {
|
||||
return AnnotationType::TSignalName;
|
||||
} else if (s == "signal-name-end") {
|
||||
return AnnotationType::TSignalNameEnd;
|
||||
} else if (s == "signal-string") {
|
||||
return AnnotationType::TSignalString;
|
||||
} else if (s == "signal-string-end") {
|
||||
return AnnotationType::TSignalStringEnd;
|
||||
} else if (mOutput[mIndex] == 0) {
|
||||
return AnnotationType::TEOF;
|
||||
} else {
|
||||
return AnnotationType::TUnknown;;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
#ifndef DEBUGGER_H
|
||||
#define DEBUGGER_H
|
||||
|
||||
#include <QList>
|
||||
#include <QList>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QQueue>
|
||||
#include <QQueue>
|
||||
#include <memory>
|
||||
enum class DebugCommandSource {
|
||||
Console,
|
||||
Other
|
||||
};
|
||||
|
||||
enum class AnnotationType {
|
||||
TPrePrompt, TPrompt, TPostPrompt,
|
||||
TSource,
|
||||
TDisplayBegin, TDisplayEnd,
|
||||
TDisplayExpression,
|
||||
TFrameSourceFile, TFrameSourceBegin, TFrameSourceLine, TFrameFunctionName, TFrameWhere,
|
||||
TFrameArgs,
|
||||
TFrameBegin, TFrameEnd,
|
||||
TErrorBegin, TErrorEnd,
|
||||
TArrayBegin, TArrayEnd,
|
||||
TElt, TEltRep, TEltRepEnd,
|
||||
TExit,
|
||||
TSignal, TSignalName, TSignalNameEnd, TSignalString, TSignalStringEnd,
|
||||
TValueHistoryValue, TValueHistoryBegin, TValueHistoryEnd,
|
||||
TArgBegin, TArgEnd, TArgValue, TArgNameEnd,
|
||||
TFieldBegin, TFieldEnd, TFieldValue, TFieldNameEnd,
|
||||
TInfoReg, TInfoAsm,
|
||||
TUnknown, TEOF,
|
||||
TLocal, TParam
|
||||
};
|
||||
|
||||
struct DebugCommand{
|
||||
QString command;
|
||||
QString params;
|
||||
bool updateWatch;
|
||||
bool showInConsole;
|
||||
DebugCommandSource source;
|
||||
};
|
||||
|
||||
using PDebugCommand = std::shared_ptr<DebugCommand>;
|
||||
|
||||
struct Breakpoint {
|
||||
int line;
|
||||
QString filename;
|
||||
QString condition;
|
||||
};
|
||||
|
||||
using PBreakpoint = std::shared_ptr<Breakpoint>;
|
||||
|
||||
struct Trace {
|
||||
QString funcname;
|
||||
QString filename;
|
||||
int line;
|
||||
};
|
||||
|
||||
using PTrace = std::shared_ptr<Trace>;
|
||||
|
||||
struct Register {
|
||||
QString name;
|
||||
int value;
|
||||
};
|
||||
|
||||
using PRegister = std::shared_ptr<Register>;
|
||||
|
||||
class DebugReader;
|
||||
|
||||
class Debugger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Debugger(QObject *parent = nullptr);
|
||||
|
||||
signals:
|
||||
private:
|
||||
bool mExecuting;
|
||||
bool mCommandChanged;
|
||||
QList<PBreakpoint> mBreakpointList;
|
||||
bool mUseUTF8;
|
||||
QString getBreakpointFile();
|
||||
};
|
||||
|
||||
class DebugReader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DebugReader(QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
void clearCmdQueue();
|
||||
bool findAnnotation(AnnotationType annotation);
|
||||
AnnotationType getAnnotation(const QString& s);
|
||||
AnnotationType getLastAnnotation(const QString& text,int curpos, int len;
|
||||
AnnotationType getNextAnnotation();
|
||||
private:
|
||||
QMutex mMutex;
|
||||
QQueue<PDebugCommand> mCmdQueue;
|
||||
int mUpdateCount;
|
||||
bool mInvalidateAllVars;
|
||||
|
||||
//fOnInvalidateAllVars: TInvalidateAllVarsEvent;
|
||||
bool mCmdRunning;
|
||||
PDebugCommand mCurrentCmd;
|
||||
QList<PRegister> mRegisters;
|
||||
QStringList mDisassembly;
|
||||
QList<PTrace> mBacktrace;
|
||||
QList<PBreakpoint> mBreakpoints;
|
||||
//fWatchVarList: TList; // contains all parents
|
||||
//fWatchView: TTreeView;
|
||||
int mIndex;
|
||||
int mBreakPointLine;
|
||||
QString mBreakPointFile;
|
||||
QString mOutput;
|
||||
QString mEvalValue;
|
||||
QString mSignal;
|
||||
bool mUseUTF8;
|
||||
|
||||
// attempt to cut down on Synchronize calls
|
||||
bool dobacktraceready;
|
||||
bool dodisassemblerready;
|
||||
bool doregistersready;
|
||||
bool dorescanwatches;
|
||||
bool doevalready;
|
||||
bool doprocessexited;
|
||||
bool doupdatecpuwindow;
|
||||
bool doupdateexecution;
|
||||
bool doreceivedsignal;
|
||||
bool doreceivedsfwarning;
|
||||
};
|
||||
|
||||
#endif // DEBUGGER_H
|
Loading…
Reference in New Issue