Esempio n. 1
0
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();
}
Esempio n. 2
0
void CBoot::UpdateDebugger_MapLoaded()
{
	Host_NotifyMapLoaded();
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
void CBoot::UpdateDebugger_MapLoaded(const char *_gameID)
{
	Host_NotifyMapLoaded();
}
// Stop the emulation
void CFrame::DoStop()
{
  if (!Core::IsRunningAndStarted())
    return;
  if (m_confirmStop)
    return;

  // don't let this function run again until it finishes, or is aborted.
  m_confirmStop = true;

  m_bGameLoading = false;
  if (Core::GetState() != Core::CORE_UNINITIALIZED || m_RenderParent != nullptr)
  {
#if defined __WXGTK__
    wxMutexGuiLeave();
    std::lock_guard<std::recursive_mutex> lk(keystate_lock);
    wxMutexGuiEnter();
#endif
    // Ask for confirmation in case the user accidentally clicked Stop / Escape
    if (SConfig::GetInstance().bConfirmStop)
    {
      // Exit fullscreen to ensure it does not cover the stop dialog.
      DoFullscreen(false);

      // Pause the state during confirmation and restore it afterwards
      Core::EState state = Core::GetState();

      // Do not pause if netplay is running as CPU thread might be blocked
      // waiting on inputs
      bool should_pause = !NetPlayDialog::GetNetPlayClient();

      // If exclusive fullscreen is not enabled then we can pause the emulation
      // before we've exited fullscreen. If not then we need to exit fullscreen first.
      should_pause =
          should_pause && (!RendererIsFullscreen() || !g_Config.ExclusiveFullscreenEnabled() ||
                           SConfig::GetInstance().bRenderToMain);

      if (should_pause)
      {
        Core::SetState(Core::CORE_PAUSE);
      }

      wxMessageDialog m_StopDlg(
          this, !m_tried_graceful_shutdown ? _("Do you want to stop the current emulation?") :
                                             _("A shutdown is already in progress. Unsaved data "
                                               "may be lost if you stop the current emulation "
                                               "before it completes. Force stop?"),
          _("Please confirm..."), wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION, wxDefaultPosition);

      HotkeyManagerEmu::Enable(false);
      int Ret = m_StopDlg.ShowModal();
      HotkeyManagerEmu::Enable(true);
      if (Ret != wxID_YES)
      {
        if (should_pause)
          Core::SetState(state);

        m_confirmStop = false;
        return;
      }
    }

    const auto& stm = WII_IPC_HLE_Interface::GetDeviceByName("/dev/stm/eventhook");
    if (!m_tried_graceful_shutdown && stm &&
        std::static_pointer_cast<CWII_IPC_HLE_Device_stm_eventhook>(stm)->HasHookInstalled())
    {
      Core::DisplayMessage("Shutting down", 30000);
      // Unpause because gracefully shutting down needs the game to actually request a shutdown
      if (Core::GetState() == Core::CORE_PAUSE)
        DoPause();
      ProcessorInterface::PowerButton_Tap();
      m_confirmStop = false;
      m_tried_graceful_shutdown = true;
      return;
    }

    if (UseDebugger && g_pCodeWindow)
    {
      if (g_pCodeWindow->HasPanel<CWatchWindow>())
        g_pCodeWindow->GetPanel<CWatchWindow>()->SaveAll();
      PowerPC::watches.Clear();
      if (g_pCodeWindow->HasPanel<CBreakPointWindow>())
        g_pCodeWindow->GetPanel<CBreakPointWindow>()->SaveAll();
      PowerPC::breakpoints.Clear();
      PowerPC::memchecks.Clear();
      if (g_pCodeWindow->HasPanel<CBreakPointWindow>())
        g_pCodeWindow->GetPanel<CBreakPointWindow>()->NotifyUpdate();
      g_symbolDB.Clear();
      Host_NotifyMapLoaded();
    }

    // TODO: Show the author/description dialog here
    if (Movie::IsRecordingInput())
      DoRecordingSave();
    if (Movie::IsMovieActive())
      Movie::EndPlayInput(false);

    if (NetPlayDialog::GetNetPlayClient())
      NetPlayDialog::GetNetPlayClient()->Stop();

    Core::Stop();
    UpdateGUI();
  }
}
Esempio n. 6
0
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;
  }
}