work save

This commit is contained in:
royqh1979@gmail.com 2021-08-01 23:24:37 +08:00
parent 3ff9a6dafe
commit 62527a04ae
22 changed files with 790 additions and 122 deletions

View File

@ -16,7 +16,8 @@ SOURCES += \
compiler/executablerunner.cpp \
compiler/filecompiler.cpp \
compiler/stdincompiler.cpp \
cpudialog.cpp \
settingsdialog/debuggeneralwidget.cpp \
widgets/cpudialog.cpp \
debugger.cpp \
editor.cpp \
editorlist.cpp \
@ -67,7 +68,8 @@ HEADERS += \
compiler/executablerunner.h \
compiler/filecompiler.h \
compiler/stdincompiler.h \
cpudialog.h \
settingsdialog/debuggeneralwidget.h \
widgets/cpudialog.h \
debugger.h \
editor.h \
editorlist.h \
@ -112,7 +114,8 @@ HEADERS += \
widgets/qpatchedcombobox.h
FORMS += \
cpudialog.ui \
settingsdialog/debuggeneralwidget.ui \
widgets/cpudialog.ui \
mainwindow.ui \
settingsdialog/compilersetdirectorieswidget.ui \
settingsdialog/compilersetoptionwidget.ui \

View File

@ -99,8 +99,8 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
} else {
mRunner = new ExecutableRunner(filename,arguments,workDir);
}
connect(mRunner, &ExecutableRunner::terminated, this ,&CompilerManager::onRunnerTerminated);
connect(mRunner, &ExecutableRunner::terminated, pMainWindow ,&MainWindow::onRunFinished);
connect(mRunner, &ExecutableRunner::finished, this ,&CompilerManager::onRunnerTerminated);
connect(mRunner, &ExecutableRunner::finished, pMainWindow ,&MainWindow::onRunFinished);
connect(mRunner, &ExecutableRunner::runErrorOccurred, pMainWindow ,&MainWindow::onRunErrorOccured);
mRunner->start();
}
@ -134,8 +134,9 @@ void CompilerManager::onCompileFinished()
void CompilerManager::onRunnerTerminated()
{
QMutexLocker locker(&mRunnerMutex);
delete mRunner;
ExecutableRunner* p=mRunner;
mRunner=nullptr;
p->deleteLater();
}
void CompilerManager::onCompileIssue(PCompileIssue)

View File

@ -49,8 +49,12 @@ void ExecutableRunner::run()
break;
}
if (mStop) {
process.closeReadChannel(QProcess::StandardOutput);
process.closeReadChannel(QProcess::StandardError);
process.closeWriteChannel();
process.terminate();
//break;
process.kill();
break;
}
if (errorOccurred)
break;

View File

@ -1,14 +0,0 @@
#include "cpudialog.h"
#include "ui_cpudialog.h"
CPUDialog::CPUDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CPUDialog)
{
ui->setupUi(this);
}
CPUDialog::~CPUDialog()
{
delete ui;
}

View File

@ -1,22 +0,0 @@
#ifndef CPUDIALOG_H
#define CPUDIALOG_H
#include <QDialog>
namespace Ui {
class CPUDialog;
}
class CPUDialog : public QDialog
{
Q_OBJECT
public:
explicit CPUDialog(QWidget *parent = nullptr);
~CPUDialog();
private:
Ui::CPUDialog *ui;
};
#endif // CPUDIALOG_H

View File

