- enhancement: view memory when debugging

This commit is contained in:
royqh1979 2021-09-29 22:55:53 +08:00
parent fbdba624be
commit 9b87d93b72
9 changed files with 464 additions and 357 deletions

View File

@ -10,9 +10,11 @@ Version 0.2.2
- enhancement: redesign charset selection in the project options dialog's file widget - enhancement: redesign charset selection in the project options dialog's file widget
- fix: can't correctly load last open files / project with non-asii characters in path - fix: can't correctly load last open files / project with non-asii characters in path
- fix: can't coorectly load last open project - fix: can't coorectly load last open project
- fix: can't coorectly show code completion for array elements
- enhancement: show caret when show code/header completions - enhancement: show caret when show code/header completions
- fix: correctly display pointer info in watch console - fix: correctly display pointer info in watch console
- enhancement: search in project - enhancement: search in project
- enhancement: view memory when debugging
Version 0.2.1 Version 0.2.1
- fix: crash when load last opens - fix: crash when load last opens

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -48,8 +48,7 @@ bool Debugger::start()
connect(mReader, &QThread::finished,this,&Debugger::clearUpReader); connect(mReader, &QThread::finished,this,&Debugger::clearUpReader);
connect(mReader, &DebugReader::parseFinished,this,&Debugger::syncFinishedParsing,Qt::BlockingQueuedConnection); connect(mReader, &DebugReader::parseFinished,this,&Debugger::syncFinishedParsing,Qt::BlockingQueuedConnection);
connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline); connect(mReader, &DebugReader::changeDebugConsoleLastLine,this,&Debugger::onChangeDebugConsoleLastline);
connect(mReader, &DebugReader::addLocalLine,this,&Debugger::onAddLocalLine); connect(this, &Debugger::localsReady,pMainWindow,&MainWindow::onLocalsReady);
connect(mReader, &DebugReader::clearLocals,this,&Debugger::onClearLocals);
connect(mReader, &DebugReader::cmdStarted,pMainWindow, &MainWindow::disableDebugActions); connect(mReader, &DebugReader::cmdStarted,pMainWindow, &MainWindow::disableDebugActions);
connect(mReader, &DebugReader::cmdFinished,pMainWindow, &MainWindow::enableDebugActions); connect(mReader, &DebugReader::cmdFinished,pMainWindow, &MainWindow::enableDebugActions);
@ -102,16 +101,6 @@ void Debugger::clearUpReader()
} }
} }
void Debugger::onAddLocalLine(const QString &text)
{
pMainWindow->txtLocals()->appendPlainText(text);
}
void Debugger::onClearLocals()
{
pMainWindow->txtLocals()->clear();
}
RegisterModel *Debugger::registerModel() const RegisterModel *Debugger::registerModel() const
{ {
return mRegisterModel; return mRegisterModel;
@ -458,6 +447,18 @@ void Debugger::syncFinishedParsing()
mReader->doevalready = false; mReader->doevalready = false;
} }
if (mReader->doupdatememoryview) {
emit memoryExamineReady(mReader->mMemoryValue);
mReader->mMemoryValue.clear();
mReader->doupdatememoryview=false;
}
if (mReader->doupdatelocal) {
emit localsReady(mReader->mLocalsValue);
mReader->mLocalsValue.clear();
mReader->doupdatelocal=false;
}
// show command output // show command output
if (pSettings->debugger().showCommandLog() || if (pSettings->debugger().showCommandLog() ||
(mReader->mCurrentCmd && mReader->mCurrentCmd->showInConsole)) { (mReader->mCurrentCmd && mReader->mCurrentCmd->showInConsole)) {
@ -648,6 +649,8 @@ AnnotationType DebugReader::getAnnotation(const QString &s)
} else if ((mCurrentCmd) && (mCurrentCmd->command == "disas")) { } else if ((mCurrentCmd) && (mCurrentCmd->command == "disas")) {
// Another hack to catch assembler // Another hack to catch assembler
result = AnnotationType::TInfoAsm; result = AnnotationType::TInfoAsm;
} else if ((mCurrentCmd) && (mCurrentCmd->command.startsWith("x/"))) {
result = AnnotationType::TMemory;
} }
return result; return result;
} else if (s == "error-begin") { } else if (s == "error-begin") {
@ -980,7 +983,7 @@ void DebugReader::handleLocalOutput()
line += s; line += s;
// emit addLocalWithoutLinebreak(s); // emit addLocalWithoutLinebreak(s);
} else { } else {
emit addLocalLine(line); mLocalsValue.append(line);
line = s; line = s;
} }
nobreakLine=false; nobreakLine=false;
@ -992,18 +995,42 @@ void DebugReader::handleLocalOutput()
break; break;
} }
if (!line.isEmpty()) { if (!line.isEmpty()) {
emit addLocalLine(line); mLocalsValue.append(line);
} }
} }
void DebugReader::handleLocals() void DebugReader::handleLocals()
{ {
emit clearLocals(); mLocalsValue.clear();
handleLocalOutput(); handleLocalOutput();
} }
void DebugReader::handleMemory()
{
doupdatememoryview = true;
// name(spaces)hexvalue(tab)decimalvalue
mMemoryValue.clear();
QString s = getNextFilledLine();
bool isAnnotation = false;
while (true) {
if (!s.startsWith("\032\032")) {
s = s.trimmed();
if (!s.isEmpty()) {
mMemoryValue.append(s);
}
isAnnotation = false;
} else {
isAnnotation = true;
}
s = getNextLine();
if (!isAnnotation && s.isEmpty())
break;
}
}
void DebugReader::handleParams(){ void DebugReader::handleParams(){
handleLocalOutput(); handleLocalOutput();
doupdatelocal = true;
} }
void DebugReader::handleRegisters() void DebugReader::handleRegisters()
@ -1129,6 +1156,8 @@ void DebugReader::processDebugOutput()
dodisassemblerready = false; dodisassemblerready = false;
doregistersready = false; doregistersready = false;
doevalready = false; doevalready = false;
doupdatememoryview = false;
doupdatelocal = false;
doprocessexited = false; doprocessexited = false;
doupdateexecution = false; doupdateexecution = false;
doreceivedsignal = false; doreceivedsignal = false;
@ -1168,6 +1197,9 @@ void DebugReader::processDebugOutput()
case AnnotationType::TParam: case AnnotationType::TParam:
handleParams(); handleParams();
break; break;
case AnnotationType::TMemory:
handleMemory();
break;
case AnnotationType::TErrorBegin: case AnnotationType::TErrorBegin:
handleError(); handleError();
break; break;

