work save

This commit is contained in:
Roy Qu 2024-03-10 11:15:10 +08:00
parent 6ba9cbb78b
commit b359004f95
6 changed files with 172 additions and 39 deletions

View File

@ -275,7 +275,7 @@ void Debugger::refreshAll()
if (memoryModel()->startAddress()>0 if (memoryModel()->startAddress()>0
&& mClient) && mClient)
mClient->readMemory( mClient->readMemory(
memoryModel()->startAddress(), QString("%1").arg(memoryModel()->startAddress()),
pSettings->debugger().memoryViewRows(), pSettings->debugger().memoryViewRows(),
pSettings->debugger().memoryViewColumns() pSettings->debugger().memoryViewColumns()
); );
@ -309,9 +309,50 @@ bool Debugger::inferiorRunning()
void Debugger::interrupt() void Debugger::interrupt()
{ {
if (mClient) { if (mClient)
mClient->interrupt(); 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 bool Debugger::isForProject() const
@ -639,12 +680,43 @@ PWatchVar Debugger::watchVarAt(const QModelIndex &index)
return mWatchModel->findWatchVar(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) void Debugger::evalExpression(const QString &expression)
{ {
if (mClient) if (mClient)
mClient->evalExpression(expression); 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) //void Debugger::notifyWatchVarUpdated(PWatchVar var)
//{ //{
// mWatchModel->notifyUpdated(var); // mWatchModel->notifyUpdated(var);

View File

@ -306,6 +306,13 @@ public:
bool commandRunning(); bool commandRunning();
bool inferiorRunning(); bool inferiorRunning();
void interrupt(); void interrupt();
void stepOver();
void stepInto();
void stepOut();
void runTo(const QString& filename, int line);
void resume();
void stepOverInstruction();
void stepIntoInstruction();
bool isForProject() const; bool isForProject() const;
void setIsForProject(bool newIsForProject); void setIsForProject(bool newIsForProject);
@ -344,9 +351,12 @@ public:
PWatchVar watchVarAt(const QModelIndex& index); PWatchVar watchVarAt(const QModelIndex& index);
void refreshVars(); void refreshVars();
void readMemory(const QString& startAddress, int rows, int cols);
void evalExpression(const QString& expression); void evalExpression(const QString& expression);
void refreshFrame();
void refreshRegisters();
void disassembleCurrentFrame(bool blendMode);
void setDisassemblyLanguage(bool isIntel);
// void notifyWatchVarUpdated(PWatchVar var); // void notifyWatchVarUpdated(PWatchVar var);
std::shared_ptr<BacktraceModel> backtraceModel(); std::shared_ptr<BacktraceModel> backtraceModel();
@ -381,7 +391,6 @@ signals:
public slots: public slots:
void stop(); void stop();
void refreshAll(); void refreshAll();
private: private:
void sendWatchCommand(PWatchVar var); void sendWatchCommand(PWatchVar var);
void sendRemoveWatchCommand(PWatchVar var); void sendRemoveWatchCommand(PWatchVar var);
@ -498,10 +507,18 @@ public:
virtual DebuggerType clientType() = 0; virtual DebuggerType clientType() = 0;
//requests //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 interrupt() = 0;
virtual void refreshStackVariables() = 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 writeMemory(qulonglong address, unsigned char data) = 0;
virtual void addBreakpoint(PBreakpoint breakpoint) = 0; virtual void addBreakpoint(PBreakpoint breakpoint) = 0;
@ -521,7 +538,7 @@ public:
virtual void refreshFrame() = 0; virtual void refreshFrame() = 0;
virtual void refreshRegisters() = 0; virtual void refreshRegisters() = 0;
virtual void disassembleCurrentFrame(bool blendMode) = 0; virtual void disassembleCurrentFrame(bool blendMode) = 0;
virtual void setDisassemblyLanguage(bool isIntel) = 0;
signals: signals:
void parseStarted(); void parseStarted();

View File

@ -874,6 +874,43 @@ const PDebugCommand &GDBMIDebuggerClient::currentCmd() const
return mCurrentCmd; 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() void GDBMIDebuggerClient::interrupt()
{ {
postCommand("-exec-interrupt", ""); postCommand("-exec-interrupt", "");
@ -884,7 +921,7 @@ void GDBMIDebuggerClient::refreshStackVariables()
postCommand("-stack-list-variables", "--all-values"); 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 ") postCommand("-data-read-memory",QString("%1 x 1 %2 %3 ")
.arg(startAddress) .arg(startAddress)
@ -1000,12 +1037,21 @@ void GDBMIDebuggerClient::refreshRegisters()
void GDBMIDebuggerClient::disassembleCurrentFrame(bool blendMode) void GDBMIDebuggerClient::disassembleCurrentFrame(bool blendMode)
{ {
if (blendMode) if (blendMode && clientType()==DebuggerType::GDB)
postCommand("disas", "/s"); postCommand("disas", "/s");
else else
postCommand("disas", ""); 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() void GDBMIDebuggerClient::runInferiorStoppedHook()
{ {
QMutexLocker locker(&mCmdQueueMutex); QMutexLocker locker(&mCmdQueueMutex);

View File

@ -48,10 +48,18 @@ public:
DebuggerType clientType() override; DebuggerType clientType() override;
const PDebugCommand &currentCmd() const; const PDebugCommand &currentCmd() 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 interrupt() override;
void refreshStackVariables() 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 writeMemory(qulonglong address, unsigned char data) override;
void addBreakpoint(PBreakpoint breakpoint) override; void addBreakpoint(PBreakpoint breakpoint) override;
@ -68,9 +76,10 @@ public:
void evalExpression(const QString& expression) override; void evalExpression(const QString& expression) override;
void refreshFrame(); void refreshFrame() override;
void refreshRegisters(); void refreshRegisters() override;
void disassembleCurrentFrame(bool blendMode); void disassembleCurrentFrame(bool blendMode) override;
void setDisassemblyLanguage(bool isIntel) override;
// QThread interface // QThread interface
protected: protected:
void run() override; void run() override;

View File

@ -6416,7 +6416,7 @@ void MainWindow::on_actionStep_Over_triggered()
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->sendCommand("-exec-next", ""); mDebugger->stepOver();
} }
} }
@ -6424,7 +6424,7 @@ void MainWindow::on_actionStep_Into_triggered()
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->sendCommand("-exec-step", ""); mDebugger->stepInto();
} }
} }
@ -6433,7 +6433,7 @@ void MainWindow::on_actionStep_Out_triggered()
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->sendCommand("-exec-finish", ""); mDebugger->stepOut();
} }
} }
@ -6444,9 +6444,7 @@ void MainWindow::on_actionRun_To_Cursor_triggered()
Editor *e=mEditorList->getEditor(); Editor *e=mEditorList->getEditor();
if (e!=nullptr) { if (e!=nullptr) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->sendCommand("-exec-until", QString("\"%1\":%2") mDebugger->runTo(e->filename(), e->caretY());
.arg(e->filename())
.arg(e->caretY()));
} }
} }
@ -6456,7 +6454,7 @@ void MainWindow::on_actionContinue_triggered()
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
//WatchView.Items.BeginUpdate(); //WatchView.Items.BeginUpdate();
mDebugger->sendCommand("-exec-continue", ""); mDebugger->resume();
} }
} }
@ -6512,10 +6510,9 @@ void MainWindow::onDebugMemoryAddressInput()
if (!s.isEmpty()) { if (!s.isEmpty()) {
// connect(mDebugger, &Debugger::memoryExamineReady, // connect(mDebugger, &Debugger::memoryExamineReady,
// this, &MainWindow::onMemoryExamineReady); // this, &MainWindow::onMemoryExamineReady);
mDebugger->sendCommand("-data-read-memory",QString("%1 x 1 %2 %3 ") mDebugger->readMemory(s,
.arg(s) pSettings->debugger().memoryViewRows(),
.arg(pSettings->debugger().memoryViewRows()) pSettings->debugger().memoryViewColumns()
.arg(pSettings->debugger().memoryViewColumns())
); );
} }
} }