@ -3,7 +3,7 @@
#include "mainwindow.h"
#include "editor.h"
#include "settings.h"
#include "cpudialog.h"
#include "widgets/cpudialog.h"
#include <QFile>
#include <QFileInfo>
@ -16,6 +16,7 @@ Debugger::Debugger(QObject *parent) : QObject(parent)
mBreakpointModel=new BreakpointModel(this);
mBacktraceModel=new BacktraceModel(this);
mWatchModel = new WatchModel(this);
mRegisterModel = new RegisterModel(this);
mExecuting = false;
mUseUTF8 = false;
mReader = nullptr;
@ -74,8 +75,9 @@ void Debugger::clearUpReader()
// MainForm.LeftPageControl.ActivePageIndex := LeftPageIndexBackup;
// // Close CPU window
// if Assigned(CPUForm) then
// CPUForm.Close;
if (pMainWindow->cpuDialog()!=nullptr) {
pMainWindow->cpuDialog()->close();
}
// Free resources
pMainWindow->removeActiveBreakpoints();
@ -84,6 +86,8 @@ void Debugger::clearUpReader()
pMainWindow->updateAppTitle();
pMainWindow->updateDebugEval("");
mBacktraceModel->clear();
for(PWatchVar var:mWatchModel->watchVars()) {
@ -109,6 +113,11 @@ void Debugger::onClearLocals()
pMainWindow->txtLocals()->clear();
}
RegisterModel *Debugger::registerModel() const
{
return mRegisterModel;
}
WatchModel *Debugger::watchModel() const
{
return mWatchModel;
@ -391,7 +400,9 @@ void Debugger::syncFinishedParsing()
// An evaluation variable has been processed. Forward the results
if (mReader->doevalready) {
emit evalReady(mReader->mEvalValue);
pMainWindow->updateDebugEval(mReader->mEvalValue);
mReader->mEvalValue="";
mReader->doevalready = false;
}
// show command output
@ -427,12 +438,18 @@ void Debugger::syncFinishedParsing()
}
// Some part of the CPU form has been updated
if (pMainWindow->cpuDialog()->isVisible() && !mReader->doreceivedsignal) {
// if (mReader->doregistersready)
// CPUForm.OnRegistersReady;
if (pMainWindow->cpuDialog()!=nullptr && !mReader->doreceivedsignal) {
if (mReader->doregistersready) {
mRegisterModel->update(mReader->mRegisters);
mReader->mRegisters.clear();
mReader->doregistersready = false;
}
// if (mReader->dodisassemblerready)
// CPUForm.OnAssemblerReady;
if (mReader->dodisassemblerready) {
pMainWindow->cpuDialog()->setDisassembly(mReader->mDisassembly);
mReader->mDisassembly.clear();
mReader->dodisassemblerready = false;
}
}
if (mReader->doupdateexecution) {
@ -477,9 +494,8 @@ void Debugger::syncFinishedParsing()
// CPU form updates itself when spawned, don't update twice!
if ((mReader->doupdatecpuwindow && !spawnedcpuform) && (pMainWindow->cpuDialog()->isVisible())) {
sendCommand("disas", "");
sendCommand("info registers", "");
if ((mReader->doupdatecpuwindow && !spawnedcpuform) && (pMainWindow->cpuDialog()!=nullptr)) {
pMainWindow->cpuDialog()->updateInfo();
}
}
@ -573,12 +589,11 @@ AnnotationType DebugReader::getAnnotation(const QString &s)
} else if ((mCurrentCmd) && (mCurrentCmd->command == "info args")) {
//hack to catch params
result = AnnotationType::TParam;
} else if (t.startsWith("rax ") || t.startsWith("eax ")) {
} else if ((mCurrentCmd) && (mCurrentCmd->command == "info") && (mCurrentCmd->params=="registers")) {
// Hack fix to catch register dump
result = AnnotationType::TInfoReg;
} else {
// Another hack to catch assembler
if (t.startsWith("Dump of assembler code for function "))
} else if ((mCurrentCmd) && (mCurrentCmd->command == "disas")) {
// Another hack to catch assembler
result = AnnotationType::TInfoAsm;
}
return result;
@ -750,9 +765,6 @@ QString DebugReader::getRemainingLine()
void DebugReader::handleDisassembly()
{
if (mDisassembly.isEmpty())
return;
// Get info message
QString s = getNextLine();
@ -762,7 +774,7 @@ void DebugReader::handleDisassembly()
s = getNextLine();
// Add lines of disassembly
while (!s.isEmpty() && (s != "End of assembler dump")) {
while (!s.isEmpty() && (s != "End of assembler dump.")) {
mDisassembly.append(s);
s = getNextLine();
}
@ -941,7 +953,7 @@ void DebugReader::handleRegisters()
PRegister reg = std::make_shared<Register>();
// Cut name from 1 to first space
int x = s.indexOf(' ');
reg->name = s.mid(0,x-1);
reg->name = s.mid(0,x);
s.remove(0,x);
// Remove spaces
s = TrimLeft(s);
@ -950,14 +962,15 @@ void DebugReader::handleRegisters()
x = s.indexOf('\t');
if (x<0)
x = s.indexOf(' ');
reg->hexValue = s.mid(0,x - 1);
reg->hexValue = s.mid(0,x);
s.remove(0,x); // delete tab too
s = TrimLeft(s);
// Remaining part contains decimal value
reg->decValue = s;
mRegisters.append(reg);
if (!reg->name.trimmed().isEmpty())
mRegisters.append(reg);
s = getNextLine();
if (s.isEmpty())
break;
@ -1350,7 +1363,11 @@ void DebugReader::run()
break;
}
if (mStop) {
mProcess->closeReadChannel(QProcess::StandardOutput);
mProcess->closeReadChannel(QProcess::StandardError);
mProcess->closeWriteChannel();
mProcess->terminate();
mProcess->kill();
break;
}
if (errorOccurred)
@ -1722,3 +1739,75 @@ void WatchModel::notifyUpdated(PWatchVar var)
qDebug()<<"dataChanged"<<row<<":"<<var->text;
emit dataChanged(createIndex(row,0,var.get()),createIndex(row,0,var.get()));
}
RegisterModel::RegisterModel(QObject *parent):QAbstractTableModel(parent)
{
}
int RegisterModel::rowCount(const QModelIndex &parent) const
{
return mRegisters.count();
}
int RegisterModel::columnCount(const QModelIndex &parent) const
{
return 3;
}
QVariant RegisterModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row()<0 || index.row() >= static_cast<int>(mRegisters.size()))
return QVariant();
PRegister reg = mRegisters[index.row()];
if (!reg)
return QVariant();
switch (role) {
case Qt::DisplayRole:
switch (index.column()) {
case 0:
return reg->name;
case 1:
return reg->hexValue;
case 2:
return reg->decValue;
default:
return QVariant();
}
default:
return QVariant();
}
}
QVariant RegisterModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
switch(section) {
case 0:
return tr("Register");
case 1:
return tr("Value(Hex)");
case 2:
return tr("Value(Dec)");
}
}
return QVariant();
}
void RegisterModel::update(const QList<PRegister> &regs)
{
beginResetModel();
mRegisters.clear();
mRegisters.append(regs);
endResetModel();
}
void RegisterModel::clear()
{
beginResetModel();
mRegisters.clear();
endResetModel();
}