View File

@ -36,7 +36,7 @@ enum class AnnotationType {
TFieldBegin, TFieldEnd, TFieldValue, TFieldNameEnd, TFieldBegin, TFieldEnd, TFieldValue, TFieldNameEnd,
TInfoReg, TInfoAsm, TInfoReg, TInfoAsm,
TUnknown, TEOF, TUnknown, TEOF,
TLocal, TParam TLocal, TParam, TMemory
}; };
struct DebugCommand{ struct DebugCommand{
@ -238,6 +238,8 @@ public:
signals: signals:
void evalValueReady(const QString& s); void evalValueReady(const QString& s);
void memoryExamineReady(const QStringList& s);
void localsReady(const QStringList& s);
public slots: public slots:
void stop(); void stop();
@ -252,8 +254,7 @@ private slots:
void syncFinishedParsing(); void syncFinishedParsing();
void onChangeDebugConsoleLastline(const QString& text); void onChangeDebugConsoleLastline(const QString& text);
void clearUpReader(); void clearUpReader();
void onAddLocalLine(const QString& text);
void onClearLocals();
private: private:
bool mExecuting; bool mExecuting;
bool mCommandChanged; bool mCommandChanged;
@ -291,8 +292,6 @@ signals:
void updateWatch(); void updateWatch();
void processError(QProcess::ProcessError error); void processError(QProcess::ProcessError error);
void changeDebugConsoleLastLine(const QString& text); void changeDebugConsoleLastLine(const QString& text);
void addLocalLine(const QString& text);
void clearLocals();
void cmdStarted(); void cmdStarted();
void cmdFinished(); void cmdFinished();
private: private:
@ -312,6 +311,7 @@ private:
void handleFrames(); void handleFrames();
void handleLocalOutput(); void handleLocalOutput();
void handleLocals(); void handleLocals();
void handleMemory();
void handleParams(); void handleParams();
void handleRegisters(); void handleRegisters();
void handleSignal(); void handleSignal();
@ -348,6 +348,8 @@ private:
QString mBreakPointFile; QString mBreakPointFile;
QString mOutput; QString mOutput;
QString mEvalValue; QString mEvalValue;
QStringList mMemoryValue;
QStringList mLocalsValue;
QString mSignal; QString mSignal;
bool mUseUTF8; bool mUseUTF8;
@ -361,6 +363,8 @@ private:
bool doupdateexecution; bool doupdateexecution;
bool doreceivedsignal; bool doreceivedsignal;
bool doreceivedsfwarning; bool doreceivedsfwarning;
bool doupdatememoryview;
bool doupdatelocal;
bool mStop; bool mStop;
friend class Debugger; friend class Debugger;

View File

@ -120,6 +120,8 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->debugConsole,&QConsole::commandInput,this,&MainWindow::onDebugCommandInput); connect(ui->debugConsole,&QConsole::commandInput,this,&MainWindow::onDebugCommandInput);
connect(ui->cbEvaluate->lineEdit(), &QLineEdit::returnPressed, connect(ui->cbEvaluate->lineEdit(), &QLineEdit::returnPressed,
this, &MainWindow::onDebugEvaluateInput); this, &MainWindow::onDebugEvaluateInput);
connect(ui->cbMemoryAddress->lineEdit(), &QLineEdit::returnPressed,
this, &MainWindow::onDebugMemoryAddressInput);
mSearchResultTreeModel = std::make_shared<SearchResultTreeModel>(&mSearchResultModel); mSearchResultTreeModel = std::make_shared<SearchResultTreeModel>(&mSearchResultModel);
mSearchResultListModel = std::make_shared<SearchResultListModel>(&mSearchResultModel); mSearchResultListModel = std::make_shared<SearchResultListModel>(&mSearchResultModel);
@ -556,6 +558,7 @@ void MainWindow::updateDebugEval(const QString &value)
{ {
ui->txtEvalOutput->clear(); ui->txtEvalOutput->clear();
ui->txtEvalOutput->appendPlainText(value); ui->txtEvalOutput->appendPlainText(value);
ui->txtEvalOutput->moveCursor(QTextCursor::Start);
} }
void MainWindow::rebuildOpenedFileHisotryMenu() void MainWindow::rebuildOpenedFileHisotryMenu()
@ -2124,6 +2127,7 @@ void MainWindow::disableDebugActions()
ui->actionRun_To_Cursor->setEnabled(false); ui->actionRun_To_Cursor->setEnabled(false);
ui->actionContinue->setEnabled(false); ui->actionContinue->setEnabled(false);
ui->cbEvaluate->setEnabled(false); ui->cbEvaluate->setEnabled(false);
ui->cbMemoryAddress->setEnabled(false);
} }
void MainWindow::enableDebugActions() void MainWindow::enableDebugActions()
@ -2134,6 +2138,7 @@ void MainWindow::enableDebugActions()
ui->actionRun_To_Cursor->setEnabled(true); ui->actionRun_To_Cursor->setEnabled(true);
ui->actionContinue->setEnabled(true); ui->actionContinue->setEnabled(true);
ui->cbEvaluate->setEnabled(true); ui->cbEvaluate->setEnabled(true);
ui->cbMemoryAddress->setEnabled(true);
} }
void MainWindow::prepareProjectForCompile() void MainWindow::prepareProjectForCompile()
@ -3017,6 +3022,16 @@ void MainWindow::onDebugEvaluateInput()
} }
} }
void MainWindow::onDebugMemoryAddressInput()
{
QString s=ui->cbMemoryAddress->currentText().trimmed();
if (!s.isEmpty()) {
connect(mDebugger, &Debugger::memoryExamineReady,
this, &MainWindow::onMemoryExamineReady);
mDebugger->sendCommand("x/64bx",s,false);
}
}
void MainWindow::onParserProgress(const QString &fileName, int total, int current) void MainWindow::onParserProgress(const QString &fileName, int total, int current)
{ {
// Mention every 5% progress // Mention every 5% progress
@ -3068,6 +3083,27 @@ void MainWindow::onEvalValueReady(const QString &value)
this, &MainWindow::onEvalValueReady); this, &MainWindow::onEvalValueReady);
} }
void MainWindow::onMemoryExamineReady(const QStringList &value)
{
ui->txtMemoryView->clear();
foreach (QString s, value) {
s.replace("\t"," ");
ui->txtMemoryView->appendPlainText(s);
}
ui->txtMemoryView->moveCursor(QTextCursor::Start);
disconnect(mDebugger, &Debugger::memoryExamineReady,
this, &MainWindow::onMemoryExamineReady);
}
void MainWindow::onLocalsReady(const QStringList &value)
{
ui->txtLocals->clear();
foreach (QString s, value) {
ui->txtLocals->appendPlainText(s);
}
ui->txtLocals->moveCursor(QTextCursor::Start);
}
void MainWindow::on_actionFind_triggered() void MainWindow::on_actionFind_triggered()
{ {
Editor *e = mEditorList->getEditor(); Editor *e = mEditorList->getEditor();

View File

@ -88,7 +88,6 @@ public:
void saveLastOpens(); void saveLastOpens();
void loadLastOpens(); void loadLastOpens();
QPlainTextEdit* txtLocals(); QPlainTextEdit* txtLocals();
CPUDialog *cpuDialog() const; CPUDialog *cpuDialog() const;
@ -125,10 +124,13 @@ public slots:
void cleanUpCPUDialog(); void cleanUpCPUDialog();
void onDebugCommandInput(const QString& command); void onDebugCommandInput(const QString& command);
void onDebugEvaluateInput(); void onDebugEvaluateInput();
void onDebugMemoryAddressInput();
void onParserProgress(const QString& fileName, int total, int current); void onParserProgress(const QString& fileName, int total, int current);
void onStartParsing(); void onStartParsing();
void onEndParsing(int total, int updateView); void onEndParsing(int total, int updateView);
void onEvalValueReady(const QString& value); void onEvalValueReady(const QString& value);
void onMemoryExamineReady(const QStringList& value);
void onLocalsReady(const QStringList& value);
void onEditorContextMenu(const QPoint& pos); void onEditorContextMenu(const QPoint& pos);
void onEditorTabContextMenu(const QPoint& pos); void onEditorTabContextMenu(const QPoint& pos);
void disableDebugActions(); void disableDebugActions();

View File

@ -288,7 +288,7 @@
<enum>QTabWidget::South</enum> <enum>QTabWidget::South</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="tabIssues"> <widget class="QWidget" name="tabIssues">
<attribute name="icon"> <attribute name="icon">
@ -416,67 +416,43 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>11</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>11</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>11</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>11</number>
</property> </property>
<item> <item row="0" column="0">
<widget class="QFrame" name="frame_2"> <widget class="QLabel" name="lblEvaluate">
<property name="frameShape"> <property name="text">
<enum>QFrame::StyledPanel</enum> <string>Evaluate:</string>
</property> </property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<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="lblEvaluate">
<property name="text">
<string>Evaluate:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbEvaluate">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAtTop</enum>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QComboBox" name="cbEvaluate">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAtTop</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPlainTextEdit" name="txtEvalOutput"> <widget class="QPlainTextEdit" name="txtEvalOutput">
<property name="undoRedoEnabled"> <property name="undoRedoEnabled">
<bool>false</bool> <bool>false</bool>
@ -493,7 +469,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>4</number>
</property> </property>
<widget class="QWidget" name="tabDebugConsole"> <widget class="QWidget" name="tabDebugConsole">
<attribute name="title"> <attribute name="title">
@ -623,6 +599,46 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabMemory">
<attribute name="title">
<string>Memory</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Address Expression:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cbMemoryAddress">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAtTop</enum>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QPlainTextEdit" name="txtMemoryView">
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>
@ -801,7 +817,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>946</width> <width>946</width>
<height>25</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

View File

@ -3,6 +3,8 @@
#include <QStringList> #include <QStringList>
#define DEVCPP_VERSION "0.2.2"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#define APP_SETTSINGS_FILENAME "redpandacpp.ini" #define APP_SETTSINGS_FILENAME "redpandacpp.ini"
#define GCC_PROGRAM "gcc.exe" #define GCC_PROGRAM "gcc.exe"
@ -51,8 +53,6 @@
#error "Only support windows and linux now!" #error "Only support windows and linux now!"
#endif #endif
#define DEVCPP_VERSION "0.2.0"
class SystemConsts class SystemConsts
{ {
public: public: