diff --git a/RedPandaIDE/debugger/debugger.cpp b/RedPandaIDE/debugger/debugger.cpp index e7122f52..2b69a54c 100644 --- a/RedPandaIDE/debugger/debugger.cpp +++ b/RedPandaIDE/debugger/debugger.cpp @@ -275,7 +275,7 @@ void Debugger::refreshAll() if (memoryModel()->startAddress()>0 && mClient) mClient->readMemory( - memoryModel()->startAddress(), + QString("%1").arg(memoryModel()->startAddress()), pSettings->debugger().memoryViewRows(), pSettings->debugger().memoryViewColumns() ); @@ -309,9 +309,50 @@ bool Debugger::inferiorRunning() void Debugger::interrupt() { - if (mClient) { + if (mClient) mClient->interrupt(); - } +} + +void Debugger::stepOver() +{ + if (mClient) + mClient->stepOver(); +} + +void Debugger::stepInto() +{ + if (mClient) + mClient->stepInto(); +} + +void Debugger::stepOut() +{ + if (mClient) + mClient->stepOut(); +} + +void Debugger::runTo(const QString &filename, int line) +{ + if (mClient) + mClient->runTo(filename, line); +} + +void Debugger::resume() +{ + if (mClient) + mClient->resume(); +} + +void Debugger::stepOverInstruction() +{ + if (mClient) + mClient->stepOverInstruction(); +} + +void Debugger::stepIntoInstruction() +{ + if (mClient) + mClient->stepIntoInstruction(); } bool Debugger::isForProject() const @@ -639,12 +680,43 @@ PWatchVar Debugger::watchVarAt(const QModelIndex &index) return mWatchModel->findWatchVar(index); } +void Debugger::readMemory(const QString &startAddress, int rows, int cols) +{ + if (mClient) + mClient->readMemory(startAddress, rows, cols); +} + void Debugger::evalExpression(const QString &expression) { if (mClient) mClient->evalExpression(expression); } +void Debugger::refreshFrame() +{ + if (mClient) { + mClient->refreshFrame(); + } +} + +void Debugger::refreshRegisters() +{ + if (mClient) + mClient->refreshRegisters(); +} + +void Debugger::disassembleCurrentFrame(bool blendMode) +{ + if (mClient) + mClient->disassembleCurrentFrame(blendMode); +} + +void Debugger::setDisassemblyLanguage(bool isIntel) +{ + if (mClient) + mClient->setDisassemblyLanguage(isIntel); +} + //void Debugger::notifyWatchVarUpdated(PWatchVar var) //{ // mWatchModel->notifyUpdated(var); diff --git a/RedPandaIDE/debugger/debugger.h b/RedPandaIDE/debugger/debugger.h index 88c9d44f..1a9a9995 100644 --- a/RedPandaIDE/debugger/debugger.h +++ b/RedPandaIDE/debugger/debugger.h @@ -306,6 +306,13 @@ public: bool commandRunning(); bool inferiorRunning(); void interrupt(); + void stepOver(); + void stepInto(); + void stepOut(); + void runTo(const QString& filename, int line); + void resume(); + void stepOverInstruction(); + void stepIntoInstruction(); bool isForProject() const; void setIsForProject(bool newIsForProject); @@ -344,9 +351,12 @@ public: PWatchVar watchVarAt(const QModelIndex& index); void refreshVars(); + void readMemory(const QString& startAddress, int rows, int cols); void evalExpression(const QString& expression); - - + void refreshFrame(); + void refreshRegisters(); + void disassembleCurrentFrame(bool blendMode); + void setDisassemblyLanguage(bool isIntel); // void notifyWatchVarUpdated(PWatchVar var); std::shared_ptr backtraceModel(); @@ -381,7 +391,6 @@ signals: public slots: void stop(); void refreshAll(); - private: void sendWatchCommand(PWatchVar var); void sendRemoveWatchCommand(PWatchVar var); @@ -498,10 +507,18 @@ public: virtual DebuggerType clientType() = 0; //requests + virtual void stepOver() = 0; + virtual void stepInto() = 0; + virtual void stepOut() = 0; + virtual void runTo(const QString& filename, int line) = 0; + virtual void resume() = 0; + virtual void stepOverInstruction() = 0; + virtual void stepIntoInstruction() = 0; virtual void interrupt() = 0; + virtual void refreshStackVariables() = 0; - virtual void readMemory(qulonglong startAddress, int rows, int cols) = 0; + virtual void readMemory(const QString& startAddress, int rows, int cols) = 0; virtual void writeMemory(qulonglong address, unsigned char data) = 0; virtual void addBreakpoint(PBreakpoint breakpoint) = 0; @@ -521,7 +538,7 @@ public: virtual void refreshFrame() = 0; virtual void refreshRegisters() = 0; virtual void disassembleCurrentFrame(bool blendMode) = 0; - + virtual void setDisassemblyLanguage(bool isIntel) = 0; signals: void parseStarted(); diff --git a/RedPandaIDE/debugger/gdbmidebugger.cpp b/RedPandaIDE/debugger/gdbmidebugger.cpp index b8f09d43..7de60a97 100644 --- a/RedPandaIDE/debugger/gdbmidebugger.cpp +++ b/RedPandaIDE/debugger/gdbmidebugger.cpp @@ -874,6 +874,43 @@ const PDebugCommand &GDBMIDebuggerClient::currentCmd() const return mCurrentCmd; } +void GDBMIDebuggerClient::stepOver() +{ + postCommand("-exec-next", ""); +} + +void GDBMIDebuggerClient::stepInto() +{ + postCommand("-exec-step", ""); +} + +void GDBMIDebuggerClient::stepOut() +{ + postCommand("-exec-finish", ""); +} + +void GDBMIDebuggerClient::runTo(const QString &filename, int line) +{ + postCommand("-exec-until", QString("\"%1\":%2") + .arg(filename) + .arg(line)); +} + +void GDBMIDebuggerClient::resume() +{ + postCommand("-exec-continue", ""); +} + +void GDBMIDebuggerClient::stepOverInstruction() +{ + postCommand("-exec-next-instruction",""); +} + +void GDBMIDebuggerClient::stepIntoInstruction() +{ + postCommand("-exec-step-instruction",""); +} + void GDBMIDebuggerClient::interrupt() { postCommand("-exec-interrupt", ""); @@ -884,7 +921,7 @@ void GDBMIDebuggerClient::refreshStackVariables() postCommand("-stack-list-variables", "--all-values"); } -void GDBMIDebuggerClient::readMemory(qulonglong startAddress, int rows, int cols) +void GDBMIDebuggerClient::readMemory(const QString& startAddress, int rows, int cols) { postCommand("-data-read-memory",QString("%1 x 1 %2 %3 ") .arg(startAddress) @@ -1000,12 +1037,21 @@ void GDBMIDebuggerClient::refreshRegisters() void GDBMIDebuggerClient::disassembleCurrentFrame(bool blendMode) { - if (blendMode) + if (blendMode && clientType()==DebuggerType::GDB) postCommand("disas", "/s"); else postCommand("disas", ""); } +void GDBMIDebuggerClient::setDisassemblyLanguage(bool isIntel) +{ + if (isIntel) { + postCommand("-gdb-set", "disassembly-flavor intel"); + } else { + postCommand("-gdb-set", "disassembly-flavor att"); + } +} + void GDBMIDebuggerClient::runInferiorStoppedHook() { QMutexLocker locker(&mCmdQueueMutex); diff --git a/RedPandaIDE/debugger/gdbmidebugger.h b/RedPandaIDE/debugger/gdbmidebugger.h index 3a09504d..c86d4bba 100644 --- a/RedPandaIDE/debugger/gdbmidebugger.h +++ b/RedPandaIDE/debugger/gdbmidebugger.h @@ -48,10 +48,18 @@ public: DebuggerType clientType() override; const PDebugCommand ¤tCmd() const; + void stepOver() override; + void stepInto() override; + void stepOut() override; + void runTo(const QString& filename, int line) override; + void resume() override; + void stepOverInstruction() override; + void stepIntoInstruction() override; void interrupt() override; + void refreshStackVariables() override; - void readMemory(qulonglong startAddress, int rows, int cols) override; + void readMemory(const QString& startAddress, int rows, int cols) override; void writeMemory(qulonglong address, unsigned char data) override; void addBreakpoint(PBreakpoint breakpoint) override; @@ -68,9 +76,10 @@ public: void evalExpression(const QString& expression) override; - void refreshFrame(); - void refreshRegisters(); - void disassembleCurrentFrame(bool blendMode); + void refreshFrame() override; + void refreshRegisters() override; + void disassembleCurrentFrame(bool blendMode) override; + void setDisassemblyLanguage(bool isIntel) override; // QThread interface protected: void run() override; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 187d6d11..ffd43363 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -6416,7 +6416,7 @@ void MainWindow::on_actionStep_Over_triggered() { if (mDebugger->executing()) { //WatchView.Items.BeginUpdate(); - mDebugger->sendCommand("-exec-next", ""); + mDebugger->stepOver(); } } @@ -6424,7 +6424,7 @@ void MainWindow::on_actionStep_Into_triggered() { if (mDebugger->executing()) { //WatchView.Items.BeginUpdate(); - mDebugger->sendCommand("-exec-step", ""); + mDebugger->stepInto(); } } @@ -6433,7 +6433,7 @@ void MainWindow::on_actionStep_Out_triggered() { if (mDebugger->executing()) { //WatchView.Items.BeginUpdate(); - mDebugger->sendCommand("-exec-finish", ""); + mDebugger->stepOut(); } } @@ -6444,9 +6444,7 @@ void MainWindow::on_actionRun_To_Cursor_triggered() Editor *e=mEditorList->getEditor(); if (e!=nullptr) { //WatchView.Items.BeginUpdate(); - mDebugger->sendCommand("-exec-until", QString("\"%1\":%2") - .arg(e->filename()) - .arg(e->caretY())); + mDebugger->runTo(e->filename(), e->caretY()); } } @@ -6456,7 +6454,7 @@ void MainWindow::on_actionContinue_triggered() { if (mDebugger->executing()) { //WatchView.Items.BeginUpdate(); - mDebugger->sendCommand("-exec-continue", ""); + mDebugger->resume(); } } @@ -6512,10 +6510,9 @@ void MainWindow::onDebugMemoryAddressInput() if (!s.isEmpty()) { // connect(mDebugger, &Debugger::memoryExamineReady, // this, &MainWindow::onMemoryExamineReady); - mDebugger->sendCommand("-data-read-memory",QString("%1 x 1 %2 %3 ") - .arg(s) - .arg(pSettings->debugger().memoryViewRows()) - .arg(pSettings->debugger().memoryViewColumns()) + mDebugger->readMemory(s, + pSettings->debugger().memoryViewRows(), + pSettings->debugger().memoryViewColumns() ); } } diff --git a/RedPandaIDE/widgets/cpudialog.cpp b/RedPandaIDE/widgets/cpudialog.cpp index 058a4cc5..dc19d556 100644 --- a/RedPandaIDE/widgets/cpudialog.cpp +++ b/RedPandaIDE/widgets/cpudialog.cpp @@ -85,14 +85,11 @@ CPUDialog::~CPUDialog() void CPUDialog::updateInfo() { if (pMainWindow->debugger()->executing()) { - pMainWindow->debugger()->sendCommand("-stack-info-frame", ""); + pMainWindow->debugger()->refreshFrame(); // Load the registers.. sendSyntaxCommand(); - pMainWindow->debugger()->sendCommand("-data-list-register-values", "N"); - if (ui->chkBlendMode->isChecked()) - pMainWindow->debugger()->sendCommand("disas", "/s"); - else - pMainWindow->debugger()->sendCommand("disas", ""); + pMainWindow->debugger()->refreshRegisters(); + pMainWindow->debugger()->disassembleCurrentFrame(ui->chkBlendMode->isChecked()); } } @@ -157,12 +154,7 @@ void CPUDialog::resetEditorFont(float dpi) void CPUDialog::sendSyntaxCommand() { - // Set disassembly flavor - if (ui->rdIntel->isChecked()) { - pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor intel"); - } else { - pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor att"); - } + pMainWindow->debugger()->setDisassemblyLanguage(ui->rdIntel->isChecked()); } void CPUDialog::closeEvent(QCloseEvent *event) @@ -200,13 +192,13 @@ void CPUDialog::on_chkBlendMode_stateChanged(int) void CPUDialog::on_btnStepOverInstruction_clicked() { - pMainWindow->debugger()->sendCommand("-exec-next-instruction",""); + pMainWindow->debugger()->stepOverInstruction(); } void CPUDialog::on_btnStepIntoInstruction_clicked() { - pMainWindow->debugger()->sendCommand("-exec-step-instruction",""); + pMainWindow->debugger()->stepIntoInstruction(); } void CPUDialog::onUpdateIcons()