View File

@ -82,6 +82,20 @@ struct Register {
using PRegister = std::shared_ptr<Register>;
class RegisterModel: public QAbstractTableModel {
Q_OBJECT
public:
explicit RegisterModel(QObject* parent = nullptr);
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
void update(const QList<PRegister>& regs);
void clear();
private:
QList<PRegister> mRegisters;
};
class BreakpointModel: public QAbstractTableModel {
Q_OBJECT
// QAbstractItemModel interface
@ -199,10 +213,10 @@ public:
WatchModel *watchModel() const;
RegisterModel *registerModel() const;
public slots:
void stop();
signals:
void evalReady(QString value);
private:
void sendWatchCommand(PWatchVar var);
@ -221,11 +235,12 @@ private slots:
private:
bool mExecuting;
bool mCommandChanged;
BreakpointModel* mBreakpointModel;
BreakpointModel *mBreakpointModel;
bool mUseUTF8;
BacktraceModel* mBacktraceModel;
WatchModel* mWatchModel;
DebugReader* mReader;
BacktraceModel *mBacktraceModel;
WatchModel *mWatchModel;
RegisterModel *mRegisterModel;
DebugReader *mReader;
int mLeftPageIndexBackup;
};
@ -285,7 +300,7 @@ private:
void skipSpaces();
void skipToAnnotation();
private:
Debugger* mDebugger;
Debugger *mDebugger;
QString mDebuggerPath;
QRecursiveMutex mCmdQueueMutex;
QSemaphore mStartSemaphore;

View File

@ -6,6 +6,7 @@
#include <iconv.h>
#include <QDebug>
#include <QFileInfo>
#include "settings.h"
EditorList::EditorList(QTabWidget* leftPageWidget,
QTabWidget* rightPageWidget,
@ -86,7 +87,11 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) {
//todo: activate & focus the previous editor
}
delete editor;
if (pSettings->history().addToOpenedFiles(editor->filename())) {
pMainWindow->rebuildOpenedFileHisotryMenu();
}
editor->deleteLater();
return true;
}

View File

@ -70,6 +70,7 @@ int main(int argc, char *argv[])
settings->editor().load();
settings->executor().load();
settings->debugger().load();
settings->history().load();
//Translation must be loaded after language setting is loaded
QTranslator trans;

View File

