void BreakpointList::editBreakpoint(int itemIndex) { bool isMemory; int index = getBreakpointIndex(itemIndex, isMemory); if (index == -1) return; BreakpointWindow win(this,cpu); if (isMemory) { auto mem = displayedMemChecks_[index]; win.loadFromMemcheck(mem); if (win.ShowModal() == wxID_OK) { CBreakPoints::RemoveMemCheck(mem.start,mem.end); win.addBreakpoint(); } } else { auto bp = displayedBreakPoints_[index]; win.loadFromBreakpoint(bp); if (win.ShowModal() == wxID_OK) { CBreakPoints::RemoveBreakPoint(bp.addr); win.addBreakpoint(); } } }
void CtrlBreakpointList::editBreakpoint(int itemIndex) { bool isMemory; int index = getBreakpointIndex(itemIndex, isMemory); if (index == -1) return; BreakpointWindow win(GetHandle(),cpu); if (isMemory) { auto mem = displayedMemChecks_[index]; win.loadFromMemcheck(mem); if (win.exec()) { CBreakPoints::RemoveMemCheck(mem.start,mem.end); win.addBreakpoint(); } } else { auto bp = displayedBreakPoints_[index]; win.loadFromBreakpoint(bp); if (win.exec()) { CBreakPoints::RemoveBreakPoint(bp.addr); win.addBreakpoint(); } } }
void CtrlBreakpointList::showBreakpointMenu(int itemIndex, const POINT &pt) { POINT screenPt(pt); ClientToScreen(wnd, &screenPt); bool isMemory; int index = getBreakpointIndex(itemIndex, isMemory); if (index == -1) { HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_NEWBREAKPOINT); switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, wnd, 0)) { case ID_DISASM_ADDNEWBREAKPOINT: { BreakpointWindow bpw(wnd,cpu); if (bpw.exec()) bpw.addBreakpoint(); } break; } } else { MemCheck mcPrev; BreakPoint bpPrev; if (isMemory) { mcPrev = displayedMemChecks_[index]; } else { bpPrev = displayedBreakPoints_[index]; } HMENU subMenu = GetSubMenu(g_hPopupMenus, POPUP_SUBMENU_ID_BREAKPOINTLIST); if (isMemory) { CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, MF_BYCOMMAND | (mcPrev.result & MEMCHECK_BREAK ? MF_CHECKED : MF_UNCHECKED)); } else { CheckMenuItem(subMenu, ID_DISASM_DISABLEBREAKPOINT, MF_BYCOMMAND | (bpPrev.enabled ? MF_CHECKED : MF_UNCHECKED)); } switch (TrackPopupMenuEx(subMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, screenPt.x, screenPt.y, wnd, 0)) { case ID_DISASM_DISABLEBREAKPOINT: if (isMemory) { CBreakPoints::ChangeMemCheck(mcPrev.start, mcPrev.end, mcPrev.cond, MemCheckResult(mcPrev.result ^ MEMCHECK_BREAK)); } else { CBreakPoints::ChangeBreakPoint(bpPrev.addr, !bpPrev.enabled); } break; case ID_DISASM_EDITBREAKPOINT: editBreakpoint(index); break; case ID_DISASM_ADDNEWBREAKPOINT: { BreakpointWindow bpw(wnd,cpu); if (bpw.exec()) bpw.addBreakpoint(); } break; } } }
void CtrlBreakpointList::toggleEnabled(int itemIndex) { bool isMemory; int index = getBreakpointIndex(itemIndex, isMemory); if (index == -1) return; if (isMemory) { MemCheck mcPrev = displayedMemChecks_[index]; CBreakPoints::ChangeMemCheck(mcPrev.start, mcPrev.end, mcPrev.cond, MemCheckResult(mcPrev.result ^ MEMCHECK_BREAK)); } else { BreakPoint bpPrev = displayedBreakPoints_[index]; CBreakPoints::ChangeBreakPoint(bpPrev.addr, !bpPrev.enabled); } }
void CtrlBreakpointList::toggleEnabled(int itemIndex) { bool isMemory; int index = getBreakpointIndex(itemIndex, isMemory); if (index == -1) return; if (isMemory) { MemCheck mcPrev = displayedMemChecks_[index]; CBreakPoints::ChangeMemCheck(mcPrev.start, mcPrev.end, mcPrev.cond, BreakAction(mcPrev.result ^ BREAK_ACTION_PAUSE)); } else { BreakPoint bpPrev = displayedBreakPoints_[index]; CBreakPoints::ChangeBreakPoint(bpPrev.addr, BreakAction(bpPrev.result ^ BREAK_ACTION_PAUSE)); } }
void CtrlBreakpointList::removeBreakpoint(int itemIndex) { bool isMemory; int index = getBreakpointIndex(itemIndex,isMemory); if (index == -1) return; if (isMemory) { auto mc = displayedMemChecks_[index]; CBreakPoints::RemoveMemCheck(mc.start, mc.end); } else { u32 address = displayedBreakPoints_[index].addr; CBreakPoints::RemoveBreakPoint(address); } }
void BreakpointList::gotoBreakpointAddress(int itemIndex) { bool isMemory; int index = getBreakpointIndex(itemIndex,isMemory); if (index == -1) return; if (isMemory) { u32 address = displayedMemChecks_[index].start; postEvent(debEVT_GOTOINMEMORYVIEW,address); } else { u32 address = displayedBreakPoints_[index].addr; postEvent(debEVT_GOTOINDISASM,address); } }
void CtrlBreakpointList::reloadBreakpoints() { // Update the items we're displaying from the debugger. displayedBreakPoints_ = CBreakPoints::GetBreakpoints(); displayedMemChecks_= CBreakPoints::GetMemChecks(); Update(); for (int i = 0; i < GetRowCount(); i++) { bool isMemory; int index = getBreakpointIndex(i, isMemory); if (isMemory) SetCheckState(i,(displayedMemChecks_[index].result & MEMCHECK_BREAK) != 0); else SetCheckState(i,displayedBreakPoints_[index].enabled); } }
void CDisasm::gotoBreakpointAddress(int itemIndex) { bool isMemory; int index = getBreakpointIndex(itemIndex,isMemory); if (index == -1) return; if (isMemory) { u32 address = displayedMemChecks_[index].start; for (int i=0; i<numCPUs; i++) if (memoryWindow[i]) memoryWindow[i]->Goto(address); } else { u32 address = displayedBreakPoints_[index].addr; Goto(address); SetFocus(GetDlgItem(m_hDlg, IDC_DISASMVIEW)); } }
void CtrlBreakpointList::reloadBreakpoints() { // Update the items we're displaying from the debugger. displayedBreakPoints_ = CBreakPoints::GetBreakpoints(); displayedMemChecks_= CBreakPoints::GetMemChecks(); Update(); for (int i = 0; i < GetRowCount(); i++) { bool isMemory; int index = getBreakpointIndex(i, isMemory); if (index < 0) continue; if (isMemory) SetCheckState(i, displayedMemChecks_[index].IsEnabled()); else SetCheckState(i, displayedBreakPoints_[index].IsEnabled()); } }
void CtrlBreakpointList::gotoBreakpointAddress(int itemIndex) { bool isMemory; int index = getBreakpointIndex(itemIndex,isMemory); if (index == -1) return; if (isMemory) { u32 address = displayedMemChecks_[index].start; for (int i=0; i<numCPUs; i++) if (memoryWindow[i]) memoryWindow[i]->Goto(address); } else { u32 address = displayedBreakPoints_[index].addr; for (int i=0; i<numCPUs; i++) if (disasmWindow[i]) disasmWindow[i]->Goto(address); } }
void CtrlBreakpointList::handleNotify(LPARAM lParam) { const LPNMHDR header = (LPNMHDR)lParam; if (header->code == NM_DBLCLK) { const LPNMITEMACTIVATE item = (LPNMITEMACTIVATE) lParam; gotoBreakpointAddress(item->iItem); return; } if (header->code == NM_RCLICK) { const LPNMITEMACTIVATE item = (LPNMITEMACTIVATE)lParam; showBreakpointMenu(item->iItem, item->ptAction); return; } if (header->code == LVN_GETDISPINFO) { NMLVDISPINFO *dispInfo = (NMLVDISPINFO *)lParam; bool isMemory; int index = getBreakpointIndex(dispInfo->item.iItem,isMemory); if (index == -1) return; breakpointText = L""; switch (dispInfo->item.iSubItem) { case BPL_TYPE: { if (isMemory) { switch (displayedMemChecks_[index].cond) { case MEMCHECK_READ: breakpointText = L"Read"; break; case MEMCHECK_WRITE: breakpointText = L"Write"; break; case MEMCHECK_READWRITE: breakpointText = L"Read/Write"; break; } } else { breakpointText = L"Execute"; } } break; case BPL_OFFSET: { wchar_t temp[256]; if (isMemory) { wsprintf(temp,L"0x%08X",displayedMemChecks_[index].start); } else { wsprintf(temp,L"0x%08X",displayedBreakPoints_[index].addr); } breakpointText = temp; } break; case BPL_SIZELABEL: { if (isMemory) { auto mc = displayedMemChecks_[index]; wchar_t temp[256]; if (mc.end == 0) wsprintf(temp,L"0x%08X",1); else wsprintf(temp,L"0x%08X",mc.end-mc.start); breakpointText = temp; } else { const char* sym = cpu->findSymbolForAddress(displayedBreakPoints_[index].addr); if (sym != NULL) { breakpointText = ConvertUTF8ToWString(sym); } else { breakpointText = L"-"; } } } break; case BPL_OPCODE: { if (isMemory) { breakpointText = L"-"; } else { char temp[256]; disasm->getOpcodeText(displayedBreakPoints_[index].addr, temp); breakpointText = ConvertUTF8ToWString(temp); } } break; case BPL_CONDITION: { if (isMemory || displayedBreakPoints_[index].hasCond == false) { breakpointText = L"-"; } else { breakpointText = ConvertUTF8ToWString(displayedBreakPoints_[index].cond.expressionString); } } break; case BPL_HITS: { if (isMemory) { wchar_t temp[256]; wsprintf(temp,L"%d",displayedMemChecks_[index].numHits); breakpointText = temp; } else { breakpointText = L"-"; } } break; case BPL_ENABLED: { if (isMemory) { breakpointText = displayedMemChecks_[index].result & MEMCHECK_BREAK ? L"True" : L"False"; } else { breakpointText = displayedBreakPoints_[index].enabled ? L"True" : L"False"; } } break; default: return; } if (breakpointText.empty()) breakpointText = L"Invalid"; dispInfo->item.pszText = &breakpointText[0]; } }
void CtrlBreakpointList::GetColumnText(wchar_t* dest, int row, int col) { if (!PSP_IsInited()) { return; } bool isMemory; int index = getBreakpointIndex(row,isMemory); if (index == -1) return; switch (col) { case BPL_TYPE: { if (isMemory) { switch ((int)displayedMemChecks_[index].cond) { case MEMCHECK_READ: wcscpy(dest,L"Read"); break; case MEMCHECK_WRITE: wcscpy(dest,L"Write"); break; case MEMCHECK_READWRITE: wcscpy(dest,L"Read/Write"); break; case MEMCHECK_WRITE | MEMCHECK_WRITE_ONCHANGE: wcscpy(dest,L"Write Change"); break; case MEMCHECK_READWRITE | MEMCHECK_WRITE_ONCHANGE: wcscpy(dest,L"Read/Write Change"); break; } } else { wcscpy(dest,L"Execute"); } } break; case BPL_OFFSET: { if (isMemory) { wsprintf(dest,L"0x%08X",displayedMemChecks_[index].start); } else { wsprintf(dest,L"0x%08X",displayedBreakPoints_[index].addr); } } break; case BPL_SIZELABEL: { if (isMemory) { auto mc = displayedMemChecks_[index]; if (mc.end == 0) wsprintf(dest,L"0x%08X",1); else wsprintf(dest,L"0x%08X",mc.end-mc.start); } else { const std::string sym = g_symbolMap->GetLabelString(displayedBreakPoints_[index].addr); if (!sym.empty()) { std::wstring s = ConvertUTF8ToWString(sym); wcscpy(dest,s.c_str()); } else { wcscpy(dest,L"-"); } } } break; case BPL_OPCODE: { if (isMemory) { wcscpy(dest,L"-"); } else { char temp[256]; disasm->getOpcodeText(displayedBreakPoints_[index].addr, temp, sizeof(temp)); std::wstring s = ConvertUTF8ToWString(temp); wcscpy(dest,s.c_str()); } } break; case BPL_CONDITION: { if (isMemory || displayedBreakPoints_[index].hasCond == false) { wcscpy(dest,L"-"); } else { std::wstring s = ConvertUTF8ToWString(displayedBreakPoints_[index].cond.expressionString); wcscpy(dest,s.c_str()); } } break; case BPL_HITS: { if (isMemory) { wsprintf(dest,L"%d",displayedMemChecks_[index].numHits); } else { wsprintf(dest,L"-"); } } break; case BPL_ENABLED: { wsprintf(dest,L"\xFFFE"); } break; } }
void CtrlBreakpointList::GetColumnText(wchar_t* dest, int row, int col) { bool isMemory; int index = getBreakpointIndex(row,isMemory); if (index == -1) return; switch (col) { case BPL_TYPE: { if (isMemory) { switch (displayedMemChecks_[index].cond) { case MEMCHECK_READ: wcscpy(dest,L"Read"); break; case MEMCHECK_WRITE: wcscpy(dest,L"Write"); break; case MEMCHECK_READWRITE: wcscpy(dest,L"Read/Write"); break; } } else { wcscpy(dest,L"Execute"); } } break; case BPL_OFFSET: { if (isMemory) { wsprintf(dest,L"0x%08X",displayedMemChecks_[index].start); } else { wsprintf(dest,L"0x%08X",displayedBreakPoints_[index].addr); } } break; case BPL_SIZELABEL: { if (isMemory) { auto mc = displayedMemChecks_[index]; if (mc.end == 0) wsprintf(dest,L"0x%08X",1); else wsprintf(dest,L"0x%08X",mc.end-mc.start); } else { const char* sym = cpu->findSymbolForAddress(displayedBreakPoints_[index].addr); if (sym != NULL) { std::wstring s = ConvertUTF8ToWString(sym); wcscpy(dest,s.c_str()); } else { wcscpy(dest,L"-"); } } } break; case BPL_OPCODE: { if (isMemory) { wcscpy(dest,L"-"); } else { char temp[256]; disasm->getOpcodeText(displayedBreakPoints_[index].addr, temp); std::wstring s = ConvertUTF8ToWString(temp); wcscpy(dest,s.c_str()); } } break; case BPL_CONDITION: { if (isMemory || displayedBreakPoints_[index].hasCond == false) { wcscpy(dest,L"-"); } else { std::wstring s = ConvertUTF8ToWString(displayedBreakPoints_[index].cond.expressionString); wcscpy(dest,s.c_str()); } } break; case BPL_HITS: { if (isMemory) { wsprintf(dest,L"%d",displayedMemChecks_[index].numHits); } else { wsprintf(dest,L"-"); } } break; case BPL_ENABLED: { if (isMemory) { wsprintf(dest,displayedMemChecks_[index].result & MEMCHECK_BREAK ? L"True" : L"False"); } else { wsprintf(dest,displayedBreakPoints_[index].enabled ? L"True" : L"False"); } } break; } }
wxString BreakpointList::OnGetItemText(long item, long col) const { wchar_t dest[256]; bool isMemory; int index = getBreakpointIndex(item,isMemory); if (index == -1) return L"Invalid"; switch (col) { case BPL_TYPE: { if (isMemory) { switch ((int)displayedMemChecks_[index].cond) { case MEMCHECK_READ: wcscpy(dest,L"Read"); break; case MEMCHECK_WRITE: wcscpy(dest,L"Write"); break; case MEMCHECK_READWRITE: wcscpy(dest,L"Read/Write"); break; case MEMCHECK_WRITE | MEMCHECK_WRITE_ONCHANGE: wcscpy(dest,L"Write Change"); break; case MEMCHECK_READWRITE | MEMCHECK_WRITE_ONCHANGE: wcscpy(dest,L"Read/Write Change"); break; } } else { wcscpy(dest,L"Execute"); } } break; case BPL_OFFSET: { if (isMemory) { swprintf(dest,256,L"0x%08X",displayedMemChecks_[index].start); } else { swprintf(dest,256,L"0x%08X",displayedBreakPoints_[index].addr); } } break; case BPL_SIZELABEL: { if (isMemory) { auto mc = displayedMemChecks_[index]; if (mc.end == 0) swprintf(dest,256,L"0x%08X",1); else swprintf(dest,256,L"0x%08X",mc.end-mc.start); } else { const std::string sym = symbolMap.GetLabelString(displayedBreakPoints_[index].addr); if (!sym.empty()) { #ifdef __LINUX__ swprintf(dest,256,L"%s",sym.c_str()); #else swprintf(dest,256,L"%S",sym.c_str()); #endif } else { wcscpy(dest,L"-"); } } } break; case BPL_OPCODE: { if (isMemory) { wcscpy(dest,L"-"); } else { char temp[256]; disasm->getOpcodeText(displayedBreakPoints_[index].addr, temp); #ifdef __LINUX__ swprintf(dest,256,L"%s",temp); #else swprintf(dest,256,L"%S",temp); #endif } } break; case BPL_CONDITION: { if (isMemory || displayedBreakPoints_[index].hasCond == false) { wcscpy(dest,L"-"); } else { #ifdef __LINUX__ swprintf(dest,256,L"%s",displayedBreakPoints_[index].cond.expressionString); #else swprintf(dest,256,L"%S",displayedBreakPoints_[index].cond.expressionString); #endif } } break; case BPL_HITS: { if (isMemory) { swprintf(dest,256,L"%d",displayedMemChecks_[index].numHits); } else { swprintf(dest,256,L"-"); } } break; case BPL_ENABLED: { if (isMemory) { #ifdef __LINUX__ swprintf(dest,256,L"%s",displayedMemChecks_[index].cond & MEMCHECK_BREAK ? "true" : "false"); #else swprintf(dest,256,L"%S",displayedMemChecks_[index].cond & MEMCHECK_BREAK ? "true" : "false"); #endif } else { #ifdef __LINUX__ swprintf(dest,256,L"%s",displayedBreakPoints_[index].enabled ? "true" : "false"); #else swprintf(dest,256,L"%S",displayedBreakPoints_[index].enabled ? "true" : "false"); #endif } } break; default: return L"Invalid"; } return dest; }
void CDisasm::handleBreakpointNotify(LPARAM lParam) { if (((LPNMHDR)lParam)->code == NM_DBLCLK) { LPNMITEMACTIVATE item = (LPNMITEMACTIVATE) lParam; gotoBreakpointAddress(item->iItem); return; } if (((LPNMHDR)lParam)->code == LVN_GETDISPINFO) { NMLVDISPINFO* dispInfo = (NMLVDISPINFO*)lParam; bool isMemory; int index = getBreakpointIndex(dispInfo->item.iItem,isMemory); if (index == -1) return; breakpointText[0] = 0; switch (dispInfo->item.iSubItem) { case BPL_TYPE: { if (isMemory) { switch (displayedMemChecks_[index].cond) { case MEMCHECK_READ: strcpy(breakpointText, "Read"); break; case MEMCHECK_WRITE: strcpy(breakpointText, "Write"); break; case MEMCHECK_READWRITE: strcpy(breakpointText, "Read/Write"); break; } } else { strcpy(breakpointText,"Execute"); } } break; case BPL_OFFSET: { if (isMemory) { sprintf(breakpointText,"0x%08X",displayedMemChecks_[index].start); } else { sprintf(breakpointText,"0x%08X",displayedBreakPoints_[index].addr); } } break; case BPL_SIZELABEL: { if (isMemory) { auto mc = displayedMemChecks_[index]; if (mc.end == 0) sprintf(breakpointText,"0x%08X",1); else sprintf(breakpointText,"0x%08X",mc.end-mc.start); } else { const char* sym = cpu->findSymbolForAddress(displayedBreakPoints_[index].addr); if (sym != NULL) { strcpy(breakpointText,sym); } else { strcpy(breakpointText,"-"); } } } break; case BPL_OPCODE: { if (isMemory) { strcpy(breakpointText,"-"); } else { CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); ptr->getOpcodeText(displayedBreakPoints_[index].addr,breakpointText); } } break; case BPL_HITS: { if (isMemory) { sprintf(breakpointText,"%d",displayedMemChecks_[index].numHits); } else { strcpy(breakpointText,"-"); } } break; case BPL_ENABLED: { if (isMemory) { strcpy(breakpointText,displayedMemChecks_[index].result & MEMCHECK_BREAK ? "True" : "False"); } else { strcpy(breakpointText,displayedBreakPoints_[index].enabled ? "True" : "False"); } } break; default: return; } if (breakpointText[0] == 0) strcat(breakpointText,"Invalid"); dispInfo->item.pszText = breakpointText; } }