View File

@ -85,14 +85,11 @@ CPUDialog::~CPUDialog()
void CPUDialog::updateInfo() void CPUDialog::updateInfo()
{ {
if (pMainWindow->debugger()->executing()) { if (pMainWindow->debugger()->executing()) {
pMainWindow->debugger()->sendCommand("-stack-info-frame", ""); pMainWindow->debugger()->refreshFrame();
// Load the registers.. // Load the registers..
sendSyntaxCommand(); sendSyntaxCommand();
pMainWindow->debugger()->sendCommand("-data-list-register-values", "N"); pMainWindow->debugger()->refreshRegisters();
if (ui->chkBlendMode->isChecked()) pMainWindow->debugger()->disassembleCurrentFrame(ui->chkBlendMode->isChecked());
pMainWindow->debugger()->sendCommand("disas", "/s");
else
pMainWindow->debugger()->sendCommand("disas", "");
} }
} }
@ -157,12 +154,7 @@ void CPUDialog::resetEditorFont(float dpi)
void CPUDialog::sendSyntaxCommand() void CPUDialog::sendSyntaxCommand()
{ {
// Set disassembly flavor pMainWindow->debugger()->setDisassemblyLanguage(ui->rdIntel->isChecked());
if (ui->rdIntel->isChecked()) {
pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor intel");
} else {
pMainWindow->debugger()->sendCommand("-gdb-set", "disassembly-flavor att");
}
} }
void CPUDialog::closeEvent(QCloseEvent *event) void CPUDialog::closeEvent(QCloseEvent *event)
@ -200,13 +192,13 @@ void CPUDialog::on_chkBlendMode_stateChanged(int)
void CPUDialog::on_btnStepOverInstruction_clicked() void CPUDialog::on_btnStepOverInstruction_clicked()
{ {
pMainWindow->debugger()->sendCommand("-exec-next-instruction",""); pMainWindow->debugger()->stepOverInstruction();
} }
void CPUDialog::on_btnStepIntoInstruction_clicked() void CPUDialog::on_btnStepIntoInstruction_clicked()
{ {
pMainWindow->debugger()->sendCommand("-exec-step-instruction",""); pMainWindow->debugger()->stepIntoInstruction();
} }
void CPUDialog::onUpdateIcons() void CPUDialog::onUpdateIcons()