@ -6,7 +6,7 @@
#include "settings.h"
#include "qsynedit/Constants.h"
#include "debugger.h"
#include "cpudialog.h"
#include "widgets/cpudialog.h"
#include <QCloseEvent>
@ -87,7 +87,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->actionEncode_in_ANSI->setCheckable(true);
ui->actionEncode_in_UTF_8->setCheckable(true);
mCPUDialog = new CPUDialog(this);
mCPUDialog = nullptr;
updateEditorActions();
applySettings();
@ -95,6 +95,7 @@ MainWindow::MainWindow(QWidget *parent)
openCloseMessageSheet(false);
mPreviousHeight = 250;
connect(ui->debugConsole,&QConsole::commandInput,this,&MainWindow::onDebugCommandInput);
}
MainWindow::~MainWindow()
@ -227,6 +228,7 @@ void MainWindow::applySettings()
QApplication * app = dynamic_cast<QApplication*>(QApplication::instance());
app->setFont(font);
this->setFont(font);
updateDebuggerSettings();
}
void MainWindow::removeActiveBreakpoints()
@ -322,6 +324,12 @@ void MainWindow::changeDebugOutputLastline(const QString &test)
ui->debugConsole->changeLastLine(test);
}
void MainWindow::updateDebugEval(const QString &value)
{
ui->txtEvalOutput->clear();
ui->txtEvalOutput->appendPlainText(value);
}
QPlainTextEdit *MainWindow::txtLocals()
{
return ui->txtLocals;
@ -403,6 +411,13 @@ void MainWindow::updateCompilerSet()
mCompilerSet->setCurrentIndex(index);
}
void MainWindow::updateDebuggerSettings()
{
ui->debugConsole->setFont(QFont(
pSettings->debugger().fontName(),
pSettings->debugger().fontSize()));
}
void MainWindow::checkSyntaxInBack(Editor *e)
{
if (e==nullptr)
@ -1059,6 +1074,20 @@ void MainWindow::onRunFinished()
updateAppTitle();
}
void MainWindow::cleanUpCPUDialog()
{
CPUDialog* ptr=mCPUDialog;
mCPUDialog=nullptr;
ptr->deleteLater();
}
void MainWindow::onDebugCommandInput(const QString &command)
{
if (mDebugger->executing()) {
mDebugger->sendCommand(command,"");
}
}
void MainWindow::on_actionCompile_triggered()
{
mCompileSuccessionTask.reset();
@ -1331,8 +1360,6 @@ void MainWindow::on_actionStep_Over_triggered()
mDebugger->invalidateAllVars();
mDebugger->sendCommand("next", "");
mDebugger->updateDebugInfo();
// if (CPUForm) then
// CPUForm.UpdateInfo;
mDebugger->refreshWatchVars();
}
}
@ -1344,8 +1371,6 @@ void MainWindow::on_actionStep_Into_triggered()
mDebugger->invalidateAllVars();
mDebugger->sendCommand("step", "");
mDebugger->updateDebugInfo();
// if (CPUForm) then
// CPUForm.UpdateInfo;
mDebugger->refreshWatchVars();
}
@ -1358,8 +1383,6 @@ void MainWindow::on_actionStep_Out_triggered()
mDebugger->invalidateAllVars();
mDebugger->sendCommand("finish", "");
mDebugger->updateDebugInfo();
// if (CPUForm) then
// CPUForm.UpdateInfo;
mDebugger->refreshWatchVars();
}
@ -1375,8 +1398,6 @@ void MainWindow::on_actionRun_To_Cursor_triggered()
mDebugger->sendCommand("tbreak", QString(" %1").arg(e->caretY()));
mDebugger->sendCommand("continue", "");
mDebugger->updateDebugInfo();
// if (CPUForm) then
// CPUForm.UpdateInfo;
mDebugger->refreshWatchVars();
}
}
@ -1390,8 +1411,6 @@ void MainWindow::on_actionContinue_triggered()
mDebugger->invalidateAllVars();
mDebugger->sendCommand("continue", "");
mDebugger->updateDebugInfo();
// if (CPUForm) then
// CPUForm.UpdateInfo;
mDebugger->refreshWatchVars();
}
}
@ -1420,3 +1439,20 @@ void MainWindow::on_actionAdd_Watch_triggered()
mDebugger->addWatchVar(s);
}
}
void MainWindow::on_actionView_CPU_Window_triggered()
{
if (mCPUDialog==nullptr) {
mCPUDialog = new CPUDialog(this);
connect(mCPUDialog, &CPUDialog::closed, this, &MainWindow::cleanUpCPUDialog);
}
mCPUDialog->show();
}
void MainWindow::on_txtEvaludate_returnPressed()
{
QString s=ui->txtEvaludate->text().trimmed();
if (!s.isEmpty()) {
mDebugger->sendCommand("print",s,false);
}
}

View File

