work save

This commit is contained in:
royqh1979@gmail.com 2021-07-27 00:14:24 +08:00
parent 9c111be41f
commit b04972ddb4
4 changed files with 40 additions and 22 deletions

View File

@ -14,6 +14,11 @@ Debugger::Debugger(QObject *parent) : QObject(parent)
{
mBreakpointModel=new BreakpointModel(this);
mBacktraceModel=new BacktraceModel(this);
mExecuting = false;
mUseUTF8 = false;
mReader = nullptr;
mCommandChanged = false;
mLeftPageIndexBackup = -1;
}
void Debugger::start()
@ -39,7 +44,7 @@ void Debugger::start()
connect(mReader, &QThread::finished,this,&Debugger::stop);
connect(mReader, &DebugReader::parseFinished,this,&Debugger::syncFinishedParsing,Qt::BlockingQueuedConnection);
mReader->start();
mReader->mStartSemaphore.acquire(1);
//fProcessID := pi.hProcess;
@ -428,9 +433,12 @@ bool Debugger::executing() const
return mExecuting;
}
DebugReader::DebugReader(Debugger* debugger, QObject *parent) : QThread(parent)
DebugReader::DebugReader(Debugger* debugger, QObject *parent) : QThread(parent),
mStartSemaphore(0)
{
mDebugger = debugger;
mProcess = nullptr;
mUseUTF8 = false;
}
void DebugReader::postCommand(const QString &Command, const QString &Params, bool UpdateWatch, bool ShowInConsole, DebugCommandSource Source)
@ -1118,7 +1126,7 @@ void DebugReader::runNextCmd()
s+=' '+pCmd->params.toLocal8Bit();
}
s+= "\n";
if (mProcess.write(s)<0) {
if (mProcess->write(s)<0) {
emit writeToDebugFailed();
}
@ -1182,11 +1190,12 @@ void DebugReader::run()
QString arguments = "--annotate=2 --silent";
QString workingDir = QFileInfo(mDebuggerPath).path();
mProcess.setProgram(cmd);
mProcess.setArguments(QProcess::splitCommand(arguments));
mProcess.setWorkingDirectory(workingDir);
mProcess = new QProcess();
mProcess->setProgram(cmd);
mProcess->setArguments(QProcess::splitCommand(arguments));
mProcess->setWorkingDirectory(workingDir);
mProcess.connect(&mProcess, &QProcess::errorOccurred,
connect(mProcess, &QProcess::errorOccurred,
[&](){
errorOccurred= true;
});
@ -1199,20 +1208,21 @@ void DebugReader::run()
// process.connect(&mProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),[&process,this](){
// this->error(COMPILE_PROCESS_END);
// });
mProcess.start();
mProcess.waitForStarted(5000);
mProcess->start();
mProcess->waitForStarted(5000);
mStartSemaphore.release(1);
QByteArray buffer;
while (true) {
mProcess.waitForFinished(100);
if (mProcess.state()!=QProcess::Running) {
mProcess->waitForFinished(100);
if (mProcess->state()!=QProcess::Running) {
break;
}
if (mStop) {
mProcess.terminate();
mProcess->terminate();
}
if (errorOccurred)
break;
buffer += mProcess.readAll();
buffer += mProcess->readAll();
if (getLastAnnotation(buffer) == AnnotationType::TPrompt) {
mOutput = buffer;
processDebugOutput();
@ -1221,7 +1231,7 @@ void DebugReader::run()
}
}
if (errorOccurred) {
emit processError(mProcess.error());
emit processError(mProcess->error());
}
}

View File

@ -10,6 +10,7 @@
#include <QProcess>
#include <QQueue>
#include <QQueue>
#include <QSemaphore>
#include <QThread>
#include <memory>
enum class DebugCommandSource {
@ -240,7 +241,8 @@ private:
private:
Debugger* mDebugger;
QString mDebuggerPath;
QMutex mCmdQueueMutex;
QRecursiveMutex mCmdQueueMutex;
QSemaphore mStartSemaphore;
QQueue<PDebugCommand> mCmdQueue;
int mUpdateCount;
bool mInvalidateAllVars;
@ -251,8 +253,7 @@ private:
QList<PRegister> mRegisters;
QStringList mDisassembly;
QProcess mProcess;
QProcess* mProcess;
QMap<QString,PWatchVar> mWatchVarList; // contains all parents
//fWatchView: TTreeView;

View File

@ -445,12 +445,18 @@ void Editor::onGetEditingAreas(int Line, SynEditingAreaList &areaList)
bool Editor::onGetSpecialLineColors(int Line, QColor &foreground, QColor &backgroundColor)
{
if (Line == mActiveBreakpointLine) {
if (Line == mActiveBreakpointLine &&
mActiveBreakpointForegroundColor.isValid()
&& mActiveBreakpointBackgroundColor.isValid()) {
foreground = mActiveBreakpointForegroundColor;
backgroundColor = mActiveBreakpointBackgroundColor;
} else if (hasBreakpoint(Line)) {
return true;
} else if (hasBreakpoint(Line) &&
mBreakpointForegroundColor.isValid()
&& mBreakpointBackgroundColor.isValid()) {
foreground = mBreakpointForegroundColor;
backgroundColor = mBreakpointBackgroundColor;
return true;
}
// end else if Line = fErrorLine then begin
// StrToThemeColor(tc, devEditor.Syntax.Values[cErr]);
@ -459,6 +465,7 @@ bool Editor::onGetSpecialLineColors(int Line, QColor &foreground, QColor &backgr
// if (BG <> clNone) or (FG<>clNone) then
// Special := TRUE;
// end;
return false;
}
void Editor::copyToClipboard()
@ -1333,7 +1340,7 @@ void Editor::applyColorScheme(const QString& schemeName)
item = pColorManager->getItem(schemeName,COLOR_SCHEME_BREAKPOINT);
if (item) {
this->mBreakpointForegroundColor = item->foreground();
this->mBreakpointBackgroundColor = item->foreground();
this->mBreakpointBackgroundColor = item->background();
}
this->invalidate();
}

View File

@ -596,12 +596,12 @@ void MainWindow::debug()
case CompileTarget::File:
// Check if we enabled proper options
debugEnabled = compilerSet->getOptionValue("-g3")!='0';
stripEnabled = compilerSet->getOptionValue("-s")!=0;
stripEnabled = compilerSet->getOptionValue("-s")!='0';
// Ask the user if he wants to enable debugging...
if (((!debugEnabled) || stripEnabled) &&
(QMessageBox::question(this,
tr("Enable debugging"),
tr("You have not enabled debugging info (-g) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now?")
tr("You have not enabled debugging info (-g3) and/or stripped it from the executable (-s) in Compiler Options.<BR /><BR />Do you want to correct this now?")
) == QMessageBox::Yes)) {
// Enable debugging, disable stripping
compilerSet->setOption("-g3",'1');