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();
}
COLORREF scaleColor(COLORREF color, float factor)
static COLORREF scaleColor(COLORREF color, float factor)
{
unsigned char r = color & 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
}
result = MIPSAsm::MipsAssembleOpcode(op.c_str(),debugger,address);
result = MIPSAsm::MipsAssembleOpcode(op.c_str(), debugger, address);
Reporting::NotifyDebugger();
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) {
HPEN pen;
u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows);
@ -725,7 +724,7 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam)
break;
case 'c':
case VK_INSERT:
copyInstructions(selectRangeStart, selectRangeEnd, true);
CopyInstructions(selectRangeStart, selectRangeEnd, CopyInstructionsMode::DISASM);
break;
case 'x':
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)
{
if (button == 1)
@ -962,6 +971,10 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
case ID_DISASM_COPYINSTRUCTIONHEX:
CopyInstructions(selectRangeStart, selectRangeEnd, CopyInstructionsMode::OPCODES);
break;
case ID_DISASM_NOPINSTRUCTION:
NopInstructions(selectRangeStart, selectRangeEnd);
redraw();
break;
case ID_DISASM_SETPCTOHERE:
debugger->setPC(curAddress);
redraw();

View file

@ -80,6 +80,7 @@ class CtrlDisAsmView
void updateStatusBarText();
void drawBranchLine(HDC hdc, std::map<u32, int> &addressPositions, const BranchLine &line);
void CopyInstructions(u32 startAddr, u32 endAddr, CopyInstructionsMode mode);
void NopInstructions(u32 startAddr, u32 endAddr);
std::set<std::string> getSelectedLineArguments();
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 "Remove Function", ID_DISASM_REMOVEFUNCTION
MENUITEM "Add Function Here", ID_DISASM_ADDFUNCTION
MENUITEM "NOP instruction(s)", ID_DISASM_NOPINSTRUCTION
END
POPUP "reglist"
BEGIN

View file

@ -334,6 +334,7 @@
#define ID_GEDBG_COPY_IMAGE_ALPHA 40225
#define ID_GEDBG_TRACK_PIXEL 40226
#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.