@ -52,6 +52,7 @@ public:
void updateCompileActions();
void updateEditorColorSchemes();
void updateCompilerSet();
void updateDebuggerSettings();
void checkSyntaxInBack(Editor* e);
bool compile(bool rebuild=false);
void runExecutable(const QString& exeName, const QString& filename=QString());
@ -65,6 +66,7 @@ public:
void updateAppTitle();
void addDebugOutput(const QString& text);
void changeDebugOutputLastline(const QString& text);
void updateDebugEval(const QString& value);
QPlainTextEdit* txtLocals();
@ -159,6 +161,10 @@ private slots:
void on_actionAdd_Watch_triggered();
void on_actionView_CPU_Window_triggered();
void on_txtEvaludate_returnPressed();
public slots:
void onCompileLog(const QString& msg);
void onCompileIssue(PCompileIssue issue);
@ -166,6 +172,8 @@ public slots:
void onCompileErrorOccured(const QString& reason);
void onRunErrorOccured(const QString& reason);
void onRunFinished();
void cleanUpCPUDialog();
void onDebugCommandInput(const QString& command);
private:
void setupActions();

View File

@ -393,14 +393,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="cbEvaluate">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
<widget class="QLineEdit" name="txtEvaludate"/>
</item>
</layout>
</widget>
@ -415,8 +408,11 @@
</layout>
</widget>
<widget class="QTabWidget" name="debugViews">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>2</number>
</property>
<widget class="QWidget" name="tabDebugConsole">
<attribute name="title">
@ -465,7 +461,11 @@
<number>0</number>
</property>
<item>
<widget class="QTableView" name="tblStackTrace"/>
<widget class="QTableView" name="tblStackTrace">
<property name="textElideMode">
<enum>Qt::ElideNone</enum>
</property>
</widget>
</item>
</layout>
</widget>
@ -487,7 +487,11 @@
<number>0</number>
</property>
<item>
<widget class="QTableView" name="tblBreakpoints"/>
<widget class="QTableView" name="tblBreakpoints">
<property name="textElideMode">
<enum>Qt::ElideNone</enum>
</property>
</widget>
</item>
</layout>
</widget>
@ -584,7 +588,9 @@
<addaction name="actionRun_To_Cursor"/>
<addaction name="actionContinue"/>
<addaction name="actionStop_Execution"/>
<addaction name="separator"/>
<addaction name="actionAdd_Watch"/>
<addaction name="actionView_CPU_Window"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
@ -1067,6 +1073,11 @@
<string>Add Watch...</string>
</property>
</action>
<action name="actionView_CPU_Window">
<property name="text">
<string>View CPU Window...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -98,6 +98,11 @@ QString Settings::filename() const
return mFilename;
}
Settings::History& Settings::history()
{
return mHistory;
}
Settings::Debugger& Settings::debugger()
{
return mDebugger;
@ -187,6 +192,11 @@ int Settings::_Base::intValue(const QString &key, int defaultValue)
return value(key,defaultValue).toInt();
}
QStringList Settings::_Base::stringListValue(const QString &key, const QStringList &defaultValue)
{
return value(key,defaultValue).toStringList();
}
QColor Settings::_Base::colorValue(const QString &key, const QColor& defaultValue)
{
return value(key,defaultValue).value<QColor>();
@ -2275,14 +2285,93 @@ void Settings::Debugger::setShowAnnotations(bool showAnnotations)
mShowAnnotations = showAnnotations;
}
QString Settings::Debugger::fontName() const
{
return mFontName;
}
void Settings::Debugger::setFontName(const QString &fontName)
{
mFontName = fontName;
}
bool Settings::Debugger::useIntelStyle() const
{
return mUseIntelStyle;
}
void Settings::Debugger::setUseIntelStyle(bool useIntelStyle)
{
mUseIntelStyle = useIntelStyle;
}
int Settings::Debugger::fontSize() const
{
return mFontSize;
}
void Settings::Debugger::setFontSize(int fontSize)
{
mFontSize = fontSize;
}
bool Settings::Debugger::onlyShowMono() const
{
return mOnlyShowMono;
}
void Settings::Debugger::setOnlyShowMono(bool onlyShowMono)
{
mOnlyShowMono = onlyShowMono;
}
void Settings::Debugger::doSave()
{
saveValue("show_command_log", mShowCommandLog);
saveValue("show_annotations", mShowAnnotations);
saveValue("font_name",mFontName);
saveValue("only_show_mono",mOnlyShowMono);
saveValue("font_size",mFontSize);
boolValue("use_intel_style",mUseIntelStyle);
}
void Settings::Debugger::doLoad()
{
mShowCommandLog = boolValue("show_command_log",true);
mShowAnnotations = boolValue("show_annotations",true);
mShowAnnotations = boolValue("show_annotations",false);
mFontName = stringValue("font_name","Consolas");
mOnlyShowMono = boolValue("only_show_mono",true);
mFontSize = intValue("font_size",10);
mUseIntelStyle = boolValue("use_intel_style",true);
}
Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY)
{
}
bool Settings::History::addToOpenedFiles(const QString &filename)
{
if (!QFile(filename).exists())
return false;
if (openedFiles().indexOf(filename)>=0)
return false;
if (openedFiles().size()>=15) {
openedFiles().pop_front();
}
openedFiles().append(filename);
return true;
}
void Settings::History::doSave()
{
saveValue("opened_files", mOpenedFiles);
saveValue("opened_projects", mOpenedProjects);
}
void Settings::History::doLoad()
{
mOpenedFiles = stringListValue("opened_files");
mOpenedProjects =stringListValue("opened_projects");
}

