void CCodeView::OnMouseUpR(wxMouseEvent& event) { bool isSymbol = m_symbol_db->GetSymbolFromAddr(m_selection) != nullptr; // popup menu wxMenu menu; // menu->Append(IDM_GOTOINMEMVIEW, "&Goto in mem view"); menu.Append(IDM_FOLLOWBRANCH, _("&Follow branch")) ->Enable(AddrToBranch(m_selection) ? true : false); menu.AppendSeparator(); #if wxUSE_CLIPBOARD menu.Append(IDM_COPYADDRESS, _("Copy &address")); menu.Append(IDM_COPYFUNCTION, _("Copy &function"))->Enable(isSymbol); menu.Append(IDM_COPYCODE, _("Copy &code line")); menu.Append(IDM_COPYHEX, _("Copy &hex")); menu.AppendSeparator(); #endif menu.Append(IDM_RENAMESYMBOL, _("Rename &symbol"))->Enable(isSymbol); menu.AppendSeparator(); menu.Append(IDM_RUNTOHERE, _("&Run To Here"))->Enable(Core::IsRunning()); menu.Append(IDM_ADDFUNCTION, _("&Add function"))->Enable(Core::IsRunning()); menu.Append(IDM_JITRESULTS, _("PPC vs X86"))->Enable(Core::IsRunning()); menu.Append(IDM_INSERTBLR, _("Insert &blr"))->Enable(Core::IsRunning()); menu.Append(IDM_INSERTNOP, _("Insert &nop"))->Enable(Core::IsRunning()); menu.Append(IDM_PATCHALERT, _("Patch alert"))->Enable(Core::IsRunning()); PopupMenu(&menu); event.Skip(); }
void CCodeView::OnPopupMenu(wxCommandEvent& event) { #if wxUSE_CLIPBOARD wxTheClipboard->Open(); #endif switch (event.GetId()) { case IDM_GOTOINMEMVIEW: // CMemoryDlg::Goto(selection); break; #if wxUSE_CLIPBOARD case IDM_COPYADDRESS: wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(_T("%08x"), selection))); break; case IDM_COPYCODE: { char disasm[256]; debugger->Disassemble(selection, disasm, 256); wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(disasm))); } break; case IDM_COPYHEX: { char temp[24]; sprintf(temp, "%08x", debugger->ReadInstruction(selection)); wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(temp))); } break; case IDM_COPYFUNCTION: { Symbol *symbol = symbol_db->GetSymbolFromAddr(selection); if (symbol) { std::string text; text = text + symbol->name + "\r\n"; // we got a function u32 start = symbol->address; u32 end = start + symbol->size; for (u32 addr = start; addr != end; addr += 4) { char disasm[256]; debugger->Disassemble(addr, disasm, 256); text = text + StringFromFormat("%08x: ", addr) + disasm + "\r\n"; } wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(text))); } } break; #endif case IDM_RUNTOHERE: debugger->SetBreakpoint(selection); debugger->RunToBreakpoint(); Refresh(); break; // Insert blr or restore old value case IDM_INSERTBLR: InsertBlrNop(0); Refresh(); break; case IDM_INSERTNOP: InsertBlrNop(1); Refresh(); break; case IDM_JITRESULTS: debugger->ShowJitResults(selection); break; case IDM_FOLLOWBRANCH: { u32 dest = AddrToBranch(selection); if (dest) { Center(dest); RaiseEvent(); } } break; case IDM_ADDFUNCTION: symbol_db->AddFunction(selection); Host_NotifyMapLoaded(); break; case IDM_RENAMESYMBOL: { Symbol *symbol = symbol_db->GetSymbolFromAddr(selection); if (symbol) { wxTextEntryDialog input_symbol(this, StrToWxStr("Rename symbol:"), wxGetTextFromUserPromptStr, StrToWxStr(symbol->name)); if (input_symbol.ShowModal() == wxID_OK) { symbol->name = WxStrToStr(input_symbol.GetValue()); Refresh(); // Redraw to show the renamed symbol } Host_NotifyMapLoaded(); } } break; case IDM_PATCHALERT: break; } #if wxUSE_CLIPBOARD wxTheClipboard->Close(); #endif event.Skip(true); }
void CCodeView::OnPopupMenu(wxCommandEvent& event) { #if wxUSE_CLIPBOARD wxTheClipboard->Open(); #endif switch (event.GetId()) { case IDM_GOTOINMEMVIEW: // CMemoryDlg::Goto(selection); break; #if wxUSE_CLIPBOARD case IDM_COPYADDRESS: wxTheClipboard->SetData(new wxTextDataObject(wxString::Format("%08x", m_selection))); break; case IDM_COPYCODE: { std::string disasm = m_debugger->Disassemble(m_selection); wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(disasm))); } break; case IDM_COPYHEX: { std::string temp = StringFromFormat("%08x", m_debugger->ReadInstruction(m_selection)); wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(temp))); } break; case IDM_COPYFUNCTION: { Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection); if (symbol) { std::string text; text = text + symbol->name + "\r\n"; // we got a function u32 start = symbol->address; u32 end = start + symbol->size; for (u32 addr = start; addr != end; addr += 4) { std::string disasm = m_debugger->Disassemble(addr); text += StringFromFormat("%08x: ", addr) + disasm + "\r\n"; } wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(text))); } } break; #endif case IDM_RUNTOHERE: m_debugger->SetBreakpoint(m_selection); m_debugger->RunToBreakpoint(); Refresh(); break; // Insert blr or restore old value case IDM_INSERTBLR: InsertBlrNop(0); Refresh(); break; case IDM_INSERTNOP: InsertBlrNop(1); Refresh(); break; case IDM_JITRESULTS: { // Propagate back to the parent window and tell it // to flip to the JIT tab for the current address. wxCommandEvent jit_event(wxEVT_HOST_COMMAND, IDM_UPDATE_JIT_PANE); GetEventHandler()->AddPendingEvent(jit_event); } break; case IDM_FOLLOWBRANCH: { u32 dest = AddrToBranch(m_selection); if (dest) { Center(dest); RaiseEvent(); } } break; case IDM_ADDFUNCTION: m_symbol_db->AddFunction(m_selection); Host_NotifyMapLoaded(); break; case IDM_RENAMESYMBOL: { Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection); if (symbol) { wxTextEntryDialog input_symbol(this, _("Rename symbol:"), wxGetTextFromUserPromptStr, StrToWxStr(symbol->name)); if (input_symbol.ShowModal() == wxID_OK) { symbol->name = WxStrToStr(input_symbol.GetValue()); Refresh(); // Redraw to show the renamed symbol } Host_NotifyMapLoaded(); } } break; case IDM_PATCHALERT: break; } #if wxUSE_CLIPBOARD wxTheClipboard->Close(); #endif event.Skip(); }
void CCodeView::OnPopupMenu(wxCommandEvent& event) { switch (event.GetId()) { case IDM_GOTOINMEMVIEW: // CMemoryDlg::Goto(selection); break; #if wxUSE_CLIPBOARD case IDM_COPYADDRESS: { wxClipboardLocker locker; wxTheClipboard->SetData(new wxTextDataObject(wxString::Format("%08x", m_selection))); } break; case IDM_COPYCODE: { wxClipboardLocker locker; std::string disasm = m_debugger->Disassemble(m_selection); wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(disasm))); } break; case IDM_COPYHEX: { wxClipboardLocker locker; wxTheClipboard->SetData( new wxTextDataObject(wxString::Format("%08x", m_debugger->ReadInstruction(m_selection)))); } break; case IDM_COPYFUNCTION: { Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection); if (symbol) { std::string text; text = text + symbol->name + "\r\n"; // we got a function u32 start = symbol->address; u32 end = start + symbol->size; for (u32 addr = start; addr != end; addr += 4) { std::string disasm = m_debugger->Disassemble(addr); text += StringFromFormat("%08x: ", addr) + disasm + "\r\n"; } wxClipboardLocker locker; wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(text))); } } break; #endif case IDM_RUNTOHERE: m_debugger->SetBreakpoint(m_selection); m_debugger->RunToBreakpoint(); Refresh(); break; // Insert blr or restore old value case IDM_INSERTBLR: InsertBlrNop(0); Refresh(); break; case IDM_INSERTNOP: InsertBlrNop(1); Refresh(); break; case IDM_ASSEMBLE: { if (!PowerPC::HostIsInstructionRAMAddress(m_selection)) break; const PowerPC::TryReadInstResult read_result = PowerPC::TryReadInstruction(m_selection); if (!read_result.valid) break; AssemblerEntryDialog dialog(m_selection, this, _("Enter instruction code:"), wxGetTextFromUserPromptStr, wxString::Format(wxT("%#08x"), read_result.hex)); if (dialog.ShowModal() == wxID_OK) { unsigned long code; if (dialog.GetValue().ToULong(&code, 0) && code <= std::numeric_limits<u32>::max()) { m_debugger->InsertBLR(m_selection, code); Refresh(); } } break; } case IDM_JITRESULTS: { // Propagate back to the parent window and tell it // to flip to the JIT tab for the current address. wxCommandEvent jit_event(wxEVT_HOST_COMMAND, IDM_UPDATE_JIT_PANE); GetEventHandler()->AddPendingEvent(jit_event); } break; case IDM_FOLLOWBRANCH: { u32 dest = AddrToBranch(m_selection); if (dest) { Center(dest); RaiseEvent(); } } break; case IDM_ADDFUNCTION: m_symbol_db->AddFunction(m_selection); Host_NotifyMapLoaded(); break; case IDM_RENAMESYMBOL: { Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection); if (symbol) { wxTextEntryDialog input_symbol(this, _("Rename symbol:"), wxGetTextFromUserPromptStr, StrToWxStr(symbol->name)); if (input_symbol.ShowModal() == wxID_OK) { symbol->name = WxStrToStr(input_symbol.GetValue()); Refresh(); // Redraw to show the renamed symbol } Host_NotifyMapLoaded(); } } break; case IDM_SETSYMBOLSIZE: { Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection); if (!symbol) break; wxTextEntryDialog dialog(this, wxString::Format(_("Enter symbol (%s) size:"), symbol->name.c_str()), wxGetTextFromUserPromptStr, wxString::Format(wxT("%i"), symbol->size)); if (dialog.ShowModal() == wxID_OK) { unsigned long size; if (dialog.GetValue().ToULong(&size, 0) && size <= std::numeric_limits<u32>::max()) { PPCAnalyst::ReanalyzeFunction(symbol->address, *symbol, size); Refresh(); Host_NotifyMapLoaded(); } } } break; case IDM_SETSYMBOLEND: { Symbol* symbol = m_symbol_db->GetSymbolFromAddr(m_selection); if (!symbol) break; wxTextEntryDialog dialog( this, wxString::Format(_("Enter symbol (%s) end address:"), symbol->name.c_str()), wxGetTextFromUserPromptStr, wxString::Format(wxT("%#08x"), symbol->address + symbol->size)); if (dialog.ShowModal() == wxID_OK) { unsigned long address; if (dialog.GetValue().ToULong(&address, 0) && address <= std::numeric_limits<u32>::max() && address >= symbol->address) { PPCAnalyst::ReanalyzeFunction(symbol->address, *symbol, address - symbol->address); Refresh(); Host_NotifyMapLoaded(); } } } break; case IDM_PATCHALERT: break; default: event.Skip(); break; } }