| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
асть SASM. |
| 23 |
|
| 24 |
ерераспространять ее и/или |
| 25 |
ественной лицензии GNU в том виде, |
| 26 |
бодного программного обеспечения; |
| 27 |
у выбору) любой более поздней |
| 28 |
ии. |
| 29 |
|
| 30 |
что она будет полезной, |
| 31 |
явной гарантии ТОВАРНОГО ВИДА |
| 32 |
ЕЙ. Подробнее см. в Стандартной |
| 33 |
ицензии GNU. |
| 34 |
|
| 35 |
ртной общественной лицензии GNU |
| 36 |
Если это не так, см. |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#ifndef DEBUGGER_H |
| 42 |
#define DEBUGGER_H |
| 43 |
|
| 44 |
#include <QProcess> |
| 45 |
#include <QProcessEnvironment> |
| 46 |
#include <QString> |
| 47 |
#include <QTextStream> |
| 48 |
#include <QTextEdit> |
| 49 |
#include <QFile> |
| 50 |
#include <QVector> |
| 51 |
#include <QCoreApplication> |
| 52 |
#include <QTimer> |
| 53 |
#include <QQueue> |
| 54 |
#include <QSettings> |
| 55 |
#include <QFile> |
| 56 |
#include "assembler.h" |
| 57 |
|
| 58 |
#ifdef Q_OS_WIN32 |
| 59 |
#include <Windows.h> |
| 60 |
#include <stddef.h> |
| 61 |
#include <stdlib.h> |
| 62 |
#else |
| 63 |
#include <signal.h> |
| 64 |
#endif |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
enum DebugActionType {ni, si, showLine, infoRegisters, infoMemory, anyAction, none, breakpoint}; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
class Debugger : public QObject |
| 80 |
{ |
| 81 |
Q_OBJECT |
| 82 |
|
| 83 |
public: |
| 84 |
Debugger(QTextEdit *tEdit, |
| 85 |
const QString &exePathParam, |
| 86 |
const QString &workingDirectoryPathParam, |
| 87 |
const QString &inputPathParam, |
| 88 |
Assembler *assembler, |
| 89 |
QWidget *parent = 0); |
| 90 |
~Debugger(); |
| 91 |
void setWatchesCount(int count); |
| 92 |
|
| 93 |
struct registersInfo { |
| 94 |
QString name; |
| 95 |
QString hexValue; |
| 96 |
QString decValue; |
| 97 |
}; |
| 98 |
|
| 99 |
struct memoryInfo { |
| 100 |
QString value; |
| 101 |
bool isValid; |
| 102 |
}; |
| 103 |
|
| 104 |
typedef Assembler::LineNum LineNum; |
| 105 |
|
| 106 |
bool isStopped(); |
| 107 |
void pause(); |
| 108 |
|
| 109 |
private: |
| 110 |
void processLst(); |
| 111 |
void run(); |
| 112 |
|
| 113 |
QProcess *process; |
| 114 |
QTextEdit *textEdit; |
| 115 |
|
| 116 |
|
| 117 |
quint64 offset; |
| 118 |
|
| 119 |
|
| 120 |
QVector<LineNum> lines; |
| 121 |
|
| 122 |
int c; |
| 123 |
|
| 124 |
bool registersOk; |
| 125 |
|
| 126 |
|
| 127 |
bool gdbRun; |
| 128 |
|
| 129 |
|
| 130 |
QQueue<DebugActionType> actionTypeQueue; |
| 131 |
|
| 132 |
|
| 133 |
QQueue<QString> commandQueue; |
| 134 |
|
| 135 |
|
| 136 |
QString exitMessage; |
| 137 |
|
| 138 |
|
| 139 |
QRegExp cExitMessage; |
| 140 |
|
| 141 |
|
| 142 |
QString exePath; |
| 143 |
|
| 144 |
|
| 145 |
QString workingDirectoryPath; |
| 146 |
|
| 147 |
|
| 148 |
QString inputPath; |
| 149 |
|
| 150 |
|
| 151 |
QString buffer; |
| 152 |
|
| 153 |
|
| 154 |
QString allBuffer; |
| 155 |
|
| 156 |
|
| 157 |
QString errorBuffer; |
| 158 |
|
| 159 |
|
| 160 |
QString allErrorBuffer; |
| 161 |
|
| 162 |
|
| 163 |
QTimer *bufferTimer; |
| 164 |
|
| 165 |
|
| 166 |
QTimer *checkGdbRunTimer; |
| 167 |
|
| 168 |
|
| 169 |
int watchesCount; |
| 170 |
|
| 171 |
|
| 172 |
QList<Debugger::memoryInfo> watches; |
| 173 |
|
| 174 |
|
| 175 |
bool firstAction; |
| 176 |
|
| 177 |
|
| 178 |
QList<LineNum> breakPairs; |
| 179 |
|
| 180 |
Assembler *assembler; |
| 181 |
|
| 182 |
bool stopped; |
| 183 |
quint64 pid; |
| 184 |
bool dbgSymbols; |
| 185 |
|
| 186 |
quint64 entryPoint; |
| 187 |
|
| 188 |
public slots: |
| 189 |
void readOutputToBuffer(); |
| 190 |
void processOutput(); |
| 191 |
void processMessage(QString output, QString error); |
| 192 |
void processAction(QString output, QString error = QString()); |
| 193 |
void doInput(QString command, DebugActionType actionType); |
| 194 |
void changeBreakpoint(quint64 lineNumber, bool isAdded); |
| 195 |
void emitStarted(); |
| 196 |
void checkGdbRun(); |
| 197 |
|
| 198 |
signals: |
| 199 |
|
| 200 |
void highlightLine(int); |
| 201 |
void finished(); |
| 202 |
|
| 203 |
void started(); |
| 204 |
void printRegisters(QList<Debugger::registersInfo>); |
| 205 |
void printMemory(QList<Debugger::memoryInfo>); |
| 206 |
void printLog(QString msg, QColor color); |
| 207 |
void printOutput(QString msg); |
| 208 |
void inMacro(); |
| 209 |
void wasStopped(); |
| 210 |
void needToContinue(); |
| 211 |
}; |
| 212 |
|
| 213 |
#endif |