View File

@ -17,6 +17,7 @@
#define SETTING_ENVIRONMENT "Environment"
#define SETTING_EXECUTOR "Executor"
#define SETTING_DEBUGGER "Debugger"
#define SETTING_HISTORY "HISTORY"
#define SETTING_COMPILTER_SETS "CompilerSets"
#define SETTING_COMPILTER_SETS_DEFAULT_INDEX "defaultIndex"
#define SETTING_COMPILTER_SETS_COUNT "count"
@ -57,6 +58,7 @@ private:
QVariant value(const QString &key, const QVariant& defaultValue);
bool boolValue(const QString &key, bool defaultValue);
int intValue(const QString &key, int defaultValue);
QStringList stringListValue(const QString &key, const QStringList& defaultValue=QStringList());
QColor colorValue(const QString &key, const QColor& defaultValue);
QString stringValue(const QString &key, const QString& defaultValue);
void save();
@ -369,6 +371,23 @@ public:
void doLoad() override;
};
class History: public _Base {
public:
explicit History(Settings *settings);
QStringList& openedFiles();
QStringList& openedProjects();
bool addToOpenedFiles(const QString& filename);
private:
QStringList mOpenedFiles;
QStringList mOpenedProjects;
// _Base interface
protected:
void doSave() override;
void doLoad() override;
};
class Executor: public _Base {
public:
explicit Executor(Settings * settings);
@ -398,9 +417,25 @@ public:
bool showAnnotations() const;
void setShowAnnotations(bool showAnnotations);
bool onlyShowMono() const;
void setOnlyShowMono(bool onlyShowMono);
int fontSize() const;
void setFontSize(int fontSize);
bool useIntelStyle() const;
void setUseIntelStyle(bool useIntelStyle);
QString fontName() const;
void setFontName(const QString &fontName);
private:
bool mShowCommandLog;
bool mShowAnnotations;
QString mFontName;
bool mOnlyShowMono;
int mFontSize;
bool mUseIntelStyle;
// _Base interface
protected:
@ -585,9 +620,9 @@ public:
Environment& environment();
Executor& executor();
Debugger& debugger();
History& history();
QString filename() const;
private:
QString mFilename;
QSettings mSettings;
@ -597,6 +632,7 @@ private:
CompilerSets mCompilerSets;
Executor mExecutor;
Debugger mDebugger;
History mHistory;
};

View File

