work save
This commit is contained in:
parent
8b2dd308e3
commit
bab5ad37f0
|
@ -2,6 +2,11 @@
|
|||
#include "utils.h"
|
||||
#include "mainwindow.h"
|
||||
#include "editor.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
|
||||
Debugger::Debugger(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
@ -9,6 +14,49 @@ Debugger::Debugger(QObject *parent) : QObject(parent)
|
|||
mBacktraceModel=new BacktraceModel(this);
|
||||
}
|
||||
|
||||
void Debugger::start()
|
||||
{
|
||||
mExecuting = true;
|
||||
|
||||
Settings::PCompilerSet compilerSet = pSettings->compilerSets().defaultSet();
|
||||
if (!compilerSet) {
|
||||
QMessageBox::critical(pMainWindow,
|
||||
tr("No compiler set"),
|
||||
tr("No compiler set is configured.")+tr("Can't start debugging."));
|
||||
return;
|
||||
}
|
||||
QString debuggerPath = compilerSet->debugger();
|
||||
QFile debuggerProgram(debuggerPath);
|
||||
if (!debuggerProgram.exists()) {
|
||||
QMessageBox::critical(pMainWindow,
|
||||
tr("Debugger not exists"),
|
||||
tr("Can''t find debugger in : \"%1\"").arg(debuggerPath));
|
||||
return;
|
||||
}
|
||||
mReader = std::make_shared<DebugReader>();
|
||||
mReader->setDebuggerPath(debuggerPath);
|
||||
mReader->start();
|
||||
|
||||
|
||||
//fProcessID := pi.hProcess;
|
||||
|
||||
//// Create a thread that will read GDB output.
|
||||
//Reader := TDebugReader.Create(true);
|
||||
//Reader.PipeRead := fOutputRead;
|
||||
//Reader.PipeWrite := fInputWrite;
|
||||
//Reader.FreeOnTerminate := true;
|
||||
//Reader.BreakpointList := BreakPointList;
|
||||
//Reader.WatchVarList := WatchVarList;
|
||||
//Reader.WatchView := WatchView;
|
||||
//Reader.UseUTF8 := UseUTF8;
|
||||
//Reader.Resume;
|
||||
//Reader.OnInvalidateAllVars := OnInvalidateAllVars;
|
||||
|
||||
//MainForm.UpdateAppTitle;
|
||||
|
||||
//Application.HintHidePause := 5000;
|
||||
}
|
||||
|
||||
void Debugger::sendCommand(const QString &command, const QString ¶ms, bool updateWatch, bool showInConsole, DebugCommandSource source)
|
||||
{
|
||||
if (mExecuting && mReader) {
|
||||
|
@ -88,12 +136,12 @@ void Debugger::setUseUTF8(bool useUTF8)
|
|||
mUseUTF8 = useUTF8;
|
||||
}
|
||||
|
||||
const BacktraceModel* Debugger::getBacktraceModel() const
|
||||
BacktraceModel* Debugger::backtraceModel()
|
||||
{
|
||||
return mBacktraceModel;
|
||||
}
|
||||
|
||||
const BreakpointModel *Debugger::getBreakpointModel() const
|
||||
BreakpointModel *Debugger::breakpointModel()
|
||||
{
|
||||
return mBreakpointModel;
|
||||
}
|
||||
|
@ -127,9 +175,9 @@ void Debugger::sendClearBreakpointCommand(int index)
|
|||
}
|
||||
}
|
||||
|
||||
DebugReader::DebugReader(QObject *parent) : QThread(parent)
|
||||
DebugReader::DebugReader(Debugger* debugger, QObject *parent) : QThread(parent)
|
||||
{
|
||||
|
||||
mDebugger = debugger;
|
||||
}
|
||||
|
||||
void DebugReader::postCommand(const QString &Command, const QString &Params, bool UpdateWatch, bool ShowInConsole, DebugCommandSource Source)
|
||||
|
@ -184,8 +232,7 @@ AnnotationType DebugReader::getAnnotation(const QString &s)
|
|||
|
||||
int IndexBackup = mIndex;
|
||||
QString t = getNextFilledLine();
|
||||
int mIndex = IndexBackup;
|
||||
|
||||
mIndex = IndexBackup;
|
||||
//hack to catch local
|
||||
if ((mCurrentCmd) && (mCurrentCmd->command == "info locals")) {
|
||||
result = AnnotationType::TLocal;
|
||||
|
@ -500,7 +547,7 @@ void DebugReader::handleFrames()
|
|||
trace->filename = "";
|
||||
trace->line = 0;
|
||||
}
|
||||
mBacktraceModel.addTrace(trace);
|
||||
mDebugger->backtraceModel()->addTrace(trace);
|
||||
|
||||
// Skip over the remaining frame part...
|
||||
if (!findAnnotation(AnnotationType::TFrameEnd))
|
||||
|
@ -858,10 +905,29 @@ void DebugReader::skipToAnnotation()
|
|||
mIndex++;
|
||||
}
|
||||
|
||||
QString DebugReader::debuggerPath() const
|
||||
{
|
||||
return mDebuggerPath;
|
||||
}
|
||||
|
||||
void DebugReader::setDebuggerPath(const QString &debuggerPath)
|
||||
{
|
||||
mDebuggerPath = debuggerPath;
|
||||
}
|
||||
|
||||
void DebugReader::stopDebug()
|
||||
{
|
||||
mStop = true;
|
||||
}
|
||||
|
||||
void DebugReader::run()
|
||||
{
|
||||
mStop = false;
|
||||
bool errorOccurred = false;
|
||||
QString cmd = mDebuggerPath;
|
||||
QString arguments = "--annotate=2 --silent";
|
||||
QString workingDir = QFileInfo(mDebuggerPath).path();
|
||||
|
||||
mProcess.setProgram(cmd);
|
||||
mProcess.setArguments(QProcess::splitCommand(arguments));
|
||||
mProcess.setWorkingDirectory(workingDir);
|
||||
|
@ -883,7 +949,7 @@ void DebugReader::run()
|
|||
mProcess.waitForStarted(5000);
|
||||
QByteArray buffer;
|
||||
while (true) {
|
||||
mProcess.waitForFinished(1000);
|
||||
mProcess.waitForFinished(100);
|
||||
if (mProcess.state()!=QProcess::Running) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -144,9 +144,8 @@ public:
|
|||
bool useUTF8() const;
|
||||
void setUseUTF8(bool useUTF8);
|
||||
|
||||
const BacktraceModel *getBacktraceModel() const;
|
||||
const BreakpointModel* getBreakpointModel() const;
|
||||
|
||||
BacktraceModel* backtraceModel();
|
||||
BreakpointModel* breakpointModel();
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -161,17 +160,19 @@ private:
|
|||
bool mUseUTF8;
|
||||
BacktraceModel* mBacktraceModel;
|
||||
PDebugReader mReader;
|
||||
|
||||
friend class DebugReader;
|
||||
};
|
||||
|
||||
class DebugReader : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DebugReader(QObject *parent = nullptr);
|
||||
explicit DebugReader(Debugger* debugger, QObject *parent = nullptr);
|
||||
void postCommand(const QString &Command, const QString &Params,
|
||||
bool UpdateWatch, bool ShowInConsole, DebugCommandSource Source);
|
||||
QString debuggerPath() const;
|
||||
void setDebuggerPath(const QString &debuggerPath);
|
||||
void stopDebug();
|
||||
|
||||
signals:
|
||||
void parseStarted();
|
||||
void invalidateAllVars();
|
||||
|
@ -210,6 +211,8 @@ private:
|
|||
void skipSpaces();
|
||||
void skipToAnnotation();
|
||||
private:
|
||||
Debugger* mDebugger;
|
||||
QString mDebuggerPath;
|
||||
QMutex mCmdQueueMutex;
|
||||
QQueue<PDebugCommand> mCmdQueue;
|
||||
int mUpdateCount;
|
||||
|
|
|
@ -59,6 +59,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
mCompilerManager = new CompilerManager(this);
|
||||
mDebugger = new Debugger(this);
|
||||
|
||||
ui->tblBreakpoints->setModel(mDebugger->breakpointModel());
|
||||
ui->tblStackTrace->setModel(mDebugger->backtraceModel());
|
||||
|
||||
ui->actionIndent->setShortcut(Qt::Key_Tab);
|
||||
ui->actionUnIndent->setShortcut(Qt::Key_Tab | Qt::ShiftModifier);
|
||||
|
||||
|
|
Loading…
Reference in New Issue