Implement NopInstruction feature in debugger

See #16975
This commit is contained in:
Henrik Rydgård 2023-03-02 14:28:51 +01:00
parent f55782558c
commit 82097b4a3b
4 changed files with 20 additions and 4 deletions

View file

@ -206,7 +206,7 @@ CtrlDisAsmView::~CtrlDisAsmView()
manager.clear(); manager.clear();
} }
COLORREF scaleColor(COLORREF color, float factor) static COLORREF scaleColor(COLORREF color, float factor)
{ {
unsigned char r = color & 0xFF; unsigned char r = color & 0xFF;
unsigned char g = (color >> 8) & 0xFF; unsigned char g = (color >> 8) & 0xFF;
@ -315,7 +315,7 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
// try to assemble the input if it failed // try to assemble the input if it failed
} }
result = MIPSAsm::MipsAssembleOpcode(op.c_str(),debugger,address); result = MIPSAsm::MipsAssembleOpcode(op.c_str(), debugger, address);
Reporting::NotifyDebugger(); Reporting::NotifyDebugger();
if (result == true) if (result == true)
{ {
@ -331,7 +331,6 @@ void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText)
} }
} }
void CtrlDisAsmView::drawBranchLine(HDC hdc, std::map<u32,int> &addressPositions, const BranchLine &line) { void CtrlDisAsmView::drawBranchLine(HDC hdc, std::map<u32,int> &addressPositions, const BranchLine &line) {
HPEN pen; HPEN pen;
u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows); u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows);
@ -725,7 +724,7 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam)
break; break;
case 'c': case 'c':
case VK_INSERT: case VK_INSERT:
copyInstructions(selectRangeStart, selectRangeEnd, true); CopyInstructions(selectRangeStart, selectRangeEnd, CopyInstructionsMode::DISASM);
break; break;
case 'x': case 'x':
disassembleToFile(); disassembleToFile();
@ -931,6 +930,16 @@ void CtrlDisAsmView::CopyInstructions(u32 startAddr, u32 endAddr, CopyInstructio
} }
} }
void CtrlDisAsmView::NopInstructions(u32 selectRangeStart, u32 selectRangeEnd) {
for (u32 addr = selectRangeStart; addr < selectRangeEnd; addr += 4) {
Memory::Write_U32(0, addr);
}
if (currentMIPS) {
currentMIPS->InvalidateICache(selectRangeStart, selectRangeEnd - selectRangeStart);
}
}
void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
{ {
if (button == 1) if (button == 1)
@ -962,6 +971,10 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
case ID_DISASM_COPYINSTRUCTIONHEX: case ID_DISASM_COPYINSTRUCTIONHEX:
CopyInstructions(selectRangeStart, selectRangeEnd, CopyInstructionsMode::OPCODES); CopyInstructions(selectRangeStart, selectRangeEnd, CopyInstructionsMode::OPCODES);
break; break;
case ID_DISASM_NOPINSTRUCTION:
NopInstructions(selectRangeStart, selectRangeEnd);
redraw();
break;
case ID_DISASM_SETPCTOHERE: case ID_DISASM_SETPCTOHERE:
debugger->setPC(curAddress); debugger->setPC(curAddress);
redraw(); redraw();

View file

@ -80,6 +80,7 @@ class CtrlDisAsmView
void updateStatusBarText(); void updateStatusBarText();
void drawBranchLine(HDC hdc, std::map<u32, int> &addressPositions, const BranchLine &line); void drawBranchLine(HDC hdc, std::map<u32, int> &addressPositions, const BranchLine &line);
void CopyInstructions(u32 startAddr, u32 endAddr, CopyInstructionsMode mode); void CopyInstructions(u32 startAddr, u32 endAddr, CopyInstructionsMode mode);
void NopInstructions(u32 startAddr, u32 endAddr);
std::set<std::string> getSelectedLineArguments(); std::set<std::string> getSelectedLineArguments();
void drawArguments(HDC hdc, const DisassemblyLineInfo &line, int x, int y, int textColor, const std::set<std::string> &currentArguments); void drawArguments(HDC hdc, const DisassemblyLineInfo &line, int x, int y, int textColor, const std::set<std::string> &currentArguments);

View file

@ -721,6 +721,7 @@ BEGIN
MENUITEM "Rename Function...", ID_DISASM_RENAMEFUNCTION MENUITEM "Rename Function...", ID_DISASM_RENAMEFUNCTION
MENUITEM "Remove Function", ID_DISASM_REMOVEFUNCTION MENUITEM "Remove Function", ID_DISASM_REMOVEFUNCTION
MENUITEM "Add Function Here", ID_DISASM_ADDFUNCTION MENUITEM "Add Function Here", ID_DISASM_ADDFUNCTION
MENUITEM "NOP instruction(s)", ID_DISASM_NOPINSTRUCTION
END END
POPUP "reglist" POPUP "reglist"
BEGIN BEGIN

View file

@ -334,6 +334,7 @@
#define ID_GEDBG_COPY_IMAGE_ALPHA 40225 #define ID_GEDBG_COPY_IMAGE_ALPHA 40225
#define ID_GEDBG_TRACK_PIXEL 40226 #define ID_GEDBG_TRACK_PIXEL 40226
#define ID_GEDBG_TRACK_PIXEL_STOP 40227 #define ID_GEDBG_TRACK_PIXEL_STOP 40227
#define ID_DISASM_NOPINSTRUCTION 40228
// Dummy option to let the buffered rendering hotkey cycle through all the options. // Dummy option to let the buffered rendering hotkey cycle through all the options.