@ -0,0 +1,52 @@
#include "debuggeneralwidget.h"
#include "ui_debuggeneralwidget.h"
#include "../settings.h"
#include "../mainwindow.h"
DebugGeneralWidget::DebugGeneralWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::DebugGeneralWidget)
{
ui->setupUi(this);
}
DebugGeneralWidget::~DebugGeneralWidget()
{
delete ui;
}
void DebugGeneralWidget::doLoad()
{
ui->chkOnlyMono->setChecked(pSettings->debugger().onlyShowMono());
ui->cbFont->setCurrentFont(QFont(pSettings->debugger().fontName()));
ui->sbFontSize->setValue(pSettings->debugger().fontSize());
ui->chkShowLog->setChecked(pSettings->debugger().showCommandLog());
ui->chkShowFullAnnotation->setChecked(pSettings->debugger().showAnnotations());
if (pSettings->debugger().useIntelStyle()) {
ui->rbIntel->setChecked(true);
} else {
ui->rbATT->setChecked(true);
}
}
void DebugGeneralWidget::doSave()
{
pSettings->debugger().setOnlyShowMono(ui->chkOnlyMono->isChecked());
pSettings->debugger().setFontName(ui->cbFont->currentFont().family());
pSettings->debugger().setFontSize(ui->sbFontSize->value());
pSettings->debugger().setShowCommandLog(ui->chkShowLog->isChecked());
pSettings->debugger().setShowAnnotations(ui->chkShowFullAnnotation->isChecked());
pSettings->debugger().setUseIntelStyle(ui->rbIntel->isChecked());
pSettings->debugger().save();
pMainWindow->updateDebuggerSettings();
}
void DebugGeneralWidget::on_chkOnlyMono_stateChanged(int)
{
if (ui->chkOnlyMono->isChecked()) {
ui->cbFont->setFontFilters(QFontComboBox::FontFilter::MonospacedFonts);
} else {
ui->cbFont->setFontFilters(QFontComboBox::FontFilter::AllFonts);
}
}

View File

@ -0,0 +1,30 @@
#ifndef DEBUGGENERALWIDGET_H
#define DEBUGGENERALWIDGET_H
#include <QWidget>
#include "settingswidget.h"
namespace Ui {
class DebugGeneralWidget;
}
class DebugGeneralWidget : public SettingsWidget
{
Q_OBJECT
public:
explicit DebugGeneralWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~DebugGeneralWidget();
private:
Ui::DebugGeneralWidget *ui;
// SettingsWidget interface
protected:
void doLoad() override;
void doSave() override;
private slots:
void on_chkOnlyMono_stateChanged(int arg1);
};
#endif // DEBUGGENERALWIDGET_H

View File

@ -0,0 +1,202 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DebugGeneralWidget</class>
<widget class="QWidget" name="DebugGeneralWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>677</width>
<height>563</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Debug Console</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>11</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<property name="rightMargin">
<number>11</number>
</property>
<property name="bottomMargin">
<number>11</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Font:</string>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="cbFont"/>
</item>
<item>
<widget class="QCheckBox" name="chkOnlyMono">
<property name="text">
<string>Show only monospaced fonts</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbFontSize"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowLog">
<property name="text">
<string>Show debug logs in the debug console</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowFullAnnotation">
<property name="text">
<string>Show full gdb annotations</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Disassembly Coding Style</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>11</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<property name="rightMargin">
<number>11</number>
</property>
<property name="bottomMargin">
<number>11</number>
</property>
<item>
<widget class="QRadioButton" name="rbIntel">
<property name="text">
<string>Intel</string>
</property>
<attribute name="buttonGroup">
<string notr="true">grpCPUDisassembly</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbATT">
<property name="text">
<string>AT&amp;&amp;T</string>
</property>
<attribute name="buttonGroup">
<string notr="true">grpCPUDisassembly</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="grpCPUDisassembly"/>
</buttongroups>
</ui>

View File

@ -10,6 +10,7 @@
#include "editorsymbolcompletionwidget.h"
#include "environmentappearencewidget.h"
#include "executorgeneralwidget.h"
#include "debuggeneralwidget.h"
#include <QDebug>
#include <QMessageBox>
#include <QModelIndex>
@ -63,6 +64,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
pExecutorGeneralWidget->init();
addWidget(pExecutorGeneralWidget);
pDebugGeneralWidget = new DebugGeneralWidget(tr("General"),tr("Debugger"));
pDebugGeneralWidget->init();
addWidget(pDebugGeneralWidget);
ui->widgetsView->expandAll();
//select the first widget of the first group
auto groupIndex = ui->widgetsView->model()->index(0,0);

View File

@ -19,6 +19,7 @@ class EditorColorSchemeWidget;
class EditorSyntaxCheckWidget;
class EnvironmentAppearenceWidget;
class ExecutorGeneralWidget;
class DebugGeneralWidget;
class SettingsWidget;
class SettingsDialog : public QDialog
{
@ -48,15 +49,16 @@ private:
QList<SettingsWidget*> mSettingWidgets;
QStandardItemModel model;
CompilerSetOptionWidget* pCompilerSetOptionWidget;
EditorGeneralWidget* pEditorGeneralWidget;
EditorFontWidget* pEditorFontWidget;
CompilerSetOptionWidget *pCompilerSetOptionWidget;
EditorGeneralWidget *pEditorGeneralWidget;
EditorFontWidget *pEditorFontWidget;
EditorClipboardWidget *pEditorClipboardWidget;
EditorColorSchemeWidget *pEditorColorSchemeWidget;
EnvironmentAppearenceWidget* pEnvironmentAppearenceWidget;
EditorSymbolCompletionWidget* pEditorSymbolCompletionWidget;
EditorSyntaxCheckWidget* pEditorSyntaxCheckWidget;
ExecutorGeneralWidget * pExecutorGeneralWidget;
EnvironmentAppearenceWidget *pEnvironmentAppearenceWidget;
EditorSymbolCompletionWidget *pEditorSymbolCompletionWidget;
EditorSyntaxCheckWidget *pEditorSyntaxCheckWidget;
ExecutorGeneralWidget *pExecutorGeneralWidget;
DebugGeneralWidget *pDebugGeneralWidget;
};
#endif // SETTINGSDIALOG_H

View File

@ -0,0 +1,83 @@
#include "cpudialog.h"
#include "ui_cpudialog.h"
#include "../HighlighterManager.h"
#include "../mainwindow.h"
#include "../debugger.h"
#include "../settings.h"
CPUDialog::CPUDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CPUDialog)
{
ui->setupUi(this);
ui->txtCode->setHighlighter(highlighterManager.getAsmHighlighter());
highlighterManager.applyColorScheme(ui->txtCode->highlighter(),
pSettings->editor().colorScheme());
ui->lstRegister->setModel(pMainWindow->debugger()->registerModel());
ui->rdIntel->setChecked(true);
// RadioATT.Checked := devData.UseATTSyntax;
// RadioIntel.Checked := not devData.UseATTSyntax;
// fRegisters := TList.Create;
// fAssembler := TStringList.Create;
updateInfo();
}
CPUDialog::~CPUDialog()
{
delete ui;
}
void CPUDialog::updateInfo()
{
if (pMainWindow->debugger()->executing()) {
// Load the registers..
sendSyntaxCommand();
pMainWindow->debugger()->sendCommand("info", "registers");
pMainWindow->debugger()->sendCommand("disas", "");
}
}
void CPUDialog::setDisassembly(const QStringList &lines)
{
if (lines.size()>0) {
ui->txtFunctionName->setText(lines[0]);
}
int activeLine = -1;
for (int i=1;i<lines.size();i++) {
QString line = lines[i];
if (line.startsWith("=>")) {
activeLine = i;
}
ui->txtCode->lines()->add(line);
}
if (activeLine!=-1)
ui->txtCode->setCaretXY(BufferCoord{1,activeLine});
}
void CPUDialog::sendSyntaxCommand()
{
// Set disassembly flavor
if (ui->rdIntel->isChecked()) {
pMainWindow->debugger()->sendCommand("set disassembly-flavor", "intel");
} else {
pMainWindow->debugger()->sendCommand("set disassembly-flavor", "att");
}
}
void CPUDialog::closeEvent(QCloseEvent *event)
{
QDialog::closeEvent(event);
emit closed();
}
void CPUDialog::on_rdIntel_toggled(bool)
{
sendSyntaxCommand();
}
void CPUDialog::on_rdATT_toggled(bool)
{
sendSyntaxCommand();
}

View File

@ -0,0 +1,33 @@
#ifndef CPUDIALOG_H
#define CPUDIALOG_H
#include <QDialog>
namespace Ui {
class CPUDialog;
}
class CPUDialog : public QDialog
{
Q_OBJECT
public:
explicit CPUDialog(QWidget *parent = nullptr);
~CPUDialog();
void updateInfo();
void setDisassembly(const QStringList& lines);
signals:
void closed();
private:
void sendSyntaxCommand();
private:
Ui::CPUDialog *ui;
// QWidget interface
protected:
void closeEvent(QCloseEvent *event) override;
private slots:
void on_rdIntel_toggled(bool checked);
void on_rdATT_toggled(bool checked);
};
#endif // CPUDIALOG_H

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>CPU Info</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
@ -28,12 +28,6 @@
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -86,7 +80,7 @@
</widget>
</item>
<item>
<widget class="QFrame" name="txtCode">
<widget class="SynEdit" name="txtCode">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -154,21 +148,26 @@
</item>
</layout>
</widget>
<widget class="QTableWidget" name="tableRegister">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QTableView" name="lstRegister">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="columnCount">
<number>0</number>
<property name="textElideMode">
<enum>Qt::ElideNone</enum>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SynEdit</class>
<extends>QFrame</extends>
<header location="global">qsynedit/Synedit.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
<buttongroups>