mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Remove unnecessary Src/ folders
This commit is contained in:
45
Source/Core/DolphinWX/Debugger/BreakpointDlg.cpp
Normal file
45
Source/Core/DolphinWX/Debugger/BreakpointDlg.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "BreakpointDlg.h"
|
||||
#include "StringUtil.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "BreakpointWindow.h"
|
||||
#include "../WxUtils.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(BreakPointDlg, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, BreakPointDlg::OnOK)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BreakPointDlg::BreakPointDlg(CBreakPointWindow *_Parent)
|
||||
: wxDialog(_Parent, wxID_ANY, wxT("BreakPoint"), wxDefaultPosition, wxDefaultSize)
|
||||
, Parent(_Parent)
|
||||
{
|
||||
m_pEditAddress = new wxTextCtrl(this, wxID_ANY, wxT("80000000"));
|
||||
|
||||
wxBoxSizer *sMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
sMainSizer->Add(m_pEditAddress, 0, wxEXPAND | wxALL, 5);
|
||||
sMainSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALL, 5);
|
||||
|
||||
SetSizerAndFit(sMainSizer);
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
void BreakPointDlg::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
wxString AddressString = m_pEditAddress->GetLineText(0);
|
||||
u32 Address = 0;
|
||||
if (AsciiToHex(WxStrToStr(AddressString).c_str(), Address))
|
||||
{
|
||||
PowerPC::breakpoints.Add(Address);
|
||||
Parent->NotifyUpdate();
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
PanicAlert("The address %s is invalid.", WxStrToStr(AddressString).c_str());
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
27
Source/Core/DolphinWX/Debugger/BreakpointDlg.h
Normal file
27
Source/Core/DolphinWX/Debugger/BreakpointDlg.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef __BREAKPOINTDLG_h__
|
||||
#define __BREAKPOINTDLG_h__
|
||||
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class CBreakPointWindow;
|
||||
|
||||
class BreakPointDlg : public wxDialog
|
||||
{
|
||||
public:
|
||||
BreakPointDlg(CBreakPointWindow *_Parent);
|
||||
|
||||
private:
|
||||
CBreakPointWindow *Parent;
|
||||
wxTextCtrl *m_pEditAddress;
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif
|
103
Source/Core/DolphinWX/Debugger/BreakpointView.cpp
Normal file
103
Source/Core/DolphinWX/Debugger/BreakpointView.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "BreakpointView.h"
|
||||
#include "DebuggerUIUtil.h"
|
||||
#include "Debugger/Debugger_SymbolMap.h"
|
||||
#include "PowerPC/PPCSymbolDB.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "HW/Memmap.h"
|
||||
#include "../WxUtils.h"
|
||||
|
||||
CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id)
|
||||
: wxListCtrl(parent, id, wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING)
|
||||
{
|
||||
SetFont(DebuggerFont);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void CBreakPointView::Update()
|
||||
{
|
||||
ClearAll();
|
||||
|
||||
InsertColumn(0, wxT("Active"));
|
||||
InsertColumn(1, wxT("Type"));
|
||||
InsertColumn(2, wxT("Function"));
|
||||
InsertColumn(3, wxT("Address"));
|
||||
InsertColumn(4, wxT("Flags"));
|
||||
|
||||
char szBuffer[64];
|
||||
const BreakPoints::TBreakPoints& rBreakPoints = PowerPC::breakpoints.GetBreakPoints();
|
||||
for (const auto& rBP : rBreakPoints)
|
||||
{
|
||||
if (!rBP.bTemporary)
|
||||
{
|
||||
wxString temp;
|
||||
temp = StrToWxStr(rBP.bOn ? "on" : " ");
|
||||
int Item = InsertItem(0, temp);
|
||||
temp = StrToWxStr("BP");
|
||||
SetItem(Item, 1, temp);
|
||||
|
||||
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rBP.iAddress);
|
||||
if (symbol)
|
||||
{
|
||||
temp = StrToWxStr(g_symbolDB.GetDescription(rBP.iAddress));
|
||||
SetItem(Item, 2, temp);
|
||||
}
|
||||
|
||||
sprintf(szBuffer, "%08x", rBP.iAddress);
|
||||
temp = StrToWxStr(szBuffer);
|
||||
SetItem(Item, 3, temp);
|
||||
|
||||
SetItemData(Item, rBP.iAddress);
|
||||
}
|
||||
}
|
||||
|
||||
const MemChecks::TMemChecks& rMemChecks = PowerPC::memchecks.GetMemChecks();
|
||||
for (const auto& rMemCheck : rMemChecks)
|
||||
{
|
||||
wxString temp;
|
||||
temp = StrToWxStr((rMemCheck.Break || rMemCheck.Log) ? "on" : " ");
|
||||
int Item = InsertItem(0, temp);
|
||||
temp = StrToWxStr("MC");
|
||||
SetItem(Item, 1, temp);
|
||||
|
||||
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.StartAddress);
|
||||
if (symbol)
|
||||
{
|
||||
temp = StrToWxStr(g_symbolDB.GetDescription(rMemCheck.StartAddress));
|
||||
SetItem(Item, 2, temp);
|
||||
}
|
||||
|
||||
sprintf(szBuffer, "%08x to %08x", rMemCheck.StartAddress, rMemCheck.EndAddress);
|
||||
temp = StrToWxStr(szBuffer);
|
||||
SetItem(Item, 3, temp);
|
||||
|
||||
size_t c = 0;
|
||||
if (rMemCheck.OnRead) szBuffer[c++] = 'r';
|
||||
if (rMemCheck.OnWrite) szBuffer[c++] = 'w';
|
||||
szBuffer[c] = 0x00;
|
||||
temp = StrToWxStr(szBuffer);
|
||||
SetItem(Item, 4, temp);
|
||||
|
||||
SetItemData(Item, rMemCheck.StartAddress);
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void CBreakPointView::DeleteCurrentSelection()
|
||||
{
|
||||
int Item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
|
||||
if (Item >= 0)
|
||||
{
|
||||
u32 Address = (u32)GetItemData(Item);
|
||||
PowerPC::breakpoints.Remove(Address);
|
||||
PowerPC::memchecks.Remove(Address);
|
||||
Update();
|
||||
}
|
||||
}
|
20
Source/Core/DolphinWX/Debugger/BreakpointView.h
Normal file
20
Source/Core/DolphinWX/Debugger/BreakpointView.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef __BREAKPOINTVIEW_h__
|
||||
#define __BREAKPOINTVIEW_h__
|
||||
|
||||
#include <wx/listctrl.h>
|
||||
#include "Common.h"
|
||||
|
||||
class CBreakPointView : public wxListCtrl
|
||||
{
|
||||
public:
|
||||
CBreakPointView(wxWindow* parent, const wxWindowID id);
|
||||
|
||||
void Update();
|
||||
void DeleteCurrentSelection();
|
||||
};
|
||||
|
||||
#endif
|
189
Source/Core/DolphinWX/Debugger/BreakpointWindow.cpp
Normal file
189
Source/Core/DolphinWX/Debugger/BreakpointWindow.cpp
Normal file
@ -0,0 +1,189 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "BreakpointWindow.h"
|
||||
#include "BreakpointView.h"
|
||||
#include "CodeWindow.h"
|
||||
#include "HW/Memmap.h"
|
||||
#include "BreakpointDlg.h"
|
||||
#include "MemoryCheckDlg.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
extern "C" {
|
||||
#include "../resources/toolbar_add_breakpoint.c"
|
||||
#include "../resources/toolbar_add_memorycheck.c"
|
||||
#include "../resources/toolbar_debugger_delete.c"
|
||||
}
|
||||
|
||||
class CBreakPointBar : public wxAuiToolBar
|
||||
{
|
||||
public:
|
||||
CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id)
|
||||
: wxAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize,
|
||||
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT)
|
||||
{
|
||||
SetToolBitmapSize(wxSize(24, 24));
|
||||
|
||||
m_Bitmaps[Toolbar_Delete] =
|
||||
wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(24, 24));
|
||||
m_Bitmaps[Toolbar_Add_BP] =
|
||||
wxBitmap(wxGetBitmapFromMemory(toolbar_add_breakpoint_png).ConvertToImage().Rescale(24, 24));
|
||||
m_Bitmaps[Toolbar_Add_MC] =
|
||||
wxBitmap(wxGetBitmapFromMemory(toolbar_add_memcheck_png).ConvertToImage().Rescale(24, 24));
|
||||
|
||||
AddTool(ID_DELETE, wxT("Delete"), m_Bitmaps[Toolbar_Delete]);
|
||||
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::OnDelete, parent, ID_DELETE);
|
||||
|
||||
AddTool(ID_CLEAR, wxT("Clear"), m_Bitmaps[Toolbar_Delete]);
|
||||
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::OnClear, parent, ID_CLEAR);
|
||||
|
||||
AddTool(ID_ADDBP, wxT("+BP"), m_Bitmaps[Toolbar_Add_BP]);
|
||||
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::OnAddBreakPoint, parent, ID_ADDBP);
|
||||
|
||||
// Add memory breakpoints if you can use them
|
||||
if (Memory::AreMemoryBreakpointsActivated())
|
||||
{
|
||||
AddTool(ID_ADDMC, wxT("+MC"), m_Bitmaps[Toolbar_Add_MC]);
|
||||
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::OnAddMemoryCheck, parent, ID_ADDMC);
|
||||
}
|
||||
|
||||
AddTool(ID_LOAD, wxT("Load"), m_Bitmaps[Toolbar_Delete]);
|
||||
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::LoadAll, parent, ID_LOAD);
|
||||
|
||||
AddTool(ID_SAVE, wxT("Save"), m_Bitmaps[Toolbar_Delete]);
|
||||
Bind(wxEVT_COMMAND_TOOL_CLICKED, &CBreakPointWindow::Event_SaveAll, parent, ID_SAVE);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
Toolbar_Delete,
|
||||
Toolbar_Add_BP,
|
||||
Toolbar_Add_MC,
|
||||
Num_Bitmaps
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ID_DELETE = 2000,
|
||||
ID_CLEAR,
|
||||
ID_ADDBP,
|
||||
ID_ADDMC,
|
||||
ID_LOAD,
|
||||
ID_SAVE
|
||||
};
|
||||
|
||||
wxBitmap m_Bitmaps[Num_Bitmaps];
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CBreakPointWindow, wxPanel)
|
||||
EVT_CLOSE(CBreakPointWindow::OnClose)
|
||||
EVT_LIST_ITEM_SELECTED(wxID_ANY, CBreakPointWindow::OnSelectBP)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent,
|
||||
wxWindowID id, const wxString& title, const wxPoint& position,
|
||||
const wxSize& size, long style)
|
||||
: wxPanel(parent, id, position, size, style, title)
|
||||
, m_pCodeWindow(_pCodeWindow)
|
||||
{
|
||||
m_mgr.SetManagedWindow(this);
|
||||
m_mgr.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);
|
||||
|
||||
m_BreakPointListView = new CBreakPointView(this, wxID_ANY);
|
||||
|
||||
m_mgr.AddPane(new CBreakPointBar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top().
|
||||
LeftDockable(false).RightDockable(false).BottomDockable(false).Floatable(false));
|
||||
m_mgr.AddPane(m_BreakPointListView, wxAuiPaneInfo().CenterPane());
|
||||
m_mgr.Update();
|
||||
}
|
||||
|
||||
CBreakPointWindow::~CBreakPointWindow()
|
||||
{
|
||||
m_mgr.UnInit();
|
||||
}
|
||||
|
||||
void CBreakPointWindow::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
SaveAll();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void CBreakPointWindow::NotifyUpdate()
|
||||
{
|
||||
m_BreakPointListView->Update();
|
||||
}
|
||||
|
||||
void CBreakPointWindow::OnDelete(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_BreakPointListView->DeleteCurrentSelection();
|
||||
}
|
||||
|
||||
// jump to begin addr
|
||||
void CBreakPointWindow::OnSelectBP(wxListEvent& event)
|
||||
{
|
||||
long Index = event.GetIndex();
|
||||
if (Index >= 0)
|
||||
{
|
||||
u32 Address = (u32)m_BreakPointListView->GetItemData(Index);
|
||||
if (m_pCodeWindow)
|
||||
m_pCodeWindow->JumpToAddress(Address);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear all breakpoints and memchecks
|
||||
void CBreakPointWindow::OnClear(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
PowerPC::breakpoints.Clear();
|
||||
PowerPC::memchecks.Clear();
|
||||
NotifyUpdate();
|
||||
}
|
||||
|
||||
void CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
BreakPointDlg bpDlg(this);
|
||||
bpDlg.ShowModal();
|
||||
}
|
||||
|
||||
void CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
MemoryCheckDlg memDlg(this);
|
||||
memDlg.ShowModal();
|
||||
}
|
||||
|
||||
void CBreakPointWindow::Event_SaveAll(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
SaveAll();
|
||||
}
|
||||
|
||||
void CBreakPointWindow::SaveAll()
|
||||
{
|
||||
// simply dump all to bp/mc files in a way we can read again
|
||||
IniFile ini;
|
||||
if (ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
||||
{
|
||||
ini.SetLines("BreakPoints", PowerPC::breakpoints.GetStrings());
|
||||
ini.SetLines("MemoryChecks", PowerPC::memchecks.GetStrings());
|
||||
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
}
|
||||
}
|
||||
|
||||
void CBreakPointWindow::LoadAll(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
IniFile ini;
|
||||
BreakPoints::TBreakPointsStr newbps;
|
||||
MemChecks::TMemChecksStr newmcs;
|
||||
|
||||
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
||||
return;
|
||||
|
||||
if (ini.GetLines("BreakPoints", newbps, false))
|
||||
PowerPC::breakpoints.AddFromStrings(newbps);
|
||||
if (ini.GetLines("MemoryChecks", newmcs, false))
|
||||
PowerPC::memchecks.AddFromStrings(newmcs);
|
||||
|
||||
NotifyUpdate();
|
||||
}
|
49
Source/Core/DolphinWX/Debugger/BreakpointWindow.h
Normal file
49
Source/Core/DolphinWX/Debugger/BreakpointWindow.h
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef __BREAKPOINTWINDOW_h__
|
||||
#define __BREAKPOINTWINDOW_h__
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/aui/aui.h>
|
||||
|
||||
class CBreakPointView;
|
||||
class CCodeWindow;
|
||||
|
||||
class CBreakPointWindow : public wxPanel
|
||||
{
|
||||
public:
|
||||
|
||||
CBreakPointWindow(CCodeWindow* _pCodeWindow,
|
||||
wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& title = wxT("Breakpoints"),
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL | wxBORDER_NONE);
|
||||
~CBreakPointWindow();
|
||||
|
||||
void NotifyUpdate();
|
||||
|
||||
void OnDelete(wxCommandEvent& WXUNUSED(event));
|
||||
void OnClear(wxCommandEvent& WXUNUSED(event));
|
||||
void OnAddBreakPoint(wxCommandEvent& WXUNUSED(event));
|
||||
void OnAddMemoryCheck(wxCommandEvent& WXUNUSED(event));
|
||||
void Event_SaveAll(wxCommandEvent& WXUNUSED(event));
|
||||
void SaveAll();
|
||||
void LoadAll(wxCommandEvent& WXUNUSED(event));
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
wxAuiManager m_mgr;
|
||||
CBreakPointView* m_BreakPointListView;
|
||||
CCodeWindow* m_pCodeWindow;
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void OnSelectBP(wxListEvent& event);
|
||||
};
|
||||
|
||||
#endif
|
573
Source/Core/DolphinWX/Debugger/CodeView.cpp
Normal file
573
Source/Core/DolphinWX/Debugger/CodeView.cpp
Normal file
@ -0,0 +1,573 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common.h"
|
||||
#include "StringUtil.h"
|
||||
#include "DebuggerUIUtil.h"
|
||||
#include "DebugInterface.h"
|
||||
|
||||
#include "Host.h"
|
||||
#include "CodeView.h"
|
||||
#include "SymbolDB.h"
|
||||
#include "../WxUtils.h"
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/textdlg.h>
|
||||
|
||||
DEFINE_EVENT_TYPE(wxEVT_CODEVIEW_CHANGE);
|
||||
|
||||
enum
|
||||
{
|
||||
IDM_GOTOINMEMVIEW = 12000,
|
||||
IDM_COPYADDRESS,
|
||||
IDM_COPYHEX,
|
||||
IDM_COPYCODE,
|
||||
IDM_INSERTBLR, IDM_INSERTNOP,
|
||||
IDM_RUNTOHERE,
|
||||
IDM_JITRESULTS,
|
||||
IDM_FOLLOWBRANCH,
|
||||
IDM_RENAMESYMBOL,
|
||||
IDM_PATCHALERT,
|
||||
IDM_COPYFUNCTION,
|
||||
IDM_ADDFUNCTION,
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CCodeView, wxControl)
|
||||
EVT_ERASE_BACKGROUND(CCodeView::OnErase)
|
||||
EVT_PAINT(CCodeView::OnPaint)
|
||||
EVT_LEFT_DOWN(CCodeView::OnMouseDown)
|
||||
EVT_LEFT_UP(CCodeView::OnMouseUpL)
|
||||
EVT_MOTION(CCodeView::OnMouseMove)
|
||||
EVT_RIGHT_DOWN(CCodeView::OnMouseDown)
|
||||
EVT_RIGHT_UP(CCodeView::OnMouseUpR)
|
||||
EVT_MENU(-1, CCodeView::OnPopupMenu)
|
||||
EVT_SIZE(CCodeView::OnResize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CCodeView::CCodeView(DebugInterface* debuginterface, SymbolDB *symboldb,
|
||||
wxWindow* parent, wxWindowID Id)
|
||||
: wxControl(parent, Id),
|
||||
debugger(debuginterface),
|
||||
symbol_db(symboldb),
|
||||
plain(false),
|
||||
curAddress(debuginterface->getPC()),
|
||||
align(debuginterface->getInstructionSize(0)),
|
||||
rowHeight(13),
|
||||
selection(0),
|
||||
oldSelection(0),
|
||||
selecting(false),
|
||||
lx(-1),
|
||||
ly(-1)
|
||||
{
|
||||
}
|
||||
|
||||
int CCodeView::YToAddress(int y)
|
||||
{
|
||||
wxRect rc = GetClientRect();
|
||||
int ydiff = y - rc.height / 2 - rowHeight / 2;
|
||||
ydiff = (int)(floorf((float)ydiff / (float)rowHeight)) + 1;
|
||||
return curAddress + ydiff * align;
|
||||
}
|
||||
|
||||
void CCodeView::OnMouseDown(wxMouseEvent& event)
|
||||
{
|
||||
int x = event.m_x;
|
||||
int y = event.m_y;
|
||||
|
||||
if (x > 16)
|
||||
{
|
||||
oldSelection = selection;
|
||||
selection = YToAddress(y);
|
||||
// SetCapture(wnd);
|
||||
bool oldselecting = selecting;
|
||||
selecting = true;
|
||||
|
||||
if (!oldselecting || (selection != oldSelection))
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleBreakpoint(YToAddress(y));
|
||||
}
|
||||
|
||||
event.Skip(true);
|
||||
}
|
||||
|
||||
void CCodeView::ToggleBreakpoint(u32 address)
|
||||
{
|
||||
debugger->toggleBreakpoint(address);
|
||||
Refresh();
|
||||
Host_UpdateBreakPointView();
|
||||
}
|
||||
|
||||
void CCodeView::OnMouseMove(wxMouseEvent& event)
|
||||
{
|
||||
wxRect rc = GetClientRect();
|
||||
|
||||
if (event.m_leftDown && event.m_x > 16)
|
||||
{
|
||||
if (event.m_y < 0)
|
||||
{
|
||||
curAddress -= align;
|
||||
Refresh();
|
||||
}
|
||||
else if (event.m_y > rc.height)
|
||||
{
|
||||
curAddress += align;
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMouseDown(event);
|
||||
}
|
||||
}
|
||||
|
||||
event.Skip(true);
|
||||
}
|
||||
|
||||
void CCodeView::RaiseEvent()
|
||||
{
|
||||
wxCommandEvent ev(wxEVT_CODEVIEW_CHANGE, GetId());
|
||||
ev.SetEventObject(this);
|
||||
ev.SetInt(selection);
|
||||
GetEventHandler()->ProcessEvent(ev);
|
||||
}
|
||||
|
||||
void CCodeView::OnMouseUpL(wxMouseEvent& event)
|
||||
{
|
||||
if (event.m_x > 16)
|
||||
{
|
||||
curAddress = YToAddress(event.m_y);
|
||||
selecting = false;
|
||||
Refresh();
|
||||
}
|
||||
RaiseEvent();
|
||||
event.Skip(true);
|
||||
}
|
||||
|
||||
u32 CCodeView::AddrToBranch(u32 addr)
|
||||
{
|
||||
char disasm[256];
|
||||
debugger->disasm(addr, disasm, 256);
|
||||
const char *mojs = strstr(disasm, "->0x");
|
||||
if (mojs)
|
||||
{
|
||||
u32 dest;
|
||||
sscanf(mojs+4,"%08x", &dest);
|
||||
return dest;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CCodeView::InsertBlrNop(int Blr)
|
||||
{
|
||||
// Check if this address has been modified
|
||||
int find = -1;
|
||||
for(u32 i = 0; i < BlrList.size(); i++)
|
||||
{
|
||||
if(BlrList.at(i).Address == selection)
|
||||
{
|
||||
find = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Save the old value
|
||||
if (find >= 0)
|
||||
{
|
||||
debugger->writeExtraMemory(0, BlrList.at(find).OldValue, selection);
|
||||
BlrList.erase(BlrList.begin() + find);
|
||||
}
|
||||
else
|
||||
{
|
||||
BlrStruct Temp;
|
||||
Temp.Address = selection;
|
||||
Temp.OldValue = debugger->readMemory(selection);
|
||||
BlrList.push_back(Temp);
|
||||
if (Blr == 0)
|
||||
debugger->insertBLR(selection, 0x4e800020);
|
||||
else
|
||||
debugger->insertBLR(selection, 0x60000000);
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
||||
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->disasm(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->disasm(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::OnMouseUpR(wxMouseEvent& event)
|
||||
{
|
||||
bool isSymbol = symbol_db->GetSymbolFromAddr(selection) != 0;
|
||||
// popup menu
|
||||
wxMenu* menu = new wxMenu;
|
||||
//menu->Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
|
||||
menu->Append(IDM_FOLLOWBRANCH,
|
||||
StrToWxStr("&Follow branch"))->Enable(AddrToBranch(selection) ? true : false);
|
||||
menu->AppendSeparator();
|
||||
#if wxUSE_CLIPBOARD
|
||||
menu->Append(IDM_COPYADDRESS, StrToWxStr("Copy &address"));
|
||||
menu->Append(IDM_COPYFUNCTION, StrToWxStr("Copy &function"))->Enable(isSymbol);
|
||||
menu->Append(IDM_COPYCODE, StrToWxStr("Copy &code line"));
|
||||
menu->Append(IDM_COPYHEX, StrToWxStr("Copy &hex"));
|
||||
menu->AppendSeparator();
|
||||
#endif
|
||||
menu->Append(IDM_RENAMESYMBOL, StrToWxStr("Rename &symbol"))->Enable(isSymbol);
|
||||
menu->AppendSeparator();
|
||||
menu->Append(IDM_RUNTOHERE, _("&Run To Here"));
|
||||
menu->Append(IDM_ADDFUNCTION, _("&Add function"));
|
||||
menu->Append(IDM_JITRESULTS, StrToWxStr("PPC vs X86"));
|
||||
menu->Append(IDM_INSERTBLR, StrToWxStr("Insert &blr"));
|
||||
menu->Append(IDM_INSERTNOP, StrToWxStr("Insert &nop"));
|
||||
menu->Append(IDM_PATCHALERT, StrToWxStr("Patch alert"));
|
||||
PopupMenu(menu);
|
||||
event.Skip(true);
|
||||
}
|
||||
|
||||
void CCodeView::OnErase(wxEraseEvent& event)
|
||||
{}
|
||||
|
||||
void CCodeView::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
// General settings
|
||||
// -------------------------
|
||||
wxPaintDC dc(this);
|
||||
wxRect rc = GetClientRect();
|
||||
|
||||
dc.SetFont(DebuggerFont);
|
||||
|
||||
wxCoord w,h;
|
||||
dc.GetTextExtent(_T("0WJyq"),&w,&h);
|
||||
|
||||
if (h > rowHeight)
|
||||
rowHeight = h;
|
||||
|
||||
dc.GetTextExtent(_T("W"),&w,&h);
|
||||
int charWidth = w;
|
||||
|
||||
struct branch
|
||||
{
|
||||
int src, dst, srcAddr;
|
||||
};
|
||||
|
||||
branch branches[256];
|
||||
int numBranches = 0;
|
||||
// TODO: Add any drawing code here...
|
||||
int width = rc.width;
|
||||
int numRows = (rc.height / rowHeight) / 2 + 2;
|
||||
// ------------
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Colors and brushes
|
||||
// -------------------------
|
||||
dc.SetBackgroundMode(wxTRANSPARENT); // the text background
|
||||
const wxChar* bgColor = _T("#ffffff");
|
||||
wxPen nullPen(bgColor);
|
||||
wxPen currentPen(_T("#000000"));
|
||||
wxPen selPen(_T("#808080")); // gray
|
||||
nullPen.SetStyle(wxTRANSPARENT);
|
||||
currentPen.SetStyle(wxSOLID);
|
||||
wxBrush currentBrush(_T("#FFEfE8")); // light gray
|
||||
wxBrush pcBrush(_T("#70FF70")); // green
|
||||
wxBrush bpBrush(_T("#FF3311")); // red
|
||||
|
||||
wxBrush bgBrush(bgColor);
|
||||
wxBrush nullBrush(bgColor);
|
||||
nullBrush.SetStyle(wxTRANSPARENT);
|
||||
|
||||
dc.SetPen(nullPen);
|
||||
dc.SetBrush(bgBrush);
|
||||
dc.DrawRectangle(0, 0, 16, rc.height);
|
||||
dc.DrawRectangle(0, 0, rc.width, 5);
|
||||
// ------------
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Walk through all visible rows
|
||||
// -------------------------
|
||||
for (int i = -numRows; i <= numRows; i++)
|
||||
{
|
||||
unsigned int address = curAddress + i * align;
|
||||
|
||||
int rowY1 = rc.height / 2 + rowHeight * i - rowHeight / 2;
|
||||
int rowY2 = rc.height / 2 + rowHeight * i + rowHeight / 2;
|
||||
|
||||
wxString temp = wxString::Format(_T("%08x"), address);
|
||||
u32 col = debugger->getColor(address);
|
||||
wxBrush rowBrush(wxColor(col >> 16, col >> 8, col));
|
||||
dc.SetBrush(nullBrush);
|
||||
dc.SetPen(nullPen);
|
||||
dc.DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2);
|
||||
|
||||
if (selecting && (address == selection))
|
||||
dc.SetPen(selPen);
|
||||
else
|
||||
dc.SetPen(i == 0 ? currentPen : nullPen);
|
||||
|
||||
if (address == debugger->getPC())
|
||||
dc.SetBrush(pcBrush);
|
||||
else
|
||||
dc.SetBrush(rowBrush);
|
||||
|
||||
dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1);
|
||||
dc.SetBrush(currentBrush);
|
||||
if (!plain)
|
||||
{
|
||||
dc.SetTextForeground(_T("#600000")); // the address text is dark red
|
||||
dc.DrawText(temp, 17, rowY1);
|
||||
dc.SetTextForeground(_T("#000000"));
|
||||
}
|
||||
|
||||
// If running
|
||||
if (debugger->isAlive())
|
||||
{
|
||||
char dis[256];
|
||||
debugger->disasm(address, dis, 256);
|
||||
char* dis2 = strchr(dis, '\t');
|
||||
char desc[256] = "";
|
||||
|
||||
// If we have a code
|
||||
if (dis2)
|
||||
{
|
||||
*dis2 = 0;
|
||||
dis2++;
|
||||
// look for hex strings to decode branches
|
||||
const char* mojs = strstr(dis2, "0x8");
|
||||
if (mojs)
|
||||
{
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
bool found = false;
|
||||
for (int j = 0; j < 22; j++)
|
||||
{
|
||||
if (mojs[k + 2] == "0123456789ABCDEFabcdef"[j])
|
||||
found = true;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
mojs = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mojs)
|
||||
{
|
||||
int offs;
|
||||
sscanf(mojs + 2, "%08x", &offs);
|
||||
branches[numBranches].src = rowY1 + rowHeight / 2;
|
||||
branches[numBranches].srcAddr = address / align;
|
||||
branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * rowHeight / align + rowHeight / 2);
|
||||
sprintf(desc, "-->%s", debugger->getDescription(offs).c_str());
|
||||
dc.SetTextForeground(_T("#600060")); // the -> arrow illustrations are purple
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.SetTextForeground(_T("#000000"));
|
||||
}
|
||||
|
||||
dc.DrawText(StrToWxStr(dis2), 17 + 17*charWidth, rowY1);
|
||||
// ------------
|
||||
}
|
||||
|
||||
// Show blr as its' own color
|
||||
if (strcmp(dis, "blr"))
|
||||
dc.SetTextForeground(_T("#007000")); // dark green
|
||||
else
|
||||
dc.SetTextForeground(_T("#8000FF")); // purple
|
||||
|
||||
dc.DrawText(StrToWxStr(dis), 17 + (plain ? 1*charWidth : 9*charWidth), rowY1);
|
||||
|
||||
if (desc[0] == 0)
|
||||
{
|
||||
strcpy(desc, debugger->getDescription(address).c_str());
|
||||
}
|
||||
|
||||
if (!plain)
|
||||
{
|
||||
dc.SetTextForeground(_T("#0000FF")); // blue
|
||||
|
||||
//char temp[256];
|
||||
//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
|
||||
if (strlen(desc))
|
||||
{
|
||||
dc.DrawText(StrToWxStr(desc), 17 + 35 * charWidth, rowY1);
|
||||
}
|
||||
}
|
||||
|
||||
// Show red breakpoint dot
|
||||
if (debugger->isBreakpoint(address))
|
||||
{
|
||||
dc.SetBrush(bpBrush);
|
||||
dc.DrawRectangle(2, rowY1 + 1, 11, 11);
|
||||
}
|
||||
}
|
||||
} // end of for
|
||||
// ------------
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Colors and brushes
|
||||
// -------------------------
|
||||
dc.SetPen(currentPen);
|
||||
|
||||
for (int i = 0; i < numBranches; i++)
|
||||
{
|
||||
int x = 17 + 49 * charWidth + (branches[i].srcAddr % 9) * 8;
|
||||
_MoveTo(x-2, branches[i].src);
|
||||
|
||||
if (branches[i].dst < rc.height + 400 && branches[i].dst > -400)
|
||||
{
|
||||
_LineTo(dc, x+2, branches[i].src);
|
||||
_LineTo(dc, x+2, branches[i].dst);
|
||||
_LineTo(dc, x-4, branches[i].dst);
|
||||
|
||||
_MoveTo(x, branches[i].dst - 4);
|
||||
_LineTo(dc, x-4, branches[i].dst);
|
||||
_LineTo(dc, x+1, branches[i].dst+5);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// This can be re-enabled when there is a scrollbar or
|
||||
// something on the codeview (the lines are too long)
|
||||
|
||||
//_LineTo(dc, x+4, branches[i].src);
|
||||
//_MoveTo(x+2, branches[i].dst-4);
|
||||
//_LineTo(dc, x+6, branches[i].dst);
|
||||
//_LineTo(dc, x+1, branches[i].dst+5);
|
||||
//}
|
||||
|
||||
//_LineTo(dc, x, branches[i].dst+4);
|
||||
//_LineTo(dc, x-2, branches[i].dst);
|
||||
}
|
||||
// ------------
|
||||
}
|
||||
|
||||
void CCodeView::_LineTo(wxPaintDC &dc, int x, int y)
|
||||
{
|
||||
dc.DrawLine(lx, ly, x, y);
|
||||
lx = x;
|
||||
ly = y;
|
||||
}
|
||||
|
||||
void CCodeView::OnResize(wxSizeEvent& event)
|
||||
{
|
||||
Refresh();
|
||||
event.Skip();
|
||||
}
|
85
Source/Core/DolphinWX/Debugger/CodeView.h
Normal file
85
Source/Core/DolphinWX/Debugger/CodeView.h
Normal file
@ -0,0 +1,85 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef CODEVIEW_H_
|
||||
#define CODEVIEW_H_
|
||||
|
||||
#define wxUSE_XPM_IN_MSW 1
|
||||
#define USE_XPM_BITMAPS 1
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
DECLARE_EVENT_TYPE(wxEVT_CODEVIEW_CHANGE, -1);
|
||||
|
||||
class DebugInterface;
|
||||
class SymbolDB;
|
||||
|
||||
class CCodeView : public wxControl
|
||||
{
|
||||
public:
|
||||
CCodeView(DebugInterface* debuginterface, SymbolDB *symbol_db,
|
||||
wxWindow* parent, wxWindowID Id = wxID_ANY);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnErase(wxEraseEvent& event);
|
||||
void OnMouseDown(wxMouseEvent& event);
|
||||
void OnMouseMove(wxMouseEvent& event);
|
||||
void OnMouseUpL(wxMouseEvent& event);
|
||||
void OnMouseUpR(wxMouseEvent& event);
|
||||
void OnPopupMenu(wxCommandEvent& event);
|
||||
void InsertBlrNop(int);
|
||||
|
||||
u32 GetSelection() {return(selection);}
|
||||
void ToggleBreakpoint(u32 address);
|
||||
|
||||
struct BlrStruct // for IDM_INSERTBLR
|
||||
{
|
||||
u32 Address;
|
||||
u32 OldValue;
|
||||
};
|
||||
std::vector<BlrStruct> BlrList;
|
||||
|
||||
void Center(u32 addr)
|
||||
{
|
||||
curAddress = addr;
|
||||
selection = addr;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void SetPlain()
|
||||
{
|
||||
plain = true;
|
||||
}
|
||||
|
||||
private:
|
||||
void RaiseEvent();
|
||||
int YToAddress(int y);
|
||||
|
||||
u32 AddrToBranch(u32 addr);
|
||||
void OnResize(wxSizeEvent& event);
|
||||
|
||||
DebugInterface* debugger;
|
||||
SymbolDB* symbol_db;
|
||||
|
||||
bool plain;
|
||||
|
||||
int curAddress;
|
||||
int align;
|
||||
int rowHeight;
|
||||
|
||||
u32 selection;
|
||||
u32 oldSelection;
|
||||
bool selecting;
|
||||
|
||||
int lx, ly;
|
||||
void _MoveTo(int x, int y) {lx = x; ly = y;}
|
||||
void _LineTo(wxPaintDC &dc, int x, int y);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif /*CODEVIEW_H_*/
|
660
Source/Core/DolphinWX/Debugger/CodeWindow.cpp
Normal file
660
Source/Core/DolphinWX/Debugger/CodeWindow.cpp
Normal file
@ -0,0 +1,660 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
// Include
|
||||
#include "Common.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "Host.h"
|
||||
|
||||
#include "RegisterWindow.h"
|
||||
#include "BreakpointWindow.h"
|
||||
#include "MemoryWindow.h"
|
||||
#include "JitWindow.h"
|
||||
|
||||
#include "CodeWindow.h"
|
||||
#include "CodeView.h"
|
||||
|
||||
#include "../WxUtils.h"
|
||||
#include "FileUtil.h"
|
||||
#include "Core.h"
|
||||
#include "HW/Memmap.h"
|
||||
#include "HLE/HLE.h"
|
||||
#include "Boot/Boot.h"
|
||||
#include "LogManager.h"
|
||||
#include "HW/CPU.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "PowerPC/JitInterface.h"
|
||||
#include "Debugger/PPCDebugInterface.h"
|
||||
#include "Debugger/Debugger_SymbolMap.h"
|
||||
#include "PowerPC/PPCAnalyst.h"
|
||||
#include "PowerPC/PPCSymbolDB.h"
|
||||
#include "PowerPC/SignatureDB.h"
|
||||
#include "PowerPC/PPCTables.h"
|
||||
|
||||
#include "ConfigManager.h"
|
||||
|
||||
extern "C" // Bitmaps
|
||||
{
|
||||
#include "../resources/toolbar_add_memorycheck.c"
|
||||
#include "../resources/toolbar_add_breakpoint.c"
|
||||
}
|
||||
|
||||
// -------
|
||||
// Main
|
||||
|
||||
BEGIN_EVENT_TABLE(CCodeWindow, wxPanel)
|
||||
|
||||
// Menu bar
|
||||
EVT_MENU_RANGE(IDM_INTERPRETER, IDM_JITSROFF, CCodeWindow::OnCPUMode)
|
||||
EVT_MENU(IDM_FONTPICKER, CCodeWindow::OnChangeFont)
|
||||
EVT_MENU_RANGE(IDM_CLEARCODECACHE, IDM_SEARCHINSTRUCTION, CCodeWindow::OnJitMenu)
|
||||
EVT_MENU_RANGE(IDM_CLEARSYMBOLS, IDM_PATCHHLEFUNCTIONS, CCodeWindow::OnSymbolsMenu)
|
||||
EVT_MENU_RANGE(IDM_PROFILEBLOCKS, IDM_WRITEPROFILE, CCodeWindow::OnProfilerMenu)
|
||||
|
||||
// Toolbar
|
||||
EVT_MENU_RANGE(IDM_STEP, IDM_GOTOPC, CCodeWindow::OnCodeStep)
|
||||
EVT_TEXT(IDM_ADDRBOX, CCodeWindow::OnAddrBoxChange)
|
||||
|
||||
// Other
|
||||
EVT_LISTBOX(ID_SYMBOLLIST, CCodeWindow::OnSymbolListChange)
|
||||
EVT_LISTBOX(ID_CALLSTACKLIST, CCodeWindow::OnCallstackListChange)
|
||||
EVT_LISTBOX(ID_CALLERSLIST, CCodeWindow::OnCallersListChange)
|
||||
EVT_LISTBOX(ID_CALLSLIST, CCodeWindow::OnCallsListChange)
|
||||
|
||||
EVT_HOST_COMMAND(wxID_ANY, CCodeWindow::OnHostMessage)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Class
|
||||
CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, CFrame *parent,
|
||||
wxWindowID id, const wxPoint& position, const wxSize& size, long style, const wxString& name)
|
||||
: wxPanel((wxWindow*)parent, id, position, size, style, name)
|
||||
, Parent(parent)
|
||||
, m_RegisterWindow(NULL)
|
||||
, m_BreakpointWindow(NULL)
|
||||
, m_MemoryWindow(NULL)
|
||||
, m_JitWindow(NULL)
|
||||
, m_SoundWindow(NULL)
|
||||
, m_VideoWindow(NULL)
|
||||
, codeview(NULL)
|
||||
{
|
||||
InitBitmaps();
|
||||
|
||||
wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
DebugInterface* di = &PowerPC::debug_interface;
|
||||
|
||||
codeview = new CCodeView(di, &g_symbolDB, this, ID_CODEVIEW);
|
||||
sizerBig->Add(sizerLeft, 2, wxEXPAND);
|
||||
sizerBig->Add(codeview, 5, wxEXPAND);
|
||||
|
||||
sizerLeft->Add(callstack = new wxListBox(this, ID_CALLSTACKLIST,
|
||||
wxDefaultPosition, wxSize(90, 100)), 0, wxEXPAND);
|
||||
sizerLeft->Add(symbols = new wxListBox(this, ID_SYMBOLLIST,
|
||||
wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND);
|
||||
sizerLeft->Add(calls = new wxListBox(this, ID_CALLSLIST, wxDefaultPosition,
|
||||
wxSize(90, 100), 0, NULL, wxLB_SORT), 0, wxEXPAND);
|
||||
sizerLeft->Add(callers = new wxListBox(this, ID_CALLERSLIST, wxDefaultPosition,
|
||||
wxSize(90, 100), 0, NULL, wxLB_SORT), 0, wxEXPAND);
|
||||
|
||||
SetSizer(sizerBig);
|
||||
|
||||
sizerLeft->Fit(this);
|
||||
sizerBig->Fit(this);
|
||||
}
|
||||
|
||||
wxMenuBar *CCodeWindow::GetMenuBar()
|
||||
{
|
||||
return Parent->GetMenuBar();
|
||||
}
|
||||
|
||||
wxAuiToolBar *CCodeWindow::GetToolBar()
|
||||
{
|
||||
return Parent->m_ToolBarDebug;
|
||||
}
|
||||
|
||||
// ----------
|
||||
// Events
|
||||
|
||||
void CCodeWindow::OnHostMessage(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case IDM_NOTIFYMAPLOADED:
|
||||
NotifyMapLoaded();
|
||||
if (m_BreakpointWindow) m_BreakpointWindow->NotifyUpdate();
|
||||
break;
|
||||
|
||||
case IDM_UPDATEDISASMDIALOG:
|
||||
Update();
|
||||
if (codeview) codeview->Center(PC);
|
||||
if (m_RegisterWindow) m_RegisterWindow->NotifyUpdate();
|
||||
break;
|
||||
|
||||
case IDM_UPDATEBREAKPOINTS:
|
||||
Update();
|
||||
if (m_BreakpointWindow) m_BreakpointWindow->NotifyUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The Play, Stop, Step, Skip, Go to PC and Show PC buttons go here
|
||||
void CCodeWindow::OnCodeStep(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case IDM_STEP:
|
||||
SingleStep();
|
||||
break;
|
||||
|
||||
case IDM_STEPOVER:
|
||||
StepOver();
|
||||
break;
|
||||
|
||||
case IDM_TOGGLE_BREAKPOINT:
|
||||
ToggleBreakpoint();
|
||||
break;
|
||||
|
||||
case IDM_SKIP:
|
||||
PC += 4;
|
||||
Update();
|
||||
break;
|
||||
|
||||
case IDM_SETPC:
|
||||
PC = codeview->GetSelection();
|
||||
Update();
|
||||
break;
|
||||
|
||||
case IDM_GOTOPC:
|
||||
JumpToAddress(PC);
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateButtonStates();
|
||||
// Update all toolbars in the aui manager
|
||||
Parent->UpdateGUI();
|
||||
}
|
||||
|
||||
void CCodeWindow::JumpToAddress(u32 _Address)
|
||||
{
|
||||
codeview->Center(_Address);
|
||||
UpdateLists();
|
||||
}
|
||||
|
||||
void CCodeWindow::OnCodeViewChange(wxCommandEvent &event)
|
||||
{
|
||||
UpdateLists();
|
||||
}
|
||||
|
||||
void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event)
|
||||
{
|
||||
if (!GetToolBar()) return;
|
||||
|
||||
wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(IDM_ADDRBOX);
|
||||
wxString txt = pAddrCtrl->GetValue();
|
||||
|
||||
std::string text(WxStrToStr(txt));
|
||||
text = StripSpaces(text);
|
||||
if (text.size() == 8)
|
||||
{
|
||||
u32 addr;
|
||||
sscanf(text.c_str(), "%08x", &addr);
|
||||
JumpToAddress(addr);
|
||||
}
|
||||
|
||||
event.Skip(1);
|
||||
}
|
||||
|
||||
void CCodeWindow::OnCallstackListChange(wxCommandEvent& event)
|
||||
{
|
||||
int index = callstack->GetSelection();
|
||||
if (index >= 0)
|
||||
{
|
||||
u32 address = (u32)(u64)(callstack->GetClientData(index));
|
||||
if (address)
|
||||
JumpToAddress(address);
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::OnCallersListChange(wxCommandEvent& event)
|
||||
{
|
||||
int index = callers->GetSelection();
|
||||
if (index >= 0)
|
||||
{
|
||||
u32 address = (u32)(u64)(callers->GetClientData(index));
|
||||
if (address)
|
||||
JumpToAddress(address);
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::OnCallsListChange(wxCommandEvent& event)
|
||||
{
|
||||
int index = calls->GetSelection();
|
||||
if (index >= 0)
|
||||
{
|
||||
u32 address = (u32)(u64)(calls->GetClientData(index));
|
||||
if (address)
|
||||
JumpToAddress(address);
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::SingleStep()
|
||||
{
|
||||
if (CCPU::IsStepping())
|
||||
{
|
||||
JitInterface::InvalidateICache(PC, 4);
|
||||
CCPU::StepOpcode(&sync_event);
|
||||
wxThread::Sleep(20);
|
||||
// need a short wait here
|
||||
JumpToAddress(PC);
|
||||
Update();
|
||||
Host_UpdateLogDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::StepOver()
|
||||
{
|
||||
if (CCPU::IsStepping())
|
||||
{
|
||||
UGeckoInstruction inst = Memory::Read_Instruction(PC);
|
||||
if (inst.LK)
|
||||
{
|
||||
PowerPC::breakpoints.Add(PC + 4, true);
|
||||
CCPU::EnableStepping(false);
|
||||
JumpToAddress(PC);
|
||||
Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
SingleStep();
|
||||
}
|
||||
|
||||
UpdateButtonStates();
|
||||
// Update all toolbars in the aui manager
|
||||
Parent->UpdateGUI();
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::ToggleBreakpoint()
|
||||
{
|
||||
if (CCPU::IsStepping())
|
||||
{
|
||||
if (codeview) codeview->ToggleBreakpoint(codeview->GetSelection());
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::UpdateLists()
|
||||
{
|
||||
callers->Clear();
|
||||
u32 addr = codeview->GetSelection();
|
||||
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(addr);
|
||||
if (!symbol)
|
||||
return;
|
||||
|
||||
for (auto& call : symbol->callers)
|
||||
{
|
||||
u32 caller_addr = call.callAddress;
|
||||
Symbol *caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr);
|
||||
if (caller_symbol)
|
||||
{
|
||||
int idx = callers->Append(StrToWxStr(StringFromFormat
|
||||
("< %s (%08x)", caller_symbol->name.c_str(), caller_addr).c_str()));
|
||||
callers->SetClientData(idx, (void*)(u64)caller_addr);
|
||||
}
|
||||
}
|
||||
|
||||
calls->Clear();
|
||||
for (auto& call : symbol->calls)
|
||||
{
|
||||
u32 call_addr = call.function;
|
||||
Symbol *call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr);
|
||||
if (call_symbol)
|
||||
{
|
||||
int idx = calls->Append(StrToWxStr(StringFromFormat
|
||||
("> %s (%08x)", call_symbol->name.c_str(), call_addr).c_str()));
|
||||
calls->SetClientData(idx, (void*)(u64)call_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::UpdateCallstack()
|
||||
{
|
||||
if (Core::GetState() == Core::CORE_STOPPING) return;
|
||||
|
||||
callstack->Clear();
|
||||
|
||||
std::vector<Dolphin_Debugger::CallstackEntry> stack;
|
||||
|
||||
bool ret = Dolphin_Debugger::GetCallstack(stack);
|
||||
|
||||
for (auto& frame : stack)
|
||||
{
|
||||
int idx = callstack->Append(StrToWxStr(frame.Name));
|
||||
callstack->SetClientData(idx, (void*)(u64)frame.vAddress);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
callstack->Append(StrToWxStr("invalid callstack"));
|
||||
}
|
||||
|
||||
// Create CPU Mode menus
|
||||
void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter, wxMenuBar *pMenuBar)
|
||||
{
|
||||
// CPU Mode
|
||||
wxMenu* pCoreMenu = new wxMenu;
|
||||
|
||||
wxMenuItem* interpreter = pCoreMenu->Append(IDM_INTERPRETER, _("&Interpreter core"),
|
||||
StrToWxStr("This is necessary to get break points"
|
||||
" and stepping to work as explained in the Developer Documentation. But it can be very"
|
||||
" slow, perhaps slower than 1 fps."),
|
||||
wxITEM_CHECK);
|
||||
interpreter->Check(_LocalCoreStartupParameter.iCPUCore == 0);
|
||||
pCoreMenu->AppendSeparator();
|
||||
|
||||
pCoreMenu->Append(IDM_JITBLOCKLINKING, _("&JIT Block Linking off"),
|
||||
_("Provide safer execution by not linking the JIT blocks."),
|
||||
wxITEM_CHECK);
|
||||
|
||||
pCoreMenu->Append(IDM_JITNOBLOCKCACHE, _("&Disable JIT Cache"),
|
||||
_("Avoid any involuntary JIT cache clearing, this may prevent Zelda TP from crashing.\n[This option must be selected before a game is started.]"),
|
||||
wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_CLEARCODECACHE, _("&Clear JIT cache"));
|
||||
|
||||
pCoreMenu->AppendSeparator();
|
||||
pCoreMenu->Append(IDM_LOGINSTRUCTIONS, _("&Log JIT instruction coverage"));
|
||||
pCoreMenu->Append(IDM_SEARCHINSTRUCTION, _("&Search for an op"));
|
||||
|
||||
pCoreMenu->AppendSeparator();
|
||||
pCoreMenu->Append(IDM_JITOFF, _("&JIT off (JIT core)"),
|
||||
_("Turn off all JIT functions, but still use the JIT core from Jit.cpp"),
|
||||
wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITLSOFF, _("&JIT LoadStore off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITLSLBZXOFF, _(" &JIT LoadStore lbzx off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITLSLXZOFF, _(" &JIT LoadStore lXz off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITLSLWZOFF, _("&JIT LoadStore lwz off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITLSFOFF, _("&JIT LoadStore Floating off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITLSPOFF, _("&JIT LoadStore Paired off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITFPOFF, _("&JIT FloatingPoint off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITIOFF, _("&JIT Integer off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITPOFF, _("&JIT Paired off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
pCoreMenu->Append(IDM_JITSROFF, _("&JIT SystemRegisters off"),
|
||||
wxEmptyString, wxITEM_CHECK);
|
||||
|
||||
pMenuBar->Append(pCoreMenu, _("&JIT"));
|
||||
|
||||
|
||||
// Debug Menu
|
||||
wxMenu* pDebugMenu = new wxMenu;
|
||||
|
||||
pDebugMenu->Append(IDM_STEP, _("Step &Into\tF11"));
|
||||
pDebugMenu->Append(IDM_STEPOVER, _("Step &Over\tF10"));
|
||||
pDebugMenu->Append(IDM_TOGGLE_BREAKPOINT, _("Toggle &Breakpoint\tF9"));
|
||||
|
||||
pMenuBar->Append(pDebugMenu, _("&Debug"));
|
||||
|
||||
CreateMenuSymbols(pMenuBar);
|
||||
}
|
||||
|
||||
void CCodeWindow::CreateMenuOptions(wxMenu* pMenu)
|
||||
{
|
||||
wxMenuItem* boottopause = pMenu->Append(IDM_BOOTTOPAUSE, _("Boot to pause"),
|
||||
_("Start the game directly instead of booting to pause"),
|
||||
wxITEM_CHECK);
|
||||
boottopause->Check(bBootToPause);
|
||||
|
||||
wxMenuItem* automaticstart = pMenu->Append(IDM_AUTOMATICSTART, _("&Automatic start"),
|
||||
StrToWxStr(
|
||||
"Automatically load the Default ISO when Dolphin starts, or the last game you loaded,"
|
||||
" if you have not given it an elf file with the --elf command line. [This can be"
|
||||
" convenient if you are bug-testing with a certain game and want to rebuild"
|
||||
" and retry it several times, either with changes to Dolphin or if you are"
|
||||
" developing a homebrew game.]"),
|
||||
wxITEM_CHECK);
|
||||
automaticstart->Check(bAutomaticStart);
|
||||
|
||||
pMenu->Append(IDM_FONTPICKER, _("&Font..."), wxEmptyString, wxITEM_NORMAL);
|
||||
}
|
||||
|
||||
// CPU Mode and JIT Menu
|
||||
void CCodeWindow::OnCPUMode(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case IDM_INTERPRETER:
|
||||
PowerPC::SetMode(UseInterpreter() ? PowerPC::MODE_INTERPRETER : PowerPC::MODE_JIT);
|
||||
break;
|
||||
case IDM_BOOTTOPAUSE:
|
||||
bBootToPause = !bBootToPause;
|
||||
return;
|
||||
case IDM_AUTOMATICSTART:
|
||||
bAutomaticStart = !bAutomaticStart;
|
||||
return;
|
||||
case IDM_JITOFF:
|
||||
Core::g_CoreStartupParameter.bJITOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITLSOFF:
|
||||
Core::g_CoreStartupParameter.bJITLoadStoreOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITLSLXZOFF:
|
||||
Core::g_CoreStartupParameter.bJITLoadStorelXzOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITLSLWZOFF:
|
||||
Core::g_CoreStartupParameter.bJITLoadStorelwzOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITLSLBZXOFF:
|
||||
Core::g_CoreStartupParameter.bJITLoadStorelbzxOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITLSFOFF:
|
||||
Core::g_CoreStartupParameter.bJITLoadStoreFloatingOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITLSPOFF:
|
||||
Core::g_CoreStartupParameter.bJITLoadStorePairedOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITFPOFF:
|
||||
Core::g_CoreStartupParameter.bJITFloatingPointOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITIOFF:
|
||||
Core::g_CoreStartupParameter.bJITIntegerOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITPOFF:
|
||||
Core::g_CoreStartupParameter.bJITPairedOff = event.IsChecked();
|
||||
break;
|
||||
case IDM_JITSROFF:
|
||||
Core::g_CoreStartupParameter.bJITSystemRegistersOff = event.IsChecked();
|
||||
break;
|
||||
}
|
||||
|
||||
// Clear the JIT cache to enable these changes
|
||||
JitInterface::ClearCache();
|
||||
|
||||
// Update
|
||||
UpdateButtonStates();
|
||||
}
|
||||
|
||||
void CCodeWindow::OnJitMenu(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case IDM_LOGINSTRUCTIONS:
|
||||
PPCTables::LogCompiledInstructions();
|
||||
break;
|
||||
|
||||
case IDM_CLEARCODECACHE:
|
||||
JitInterface::ClearCache();
|
||||
break;
|
||||
|
||||
case IDM_SEARCHINSTRUCTION:
|
||||
{
|
||||
wxString str;
|
||||
str = wxGetTextFromUser(_T(""), wxT("Op?"), wxEmptyString, this);
|
||||
for (u32 addr = 0x80000000; addr < 0x80100000; addr += 4)
|
||||
{
|
||||
const char *name = PPCTables::GetInstructionName(Memory::ReadUnchecked_U32(addr));
|
||||
auto const wx_name = WxStrToStr(str);
|
||||
if (name && (wx_name == name))
|
||||
{
|
||||
NOTICE_LOG(POWERPC, "Found %s at %08x", wx_name.c_str(), addr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
bool CCodeWindow::UseInterpreter()
|
||||
{
|
||||
return GetMenuBar()->IsChecked(IDM_INTERPRETER);
|
||||
}
|
||||
|
||||
bool CCodeWindow::BootToPause()
|
||||
{
|
||||
return GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE);
|
||||
}
|
||||
|
||||
bool CCodeWindow::AutomaticStart()
|
||||
{
|
||||
return GetMenuBar()->IsChecked(IDM_AUTOMATICSTART);
|
||||
}
|
||||
|
||||
bool CCodeWindow::JITNoBlockCache()
|
||||
{
|
||||
return GetMenuBar()->IsChecked(IDM_JITNOBLOCKCACHE);
|
||||
}
|
||||
|
||||
bool CCodeWindow::JITBlockLinking()
|
||||
{
|
||||
return GetMenuBar()->IsChecked(IDM_JITBLOCKLINKING);
|
||||
}
|
||||
|
||||
// Toolbar
|
||||
void CCodeWindow::InitBitmaps()
|
||||
{
|
||||
// load original size 48x48
|
||||
m_Bitmaps[Toolbar_Step] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
|
||||
m_Bitmaps[Toolbar_StepOver] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
m_Bitmaps[Toolbar_Skip] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
m_Bitmaps[Toolbar_GotoPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
m_Bitmaps[Toolbar_SetPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
|
||||
// scale to 24x24 for toolbar
|
||||
for (auto& bitmap : m_Bitmaps)
|
||||
bitmap = wxBitmap(bitmap.ConvertToImage().Scale(24, 24));
|
||||
}
|
||||
|
||||
void CCodeWindow::PopulateToolbar(wxAuiToolBar* toolBar)
|
||||
{
|
||||
int w = m_Bitmaps[0].GetWidth(),
|
||||
h = m_Bitmaps[0].GetHeight();
|
||||
|
||||
toolBar->SetToolBitmapSize(wxSize(w, h));
|
||||
toolBar->AddTool(IDM_STEP, _("Step"), m_Bitmaps[Toolbar_Step]);
|
||||
toolBar->AddTool(IDM_STEPOVER, _("Step Over"), m_Bitmaps[Toolbar_StepOver]);
|
||||
toolBar->AddTool(IDM_SKIP, _("Skip"), m_Bitmaps[Toolbar_Skip]);
|
||||
toolBar->AddSeparator();
|
||||
toolBar->AddTool(IDM_GOTOPC, _("Show PC"), m_Bitmaps[Toolbar_GotoPC]);
|
||||
toolBar->AddTool(IDM_SETPC, _("Set PC"), m_Bitmaps[Toolbar_SetPC]);
|
||||
toolBar->AddSeparator();
|
||||
toolBar->AddControl(new wxTextCtrl(toolBar, IDM_ADDRBOX, _T("")));
|
||||
|
||||
toolBar->Realize();
|
||||
}
|
||||
|
||||
// Update GUI
|
||||
void CCodeWindow::Update()
|
||||
{
|
||||
if (!codeview) return;
|
||||
|
||||
codeview->Refresh();
|
||||
UpdateCallstack();
|
||||
UpdateButtonStates();
|
||||
|
||||
// Do not automatically show the current PC position when a breakpoint is hit or
|
||||
// when we pause since this can be called at other times too.
|
||||
//codeview->Center(PC);
|
||||
}
|
||||
|
||||
void CCodeWindow::UpdateButtonStates()
|
||||
{
|
||||
bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED);
|
||||
bool Pause = (Core::GetState() == Core::CORE_PAUSE);
|
||||
bool Stepping = CCPU::IsStepping();
|
||||
wxAuiToolBar* ToolBar = GetToolBar();
|
||||
|
||||
// Toolbar
|
||||
if (!ToolBar) return;
|
||||
|
||||
if (!Initialized)
|
||||
{
|
||||
ToolBar->EnableTool(IDM_STEPOVER, false);
|
||||
ToolBar->EnableTool(IDM_SKIP, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Stepping)
|
||||
{
|
||||
ToolBar->EnableTool(IDM_STEPOVER, false);
|
||||
ToolBar->EnableTool(IDM_SKIP, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToolBar->EnableTool(IDM_STEPOVER, true);
|
||||
ToolBar->EnableTool(IDM_SKIP, true);
|
||||
}
|
||||
}
|
||||
|
||||
ToolBar->EnableTool(IDM_STEP, Initialized && Stepping);
|
||||
|
||||
if (ToolBar) ToolBar->Realize();
|
||||
|
||||
// Menu bar
|
||||
// ------------------
|
||||
GetMenuBar()->Enable(IDM_INTERPRETER, Pause); // CPU Mode
|
||||
|
||||
GetMenuBar()->Enable(IDM_JITNOBLOCKCACHE, !Initialized);
|
||||
|
||||
GetMenuBar()->Enable(IDM_JITOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITLSOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITLSLXZOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITLSLWZOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITLSLBZXOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITLSFOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITLSPOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITFPOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITIOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITPOFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JITSROFF, Pause);
|
||||
|
||||
GetMenuBar()->Enable(IDM_CLEARCODECACHE, Pause); // JIT Menu
|
||||
GetMenuBar()->Enable(IDM_SEARCHINSTRUCTION, Initialized);
|
||||
|
||||
GetMenuBar()->Enable(IDM_CLEARSYMBOLS, Initialized); // Symbols menu
|
||||
GetMenuBar()->Enable(IDM_SCANFUNCTIONS, Initialized);
|
||||
GetMenuBar()->Enable(IDM_LOADMAPFILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_SAVEMAPFILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_SAVEMAPFILEWITHCODES, Initialized);
|
||||
GetMenuBar()->Enable(IDM_CREATESIGNATUREFILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_RENAME_SYMBOLS, Initialized);
|
||||
GetMenuBar()->Enable(IDM_USESIGNATUREFILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_PATCHHLEFUNCTIONS, Initialized);
|
||||
|
||||
// Update Fonts
|
||||
callstack->SetFont(DebuggerFont);
|
||||
symbols->SetFont(DebuggerFont);
|
||||
callers->SetFont(DebuggerFont);
|
||||
calls->SetFont(DebuggerFont);
|
||||
}
|
145
Source/Core/DolphinWX/Debugger/CodeWindow.h
Normal file
145
Source/Core/DolphinWX/Debugger/CodeWindow.h
Normal file
@ -0,0 +1,145 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef CODEWINDOW_H_
|
||||
#define CODEWINDOW_H_
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/listbox.h>
|
||||
#include <wx/artprov.h>
|
||||
|
||||
#include "Thread.h"
|
||||
#include "CoreParameter.h"
|
||||
|
||||
// GUI global
|
||||
#include "../Globals.h"
|
||||
#include "../Frame.h"
|
||||
|
||||
class CFrame;
|
||||
class CRegisterWindow;
|
||||
class CBreakPointWindow;
|
||||
class CMemoryWindow;
|
||||
class CJitWindow;
|
||||
class CCodeView;
|
||||
class DSPDebuggerLLE;
|
||||
class GFXDebuggerPanel;
|
||||
|
||||
class CCodeWindow
|
||||
: public wxPanel
|
||||
{
|
||||
public:
|
||||
|
||||
CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter,
|
||||
CFrame * parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL | wxBORDER_NONE,
|
||||
const wxString& name = _("Code")
|
||||
);
|
||||
|
||||
void Load();
|
||||
void Save();
|
||||
|
||||
// Parent interaction
|
||||
CFrame *Parent;
|
||||
wxMenuBar * GetMenuBar();
|
||||
wxAuiToolBar * GetToolBar();
|
||||
wxBitmap m_Bitmaps[ToolbarDebugBitmapMax];
|
||||
|
||||
bool UseInterpreter();
|
||||
bool BootToPause();
|
||||
bool AutomaticStart();
|
||||
bool JITNoBlockCache();
|
||||
bool JITBlockLinking();
|
||||
void JumpToAddress(u32 _Address);
|
||||
|
||||
void Update();
|
||||
void NotifyMapLoaded();
|
||||
void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter,
|
||||
wxMenuBar *pMenuBar);
|
||||
void CreateMenuOptions(wxMenu *pMenu);
|
||||
void CreateMenuSymbols(wxMenuBar *pMenuBar);
|
||||
void RecreateToolbar(wxAuiToolBar*);
|
||||
void PopulateToolbar(wxAuiToolBar* toolBar);
|
||||
void UpdateButtonStates();
|
||||
void OpenPages();
|
||||
void UpdateManager();
|
||||
|
||||
// Menu bar
|
||||
// -------------------
|
||||
void OnCPUMode(wxCommandEvent& event); // CPU Mode menu
|
||||
void OnJITOff(wxCommandEvent& event);
|
||||
|
||||
void ToggleCodeWindow(bool bShow);
|
||||
void ToggleRegisterWindow(bool bShow);
|
||||
void ToggleBreakPointWindow(bool bShow);
|
||||
void ToggleMemoryWindow(bool bShow);
|
||||
void ToggleJitWindow(bool bShow);
|
||||
void ToggleSoundWindow(bool bShow);
|
||||
void ToggleVideoWindow(bool bShow);
|
||||
|
||||
void OnChangeFont(wxCommandEvent& event);
|
||||
|
||||
void OnCodeStep(wxCommandEvent& event);
|
||||
void OnAddrBoxChange(wxCommandEvent& event);
|
||||
void OnSymbolsMenu(wxCommandEvent& event);
|
||||
void OnJitMenu(wxCommandEvent& event);
|
||||
void OnProfilerMenu(wxCommandEvent& event);
|
||||
|
||||
// Sub dialogs
|
||||
CRegisterWindow* m_RegisterWindow;
|
||||
CBreakPointWindow* m_BreakpointWindow;
|
||||
CMemoryWindow* m_MemoryWindow;
|
||||
CJitWindow* m_JitWindow;
|
||||
DSPDebuggerLLE* m_SoundWindow;
|
||||
GFXDebuggerPanel* m_VideoWindow;
|
||||
|
||||
// Settings
|
||||
bool bAutomaticStart; bool bBootToPause;
|
||||
bool bShowOnStart[IDM_VIDEOWINDOW - IDM_LOGWINDOW + 1];
|
||||
int iNbAffiliation[IDM_CODEWINDOW - IDM_LOGWINDOW + 1];
|
||||
|
||||
private:
|
||||
|
||||
enum
|
||||
{
|
||||
// Debugger GUI Objects
|
||||
ID_CODEVIEW,
|
||||
ID_CALLSTACKLIST,
|
||||
ID_CALLERSLIST,
|
||||
ID_CALLSLIST,
|
||||
ID_SYMBOLLIST
|
||||
};
|
||||
|
||||
void OnSymbolListChange(wxCommandEvent& event);
|
||||
void OnSymbolListContextMenu(wxContextMenuEvent& event);
|
||||
void OnCallstackListChange(wxCommandEvent& event);
|
||||
void OnCallersListChange(wxCommandEvent& event);
|
||||
void OnCallsListChange(wxCommandEvent& event);
|
||||
void OnCodeViewChange(wxCommandEvent &event);
|
||||
void OnHostMessage(wxCommandEvent& event);
|
||||
|
||||
// Debugger functions
|
||||
void SingleStep();
|
||||
void StepOver();
|
||||
void ToggleBreakpoint();
|
||||
|
||||
void UpdateLists();
|
||||
void UpdateCallstack();
|
||||
|
||||
void InitBitmaps();
|
||||
|
||||
CCodeView* codeview;
|
||||
wxListBox* callstack;
|
||||
wxListBox* symbols;
|
||||
wxListBox* callers;
|
||||
wxListBox* calls;
|
||||
Common::Event sync_event;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif // CODEWINDOW_H_
|
544
Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp
Normal file
544
Source/Core/DolphinWX/Debugger/CodeWindowFunctions.cpp
Normal file
@ -0,0 +1,544 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common.h"
|
||||
#include "CommonPaths.h"
|
||||
|
||||
#include <wx/fontdlg.h>
|
||||
#include <wx/mimetype.h>
|
||||
|
||||
#include "Host.h"
|
||||
|
||||
#include "DebuggerUIUtil.h"
|
||||
|
||||
#include "../WxUtils.h"
|
||||
#include "RegisterWindow.h"
|
||||
#include "BreakpointWindow.h"
|
||||
#include "MemoryWindow.h"
|
||||
#include "JitWindow.h"
|
||||
#include "DebuggerPanel.h"
|
||||
#include "DSPDebugWindow.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
#include "CodeWindow.h"
|
||||
#include "CodeView.h"
|
||||
|
||||
#include "Core.h"
|
||||
#include "HLE/HLE.h"
|
||||
#include "Boot/Boot.h"
|
||||
#include "LogManager.h"
|
||||
#include "HW/CPU.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "Debugger/PPCDebugInterface.h"
|
||||
#include "Debugger/Debugger_SymbolMap.h"
|
||||
#include "PowerPC/PPCAnalyst.h"
|
||||
#include "PowerPC/Profiler.h"
|
||||
#include "PowerPC/PPCSymbolDB.h"
|
||||
#include "PowerPC/SignatureDB.h"
|
||||
#include "PowerPC/PPCTables.h"
|
||||
#include "PowerPC/JitCommon/JitBase.h"
|
||||
#include "PowerPC/JitCommon/JitCache.h" // for ClearCache()
|
||||
|
||||
#include "ConfigManager.h"
|
||||
|
||||
// Save and load settings
|
||||
// -----------------------------
|
||||
void CCodeWindow::Load()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
// The font to override DebuggerFont with
|
||||
std::string fontDesc;
|
||||
ini.Get("General", "DebuggerFont", &fontDesc);
|
||||
if (!fontDesc.empty())
|
||||
DebuggerFont.SetNativeFontInfoUserDesc(StrToWxStr(fontDesc));
|
||||
|
||||
// Boot to pause or not
|
||||
ini.Get("General", "AutomaticStart", &bAutomaticStart, false);
|
||||
ini.Get("General", "BootToPause", &bBootToPause, true);
|
||||
|
||||
const char* SettingName[] = {
|
||||
"Log",
|
||||
"LogConfig",
|
||||
"Console",
|
||||
"Registers",
|
||||
"Breakpoints",
|
||||
"Memory",
|
||||
"JIT",
|
||||
"Sound",
|
||||
"Video",
|
||||
"Code"
|
||||
};
|
||||
|
||||
// Decide what windows to show
|
||||
for (int i = 0; i <= IDM_VIDEOWINDOW - IDM_LOGWINDOW; i++)
|
||||
ini.Get("ShowOnStart", SettingName[i], &bShowOnStart[i], false);
|
||||
|
||||
// Get notebook affiliation
|
||||
std::string _Section = "P - " +
|
||||
((Parent->ActivePerspective < Parent->Perspectives.size())
|
||||
? Parent->Perspectives[Parent->ActivePerspective].Name : "Perspective 1");
|
||||
|
||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||
ini.Get(_Section.c_str(), SettingName[i], &iNbAffiliation[i], 0);
|
||||
|
||||
// Get floating setting
|
||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||
ini.Get("Float", SettingName[i], &Parent->bFloatWindow[i], false);
|
||||
}
|
||||
|
||||
void CCodeWindow::Save()
|
||||
{
|
||||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
ini.Set("General", "DebuggerFont",
|
||||
WxStrToStr(DebuggerFont.GetNativeFontInfoUserDesc()));
|
||||
|
||||
// Boot to pause or not
|
||||
ini.Set("General", "AutomaticStart", GetMenuBar()->IsChecked(IDM_AUTOMATICSTART));
|
||||
ini.Set("General", "BootToPause", GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE));
|
||||
|
||||
const char* SettingName[] = {
|
||||
"Log",
|
||||
"LogConfig",
|
||||
"Console",
|
||||
"Registers",
|
||||
"Breakpoints",
|
||||
"Memory",
|
||||
"JIT",
|
||||
"Sound",
|
||||
"Video",
|
||||
"Code"
|
||||
};
|
||||
|
||||
// Save windows settings
|
||||
for (int i = IDM_LOGWINDOW; i <= IDM_VIDEOWINDOW; i++)
|
||||
ini.Set("ShowOnStart", SettingName[i - IDM_LOGWINDOW], GetMenuBar()->IsChecked(i));
|
||||
|
||||
// Save notebook affiliations
|
||||
std::string _Section = "P - " + Parent->Perspectives[Parent->ActivePerspective].Name;
|
||||
for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
|
||||
ini.Set(_Section.c_str(), SettingName[i], iNbAffiliation[i]);
|
||||
|
||||
// Save floating setting
|
||||
for (int i = IDM_LOGWINDOW_PARENT; i <= IDM_CODEWINDOW_PARENT; i++)
|
||||
ini.Set("Float", SettingName[i - IDM_LOGWINDOW_PARENT], !!FindWindowById(i));
|
||||
|
||||
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
}
|
||||
|
||||
// Symbols, JIT, Profiler
|
||||
// ----------------
|
||||
void CCodeWindow::CreateMenuSymbols(wxMenuBar *pMenuBar)
|
||||
{
|
||||
wxMenu *pSymbolsMenu = new wxMenu;
|
||||
pSymbolsMenu->Append(IDM_CLEARSYMBOLS, _("&Clear symbols"));
|
||||
pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _("&Generate symbol map"));
|
||||
pSymbolsMenu->AppendSeparator();
|
||||
pSymbolsMenu->Append(IDM_LOADMAPFILE, _("&Load symbol map"));
|
||||
pSymbolsMenu->Append(IDM_SAVEMAPFILE, _("&Save symbol map"));
|
||||
pSymbolsMenu->AppendSeparator();
|
||||
pSymbolsMenu->Append(IDM_SAVEMAPFILEWITHCODES, _("Save code"),
|
||||
StrToWxStr("Save the entire disassembled code. This may take a several seconds"
|
||||
" and may require between 50 and 100 MB of hard drive space. It will only save code"
|
||||
" that are in the first 4 MB of memory, if you are debugging a game that load .rel"
|
||||
" files with code to memory you may want to increase that to perhaps 8 MB, you can do"
|
||||
" that from SymbolDB::SaveMap().")
|
||||
);
|
||||
|
||||
pSymbolsMenu->AppendSeparator();
|
||||
pSymbolsMenu->Append(IDM_CREATESIGNATUREFILE, _("&Create signature file..."));
|
||||
pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _("&Use signature file..."));
|
||||
pSymbolsMenu->AppendSeparator();
|
||||
pSymbolsMenu->Append(IDM_PATCHHLEFUNCTIONS, _("&Patch HLE functions"));
|
||||
pSymbolsMenu->Append(IDM_RENAME_SYMBOLS, _("&Rename symbols from file..."));
|
||||
pMenuBar->Append(pSymbolsMenu, _("&Symbols"));
|
||||
|
||||
wxMenu *pProfilerMenu = new wxMenu;
|
||||
pProfilerMenu->Append(IDM_PROFILEBLOCKS, _("&Profile blocks"), wxEmptyString, wxITEM_CHECK);
|
||||
pProfilerMenu->AppendSeparator();
|
||||
pProfilerMenu->Append(IDM_WRITEPROFILE, _("&Write to profile.txt, show"));
|
||||
pMenuBar->Append(pProfilerMenu, _("&Profiler"));
|
||||
}
|
||||
|
||||
void CCodeWindow::OnProfilerMenu(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case IDM_PROFILEBLOCKS:
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
if (jit != NULL)
|
||||
jit->ClearCache();
|
||||
Profiler::g_ProfileBlocks = GetMenuBar()->IsChecked(IDM_PROFILEBLOCKS);
|
||||
Core::SetState(Core::CORE_RUN);
|
||||
break;
|
||||
case IDM_WRITEPROFILE:
|
||||
if (Core::GetState() == Core::CORE_RUN)
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
|
||||
if (Core::GetState() == Core::CORE_PAUSE && PowerPC::GetMode() == PowerPC::MODE_JIT)
|
||||
{
|
||||
if (jit != NULL)
|
||||
{
|
||||
std::string filename = File::GetUserPath(D_DUMP_IDX) + "Debug/profiler.txt";
|
||||
File::CreateFullPath(filename);
|
||||
Profiler::WriteProfileResults(filename.c_str());
|
||||
|
||||
wxFileType* filetype = NULL;
|
||||
if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("txt"))))
|
||||
{
|
||||
// From extension failed, trying with MIME type now
|
||||
if (!(filetype = wxTheMimeTypesManager->GetFileTypeFromMimeType(_T("text/plain"))))
|
||||
// MIME type failed, aborting mission
|
||||
break;
|
||||
}
|
||||
wxString OpenCommand;
|
||||
OpenCommand = filetype->GetOpenCommand(StrToWxStr(filename));
|
||||
if(!OpenCommand.IsEmpty())
|
||||
wxExecute(OpenCommand, wxEXEC_SYNC);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
|
||||
{
|
||||
Parent->ClearStatusBar();
|
||||
|
||||
if (Core::GetState() == Core::CORE_UNINITIALIZED) return;
|
||||
|
||||
std::string existing_map_file, writable_map_file;
|
||||
bool map_exists = CBoot::FindMapFile(&existing_map_file,
|
||||
&writable_map_file);
|
||||
switch (event.GetId())
|
||||
{
|
||||
case IDM_CLEARSYMBOLS:
|
||||
if(!AskYesNo("Do you want to clear the list of symbol names?")) return;
|
||||
g_symbolDB.Clear();
|
||||
Host_NotifyMapLoaded();
|
||||
break;
|
||||
case IDM_SCANFUNCTIONS:
|
||||
{
|
||||
PPCAnalyst::FindFunctions(0x80000000, 0x81800000, &g_symbolDB);
|
||||
SignatureDB db;
|
||||
if (db.Load((File::GetSysDirectory() + TOTALDB).c_str()))
|
||||
{
|
||||
db.Apply(&g_symbolDB);
|
||||
Parent->StatusBarMessage("Generated symbol names from '%s'", TOTALDB);
|
||||
}
|
||||
else
|
||||
{
|
||||
Parent->StatusBarMessage("'%s' not found, no symbol names generated", TOTALDB);
|
||||
}
|
||||
// HLE::PatchFunctions();
|
||||
// Update GUI
|
||||
NotifyMapLoaded();
|
||||
break;
|
||||
}
|
||||
case IDM_LOADMAPFILE:
|
||||
if (!map_exists)
|
||||
{
|
||||
g_symbolDB.Clear();
|
||||
PPCAnalyst::FindFunctions(0x81300000, 0x81800000, &g_symbolDB);
|
||||
SignatureDB db;
|
||||
if (db.Load((File::GetSysDirectory() + TOTALDB).c_str()))
|
||||
db.Apply(&g_symbolDB);
|
||||
Parent->StatusBarMessage("'%s' not found, scanning for common functions instead", writable_map_file.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
g_symbolDB.LoadMap(existing_map_file.c_str());
|
||||
Parent->StatusBarMessage("Loaded symbols from '%s'", existing_map_file.c_str());
|
||||
}
|
||||
HLE::PatchFunctions();
|
||||
NotifyMapLoaded();
|
||||
break;
|
||||
case IDM_SAVEMAPFILE:
|
||||
g_symbolDB.SaveMap(writable_map_file.c_str());
|
||||
break;
|
||||
case IDM_SAVEMAPFILEWITHCODES:
|
||||
g_symbolDB.SaveMap(writable_map_file.c_str(), true);
|
||||
break;
|
||||
|
||||
case IDM_RENAME_SYMBOLS:
|
||||
{
|
||||
const wxString path = wxFileSelector(
|
||||
_("Apply signature file"), wxEmptyString,
|
||||
wxEmptyString, wxEmptyString,
|
||||
_T("Dolphin Symbol Rename File (*.sym)|*.sym"),
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
|
||||
|
||||
if (!path.IsEmpty())
|
||||
{
|
||||
std::ifstream f;
|
||||
OpenFStream(f, WxStrToStr(path), std::ios_base::in);
|
||||
|
||||
std::string line;
|
||||
while (std::getline(f, line))
|
||||
{
|
||||
if (line.length() < 12)
|
||||
continue;
|
||||
|
||||
u32 address, type;
|
||||
std::string name;
|
||||
|
||||
std::istringstream ss(line);
|
||||
ss >> std::hex >> address >> std::dec >> type >> name;
|
||||
|
||||
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
if (symbol)
|
||||
symbol->name = line.substr(12);
|
||||
}
|
||||
|
||||
Host_NotifyMapLoaded();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_CREATESIGNATUREFILE:
|
||||
{
|
||||
wxTextEntryDialog input_prefix(
|
||||
this,
|
||||
StrToWxStr("Only export symbols with prefix:\n(Blank for all symbols)"),
|
||||
wxGetTextFromUserPromptStr,
|
||||
wxEmptyString);
|
||||
|
||||
if (input_prefix.ShowModal() == wxID_OK)
|
||||
{
|
||||
std::string prefix(WxStrToStr(input_prefix.GetValue()));
|
||||
|
||||
wxString path = wxFileSelector(
|
||||
_T("Save signature as"), wxEmptyString, wxEmptyString, wxEmptyString,
|
||||
_T("Dolphin Signature File (*.dsy)|*.dsy;"), wxFD_SAVE,
|
||||
this);
|
||||
if (!path.IsEmpty())
|
||||
{
|
||||
SignatureDB db;
|
||||
db.Initialize(&g_symbolDB, prefix.c_str());
|
||||
db.Save(WxStrToStr(path).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IDM_USESIGNATUREFILE:
|
||||
{
|
||||
wxString path = wxFileSelector(
|
||||
_T("Apply signature file"), wxEmptyString, wxEmptyString, wxEmptyString,
|
||||
_T("Dolphin Signature File (*.dsy)|*.dsy;"), wxFD_OPEN | wxFD_FILE_MUST_EXIST,
|
||||
this);
|
||||
if (!path.IsEmpty())
|
||||
{
|
||||
SignatureDB db;
|
||||
db.Load(WxStrToStr(path).c_str());
|
||||
db.Apply(&g_symbolDB);
|
||||
}
|
||||
}
|
||||
NotifyMapLoaded();
|
||||
break;
|
||||
case IDM_PATCHHLEFUNCTIONS:
|
||||
HLE::PatchFunctions();
|
||||
Update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::NotifyMapLoaded()
|
||||
{
|
||||
if (!codeview) return;
|
||||
|
||||
g_symbolDB.FillInCallers();
|
||||
//symbols->Show(false); // hide it for faster filling
|
||||
symbols->Freeze(); // HyperIris: wx style fast filling
|
||||
symbols->Clear();
|
||||
for (PPCSymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); ++iter)
|
||||
{
|
||||
int idx = symbols->Append(StrToWxStr(iter->second.name));
|
||||
symbols->SetClientData(idx, (void*)&iter->second);
|
||||
}
|
||||
symbols->Thaw();
|
||||
//symbols->Show(true);
|
||||
Update();
|
||||
}
|
||||
|
||||
void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
|
||||
{
|
||||
int index = symbols->GetSelection();
|
||||
if (index >= 0) {
|
||||
Symbol* pSymbol = static_cast<Symbol *>(symbols->GetClientData(index));
|
||||
if (pSymbol != NULL)
|
||||
{
|
||||
if(pSymbol->type == Symbol::SYMBOL_DATA)
|
||||
{
|
||||
if(m_MemoryWindow)// && m_MemoryWindow->IsVisible())
|
||||
m_MemoryWindow->JumpToAddress(pSymbol->address);
|
||||
}
|
||||
else
|
||||
{
|
||||
JumpToAddress(pSymbol->address);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::OnSymbolListContextMenu(wxContextMenuEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
// Change the global DebuggerFont
|
||||
void CCodeWindow::OnChangeFont(wxCommandEvent& event)
|
||||
{
|
||||
wxFontData data;
|
||||
data.SetInitialFont(DebuggerFont);
|
||||
|
||||
wxFontDialog dialog(this, data);
|
||||
if ( dialog.ShowModal() == wxID_OK )
|
||||
DebuggerFont = dialog.GetFontData().GetChosenFont();
|
||||
}
|
||||
|
||||
// Toggle windows
|
||||
|
||||
void CCodeWindow::OpenPages()
|
||||
{
|
||||
ToggleCodeWindow(true);
|
||||
if (bShowOnStart[0])
|
||||
Parent->ToggleLogWindow(true);
|
||||
if (bShowOnStart[IDM_LOGCONFIGWINDOW - IDM_LOGWINDOW])
|
||||
Parent->ToggleLogConfigWindow(true);
|
||||
if (bShowOnStart[IDM_CONSOLEWINDOW - IDM_LOGWINDOW])
|
||||
Parent->ToggleConsole(true);
|
||||
if (bShowOnStart[IDM_REGISTERWINDOW - IDM_LOGWINDOW])
|
||||
ToggleRegisterWindow(true);
|
||||
if (bShowOnStart[IDM_BREAKPOINTWINDOW - IDM_LOGWINDOW])
|
||||
ToggleBreakPointWindow(true);
|
||||
if (bShowOnStart[IDM_MEMORYWINDOW - IDM_LOGWINDOW])
|
||||
ToggleMemoryWindow(true);
|
||||
if (bShowOnStart[IDM_JITWINDOW - IDM_LOGWINDOW])
|
||||
ToggleJitWindow(true);
|
||||
if (bShowOnStart[IDM_SOUNDWINDOW - IDM_LOGWINDOW])
|
||||
ToggleSoundWindow(true);
|
||||
if (bShowOnStart[IDM_VIDEOWINDOW - IDM_LOGWINDOW])
|
||||
ToggleVideoWindow(true);
|
||||
}
|
||||
|
||||
void CCodeWindow::ToggleCodeWindow(bool bShow)
|
||||
{
|
||||
if (bShow)
|
||||
Parent->DoAddPage(this,
|
||||
iNbAffiliation[IDM_CODEWINDOW - IDM_LOGWINDOW],
|
||||
Parent->bFloatWindow[IDM_CODEWINDOW - IDM_LOGWINDOW]);
|
||||
else // Hide
|
||||
Parent->DoRemovePage(this);
|
||||
}
|
||||
|
||||
void CCodeWindow::ToggleRegisterWindow(bool bShow)
|
||||
{
|
||||
GetMenuBar()->FindItem(IDM_REGISTERWINDOW)->Check(bShow);
|
||||
if (bShow)
|
||||
{
|
||||
if (!m_RegisterWindow)
|
||||
m_RegisterWindow = new CRegisterWindow(Parent, IDM_REGISTERWINDOW);
|
||||
Parent->DoAddPage(m_RegisterWindow,
|
||||
iNbAffiliation[IDM_REGISTERWINDOW - IDM_LOGWINDOW],
|
||||
Parent->bFloatWindow[IDM_REGISTERWINDOW - IDM_LOGWINDOW]);
|
||||
}
|
||||
else // Close
|
||||
{
|
||||
Parent->DoRemovePage(m_RegisterWindow, false);
|
||||
m_RegisterWindow = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::ToggleBreakPointWindow(bool bShow)
|
||||
{
|
||||
GetMenuBar()->FindItem(IDM_BREAKPOINTWINDOW)->Check(bShow);
|
||||
if (bShow)
|
||||
{
|
||||
if (!m_BreakpointWindow)
|
||||
m_BreakpointWindow = new CBreakPointWindow(this, Parent, IDM_BREAKPOINTWINDOW);
|
||||
Parent->DoAddPage(m_BreakpointWindow,
|
||||
iNbAffiliation[IDM_BREAKPOINTWINDOW - IDM_LOGWINDOW],
|
||||
Parent->bFloatWindow[IDM_BREAKPOINTWINDOW - IDM_LOGWINDOW]);
|
||||
}
|
||||
else // Close
|
||||
{
|
||||
Parent->DoRemovePage(m_BreakpointWindow, false);
|
||||
m_BreakpointWindow = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::ToggleMemoryWindow(bool bShow)
|
||||
{
|
||||
GetMenuBar()->FindItem(IDM_MEMORYWINDOW)->Check(bShow);
|
||||
if (bShow)
|
||||
{
|
||||
if (!m_MemoryWindow)
|
||||
m_MemoryWindow = new CMemoryWindow(Parent, IDM_MEMORYWINDOW);
|
||||
Parent->DoAddPage(m_MemoryWindow,
|
||||
iNbAffiliation[IDM_MEMORYWINDOW - IDM_LOGWINDOW],
|
||||
Parent->bFloatWindow[IDM_MEMORYWINDOW - IDM_LOGWINDOW]);
|
||||
}
|
||||
else // Close
|
||||
{
|
||||
Parent->DoRemovePage(m_MemoryWindow, false);
|
||||
m_MemoryWindow = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::ToggleJitWindow(bool bShow)
|
||||
{
|
||||
GetMenuBar()->FindItem(IDM_JITWINDOW)->Check(bShow);
|
||||
if (bShow)
|
||||
{
|
||||
if (!m_JitWindow)
|
||||
m_JitWindow = new CJitWindow(Parent, IDM_JITWINDOW);
|
||||
Parent->DoAddPage(m_JitWindow,
|
||||
iNbAffiliation[IDM_JITWINDOW - IDM_LOGWINDOW],
|
||||
Parent->bFloatWindow[IDM_JITWINDOW - IDM_LOGWINDOW]);
|
||||
}
|
||||
else // Close
|
||||
{
|
||||
Parent->DoRemovePage(m_JitWindow, false);
|
||||
m_JitWindow = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CCodeWindow::ToggleSoundWindow(bool bShow)
|
||||
{
|
||||
GetMenuBar()->FindItem(IDM_SOUNDWINDOW)->Check(bShow);
|
||||
if (bShow)
|
||||
{
|
||||
if (!m_SoundWindow)
|
||||
m_SoundWindow = new DSPDebuggerLLE(Parent, IDM_SOUNDWINDOW);
|
||||
Parent->DoAddPage(m_SoundWindow,
|
||||
iNbAffiliation[IDM_SOUNDWINDOW - IDM_LOGWINDOW],
|
||||
Parent->bFloatWindow[IDM_SOUNDWINDOW - IDM_LOGWINDOW]);
|
||||
}
|
||||
else // Close
|
||||
{
|
||||
Parent->DoRemovePage(m_SoundWindow, false);
|
||||
m_SoundWindow = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::ToggleVideoWindow(bool bShow)
|
||||
{
|
||||
GetMenuBar()->FindItem(IDM_VIDEOWINDOW)->Check(bShow);
|
||||
if (bShow)
|
||||
{
|
||||
if (!m_VideoWindow)
|
||||
m_VideoWindow = new GFXDebuggerPanel(Parent, IDM_VIDEOWINDOW);
|
||||
Parent->DoAddPage(m_VideoWindow,
|
||||
iNbAffiliation[IDM_VIDEOWINDOW - IDM_LOGWINDOW],
|
||||
Parent->bFloatWindow[IDM_VIDEOWINDOW - IDM_LOGWINDOW]);
|
||||
}
|
||||
else // Close
|
||||
{
|
||||
Parent->DoRemovePage(m_VideoWindow, false);
|
||||
m_VideoWindow = NULL;
|
||||
}
|
||||
}
|
279
Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp
Normal file
279
Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp
Normal file
@ -0,0 +1,279 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <wx/artprov.h>
|
||||
|
||||
#include "../WxUtils.h"
|
||||
#include "StringUtil.h"
|
||||
#include "DSPDebugWindow.h"
|
||||
#include "DSPRegisterView.h"
|
||||
#include "CodeView.h"
|
||||
#include "MemoryView.h"
|
||||
#include "HW/DSPLLE/DSPSymbols.h"
|
||||
|
||||
DSPDebuggerLLE* m_DebuggerFrame = NULL;
|
||||
|
||||
BEGIN_EVENT_TABLE(DSPDebuggerLLE, wxPanel)
|
||||
EVT_CLOSE(DSPDebuggerLLE::OnClose)
|
||||
EVT_MENU_RANGE(ID_RUNTOOL, ID_SHOWPCTOOL, DSPDebuggerLLE::OnChangeState)
|
||||
EVT_TEXT_ENTER(ID_ADDRBOX, DSPDebuggerLLE::OnAddrBoxChange)
|
||||
EVT_LISTBOX(ID_SYMBOLLIST, DSPDebuggerLLE::OnSymbolListChange)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
DSPDebuggerLLE::DSPDebuggerLLE(wxWindow* parent, wxWindowID id)
|
||||
: wxPanel(parent, id, wxDefaultPosition, wxDefaultSize,
|
||||
wxTAB_TRAVERSAL, _("DSP LLE Debugger"))
|
||||
, m_CachedStepCounter(-1)
|
||||
{
|
||||
m_DebuggerFrame = this;
|
||||
|
||||
// notify wxAUI which frame to use
|
||||
m_mgr.SetManagedWindow(this);
|
||||
m_mgr.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);
|
||||
|
||||
m_Toolbar = new wxAuiToolBar(this, ID_TOOLBAR,
|
||||
wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_TEXT);
|
||||
m_Toolbar->AddTool(ID_RUNTOOL, wxT("Pause"),
|
||||
wxArtProvider::GetBitmap(wxART_TICK_MARK, wxART_OTHER, wxSize(10,10)));
|
||||
m_Toolbar->AddTool(ID_STEPTOOL, wxT("Step"),
|
||||
wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_OTHER, wxSize(10,10)));
|
||||
m_Toolbar->AddTool(ID_SHOWPCTOOL, wxT("Show PC"),
|
||||
wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_OTHER, wxSize(10,10)));
|
||||
m_Toolbar->AddSeparator();
|
||||
m_Toolbar->AddControl(new wxTextCtrl(m_Toolbar, ID_ADDRBOX, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER));
|
||||
m_Toolbar->Realize();
|
||||
|
||||
m_SymbolList = new wxListBox(this, ID_SYMBOLLIST, wxDefaultPosition,
|
||||
wxSize(140, 100), 0, NULL, wxLB_SORT);
|
||||
|
||||
m_MainNotebook = new wxAuiNotebook(this, wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE);
|
||||
|
||||
wxPanel *code_panel = new wxPanel(m_MainNotebook, wxID_ANY);
|
||||
wxBoxSizer *code_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_CodeView = new CCodeView(&debug_interface, &DSPSymbols::g_dsp_symbol_db, code_panel);
|
||||
m_CodeView->SetPlain();
|
||||
code_sizer->Add(m_CodeView, 1, wxALL | wxEXPAND);
|
||||
code_panel->SetSizer(code_sizer);
|
||||
m_MainNotebook->AddPage(code_panel, wxT("Disasm"), true);
|
||||
|
||||
wxPanel *mem_panel = new wxPanel(m_MainNotebook, wxID_ANY);
|
||||
wxBoxSizer *mem_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
// TODO insert memViewer class
|
||||
m_MemView = new CMemoryView(&debug_interface, mem_panel);
|
||||
mem_sizer->Add(m_MemView, 1, wxALL | wxEXPAND);
|
||||
mem_panel->SetSizer(mem_sizer);
|
||||
m_MainNotebook->AddPage(mem_panel, wxT("Mem"));
|
||||
|
||||
m_Regs = new DSPRegisterView(this, ID_DSP_REGS);
|
||||
|
||||
// add the panes to the manager
|
||||
m_mgr.AddPane(m_Toolbar, wxAuiPaneInfo().
|
||||
ToolbarPane().Top().
|
||||
LeftDockable(false).RightDockable(false));
|
||||
|
||||
m_mgr.AddPane(m_SymbolList, wxAuiPaneInfo().
|
||||
Left().CloseButton(false).
|
||||
Caption(wxT("Symbols")).Dockable(true));
|
||||
|
||||
m_mgr.AddPane(m_MainNotebook, wxAuiPaneInfo().
|
||||
Name(wxT("m_MainNotebook")).Center().
|
||||
CloseButton(false).MaximizeButton(true));
|
||||
|
||||
m_mgr.AddPane(m_Regs, wxAuiPaneInfo().Right().
|
||||
CloseButton(false).Caption(wxT("Registers")).
|
||||
Dockable(true));
|
||||
|
||||
UpdateState();
|
||||
|
||||
m_mgr.Update();
|
||||
}
|
||||
|
||||
DSPDebuggerLLE::~DSPDebuggerLLE()
|
||||
{
|
||||
m_mgr.UnInit();
|
||||
m_DebuggerFrame = NULL;
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::OnChangeState(wxCommandEvent& event)
|
||||
{
|
||||
if (DSPCore_GetState() == DSPCORE_STOP)
|
||||
return;
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_RUNTOOL:
|
||||
if (DSPCore_GetState() == DSPCORE_RUNNING)
|
||||
DSPCore_SetState(DSPCORE_STEPPING);
|
||||
else
|
||||
DSPCore_SetState(DSPCORE_RUNNING);
|
||||
break;
|
||||
|
||||
case ID_STEPTOOL:
|
||||
if (DSPCore_GetState() == DSPCORE_STEPPING)
|
||||
{
|
||||
DSPCore_Step();
|
||||
Update();
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_SHOWPCTOOL:
|
||||
FocusOnPC();
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateState();
|
||||
m_mgr.Update();
|
||||
}
|
||||
|
||||
void Host_RefreshDSPDebuggerWindow()
|
||||
{
|
||||
if (m_DebuggerFrame)
|
||||
m_DebuggerFrame->Update();
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::Update()
|
||||
{
|
||||
#if defined __WXGTK__
|
||||
if (!wxIsMainThread())
|
||||
wxMutexGuiEnter();
|
||||
#endif
|
||||
UpdateSymbolMap();
|
||||
UpdateDisAsmListView();
|
||||
UpdateRegisterFlags();
|
||||
UpdateState();
|
||||
m_mgr.Update();
|
||||
#if defined __WXGTK__
|
||||
if (!wxIsMainThread())
|
||||
wxMutexGuiLeave();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::FocusOnPC()
|
||||
{
|
||||
JumpToAddress(g_dsp.pc);
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::UpdateState()
|
||||
{
|
||||
if (DSPCore_GetState() == DSPCORE_RUNNING)
|
||||
{
|
||||
m_Toolbar->SetToolLabel(ID_RUNTOOL, wxT("Pause"));
|
||||
m_Toolbar->SetToolBitmap(ID_RUNTOOL,
|
||||
wxArtProvider::GetBitmap(wxART_TICK_MARK, wxART_OTHER, wxSize(10,10)));
|
||||
m_Toolbar->EnableTool(ID_STEPTOOL, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Toolbar->SetToolLabel(ID_RUNTOOL, wxT("Run"));
|
||||
m_Toolbar->SetToolBitmap(ID_RUNTOOL,
|
||||
wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_OTHER, wxSize(10,10)));
|
||||
m_Toolbar->EnableTool(ID_STEPTOOL, true);
|
||||
}
|
||||
m_Toolbar->Realize();
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::UpdateDisAsmListView()
|
||||
{
|
||||
if (m_CachedStepCounter == g_dsp.step_counter)
|
||||
return;
|
||||
|
||||
// show PC
|
||||
FocusOnPC();
|
||||
m_CachedStepCounter = g_dsp.step_counter;
|
||||
m_Regs->Update();
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::UpdateSymbolMap()
|
||||
{
|
||||
if (g_dsp.dram == NULL)
|
||||
return;
|
||||
|
||||
m_SymbolList->Freeze(); // HyperIris: wx style fast filling
|
||||
m_SymbolList->Clear();
|
||||
for (SymbolDB::XFuncMap::iterator iter = DSPSymbols::g_dsp_symbol_db.GetIterator();
|
||||
iter != DSPSymbols::g_dsp_symbol_db.End(); ++iter)
|
||||
{
|
||||
int idx = m_SymbolList->Append(StrToWxStr(iter->second.name));
|
||||
m_SymbolList->SetClientData(idx, (void*)&iter->second);
|
||||
}
|
||||
m_SymbolList->Thaw();
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::OnSymbolListChange(wxCommandEvent& event)
|
||||
{
|
||||
int index = m_SymbolList->GetSelection();
|
||||
if (index >= 0) {
|
||||
Symbol* pSymbol = static_cast<Symbol *>(m_SymbolList->GetClientData(index));
|
||||
if (pSymbol != NULL)
|
||||
{
|
||||
if (pSymbol->type == Symbol::SYMBOL_FUNCTION)
|
||||
{
|
||||
JumpToAddress(pSymbol->address);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::UpdateRegisterFlags()
|
||||
{
|
||||
}
|
||||
|
||||
void DSPDebuggerLLE::OnAddrBoxChange(wxCommandEvent& event)
|
||||
{
|
||||
wxTextCtrl* pAddrCtrl = (wxTextCtrl*)m_Toolbar->FindControl(ID_ADDRBOX);
|
||||
wxString txt = pAddrCtrl->GetValue();
|
||||
|
||||
auto text = StripSpaces(WxStrToStr(txt));
|
||||
if (text.size())
|
||||
{
|
||||
u32 addr;
|
||||
sscanf(text.c_str(), "%04x", &addr);
|
||||
if (JumpToAddress(addr))
|
||||
pAddrCtrl->SetBackgroundColour(*wxWHITE);
|
||||
else
|
||||
pAddrCtrl->SetBackgroundColour(*wxRED);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
bool DSPDebuggerLLE::JumpToAddress(u16 addr)
|
||||
{
|
||||
int page = m_MainNotebook->GetSelection();
|
||||
if (page == 0)
|
||||
{
|
||||
// Center on valid instruction in IRAM/IROM
|
||||
int new_line = DSPSymbols::Addr2Line(addr);
|
||||
if (new_line >= 0) {
|
||||
m_CodeView->Center(new_line);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (page == 1)
|
||||
{
|
||||
// Center on any location in any valid ROM/RAM
|
||||
int seg = addr >> 12;
|
||||
if (seg == 0 || seg == 1 ||
|
||||
seg == 8 || seg == 0xf)
|
||||
{
|
||||
m_MemView->Center(addr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
89
Source/Core/DolphinWX/Debugger/DSPDebugWindow.h
Normal file
89
Source/Core/DolphinWX/Debugger/DSPDebugWindow.h
Normal file
@ -0,0 +1,89 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef _DSP_DEBUGGER_LLE_H
|
||||
#define _DSP_DEBUGGER_LLE_H
|
||||
|
||||
// general things
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/aui/aui.h>
|
||||
|
||||
#include "DSP/disassemble.h"
|
||||
#include "DSP/DSPInterpreter.h"
|
||||
#include "DSP/DSPMemoryMap.h"
|
||||
#include "HW/DSPLLE/DSPDebugInterface.h"
|
||||
|
||||
class DSPRegisterView;
|
||||
class CCodeView;
|
||||
class CMemoryView;
|
||||
|
||||
class DSPDebuggerLLE : public wxPanel
|
||||
{
|
||||
public:
|
||||
DSPDebuggerLLE(wxWindow *parent, wxWindowID id = wxID_ANY);
|
||||
virtual ~DSPDebuggerLLE();
|
||||
|
||||
void Update();
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
enum
|
||||
{
|
||||
ID_TOOLBAR = 1000,
|
||||
ID_RUNTOOL,
|
||||
ID_STEPTOOL,
|
||||
ID_SHOWPCTOOL,
|
||||
ID_ADDRBOX,
|
||||
ID_SYMBOLLIST,
|
||||
ID_DSP_REGS
|
||||
};
|
||||
|
||||
DSPDebugInterface debug_interface;
|
||||
u64 m_CachedStepCounter;
|
||||
|
||||
// GUI updaters
|
||||
void UpdateDisAsmListView();
|
||||
void UpdateRegisterFlags();
|
||||
void UpdateSymbolMap();
|
||||
void UpdateState();
|
||||
|
||||
// GUI items
|
||||
wxAuiManager m_mgr;
|
||||
wxAuiToolBar* m_Toolbar;
|
||||
CCodeView* m_CodeView;
|
||||
CMemoryView* m_MemView;
|
||||
DSPRegisterView* m_Regs;
|
||||
wxListBox* m_SymbolList;
|
||||
wxAuiNotebook* m_MainNotebook;
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void OnChangeState(wxCommandEvent& event);
|
||||
//void OnRightClick(wxListEvent& event);
|
||||
//void OnDoubleClick(wxListEvent& event);
|
||||
void OnAddrBoxChange(wxCommandEvent& event);
|
||||
void OnSymbolListChange(wxCommandEvent& event);
|
||||
|
||||
bool JumpToAddress(u16 addr);
|
||||
|
||||
void FocusOnPC();
|
||||
//void UnselectAll();
|
||||
};
|
||||
|
||||
extern DSPDebuggerLLE* m_DebuggerFrame;
|
||||
|
||||
#endif //_DSP_DEBUGGER_LLE_H
|
81
Source/Core/DolphinWX/Debugger/DSPRegisterView.cpp
Normal file
81
Source/Core/DolphinWX/Debugger/DSPRegisterView.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DSPDebugWindow.h"
|
||||
#include "DSPRegisterView.h"
|
||||
#include "../WxUtils.h"
|
||||
|
||||
wxString CDSPRegTable::GetValue(int row, int col)
|
||||
{
|
||||
if (row < 32) // 32 "normal" regs
|
||||
{
|
||||
switch (col)
|
||||
{
|
||||
case 0: return StrToWxStr(pdregname(row));
|
||||
case 1: return wxString::Format(wxT("0x%04x"), DSPCore_ReadRegister(row));
|
||||
default: return wxEmptyString;
|
||||
}
|
||||
}
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
void CDSPRegTable::SetValue(int, int, const wxString &)
|
||||
{
|
||||
}
|
||||
|
||||
void CDSPRegTable::UpdateCachedRegs()
|
||||
{
|
||||
if (m_CachedCounter == g_dsp.step_counter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_CachedCounter = g_dsp.step_counter;
|
||||
|
||||
for (int i = 0; i < 32; ++i)
|
||||
{
|
||||
m_CachedRegHasChanged[i] = (m_CachedRegs[i] != DSPCore_ReadRegister(i));
|
||||
m_CachedRegs[i] = DSPCore_ReadRegister(i);
|
||||
}
|
||||
}
|
||||
|
||||
wxGridCellAttr *CDSPRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind)
|
||||
{
|
||||
wxGridCellAttr *attr = new wxGridCellAttr();
|
||||
|
||||
attr->SetBackgroundColour(wxColour(wxT("#FFFFFF")));
|
||||
|
||||
switch (col)
|
||||
{
|
||||
case 1:
|
||||
attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER);
|
||||
break;
|
||||
default:
|
||||
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
|
||||
break;
|
||||
}
|
||||
|
||||
if (col == 1)
|
||||
attr->SetTextColour(m_CachedRegHasChanged[row] ? wxColor(wxT("#FF0000")) : wxColor(wxT("#000000")));
|
||||
|
||||
attr->IncRef();
|
||||
return attr;
|
||||
}
|
||||
|
||||
DSPRegisterView::DSPRegisterView(wxWindow *parent, wxWindowID id)
|
||||
: wxGrid(parent, id, wxDefaultPosition, wxSize(130, 120))
|
||||
{
|
||||
SetTable(new CDSPRegTable(), true);
|
||||
SetRowLabelSize(0);
|
||||
SetColLabelSize(0);
|
||||
DisableDragRowSize();
|
||||
|
||||
AutoSizeColumns();
|
||||
}
|
||||
|
||||
void DSPRegisterView::Update()
|
||||
{
|
||||
((CDSPRegTable *)GetTable())->UpdateCachedRegs();
|
||||
ForceRefresh();
|
||||
}
|
43
Source/Core/DolphinWX/Debugger/DSPRegisterView.h
Normal file
43
Source/Core/DolphinWX/Debugger/DSPRegisterView.h
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef __DSPREGISTERVIEW_h__
|
||||
#define __DSPREGISTERVIEW_h__
|
||||
|
||||
#include <wx/grid.h>
|
||||
|
||||
|
||||
class CDSPRegTable : public wxGridTableBase
|
||||
{
|
||||
private:
|
||||
u64 m_CachedCounter;
|
||||
u16 m_CachedRegs[32];
|
||||
bool m_CachedRegHasChanged[32];
|
||||
|
||||
DECLARE_NO_COPY_CLASS(CDSPRegTable);
|
||||
|
||||
public:
|
||||
CDSPRegTable()
|
||||
{
|
||||
memset(m_CachedRegs, 0, sizeof(m_CachedRegs));
|
||||
memset(m_CachedRegHasChanged, 0, sizeof(m_CachedRegHasChanged));
|
||||
}
|
||||
|
||||
int GetNumberCols(void) {return 2;}
|
||||
int GetNumberRows(void) {return 32;}
|
||||
bool IsEmptyCell(int row, int col) {return false;}
|
||||
wxString GetValue(int row, int col);
|
||||
void SetValue(int row, int col, const wxString &);
|
||||
wxGridCellAttr *GetAttr(int, int, wxGridCellAttr::wxAttrKind);
|
||||
void UpdateCachedRegs();
|
||||
};
|
||||
|
||||
class DSPRegisterView : public wxGrid
|
||||
{
|
||||
public:
|
||||
DSPRegisterView(wxWindow* parent, wxWindowID id);
|
||||
void Update();
|
||||
};
|
||||
|
||||
#endif //__DSPREGISTERVIEW_h__
|
346
Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp
Normal file
346
Source/Core/DolphinWX/Debugger/DebuggerPanel.cpp
Normal file
@ -0,0 +1,346 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "IniFile.h"
|
||||
#include "DebuggerPanel.h"
|
||||
#include "FileUtil.h"
|
||||
#include "../../Core/ConfigManager.h"
|
||||
|
||||
#include "VideoConfig.h"
|
||||
#include "TextureCacheBase.h"
|
||||
#include "PixelShaderGen.h"
|
||||
#include "VertexShaderGen.h"
|
||||
#include "NativeVertexFormat.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(GFXDebuggerPanel, wxPanel)
|
||||
EVT_CLOSE(GFXDebuggerPanel::OnClose)
|
||||
EVT_BUTTON(ID_PAUSE,GFXDebuggerPanel::OnPauseButton)
|
||||
EVT_BUTTON(ID_PAUSE_AT_NEXT,GFXDebuggerPanel::OnPauseAtNextButton)
|
||||
EVT_BUTTON(ID_PAUSE_AT_NEXT_FRAME,GFXDebuggerPanel::OnPauseAtNextFrameButton)
|
||||
EVT_BUTTON(ID_CONT,GFXDebuggerPanel::OnContButton)
|
||||
EVT_BUTTON(ID_DUMP,GFXDebuggerPanel::OnDumpButton)
|
||||
EVT_BUTTON(ID_UPDATE_SCREEN,GFXDebuggerPanel::OnUpdateScreenButton)
|
||||
EVT_BUTTON(ID_CLEAR_SCREEN,GFXDebuggerPanel::OnClearScreenButton)
|
||||
EVT_BUTTON(ID_CLEAR_TEXTURE_CACHE,GFXDebuggerPanel::OnClearTextureCacheButton)
|
||||
EVT_BUTTON(ID_CLEAR_VERTEX_SHADER_CACHE,GFXDebuggerPanel::OnClearVertexShaderCacheButton)
|
||||
EVT_BUTTON(ID_CLEAR_PIXEL_SHADER_CACHE,GFXDebuggerPanel::OnClearPixelShaderCacheButton)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// From VideoCommon
|
||||
extern GFXDebuggerBase *g_pdebugger;
|
||||
extern volatile bool GFXDebuggerPauseFlag;
|
||||
extern volatile PauseEvent GFXDebuggerToPauseAtNext;
|
||||
extern volatile int GFXDebuggerEventToPauseCount;
|
||||
|
||||
GFXDebuggerPanel::GFXDebuggerPanel(wxWindow *parent, wxWindowID id, const wxPoint &position,
|
||||
const wxSize& size, long style, const wxString &title)
|
||||
: wxPanel(parent, id, position, size, style, title)
|
||||
{
|
||||
g_pdebugger = this;
|
||||
|
||||
CreateGUIControls();
|
||||
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
GFXDebuggerPanel::~GFXDebuggerPanel()
|
||||
{
|
||||
g_pdebugger = NULL;
|
||||
GFXDebuggerPauseFlag = false;
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnClose(wxCloseEvent& event)
|
||||
{
|
||||
// save the window position when we hide the window
|
||||
SaveSettings();
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::SaveSettings() const
|
||||
{
|
||||
IniFile file;
|
||||
file.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
// TODO: make this work when we close the entire program too, currently on total close we get
|
||||
// weird values, perhaps because of some conflict with the rendering window
|
||||
|
||||
// TODO: get the screen resolution and make limits from that
|
||||
if (GetPosition().x < 1000 && GetPosition().y < 1000
|
||||
&& GetSize().GetWidth() < 1000
|
||||
&& GetSize().GetHeight() < 1000)
|
||||
{
|
||||
file.Set("VideoWindow", "x", GetPosition().x);
|
||||
file.Set("VideoWindow", "y", GetPosition().y);
|
||||
file.Set("VideoWindow", "w", GetSize().GetWidth());
|
||||
file.Set("VideoWindow", "h", GetSize().GetHeight());
|
||||
}
|
||||
|
||||
file.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::LoadSettings()
|
||||
{
|
||||
IniFile file;
|
||||
file.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
int x = 100, y = 100, w = 100, h = 100;
|
||||
file.Get("VideoWindow", "x", &x, GetPosition().x);
|
||||
file.Get("VideoWindow", "y", &y, GetPosition().y);
|
||||
file.Get("VideoWindow", "w", &w, GetSize().GetWidth());
|
||||
file.Get("VideoWindow", "h", &h, GetSize().GetHeight());
|
||||
SetSize(x, y, w, h);
|
||||
}
|
||||
|
||||
struct PauseEventMap
|
||||
{
|
||||
PauseEvent event;
|
||||
const wxString ListStr;
|
||||
};
|
||||
|
||||
static PauseEventMap* pauseEventMap;
|
||||
|
||||
void GFXDebuggerPanel::CreateGUIControls()
|
||||
{
|
||||
static PauseEventMap map[] = {
|
||||
{NEXT_FRAME, _("Frame")},
|
||||
{NEXT_FLUSH, _("Flush")},
|
||||
|
||||
{NEXT_PIXEL_SHADER_CHANGE, _("Pixel Shader")},
|
||||
{NEXT_VERTEX_SHADER_CHANGE, _("Vertex Shader")},
|
||||
{NEXT_TEXTURE_CHANGE, _("Texture")},
|
||||
{NEXT_NEW_TEXTURE, _("New Texture")},
|
||||
|
||||
{NEXT_XFB_CMD, _("XFB Cmd")},
|
||||
{NEXT_EFB_CMD, _("EFB Cmd")},
|
||||
|
||||
{NEXT_MATRIX_CMD, _("Matrix Cmd")},
|
||||
{NEXT_VERTEX_CMD, _("Vertex Cmd")},
|
||||
{NEXT_TEXTURE_CMD, _("Texture Cmd")},
|
||||
{NEXT_LIGHT_CMD, _("Light Cmd")},
|
||||
{NEXT_FOG_CMD, _("Fog Cmd")},
|
||||
|
||||
{NEXT_SET_TLUT, _("TLUT Cmd")},
|
||||
|
||||
{NEXT_ERROR, _("Error")}
|
||||
};
|
||||
pauseEventMap = map;
|
||||
const int numPauseEventMap = sizeof(map)/sizeof(PauseEventMap);
|
||||
|
||||
// Basic settings
|
||||
CenterOnParent();
|
||||
|
||||
m_pButtonPause = new wxButton(this, ID_PAUSE, _("Pause"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Pause"));
|
||||
m_pButtonPauseAtNext = new wxButton(this, ID_PAUSE_AT_NEXT, _("Pause After"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Pause At Next"));
|
||||
m_pButtonPauseAtNextFrame = new wxButton(this, ID_PAUSE_AT_NEXT_FRAME, _("Go to Next Frame"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Next Frame"));
|
||||
m_pButtonCont = new wxButton(this, ID_CONT, _("Continue"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Continue"));
|
||||
|
||||
m_pCount = new wxTextCtrl(this, ID_COUNT, wxT("1"), wxDefaultPosition, wxSize(50,25), wxTE_RIGHT, wxDefaultValidator, _("Count"));
|
||||
|
||||
m_pPauseAtList = new wxChoice(this, ID_PAUSE_AT_LIST, wxDefaultPosition, wxSize(100,25), 0, NULL,0,wxDefaultValidator, _("PauseAtList"));
|
||||
for (int i=0; i<numPauseEventMap; i++)
|
||||
{
|
||||
m_pPauseAtList->Append(pauseEventMap[i].ListStr);
|
||||
}
|
||||
m_pPauseAtList->SetSelection(0);
|
||||
|
||||
m_pButtonDump = new wxButton(this, ID_DUMP, _("Dump"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Dump"));
|
||||
m_pButtonUpdateScreen = new wxButton(this, ID_UPDATE_SCREEN, _("Update Screen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Update Screen"));
|
||||
m_pButtonClearScreen = new wxButton(this, ID_CLEAR_SCREEN, _("Clear Screen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear Screen"));
|
||||
m_pButtonClearTextureCache = new wxButton(this, ID_CLEAR_TEXTURE_CACHE, _("Clear Textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear Textures"));
|
||||
m_pButtonClearVertexShaderCache = new wxButton(this, ID_CLEAR_VERTEX_SHADER_CACHE, _("Clear V Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear V Shaders"));
|
||||
m_pButtonClearPixelShaderCache = new wxButton(this, ID_CLEAR_PIXEL_SHADER_CACHE, _("Clear P Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Clear P Shaders"));
|
||||
|
||||
m_pDumpList = new wxChoice(this, ID_DUMP_LIST, wxDefaultPosition, wxSize(120,25), 0, NULL, 0 ,wxDefaultValidator, _("DumpList"));
|
||||
m_pDumpList->Insert(_("Pixel Shader"),0);
|
||||
m_pDumpList->Append(_("Vertex Shader"));
|
||||
m_pDumpList->Append(_("Pixel Shader Constants"));
|
||||
m_pDumpList->Append(_("Vertex Shader Constants"));
|
||||
m_pDumpList->Append(_("Textures"));
|
||||
m_pDumpList->Append(_("Frame Buffer"));
|
||||
m_pDumpList->Append(_("Geometry data"));
|
||||
m_pDumpList->Append(_("Vertex Description"));
|
||||
m_pDumpList->Append(_("Vertex Matrices"));
|
||||
m_pDumpList->Append(_("Statistics"));
|
||||
m_pDumpList->SetSelection(0);
|
||||
|
||||
// Layout everything on m_MainPanel
|
||||
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxStaticBoxSizer* const pFlowCtrlBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Flow Control"));
|
||||
wxBoxSizer* const pPauseAtNextSzr = new wxBoxSizer(wxHORIZONTAL);
|
||||
pFlowCtrlBox->Add(m_pButtonPause);
|
||||
pPauseAtNextSzr->Add(m_pButtonPauseAtNext);
|
||||
pPauseAtNextSzr->Add(m_pCount);
|
||||
pPauseAtNextSzr->Add(m_pPauseAtList);
|
||||
pFlowCtrlBox->Add(pPauseAtNextSzr);
|
||||
pFlowCtrlBox->Add(m_pButtonPauseAtNextFrame);
|
||||
pFlowCtrlBox->Add(m_pButtonCont);
|
||||
|
||||
wxStaticBoxSizer* const pDebugBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Debugging"));
|
||||
wxBoxSizer* const pDumpSzr = new wxBoxSizer(wxHORIZONTAL);
|
||||
pDumpSzr->Add(m_pButtonDump);
|
||||
pDumpSzr->Add(m_pDumpList);
|
||||
pDebugBox->Add(pDumpSzr);
|
||||
wxGridSizer* const pDbgGrid = new wxGridSizer(2, 5, 5);
|
||||
pDbgGrid->Add(m_pButtonUpdateScreen);
|
||||
pDbgGrid->Add(m_pButtonClearScreen);
|
||||
pDbgGrid->Add(m_pButtonClearTextureCache);
|
||||
pDbgGrid->Add(m_pButtonClearVertexShaderCache);
|
||||
pDbgGrid->Add(m_pButtonClearPixelShaderCache);
|
||||
pDebugBox->Add(pDbgGrid);
|
||||
|
||||
sMain->Add(pFlowCtrlBox, 0, 0, 5);
|
||||
sMain->Add(pDebugBox, 0, 0, 5);
|
||||
SetSizerAndFit(sMain);
|
||||
|
||||
OnContinue();
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnPause()
|
||||
{
|
||||
m_pButtonDump->Enable(true);
|
||||
m_pDumpList->Enable(true);
|
||||
m_pButtonUpdateScreen->Enable(true);
|
||||
m_pButtonClearScreen->Enable(true);
|
||||
m_pButtonClearTextureCache->Enable(true);
|
||||
m_pButtonClearVertexShaderCache->Enable(true);
|
||||
m_pButtonClearPixelShaderCache->Enable(true);
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnContinue()
|
||||
{
|
||||
m_pButtonDump->Enable(false);
|
||||
m_pDumpList->Enable(false);
|
||||
m_pButtonUpdateScreen->Enable(false);
|
||||
m_pButtonClearScreen->Enable(false);
|
||||
m_pButtonClearTextureCache->Enable(false);
|
||||
m_pButtonClearVertexShaderCache->Enable(false);
|
||||
m_pButtonClearPixelShaderCache->Enable(false);
|
||||
}
|
||||
|
||||
|
||||
// General settings
|
||||
void GFXDebuggerPanel::GeneralSettings(wxCommandEvent& event)
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnPauseButton(wxCommandEvent& event)
|
||||
{
|
||||
GFXDebuggerPauseFlag = true;
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnPauseAtNextButton(wxCommandEvent& event)
|
||||
{
|
||||
GFXDebuggerPauseFlag = false;
|
||||
GFXDebuggerToPauseAtNext = pauseEventMap[m_pPauseAtList->GetSelection()].event;
|
||||
wxString val = m_pCount->GetValue();
|
||||
long value;
|
||||
if (val.ToLong(&value))
|
||||
GFXDebuggerEventToPauseCount = value;
|
||||
else
|
||||
GFXDebuggerEventToPauseCount = 1;
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnPauseAtNextFrameButton(wxCommandEvent& event)
|
||||
{
|
||||
GFXDebuggerPauseFlag = false;
|
||||
GFXDebuggerToPauseAtNext = NEXT_FRAME;
|
||||
GFXDebuggerEventToPauseCount = 1;
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnDumpButton(wxCommandEvent& event)
|
||||
{
|
||||
std::string dump_path = File::GetUserPath(D_DUMP_IDX) + "Debug/" +
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID + "/";
|
||||
if (!File::CreateFullPath(dump_path))
|
||||
return;
|
||||
|
||||
switch (m_pDumpList->GetSelection())
|
||||
{
|
||||
case 0: // Pixel Shader
|
||||
DumpPixelShader(dump_path.c_str());
|
||||
break;
|
||||
|
||||
case 1: // Vertex Shader
|
||||
DumpVertexShader(dump_path.c_str());
|
||||
break;
|
||||
|
||||
case 2: // Pixel Shader Constants
|
||||
DumpPixelShaderConstants(dump_path.c_str());
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
break;
|
||||
|
||||
case 3: // Vertex Shader Constants
|
||||
DumpVertexShaderConstants(dump_path.c_str());
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
break;
|
||||
|
||||
case 4: // Textures
|
||||
DumpTextures(dump_path.c_str());
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
break;
|
||||
|
||||
case 5: // Frame Buffer
|
||||
DumpFrameBuffer(dump_path.c_str());
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
break;
|
||||
|
||||
case 6: // Geometry
|
||||
DumpGeometry(dump_path.c_str());
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
break;
|
||||
|
||||
case 7: // Vertex Description
|
||||
DumpVertexDecl(dump_path.c_str());
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
break;
|
||||
|
||||
case 8: // Vertex Matrices
|
||||
DumpMatrices(dump_path.c_str());
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
break;
|
||||
|
||||
case 9: // Statistics
|
||||
DumpStats(dump_path.c_str());
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnContButton(wxCommandEvent& event)
|
||||
{
|
||||
GFXDebuggerToPauseAtNext = NOT_PAUSE;
|
||||
GFXDebuggerPauseFlag = false;
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnClearScreenButton(wxCommandEvent& event)
|
||||
{
|
||||
// TODO
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnClearTextureCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
TextureCache::Invalidate();
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnClearVertexShaderCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
// TODO
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnClearPixelShaderCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
// TODO
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
}
|
||||
|
||||
void GFXDebuggerPanel::OnUpdateScreenButton(wxCommandEvent& event)
|
||||
{
|
||||
wxMessageBox(_("Not implemented"), _("Error"), wxOK);
|
||||
GFXDebuggerUpdateScreen();
|
||||
}
|
100
Source/Core/DolphinWX/Debugger/DebuggerPanel.h
Normal file
100
Source/Core/DolphinWX/Debugger/DebuggerPanel.h
Normal file
@ -0,0 +1,100 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef _GFX_DEBUGGER_PANEL_H_
|
||||
#define _GFX_DEBUGGER_PANEL_H_
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
#include "Debugger.h"
|
||||
|
||||
class GFXDebuggerPanel : public wxPanel, public GFXDebuggerBase
|
||||
{
|
||||
public:
|
||||
GFXDebuggerPanel(wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL,
|
||||
const wxString &title = _("GFX Debugger"));
|
||||
|
||||
virtual ~GFXDebuggerPanel();
|
||||
|
||||
void SaveSettings() const;
|
||||
void LoadSettings();
|
||||
|
||||
bool bInfoLog;
|
||||
bool bPrimLog;
|
||||
bool bSaveTextures;
|
||||
bool bSaveTargets;
|
||||
bool bSaveShaders;
|
||||
|
||||
void OnPause();
|
||||
|
||||
// Called from GFX thread once the GFXDebuggerPauseFlag spin lock has finished
|
||||
void OnContinue();
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
wxPanel *m_MainPanel;
|
||||
|
||||
wxButton *m_pButtonPause;
|
||||
wxButton *m_pButtonPauseAtNext;
|
||||
wxButton *m_pButtonPauseAtNextFrame;
|
||||
wxButton *m_pButtonCont;
|
||||
wxChoice *m_pPauseAtList;
|
||||
wxButton *m_pButtonDump;
|
||||
wxChoice *m_pDumpList;
|
||||
wxButton *m_pButtonUpdateScreen;
|
||||
wxButton *m_pButtonClearScreen;
|
||||
wxButton *m_pButtonClearTextureCache;
|
||||
wxButton *m_pButtonClearVertexShaderCache;
|
||||
wxButton *m_pButtonClearPixelShaderCache;
|
||||
wxTextCtrl *m_pCount;
|
||||
|
||||
|
||||
// TODO: Prefix with GFX_
|
||||
enum
|
||||
{
|
||||
ID_MAINPANEL = 3900,
|
||||
ID_CONT,
|
||||
ID_PAUSE,
|
||||
ID_PAUSE_AT_NEXT,
|
||||
ID_PAUSE_AT_NEXT_FRAME,
|
||||
ID_PAUSE_AT_LIST,
|
||||
ID_DUMP,
|
||||
ID_DUMP_LIST,
|
||||
ID_UPDATE_SCREEN,
|
||||
ID_CLEAR_SCREEN,
|
||||
ID_CLEAR_TEXTURE_CACHE,
|
||||
ID_CLEAR_VERTEX_SHADER_CACHE,
|
||||
ID_CLEAR_PIXEL_SHADER_CACHE,
|
||||
ID_COUNT
|
||||
};
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void CreateGUIControls();
|
||||
|
||||
void GeneralSettings(wxCommandEvent& event);
|
||||
|
||||
// These set GFXDebuggerPauseFlag to true (either immediately or once the specified event has occurred)
|
||||
void OnPauseButton(wxCommandEvent& event);
|
||||
void OnPauseAtNextButton(wxCommandEvent& event);
|
||||
|
||||
void OnPauseAtNextFrameButton(wxCommandEvent& event);
|
||||
void OnDumpButton(wxCommandEvent& event);
|
||||
|
||||
// sets GFXDebuggerPauseFlag to false
|
||||
void OnContButton(wxCommandEvent& event);
|
||||
|
||||
void OnUpdateScreenButton(wxCommandEvent& event);
|
||||
void OnClearScreenButton(wxCommandEvent& event);
|
||||
void OnClearTextureCacheButton(wxCommandEvent& event);
|
||||
void OnClearVertexShaderCacheButton(wxCommandEvent& event);
|
||||
void OnClearPixelShaderCacheButton(wxCommandEvent& event);
|
||||
void OnCountEnter(wxCommandEvent& event);
|
||||
};
|
||||
|
||||
#endif // _GFX_DEBUGGER_PANEL_H_
|
10
Source/Core/DolphinWX/Debugger/DebuggerUIUtil.cpp
Normal file
10
Source/Core/DolphinWX/Debugger/DebuggerUIUtil.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
||||
#include "DebuggerUIUtil.h"
|
||||
|
||||
// The default font
|
||||
wxFont DebuggerFont = wxFont(9, wxMODERN, wxNORMAL, wxNORMAL, false, wxT("monospace"));
|
||||
|
12
Source/Core/DolphinWX/Debugger/DebuggerUIUtil.h
Normal file
12
Source/Core/DolphinWX/Debugger/DebuggerUIUtil.h
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef _DEBUGGER_UI_UTIL_H
|
||||
#define _DEBUGGER_UI_UTIL_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
extern wxFont DebuggerFont;
|
||||
|
||||
#endif
|
244
Source/Core/DolphinWX/Debugger/JitWindow.cpp
Normal file
244
Source/Core/DolphinWX/Debugger/JitWindow.cpp
Normal file
@ -0,0 +1,244 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <wx/button.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/thread.h>
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
#include "JitWindow.h"
|
||||
#include "HW/CPU.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "PowerPC/JitCommon/JitBase.h"
|
||||
#include "PowerPC/JitCommon/JitCache.h"
|
||||
#include "PowerPC/PPCAnalyst.h"
|
||||
#include "PowerPCDisasm.h"
|
||||
#include "disasm.h"
|
||||
|
||||
#include "Debugger/PPCDebugInterface.h"
|
||||
#include "Debugger/Debugger_SymbolMap.h"
|
||||
|
||||
#include "Core.h"
|
||||
#include "StringUtil.h"
|
||||
#include "LogManager.h"
|
||||
#include "../WxUtils.h"
|
||||
|
||||
#include "../Globals.h"
|
||||
|
||||
enum
|
||||
{
|
||||
IDM_REFRESH_LIST = 23350,
|
||||
IDM_PPC_BOX,
|
||||
IDM_X86_BOX,
|
||||
IDM_NEXT,
|
||||
IDM_PREV,
|
||||
IDM_BLOCKLIST,
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CJitWindow, wxPanel)
|
||||
//EVT_TEXT(IDM_ADDRBOX, CJitWindow::OnAddrBoxChange)
|
||||
//EVT_LISTBOX(IDM_SYMBOLLIST, CJitWindow::OnSymbolListChange)
|
||||
//EVT_HOST_COMMAND(wxID_ANY, CJitWindow::OnHostMessage)
|
||||
EVT_BUTTON(IDM_REFRESH_LIST, CJitWindow::OnRefresh)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CJitWindow::CJitWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
||||
const wxSize& size, long style, const wxString& name)
|
||||
: wxPanel(parent, id, pos, size, style, name)
|
||||
{
|
||||
wxBoxSizer* sizerBig = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer* sizerSplit = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizerSplit->Add(ppc_box = new wxTextCtrl(this, IDM_PPC_BOX, _T("(ppc)"),
|
||||
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE), 1, wxEXPAND);
|
||||
sizerSplit->Add(x86_box = new wxTextCtrl(this, IDM_X86_BOX, _T("(x86)"),
|
||||
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE), 1, wxEXPAND);
|
||||
sizerBig->Add(block_list = new JitBlockList(this, IDM_BLOCKLIST,
|
||||
wxDefaultPosition, wxSize(100, 140),
|
||||
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING),
|
||||
0, wxEXPAND);
|
||||
sizerBig->Add(sizerSplit, 2, wxEXPAND);
|
||||
// sizerBig->Add(memview, 5, wxEXPAND);
|
||||
// sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3);
|
||||
sizerBig->Add(button_refresh = new wxButton(this, IDM_REFRESH_LIST, _("&Refresh")));
|
||||
// sizerRight->Add(addrbox = new wxTextCtrl(this, IDM_ADDRBOX, _T("")));
|
||||
// sizerRight->Add(new wxButton(this, IDM_SETPC, _("S&et PC")));
|
||||
|
||||
SetSizer(sizerBig);
|
||||
|
||||
sizerSplit->Fit(this);
|
||||
sizerBig->Fit(this);
|
||||
}
|
||||
|
||||
void CJitWindow::OnRefresh(wxCommandEvent& /*event*/) {
|
||||
block_list->Update();
|
||||
}
|
||||
|
||||
void CJitWindow::ViewAddr(u32 em_address)
|
||||
{
|
||||
Show(true);
|
||||
Compare(em_address);
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
void CJitWindow::Compare(u32 em_address)
|
||||
{
|
||||
u8 *xDis = new u8[1<<18];
|
||||
memset(xDis, 0, 1<<18);
|
||||
|
||||
disassembler x64disasm;
|
||||
x64disasm.set_syntax_intel();
|
||||
|
||||
int block_num = jit->GetBlockCache()->GetBlockNumberFromStartAddress(em_address);
|
||||
if (block_num < 0)
|
||||
{
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
block_num = jit->GetBlockCache()->GetBlockNumberFromStartAddress(em_address - 4 * i);
|
||||
if (block_num >= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (block_num >= 0)
|
||||
{
|
||||
JitBlock *block = jit->GetBlockCache()->GetBlock(block_num);
|
||||
if (!(block->originalAddress <= em_address &&
|
||||
block->originalSize + block->originalAddress >= em_address))
|
||||
block_num = -1;
|
||||
}
|
||||
|
||||
// Do not merge this "if" with the above - block_num changes inside it.
|
||||
if (block_num < 0)
|
||||
{
|
||||
ppc_box->SetValue(StrToWxStr(StringFromFormat("(non-code address: %08x)",
|
||||
em_address)));
|
||||
x86_box->SetValue(StrToWxStr(StringFromFormat("(no translation)")));
|
||||
delete[] xDis;
|
||||
return;
|
||||
}
|
||||
}
|
||||
JitBlock *block = jit->GetBlockCache()->GetBlock(block_num);
|
||||
|
||||
// 800031f0
|
||||
// == Fill in x86 box
|
||||
|
||||
const u8 *code = (const u8 *)jit->GetBlockCache()->GetCompiledCodeFromBlock(block_num);
|
||||
u64 disasmPtr = (u64)code;
|
||||
int size = block->codeSize;
|
||||
const u8 *end = code + size;
|
||||
char *sptr = (char*)xDis;
|
||||
|
||||
int num_x86_instructions = 0;
|
||||
while ((u8*)disasmPtr < end)
|
||||
{
|
||||
#ifdef _M_X64
|
||||
disasmPtr += x64disasm.disasm64(disasmPtr, disasmPtr, (u8*)disasmPtr, sptr);
|
||||
#else
|
||||
disasmPtr += x64disasm.disasm32(disasmPtr, disasmPtr, (u8*)disasmPtr, sptr);
|
||||
#endif
|
||||
sptr += strlen(sptr);
|
||||
*sptr++ = 13;
|
||||
*sptr++ = 10;
|
||||
num_x86_instructions++;
|
||||
}
|
||||
x86_box->SetValue(StrToWxStr((char*)xDis));
|
||||
|
||||
// == Fill in ppc box
|
||||
u32 ppc_addr = block->originalAddress;
|
||||
PPCAnalyst::CodeBuffer code_buffer(32000);
|
||||
PPCAnalyst::BlockStats st;
|
||||
PPCAnalyst::BlockRegStats gpa;
|
||||
PPCAnalyst::BlockRegStats fpa;
|
||||
bool broken_block = false;
|
||||
u32 merged_addresses[32];
|
||||
const int capacity_of_merged_addresses = sizeof(merged_addresses) / sizeof(merged_addresses[0]);
|
||||
int size_of_merged_addresses;
|
||||
if (PPCAnalyst::Flatten(ppc_addr, &size, &st, &gpa, &fpa, broken_block, &code_buffer, size, merged_addresses, capacity_of_merged_addresses, size_of_merged_addresses) != 0xffffffff)
|
||||
{
|
||||
sptr = (char*)xDis;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
const PPCAnalyst::CodeOp &op = code_buffer.codebuffer[i];
|
||||
char temp[256];
|
||||
DisassembleGekko(op.inst.hex, op.address, temp, 256);
|
||||
sptr += sprintf(sptr, "%08x %s\n", op.address, temp);
|
||||
}
|
||||
|
||||
// Add stats to the end of the ppc box since it's generally the shortest.
|
||||
sptr += sprintf(sptr, "\n");
|
||||
|
||||
// Add some generic analysis
|
||||
if (st.isFirstBlockOfFunction)
|
||||
sptr += sprintf(sptr, "(first block of function)\n");
|
||||
if (st.isLastBlockOfFunction)
|
||||
sptr += sprintf(sptr, "(first block of function)\n");
|
||||
|
||||
sptr += sprintf(sptr, "%i estimated cycles\n", st.numCycles);
|
||||
|
||||
sptr += sprintf(sptr, "Num instr: PPC: %i x86: %i (blowup: %i%%)\n",
|
||||
size, num_x86_instructions, 100 * (num_x86_instructions / size - 1));
|
||||
sptr += sprintf(sptr, "Num bytes: PPC: %i x86: %i (blowup: %i%%)\n",
|
||||
size * 4, block->codeSize, 100 * (block->codeSize / (4 * size) - 1));
|
||||
|
||||
ppc_box->SetValue(StrToWxStr((char*)xDis));
|
||||
}
|
||||
else
|
||||
{
|
||||
ppc_box->SetValue(StrToWxStr(StringFromFormat(
|
||||
"(non-code address: %08x)", em_address)));
|
||||
x86_box->SetValue("---");
|
||||
}
|
||||
|
||||
delete[] xDis;
|
||||
}
|
||||
|
||||
void CJitWindow::Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CJitWindow::OnHostMessage(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case IDM_NOTIFYMAPLOADED:
|
||||
//NotifyMapLoaded();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// JitBlockList
|
||||
//================
|
||||
|
||||
enum {
|
||||
COLUMN_ADDRESS,
|
||||
COLUMN_PPCSIZE,
|
||||
COLUMN_X86SIZE,
|
||||
COLUMN_NAME,
|
||||
COLUMN_FLAGS,
|
||||
COLUMN_NUMEXEC,
|
||||
COLUMN_COST, // (estimated as x86size * numexec)
|
||||
};
|
||||
|
||||
JitBlockList::JitBlockList(wxWindow* parent, const wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style)
|
||||
: wxListCtrl(parent, id, pos, size, style) // | wxLC_VIRTUAL)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
void JitBlockList::Init()
|
||||
{
|
||||
InsertColumn(COLUMN_ADDRESS, _("Address"));
|
||||
InsertColumn(COLUMN_PPCSIZE, _("PPC Size"));
|
||||
InsertColumn(COLUMN_X86SIZE, _("x86 Size"));
|
||||
InsertColumn(COLUMN_NAME, _("Symbol"));
|
||||
InsertColumn(COLUMN_FLAGS, _("Flags"));
|
||||
InsertColumn(COLUMN_NUMEXEC, _("NumExec"));
|
||||
InsertColumn(COLUMN_COST, _("Cost"));
|
||||
}
|
||||
|
||||
void JitBlockList::Update()
|
||||
{
|
||||
}
|
59
Source/Core/DolphinWX/Debugger/JitWindow.h
Normal file
59
Source/Core/DolphinWX/Debugger/JitWindow.h
Normal file
@ -0,0 +1,59 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef JITWINDOW_H_
|
||||
#define JITWINDOW_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/listbox.h>
|
||||
|
||||
#include "MemoryView.h"
|
||||
#include "Thread.h"
|
||||
#include "CoreParameter.h"
|
||||
|
||||
class JitBlockList : public wxListCtrl
|
||||
{
|
||||
std::vector<int> block_ranking;
|
||||
public:
|
||||
JitBlockList(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
|
||||
void Init();
|
||||
void Update();
|
||||
};
|
||||
|
||||
class CJitWindow : public wxPanel
|
||||
{
|
||||
public:
|
||||
CJitWindow(wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL | wxBORDER_NONE,
|
||||
const wxString& name = _("JIT block viewer"));
|
||||
|
||||
void ViewAddr(u32 em_address);
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void OnRefresh(wxCommandEvent& /*event*/);
|
||||
void Compare(u32 em_address);
|
||||
|
||||
JitBlockList* block_list;
|
||||
wxButton* button_refresh;
|
||||
wxTextCtrl* ppc_box;
|
||||
wxTextCtrl* x86_box;
|
||||
wxListBox* top_instructions;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
void OnSymbolListChange(wxCommandEvent& event);
|
||||
void OnCallstackListChange(wxCommandEvent& event);
|
||||
void OnAddrBoxChange(wxCommandEvent& event);
|
||||
void OnHostMessage(wxCommandEvent& event);
|
||||
};
|
||||
|
||||
#endif /*MEMORYWINDOW_*/
|
94
Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp
Normal file
94
Source/Core/DolphinWX/Debugger/MemoryCheckDlg.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "../WxUtils.h"
|
||||
#include "MemoryCheckDlg.h"
|
||||
#include "Common.h"
|
||||
#include "StringUtil.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "BreakpointWindow.h"
|
||||
|
||||
#define TEXT_BOX(text) new wxStaticText(this, wxID_ANY, wxT(text), wxDefaultPosition, wxDefaultSize)
|
||||
|
||||
BEGIN_EVENT_TABLE(MemoryCheckDlg, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, MemoryCheckDlg::OnOK)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MemoryCheckDlg::MemoryCheckDlg(CBreakPointWindow *parent)
|
||||
: wxDialog(parent, wxID_ANY, _("Memory Check"), wxDefaultPosition, wxDefaultSize)
|
||||
, m_parent(parent)
|
||||
{
|
||||
m_pEditStartAddress = new wxTextCtrl(this, wxID_ANY, wxT(""));
|
||||
m_pEditEndAddress = new wxTextCtrl(this, wxID_ANY, wxT(""));
|
||||
m_pWriteFlag = new wxCheckBox(this, wxID_ANY, _("Write"));
|
||||
m_pWriteFlag->SetValue(true);
|
||||
m_pReadFlag = new wxCheckBox(this, wxID_ANY, _("Read"));
|
||||
|
||||
m_log_flag = new wxCheckBox(this, wxID_ANY, _("Log"));
|
||||
m_log_flag->SetValue(true);
|
||||
m_break_flag = new wxCheckBox(this, wxID_ANY, _("Break"));
|
||||
|
||||
wxStaticBoxSizer *sAddressRangeBox = new wxStaticBoxSizer(wxHORIZONTAL, this, wxT("Address Range"));
|
||||
sAddressRangeBox->Add(TEXT_BOX("Start"), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
|
||||
sAddressRangeBox->Add(m_pEditStartAddress, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, 10);
|
||||
sAddressRangeBox->Add(TEXT_BOX("End"), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
|
||||
sAddressRangeBox->Add(m_pEditEndAddress, 1, wxALIGN_CENTER_VERTICAL);
|
||||
|
||||
wxStaticBoxSizer *sActionBox = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Action"));
|
||||
sActionBox->Add(m_pWriteFlag);
|
||||
sActionBox->Add(m_pReadFlag);
|
||||
|
||||
wxBoxSizer* sFlags = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Flags"));
|
||||
sFlags->Add(m_log_flag);
|
||||
sFlags->Add(m_break_flag);
|
||||
|
||||
wxBoxSizer *sControls = new wxBoxSizer(wxHORIZONTAL);
|
||||
sControls->Add(sAddressRangeBox, 0, wxEXPAND);
|
||||
sControls->Add(sActionBox, 0, wxEXPAND);
|
||||
sControls->Add(sFlags, 0, wxEXPAND);
|
||||
|
||||
wxBoxSizer *sMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
sMainSizer->Add(sControls, 0, wxEXPAND | wxALL, 5);
|
||||
sMainSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
|
||||
|
||||
SetSizerAndFit(sMainSizer);
|
||||
SetFocus();
|
||||
}
|
||||
|
||||
void MemoryCheckDlg::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
wxString StartAddressString = m_pEditStartAddress->GetLineText(0);
|
||||
wxString EndAddressString = m_pEditEndAddress->GetLineText(0);
|
||||
bool OnRead = m_pReadFlag->GetValue();
|
||||
bool OnWrite = m_pWriteFlag->GetValue();
|
||||
bool Log = m_log_flag->GetValue();
|
||||
bool Break = m_break_flag->GetValue();;
|
||||
|
||||
u32 StartAddress, EndAddress;
|
||||
bool EndAddressOK = EndAddressString.Len() &&
|
||||
AsciiToHex(WxStrToStr(EndAddressString).c_str(), EndAddress);
|
||||
|
||||
if (AsciiToHex(WxStrToStr(StartAddressString).c_str(), StartAddress) &&
|
||||
(OnRead || OnWrite) && (Log || Break))
|
||||
{
|
||||
TMemCheck MemCheck;
|
||||
|
||||
if (!EndAddressOK)
|
||||
EndAddress = StartAddress;
|
||||
|
||||
MemCheck.StartAddress = StartAddress;
|
||||
MemCheck.EndAddress = EndAddress;
|
||||
MemCheck.bRange = StartAddress != EndAddress;
|
||||
MemCheck.OnRead = OnRead;
|
||||
MemCheck.OnWrite = OnWrite;
|
||||
MemCheck.Log = Log;
|
||||
MemCheck.Break = Break;
|
||||
|
||||
PowerPC::memchecks.Add(MemCheck);
|
||||
m_parent->NotifyUpdate();
|
||||
Close();
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
31
Source/Core/DolphinWX/Debugger/MemoryCheckDlg.h
Normal file
31
Source/Core/DolphinWX/Debugger/MemoryCheckDlg.h
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef __MEMORYCHECKDLG_h__
|
||||
#define __MEMORYCHECKDLG_h__
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class CBreakPointWindow;
|
||||
|
||||
class MemoryCheckDlg : public wxDialog
|
||||
{
|
||||
public:
|
||||
MemoryCheckDlg(CBreakPointWindow *parent);
|
||||
|
||||
private:
|
||||
CBreakPointWindow *m_parent;
|
||||
wxCheckBox* m_pReadFlag;
|
||||
wxCheckBox* m_pWriteFlag;
|
||||
wxCheckBox* m_log_flag;
|
||||
wxCheckBox* m_break_flag;
|
||||
wxTextCtrl* m_pEditEndAddress;
|
||||
wxTextCtrl* m_pEditStartAddress;
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif
|
383
Source/Core/DolphinWX/Debugger/MemoryView.cpp
Normal file
383
Source/Core/DolphinWX/Debugger/MemoryView.cpp
Normal file
@ -0,0 +1,383 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DebuggerUIUtil.h"
|
||||
#include "Common.h"
|
||||
#include "Host.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "HW/Memmap.h"
|
||||
|
||||
#include "MemoryView.h"
|
||||
#include "../WxUtils.h"
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/clipbrd.h>
|
||||
|
||||
enum
|
||||
{
|
||||
IDM_GOTOINMEMVIEW = 12000,
|
||||
IDM_COPYADDRESS,
|
||||
IDM_COPYHEX,
|
||||
IDM_COPYCODE,
|
||||
IDM_RUNTOHERE,
|
||||
IDM_DYNARECRESULTS,
|
||||
IDM_TOGGLEMEMORY,
|
||||
IDM_VIEWASFP,
|
||||
IDM_VIEWASASCII,
|
||||
IDM_VIEWASHEX,
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CMemoryView, wxControl)
|
||||
EVT_PAINT(CMemoryView::OnPaint)
|
||||
EVT_LEFT_DOWN(CMemoryView::OnMouseDownL)
|
||||
EVT_LEFT_UP(CMemoryView::OnMouseUpL)
|
||||
EVT_MOTION(CMemoryView::OnMouseMove)
|
||||
EVT_RIGHT_DOWN(CMemoryView::OnMouseDownR)
|
||||
EVT_MENU(-1, CMemoryView::OnPopupMenu)
|
||||
EVT_SIZE(CMemoryView::OnResize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent)
|
||||
: wxControl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
|
||||
, curAddress(debuginterface->getPC())
|
||||
, debugger(debuginterface)
|
||||
, align(debuginterface->getInstructionSize(0))
|
||||
, rowHeight(13)
|
||||
, selection(0)
|
||||
, oldSelection(0)
|
||||
, selecting(false)
|
||||
, memory(0)
|
||||
, viewAsType(VIEWAS_FP)
|
||||
{
|
||||
}
|
||||
|
||||
int CMemoryView::YToAddress(int y)
|
||||
{
|
||||
wxRect rc = GetClientRect();
|
||||
int ydiff = y - rc.height / 2 - rowHeight / 2;
|
||||
ydiff = (int)(floorf((float)ydiff / (float)rowHeight)) + 1;
|
||||
return curAddress + ydiff * align;
|
||||
}
|
||||
|
||||
void CMemoryView::OnMouseDownL(wxMouseEvent& event)
|
||||
{
|
||||
int x = event.m_x;
|
||||
int y = event.m_y;
|
||||
|
||||
if (x > 16)
|
||||
{
|
||||
oldSelection = selection;
|
||||
selection = YToAddress(y);
|
||||
bool oldselecting = selecting;
|
||||
selecting = true;
|
||||
|
||||
if (!oldselecting || (selection != oldSelection))
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
debugger->toggleMemCheck(YToAddress(y));
|
||||
|
||||
Refresh();
|
||||
Host_UpdateBreakPointView();
|
||||
}
|
||||
|
||||
event.Skip(true);
|
||||
}
|
||||
|
||||
void CMemoryView::OnMouseMove(wxMouseEvent& event)
|
||||
{
|
||||
wxRect rc = GetClientRect();
|
||||
|
||||
if (event.m_leftDown && event.m_x > 16)
|
||||
{
|
||||
if (event.m_y < 0)
|
||||
{
|
||||
curAddress -= align;
|
||||
Refresh();
|
||||
}
|
||||
else if (event.m_y > rc.height)
|
||||
{
|
||||
curAddress += align;
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
OnMouseDownL(event);
|
||||
}
|
||||
|
||||
event.Skip(true);
|
||||
}
|
||||
|
||||
void CMemoryView::OnMouseUpL(wxMouseEvent& event)
|
||||
{
|
||||
if (event.m_x > 16)
|
||||
{
|
||||
curAddress = YToAddress(event.m_y);
|
||||
selecting = false;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
event.Skip(true);
|
||||
}
|
||||
|
||||
void CMemoryView::OnPopupMenu(wxCommandEvent& event)
|
||||
{
|
||||
#if wxUSE_CLIPBOARD
|
||||
wxTheClipboard->Open();
|
||||
#endif
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
#if wxUSE_CLIPBOARD
|
||||
case IDM_COPYADDRESS:
|
||||
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(_T("%08x"), selection)));
|
||||
break;
|
||||
|
||||
case IDM_COPYHEX:
|
||||
{
|
||||
char temp[24];
|
||||
sprintf(temp, "%08x", debugger->readExtraMemory(memory, selection));
|
||||
wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(temp)));
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case IDM_TOGGLEMEMORY:
|
||||
memory ^= 1;
|
||||
Refresh();
|
||||
break;
|
||||
|
||||
case IDM_VIEWASFP:
|
||||
viewAsType = VIEWAS_FP;
|
||||
Refresh();
|
||||
break;
|
||||
|
||||
case IDM_VIEWASASCII:
|
||||
viewAsType = VIEWAS_ASCII;
|
||||
Refresh();
|
||||
break;
|
||||
case IDM_VIEWASHEX:
|
||||
viewAsType = VIEWAS_HEX;
|
||||
Refresh();
|
||||
break;
|
||||
}
|
||||
|
||||
#if wxUSE_CLIPBOARD
|
||||
wxTheClipboard->Close();
|
||||
#endif
|
||||
event.Skip(true);
|
||||
}
|
||||
|
||||
void CMemoryView::OnMouseDownR(wxMouseEvent& event)
|
||||
{
|
||||
// popup menu
|
||||
wxMenu* menu = new wxMenu;
|
||||
//menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
|
||||
#if wxUSE_CLIPBOARD
|
||||
menu->Append(IDM_COPYADDRESS, StrToWxStr("Copy &address"));
|
||||
menu->Append(IDM_COPYHEX, StrToWxStr("Copy &hex"));
|
||||
#endif
|
||||
menu->Append(IDM_TOGGLEMEMORY, StrToWxStr("Toggle &memory"));
|
||||
|
||||
wxMenu* viewAsSubMenu = new wxMenu;
|
||||
viewAsSubMenu->Append(IDM_VIEWASFP, StrToWxStr("FP value"));
|
||||
viewAsSubMenu->Append(IDM_VIEWASASCII, StrToWxStr("ASCII"));
|
||||
viewAsSubMenu->Append(IDM_VIEWASHEX, StrToWxStr("Hex"));
|
||||
menu->AppendSubMenu(viewAsSubMenu, StrToWxStr("View As:"));
|
||||
|
||||
PopupMenu(menu);
|
||||
}
|
||||
|
||||
void CMemoryView::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
wxRect rc = GetClientRect();
|
||||
wxFont hFont(_T("Courier"));
|
||||
hFont.SetFamily(wxFONTFAMILY_TELETYPE);
|
||||
|
||||
wxCoord w,h;
|
||||
dc.GetTextExtent(_T("0WJyq"),&w,&h,NULL,NULL,&hFont);
|
||||
if (h > rowHeight)
|
||||
rowHeight = h;
|
||||
dc.GetTextExtent(_T("0WJyq"),&w,&h,NULL,NULL,&DebuggerFont);
|
||||
if (h > rowHeight)
|
||||
rowHeight = h;
|
||||
|
||||
if (viewAsType==VIEWAS_HEX)
|
||||
dc.SetFont(hFont);
|
||||
else
|
||||
dc.SetFont(DebuggerFont);
|
||||
|
||||
dc.GetTextExtent(_T("W"),&w,&h);
|
||||
int fontSize = w;
|
||||
int textPlacement = 17 + 9 * fontSize;
|
||||
struct branch
|
||||
{
|
||||
int src, dst, srcAddr;
|
||||
};
|
||||
|
||||
// TODO: Add any drawing code here...
|
||||
int width = rc.width;
|
||||
int numRows = (rc.height / rowHeight) / 2 + 2;
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
const wxChar* bgColor = _T("#ffffff");
|
||||
wxPen nullPen(bgColor);
|
||||
wxPen currentPen(_T("#000000"));
|
||||
wxPen selPen(_T("#808080")); // gray
|
||||
nullPen.SetStyle(wxTRANSPARENT);
|
||||
|
||||
wxBrush currentBrush(_T("#FFEfE8")); // light gray
|
||||
wxBrush pcBrush(_T("#70FF70")); // green
|
||||
wxBrush mcBrush(_T("#1133FF")); // blue
|
||||
wxBrush bgBrush(bgColor);
|
||||
wxBrush nullBrush(bgColor);
|
||||
nullBrush.SetStyle(wxTRANSPARENT);
|
||||
|
||||
dc.SetPen(nullPen);
|
||||
dc.SetBrush(bgBrush);
|
||||
dc.DrawRectangle(0, 0, 16, rc.height);
|
||||
dc.DrawRectangle(0, 0, rc.width, 5+8);
|
||||
|
||||
// TODO - clean up this freaking mess!!!!!
|
||||
for (int row = -numRows; row <= numRows; row++)
|
||||
{
|
||||
unsigned int address = curAddress + row * align;
|
||||
|
||||
int rowY1 = rc.height / 2 + rowHeight * row - rowHeight / 2;
|
||||
int rowY2 = rc.height / 2 + rowHeight * row + rowHeight / 2;
|
||||
|
||||
wxString temp = wxString::Format(_T("%08x"), address);
|
||||
u32 col = debugger->getColor(address);
|
||||
wxBrush rowBrush(wxColor(col >> 16, col >> 8, col));
|
||||
dc.SetBrush(nullBrush);
|
||||
dc.SetPen(nullPen);
|
||||
dc.DrawRectangle(0, rowY1, 16, rowY2);
|
||||
|
||||
if (selecting && (address == selection))
|
||||
dc.SetPen(selPen);
|
||||
else
|
||||
dc.SetPen(row == 0 ? currentPen : nullPen);
|
||||
|
||||
if (address == debugger->getPC())
|
||||
dc.SetBrush(pcBrush);
|
||||
else
|
||||
dc.SetBrush(rowBrush);
|
||||
|
||||
dc.DrawRectangle(16, rowY1, width, rowY2 - 1);
|
||||
dc.SetBrush(currentBrush);
|
||||
dc.SetTextForeground(_T("#600000"));
|
||||
dc.DrawText(temp, 17, rowY1);
|
||||
|
||||
if (viewAsType != VIEWAS_HEX)
|
||||
{
|
||||
char mem[256];
|
||||
debugger->getRawMemoryString(memory, address, mem, 256);
|
||||
dc.SetTextForeground(_T("#000080"));
|
||||
dc.DrawText(StrToWxStr(mem), 17+fontSize*(8), rowY1);
|
||||
dc.SetTextForeground(_T("#000000"));
|
||||
}
|
||||
|
||||
if (debugger->isAlive())
|
||||
{
|
||||
char dis[256] = {0};
|
||||
u32 mem_data = debugger->readExtraMemory(memory, address);
|
||||
|
||||
if (viewAsType == VIEWAS_FP)
|
||||
{
|
||||
float flt = *(float *)(&mem_data);
|
||||
sprintf(dis, "f: %f", flt);
|
||||
}
|
||||
else if (viewAsType == VIEWAS_ASCII)
|
||||
{
|
||||
u32 a[4] = {(mem_data&0xff000000)>>24,
|
||||
(mem_data&0xff0000)>>16,
|
||||
(mem_data&0xff00)>>8,
|
||||
mem_data&0xff};
|
||||
for (auto& word : a)
|
||||
if (word == '\0')
|
||||
word = ' ';
|
||||
sprintf(dis, "%c%c%c%c", a[0], a[1], a[2], a[3]);
|
||||
}
|
||||
else if (viewAsType == VIEWAS_HEX)
|
||||
{
|
||||
dis[0] = 0;
|
||||
dis[1] = 0;
|
||||
u32 mema[8] = {
|
||||
debugger->readExtraMemory(memory, address),
|
||||
debugger->readExtraMemory(memory, address+4),
|
||||
debugger->readExtraMemory(memory, address+8),
|
||||
debugger->readExtraMemory(memory, address+12),
|
||||
debugger->readExtraMemory(memory, address+16),
|
||||
debugger->readExtraMemory(memory, address+20),
|
||||
debugger->readExtraMemory(memory, address+24),
|
||||
debugger->readExtraMemory(memory, address+28)
|
||||
};
|
||||
|
||||
for (auto& word : mema)
|
||||
{
|
||||
char buf[32] = "";
|
||||
switch (dataType)
|
||||
{
|
||||
case 0:
|
||||
sprintf(buf, " %02X %02X %02X %02X",
|
||||
((word&0xff000000)>>24)&0xFF,
|
||||
((word&0xff0000)>>16)&0xFF,
|
||||
((word&0xff00)>>8)&0xFF,
|
||||
word&0xff);
|
||||
break;
|
||||
case 1:
|
||||
sprintf(buf, " %02X%02X %02X%02X",
|
||||
((word&0xff000000)>>24)&0xFF,
|
||||
((word&0xff0000)>>16)&0xFF,
|
||||
((word&0xff00)>>8)&0xFF,
|
||||
word&0xff);
|
||||
break;
|
||||
case 2:
|
||||
sprintf(buf, " %02X%02X%02X%02X",
|
||||
((word&0xff000000)>>24)&0xFF,
|
||||
((word&0xff0000)>>16)&0xFF,
|
||||
((word&0xff00)>>8)&0xFF,
|
||||
word&0xff);
|
||||
break;
|
||||
}
|
||||
strcat(dis, buf);
|
||||
}
|
||||
curAddress += 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(dis, "INVALID VIEWAS TYPE");
|
||||
}
|
||||
|
||||
char desc[256] = "";
|
||||
if (viewAsType != VIEWAS_HEX)
|
||||
dc.DrawText(StrToWxStr(dis), textPlacement + fontSize*(8 + 8), rowY1);
|
||||
else
|
||||
dc.DrawText(StrToWxStr(dis), textPlacement, rowY1);
|
||||
|
||||
if (desc[0] == 0)
|
||||
strcpy(desc, debugger->getDescription(address).c_str());
|
||||
|
||||
dc.SetTextForeground(_T("#0000FF"));
|
||||
|
||||
if (strlen(desc))
|
||||
dc.DrawText(StrToWxStr(desc), 17+fontSize*((8+8+8+30)*2), rowY1);
|
||||
|
||||
// Show blue memory check dot
|
||||
if (debugger->isMemCheck(address))
|
||||
{
|
||||
dc.SetBrush(mcBrush);
|
||||
dc.DrawRectangle(8, rowY1 + 1, 11, 11);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dc.SetPen(currentPen);
|
||||
}
|
||||
|
||||
void CMemoryView::OnResize(wxSizeEvent& event)
|
||||
{
|
||||
Refresh();
|
||||
event.Skip();
|
||||
}
|
61
Source/Core/DolphinWX/Debugger/MemoryView.h
Normal file
61
Source/Core/DolphinWX/Debugger/MemoryView.h
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef MEMORYVIEW_H_
|
||||
#define MEMORYVIEW_H_
|
||||
|
||||
#include "DebuggerUIUtil.h"
|
||||
#include "Common.h"
|
||||
#include "DebugInterface.h"
|
||||
|
||||
class CMemoryView : public wxControl
|
||||
{
|
||||
public:
|
||||
CMemoryView(DebugInterface* debuginterface, wxWindow* parent);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnMouseDownL(wxMouseEvent& event);
|
||||
void OnMouseMove(wxMouseEvent& event);
|
||||
void OnMouseUpL(wxMouseEvent& event);
|
||||
void OnMouseDownR(wxMouseEvent& event);
|
||||
void OnPopupMenu(wxCommandEvent& event);
|
||||
|
||||
u32 GetSelection() { return selection ; }
|
||||
int GetMemoryType() { return memory; }
|
||||
|
||||
void Center(u32 addr)
|
||||
{
|
||||
curAddress = addr;
|
||||
Refresh();
|
||||
}
|
||||
int dataType; // u8,u16,u32
|
||||
int curAddress; // Will be accessed by parent
|
||||
|
||||
private:
|
||||
int YToAddress(int y);
|
||||
void OnResize(wxSizeEvent& event);
|
||||
|
||||
DebugInterface* debugger;
|
||||
|
||||
int align;
|
||||
int rowHeight;
|
||||
|
||||
u32 selection;
|
||||
u32 oldSelection;
|
||||
bool selecting;
|
||||
|
||||
int memory;
|
||||
|
||||
enum EViewAsType
|
||||
{
|
||||
VIEWAS_ASCII = 0,
|
||||
VIEWAS_FP,
|
||||
VIEWAS_HEX,
|
||||
};
|
||||
|
||||
EViewAsType viewAsType;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif // MEMORYVIEW_H_
|
424
Source/Core/DolphinWX/Debugger/MemoryWindow.cpp
Normal file
424
Source/Core/DolphinWX/Debugger/MemoryWindow.cpp
Normal file
@ -0,0 +1,424 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <wx/button.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/listctrl.h>
|
||||
#include <wx/thread.h>
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
#include "../WxUtils.h"
|
||||
#include "MemoryWindow.h"
|
||||
#include "HW/CPU.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
#include "Debugger/PPCDebugInterface.h"
|
||||
#include "PowerPC/PPCSymbolDB.h"
|
||||
|
||||
#include "Core.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
#include "HW/Memmap.h"
|
||||
#include "HW/DSP.h"
|
||||
|
||||
#include "../../DolphinWX/Globals.h"
|
||||
|
||||
enum
|
||||
{
|
||||
IDM_MEM_ADDRBOX = 350,
|
||||
IDM_SYMBOLLIST,
|
||||
IDM_SETVALBUTTON,
|
||||
IDM_DUMP_MEMORY,
|
||||
IDM_DUMP_MEM2,
|
||||
IDM_DUMP_FAKEVMEM,
|
||||
IDM_VALBOX,
|
||||
IDM_U8,
|
||||
IDM_U16,
|
||||
IDM_U32,
|
||||
IDM_SEARCH,
|
||||
IDM_ASCII,
|
||||
IDM_HEX
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CMemoryWindow, wxPanel)
|
||||
EVT_TEXT(IDM_MEM_ADDRBOX, CMemoryWindow::OnAddrBoxChange)
|
||||
EVT_LISTBOX(IDM_SYMBOLLIST, CMemoryWindow::OnSymbolListChange)
|
||||
EVT_HOST_COMMAND(wxID_ANY, CMemoryWindow::OnHostMessage)
|
||||
EVT_BUTTON(IDM_SETVALBUTTON, CMemoryWindow::SetMemoryValue)
|
||||
EVT_BUTTON(IDM_DUMP_MEMORY, CMemoryWindow::OnDumpMemory)
|
||||
EVT_BUTTON(IDM_DUMP_MEM2, CMemoryWindow::OnDumpMem2)
|
||||
EVT_BUTTON(IDM_DUMP_FAKEVMEM, CMemoryWindow::OnDumpFakeVMEM)
|
||||
EVT_CHECKBOX(IDM_U8, CMemoryWindow::U8)
|
||||
EVT_CHECKBOX(IDM_U16, CMemoryWindow::U16)
|
||||
EVT_CHECKBOX(IDM_U32, CMemoryWindow::U32)
|
||||
EVT_BUTTON(IDM_SEARCH, CMemoryWindow::onSearch)
|
||||
EVT_CHECKBOX(IDM_ASCII, CMemoryWindow::onAscii)
|
||||
EVT_CHECKBOX(IDM_HEX, CMemoryWindow::onHex)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxString& name)
|
||||
: wxPanel(parent, id, pos, size, style, name)
|
||||
{
|
||||
wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer* sizerRight = new wxBoxSizer(wxVERTICAL);
|
||||
// Didn't see anything useful in the left part
|
||||
//wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
DebugInterface* di = &PowerPC::debug_interface;
|
||||
|
||||
//symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition,
|
||||
// wxSize(20, 100), 0, NULL, wxLB_SORT);
|
||||
//sizerLeft->Add(symbols, 1, wxEXPAND);
|
||||
memview = new CMemoryView(di, this);
|
||||
memview->dataType = 0;
|
||||
//sizerBig->Add(sizerLeft, 1, wxEXPAND);
|
||||
sizerBig->Add(memview, 20, wxEXPAND);
|
||||
sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3);
|
||||
sizerRight->Add(addrbox = new wxTextCtrl(this, IDM_MEM_ADDRBOX, _T("")));
|
||||
sizerRight->Add(valbox = new wxTextCtrl(this, IDM_VALBOX, _T("")));
|
||||
sizerRight->Add(new wxButton(this, IDM_SETVALBUTTON, _("Set &Value")));
|
||||
|
||||
sizerRight->AddSpacer(5);
|
||||
sizerRight->Add(new wxButton(this, IDM_DUMP_MEMORY, _("&Dump MRAM")));
|
||||
sizerRight->Add(new wxButton(this, IDM_DUMP_MEM2, _("&Dump EXRAM")));
|
||||
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bTLBHack == true)
|
||||
sizerRight->Add(new wxButton(this, IDM_DUMP_FAKEVMEM, _("&Dump FakeVMEM")));
|
||||
|
||||
wxStaticBoxSizer* sizerSearchType = new wxStaticBoxSizer(wxVERTICAL, this, _("Search"));
|
||||
|
||||
sizerSearchType->Add(btnSearch = new wxButton(this, IDM_SEARCH, _("Search")));
|
||||
sizerSearchType->Add(chkAscii = new wxCheckBox(this, IDM_ASCII, _T("&Ascii ")));
|
||||
sizerSearchType->Add(chkHex = new wxCheckBox(this, IDM_HEX, _("&Hex")));
|
||||
sizerRight->Add(sizerSearchType);
|
||||
wxStaticBoxSizer* sizerDataTypes = new wxStaticBoxSizer(wxVERTICAL, this, _("Data Type"));
|
||||
|
||||
sizerDataTypes->SetMinSize(74, 40);
|
||||
sizerDataTypes->Add(chk8 = new wxCheckBox(this, IDM_U8, _T("&U8")));
|
||||
sizerDataTypes->Add(chk16 = new wxCheckBox(this, IDM_U16, _T("&U16")));
|
||||
sizerDataTypes->Add(chk32 = new wxCheckBox(this, IDM_U32, _T("&U32")));
|
||||
sizerRight->Add(sizerDataTypes);
|
||||
SetSizer(sizerBig);
|
||||
chkHex->SetValue(1); //Set defaults
|
||||
chk8->SetValue(1);
|
||||
|
||||
//sizerLeft->Fit(this);
|
||||
sizerRight->Fit(this);
|
||||
sizerBig->Fit(this);
|
||||
}
|
||||
|
||||
void CMemoryWindow::Save(IniFile& _IniFile) const
|
||||
{
|
||||
// Prevent these bad values that can happen after a crash or hanging
|
||||
if(GetPosition().x != -32000 && GetPosition().y != -32000)
|
||||
{
|
||||
_IniFile.Set("MemoryWindow", "x", GetPosition().x);
|
||||
_IniFile.Set("MemoryWindow", "y", GetPosition().y);
|
||||
_IniFile.Set("MemoryWindow", "w", GetSize().GetWidth());
|
||||
_IniFile.Set("MemoryWindow", "h", GetSize().GetHeight());
|
||||
}
|
||||
}
|
||||
|
||||
void CMemoryWindow::Load(IniFile& _IniFile)
|
||||
{
|
||||
int x, y, w, h;
|
||||
_IniFile.Get("MemoryWindow", "x", &x, GetPosition().x);
|
||||
_IniFile.Get("MemoryWindow", "y", &y, GetPosition().y);
|
||||
_IniFile.Get("MemoryWindow", "w", &w, GetSize().GetWidth());
|
||||
_IniFile.Get("MemoryWindow", "h", &h, GetSize().GetHeight());
|
||||
SetSize(x, y, w, h);
|
||||
}
|
||||
|
||||
void CMemoryWindow::JumpToAddress(u32 _Address)
|
||||
{
|
||||
memview->Center(_Address);
|
||||
}
|
||||
|
||||
void CMemoryWindow::SetMemoryValue(wxCommandEvent& event)
|
||||
{
|
||||
std::string str_addr = WxStrToStr(addrbox->GetValue());
|
||||
std::string str_val = WxStrToStr(valbox->GetValue());
|
||||
u32 addr;
|
||||
u32 val;
|
||||
|
||||
if (!TryParse(std::string("0x") + str_addr, &addr))
|
||||
{
|
||||
PanicAlert("Invalid Address: %s", str_addr.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryParse(std::string("0x") + str_val, &val))
|
||||
{
|
||||
PanicAlert("Invalid Value: %s", str_val.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
Memory::Write_U32(val, addr);
|
||||
memview->Refresh();
|
||||
}
|
||||
|
||||
void CMemoryWindow::OnAddrBoxChange(wxCommandEvent& event)
|
||||
{
|
||||
wxString txt = addrbox->GetValue();
|
||||
if (txt.size())
|
||||
{
|
||||
u32 addr;
|
||||
sscanf(WxStrToStr(txt).c_str(), "%08x", &addr);
|
||||
memview->Center(addr & ~3);
|
||||
}
|
||||
|
||||
event.Skip(1);
|
||||
}
|
||||
|
||||
void CMemoryWindow::Update()
|
||||
{
|
||||
memview->Refresh();
|
||||
memview->Center(PC);
|
||||
}
|
||||
|
||||
void CMemoryWindow::NotifyMapLoaded()
|
||||
{
|
||||
symbols->Show(false); // hide it for faster filling
|
||||
symbols->Clear();
|
||||
#if 0
|
||||
#ifdef _WIN32
|
||||
const FunctionDB::XFuncMap &syms = g_symbolDB.Symbols();
|
||||
for (FuntionDB::XFuncMap::iterator iter = syms.begin(); iter != syms.end(); ++iter)
|
||||
{
|
||||
int idx = symbols->Append(iter->second.name.c_str());
|
||||
symbols->SetClientData(idx, (void*)&iter->second);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
symbols->Show(true);
|
||||
Update();
|
||||
}
|
||||
|
||||
void CMemoryWindow::OnSymbolListChange(wxCommandEvent& event)
|
||||
{
|
||||
int index = symbols->GetSelection();
|
||||
if (index >= 0)
|
||||
{
|
||||
Symbol* pSymbol = static_cast<Symbol *>(symbols->GetClientData(index));
|
||||
if (pSymbol != NULL)
|
||||
{
|
||||
memview->Center(pSymbol->address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMemoryWindow::OnHostMessage(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case IDM_NOTIFYMAPLOADED:
|
||||
NotifyMapLoaded();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DumpArray(const std::string& filename, const u8* data, size_t length)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
File::IOFile f(filename, "wb");
|
||||
f.WriteBytes(data, length);
|
||||
}
|
||||
}
|
||||
|
||||
// Write mram to file
|
||||
void CMemoryWindow::OnDumpMemory( wxCommandEvent& event )
|
||||
{
|
||||
DumpArray(File::GetUserPath(F_RAMDUMP_IDX), Memory::m_pRAM, Memory::REALRAM_SIZE);
|
||||
}
|
||||
|
||||
// Write exram (aram or mem2) to file
|
||||
void CMemoryWindow::OnDumpMem2( wxCommandEvent& event )
|
||||
{
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
|
||||
{
|
||||
DumpArray(File::GetUserPath(F_ARAMDUMP_IDX), Memory::m_pEXRAM, Memory::EXRAM_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
DumpArray(File::GetUserPath(F_ARAMDUMP_IDX), DSP::GetARAMPtr(), DSP::ARAM_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
// Write fake vmem to file
|
||||
void CMemoryWindow::OnDumpFakeVMEM( wxCommandEvent& event )
|
||||
{
|
||||
DumpArray(File::GetUserPath(F_FAKEVMEMDUMP_IDX), Memory::m_pVirtualFakeVMEM, Memory::FAKEVMEM_SIZE);
|
||||
}
|
||||
|
||||
void CMemoryWindow::U8(wxCommandEvent& event)
|
||||
{
|
||||
chk16->SetValue(0);
|
||||
chk32->SetValue(0);
|
||||
memview->dataType = 0;
|
||||
memview->Refresh();
|
||||
}
|
||||
|
||||
void CMemoryWindow::U16(wxCommandEvent& event)
|
||||
{
|
||||
chk8->SetValue(0);
|
||||
chk32->SetValue(0);
|
||||
memview->dataType = 1;
|
||||
memview->Refresh();
|
||||
}
|
||||
|
||||
void CMemoryWindow::U32(wxCommandEvent& event)
|
||||
{
|
||||
chk16->SetValue(0);
|
||||
chk8->SetValue(0);
|
||||
memview->dataType = 2;
|
||||
memview->Refresh();
|
||||
}
|
||||
|
||||
void CMemoryWindow::onSearch(wxCommandEvent& event)
|
||||
{
|
||||
u8* TheRAM = 0;
|
||||
u32 szRAM = 0;
|
||||
switch (memview->GetMemoryType())
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
if (Memory::m_pRAM)
|
||||
{
|
||||
TheRAM = Memory::m_pRAM;
|
||||
szRAM = Memory::REALRAM_SIZE;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
u8* aram = DSP::GetARAMPtr();
|
||||
if (aram)
|
||||
{
|
||||
TheRAM = aram;
|
||||
szRAM = DSP::ARAM_SIZE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
//Now we have memory to look in
|
||||
//Are we looking for ASCII string, or hex?
|
||||
//memview->cu
|
||||
wxString rawData = valbox->GetValue();
|
||||
std::vector<u8> Dest; //May need a better name
|
||||
u32 size = 0;
|
||||
int pad = rawData.size()%2; //If it's uneven
|
||||
unsigned int i = 0;
|
||||
long count = 0;
|
||||
char copy[3] = {0};
|
||||
long newsize = 0;
|
||||
unsigned char *tmp2 = 0;
|
||||
char* tmpstr = 0;
|
||||
|
||||
if (chkHex->GetValue())
|
||||
{
|
||||
//We are looking for hex
|
||||
//If it's uneven
|
||||
size = (rawData.size()/2) + pad;
|
||||
Dest.resize(size+32);
|
||||
newsize = rawData.size();
|
||||
|
||||
if (pad)
|
||||
{
|
||||
tmpstr = new char[newsize + 2];
|
||||
memset(tmpstr, 0, newsize + 2);
|
||||
tmpstr[0] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpstr = new char[newsize + 1];
|
||||
memset(tmpstr, 0, newsize + 1);
|
||||
}
|
||||
sprintf(tmpstr, "%s%s", tmpstr, WxStrToStr(rawData).c_str());
|
||||
tmp2 = &Dest.front();
|
||||
count = 0;
|
||||
for(i = 0; i < strlen(tmpstr); i++)
|
||||
{
|
||||
copy[0] = tmpstr[i];
|
||||
copy[1] = tmpstr[i+1];
|
||||
copy[2] = 0;
|
||||
int tmpint;
|
||||
sscanf(copy, "%02x", &tmpint);
|
||||
tmp2[count++] = tmpint;
|
||||
// Dest[count] should now be the hex of what the two chars were!
|
||||
// Also should add a check to make sure it's A-F only
|
||||
//sscanf(copy, "%02x", &tmp2[count++]);
|
||||
i += 1;
|
||||
}
|
||||
delete[] tmpstr;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Looking for an ascii string
|
||||
size = rawData.size();
|
||||
Dest.resize(size+1);
|
||||
tmpstr = new char[size+1];
|
||||
|
||||
tmp2 = &Dest.front();
|
||||
sprintf(tmpstr, "%s", WxStrToStr(rawData).c_str());
|
||||
|
||||
for(i = 0; i < size; i++)
|
||||
tmp2[i] = tmpstr[i];
|
||||
|
||||
delete[] tmpstr;
|
||||
}
|
||||
|
||||
if(size)
|
||||
{
|
||||
unsigned char* pnt = &Dest.front();
|
||||
unsigned int k = 0;
|
||||
//grab
|
||||
wxString txt = addrbox->GetValue();
|
||||
u32 addr = 0;
|
||||
if (txt.size())
|
||||
{
|
||||
sscanf(WxStrToStr(txt).c_str(), "%08x", &addr);
|
||||
}
|
||||
i = addr+4;
|
||||
for( ; i < szRAM; i++)
|
||||
{
|
||||
for(k = 0; k < size; k++)
|
||||
{
|
||||
if(i + k > szRAM) break;
|
||||
if(k > size) break;
|
||||
if(pnt[k] != TheRAM[i+k])
|
||||
{
|
||||
k = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(k == size)
|
||||
{
|
||||
//Match was found
|
||||
wxMessageBox(_("A match was found. Placing viewer at the offset."));
|
||||
wxChar tmpwxstr[128] = {0};
|
||||
wxSprintf(tmpwxstr, _T("%08x"), i);
|
||||
wxString tmpwx(tmpwxstr);
|
||||
addrbox->SetValue(tmpwx);
|
||||
//memview->curAddress = i;
|
||||
//memview->Refresh();
|
||||
OnAddrBoxChange(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
wxMessageBox(_("No match was found."));
|
||||
}
|
||||
}
|
||||
|
||||
void CMemoryWindow::onAscii(wxCommandEvent& event)
|
||||
{
|
||||
chkHex->SetValue(0);
|
||||
}
|
||||
|
||||
void CMemoryWindow::onHex(wxCommandEvent& event)
|
||||
{
|
||||
chkAscii->SetValue(0);
|
||||
}
|
72
Source/Core/DolphinWX/Debugger/MemoryWindow.h
Normal file
72
Source/Core/DolphinWX/Debugger/MemoryWindow.h
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef MEMORYWINDOW_H_
|
||||
#define MEMORYWINDOW_H_
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/listbox.h>
|
||||
#include "MemoryView.h"
|
||||
#include "Thread.h"
|
||||
#include "StringUtil.h"
|
||||
|
||||
#include "CoreParameter.h"
|
||||
|
||||
class CRegisterWindow;
|
||||
class CBreakPointWindow;
|
||||
|
||||
class CMemoryWindow
|
||||
: public wxPanel
|
||||
{
|
||||
public:
|
||||
|
||||
CMemoryWindow(wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL | wxBORDER_NONE,
|
||||
const wxString& name = _("Memory"));
|
||||
|
||||
wxCheckBox* chk8;
|
||||
wxCheckBox* chk16;
|
||||
wxCheckBox* chk32;
|
||||
wxButton* btnSearch;
|
||||
wxCheckBox* chkAscii;
|
||||
wxCheckBox* chkHex;
|
||||
void Save(IniFile& _IniFile) const;
|
||||
void Load(IniFile& _IniFile);
|
||||
|
||||
void Update();
|
||||
void NotifyMapLoaded();
|
||||
|
||||
void JumpToAddress(u32 _Address);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
CMemoryView* memview;
|
||||
wxListBox* symbols;
|
||||
|
||||
wxButton* buttonGo;
|
||||
wxTextCtrl* addrbox;
|
||||
wxTextCtrl* valbox;
|
||||
|
||||
void U8(wxCommandEvent& event);
|
||||
void U16(wxCommandEvent& event);
|
||||
void U32(wxCommandEvent& event);
|
||||
void onSearch(wxCommandEvent& event);
|
||||
void onAscii(wxCommandEvent& event);
|
||||
void onHex(wxCommandEvent& event);
|
||||
void OnSymbolListChange(wxCommandEvent& event);
|
||||
void OnCallstackListChange(wxCommandEvent& event);
|
||||
void OnAddrBoxChange(wxCommandEvent& event);
|
||||
void OnHostMessage(wxCommandEvent& event);
|
||||
void SetMemoryValue(wxCommandEvent& event);
|
||||
void OnDumpMemory(wxCommandEvent& event);
|
||||
void OnDumpMem2(wxCommandEvent& event);
|
||||
void OnDumpFakeVMEM(wxCommandEvent& event);
|
||||
};
|
||||
|
||||
#endif /*MEMORYWINDOW_*/
|
181
Source/Core/DolphinWX/Debugger/RegisterView.cpp
Normal file
181
Source/Core/DolphinWX/Debugger/RegisterView.cpp
Normal file
@ -0,0 +1,181 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DebuggerUIUtil.h"
|
||||
#include "RegisterView.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "HW/ProcessorInterface.h"
|
||||
#include "IniFile.h"
|
||||
#include "../WxUtils.h"
|
||||
|
||||
// F-zero 80005e60 wtf??
|
||||
|
||||
extern const char* GetGPRName(unsigned int index);
|
||||
extern const char* GetFPRName(unsigned int index);
|
||||
|
||||
static const char *special_reg_names[] = {
|
||||
"PC", "LR", "CTR", "CR", "FPSCR", "MSR", "SRR0", "SRR1", "Exceptions", "Int Mask", "Int Cause",
|
||||
};
|
||||
|
||||
static u32 GetSpecialRegValue(int reg)
|
||||
{
|
||||
switch (reg)
|
||||
{
|
||||
case 0: return PowerPC::ppcState.pc;
|
||||
case 1: return PowerPC::ppcState.spr[SPR_LR];
|
||||
case 2: return PowerPC::ppcState.spr[SPR_CTR];
|
||||
case 3: return GetCR();
|
||||
case 4: return PowerPC::ppcState.fpscr;
|
||||
case 5: return PowerPC::ppcState.msr;
|
||||
case 6: return PowerPC::ppcState.spr[SPR_SRR0];
|
||||
case 7: return PowerPC::ppcState.spr[SPR_SRR1];
|
||||
case 8: return PowerPC::ppcState.Exceptions;
|
||||
case 9: return ProcessorInterface::GetMask();
|
||||
case 10: return ProcessorInterface::GetCause();
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
wxString CRegTable::GetValue(int row, int col)
|
||||
{
|
||||
if (row < 32)
|
||||
{
|
||||
switch (col)
|
||||
{
|
||||
case 0: return StrToWxStr(GetGPRName(row));
|
||||
case 1: return wxString::Format(wxT("%08x"), GPR(row));
|
||||
case 2: return StrToWxStr(GetFPRName(row));
|
||||
case 3: return wxString::Format(wxT("%016llx"), riPS0(row));
|
||||
case 4: return wxString::Format(wxT("%016llx"), riPS1(row));
|
||||
default: return wxEmptyString;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (row - 32 < NUM_SPECIALS)
|
||||
{
|
||||
switch (col)
|
||||
{
|
||||
case 0: return StrToWxStr(special_reg_names[row - 32]);
|
||||
case 1: return wxString::Format(wxT("%08x"), GetSpecialRegValue(row - 32));
|
||||
default: return wxEmptyString;
|
||||
}
|
||||
}
|
||||
}
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
static void SetSpecialRegValue(int reg, u32 value)
|
||||
{
|
||||
switch (reg)
|
||||
{
|
||||
case 0: PowerPC::ppcState.pc = value; break;
|
||||
case 1: PowerPC::ppcState.spr[SPR_LR] = value; break;
|
||||
case 2: PowerPC::ppcState.spr[SPR_CTR] = value; break;
|
||||
case 3: SetCR(value); break;
|
||||
case 4: PowerPC::ppcState.fpscr = value; break;
|
||||
case 5: PowerPC::ppcState.msr = value; break;
|
||||
case 6: PowerPC::ppcState.spr[SPR_SRR0] = value; break;
|
||||
case 7: PowerPC::ppcState.spr[SPR_SRR1] = value; break;
|
||||
case 8: PowerPC::ppcState.Exceptions = value; break;
|
||||
// Should we just change the value, or use ProcessorInterface::SetInterrupt() to make the system aware?
|
||||
// case 9: return ProcessorInterface::GetMask();
|
||||
// case 10: return ProcessorInterface::GetCause();
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
void CRegTable::SetValue(int row, int col, const wxString& strNewVal)
|
||||
{
|
||||
u32 newVal = 0;
|
||||
if (TryParse(WxStrToStr(strNewVal), &newVal))
|
||||
{
|
||||
if (row < 32)
|
||||
{
|
||||
if (col == 1)
|
||||
GPR(row) = newVal;
|
||||
else if (col == 3)
|
||||
riPS0(row) = newVal;
|
||||
else if (col == 4)
|
||||
riPS1(row) = newVal;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((row - 32 < NUM_SPECIALS) && (col == 1))
|
||||
{
|
||||
SetSpecialRegValue(row - 32, newVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CRegTable::UpdateCachedRegs()
|
||||
{
|
||||
for (int i = 0; i < 32; ++i)
|
||||
{
|
||||
m_CachedRegHasChanged[i] = (m_CachedRegs[i] != GPR(i));
|
||||
m_CachedRegs[i] = GPR(i);
|
||||
|
||||
m_CachedFRegHasChanged[i][0] = (m_CachedFRegs[i][0] != riPS0(i));
|
||||
m_CachedFRegs[i][0] = riPS0(i);
|
||||
m_CachedFRegHasChanged[i][1] = (m_CachedFRegs[i][1] != riPS1(i));
|
||||
m_CachedFRegs[i][1] = riPS1(i);
|
||||
}
|
||||
for (int i = 0; i < NUM_SPECIALS; ++i)
|
||||
{
|
||||
m_CachedSpecialRegHasChanged[i] = (m_CachedSpecialRegs[i] != GetSpecialRegValue(i));
|
||||
m_CachedSpecialRegs[i] = GetSpecialRegValue(i);
|
||||
}
|
||||
}
|
||||
|
||||
wxGridCellAttr *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind)
|
||||
{
|
||||
wxGridCellAttr *attr = new wxGridCellAttr();
|
||||
|
||||
attr->SetBackgroundColour(wxColour(wxT("#FFFFFF"))); //wxWHITE
|
||||
attr->SetFont(DebuggerFont);
|
||||
|
||||
switch (col)
|
||||
{
|
||||
case 1:
|
||||
attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
attr->SetAlignment(wxALIGN_RIGHT, wxALIGN_CENTER);
|
||||
break;
|
||||
default:
|
||||
attr->SetAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
|
||||
break;
|
||||
}
|
||||
|
||||
bool red = false;
|
||||
switch (col)
|
||||
{
|
||||
case 1: red = row < 32 ? m_CachedRegHasChanged[row] : m_CachedSpecialRegHasChanged[row-32]; break;
|
||||
case 3:
|
||||
case 4: red = row < 32 ? m_CachedFRegHasChanged[row][col-3] : false; break;
|
||||
}
|
||||
|
||||
attr->SetTextColour(red ? wxColor(wxT("#FF0000")) : wxColor(wxT("#000000")));
|
||||
attr->IncRef();
|
||||
return attr;
|
||||
}
|
||||
|
||||
CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id)
|
||||
: wxGrid(parent, id)
|
||||
{
|
||||
SetTable(new CRegTable(), true);
|
||||
SetRowLabelSize(0);
|
||||
SetColLabelSize(0);
|
||||
DisableDragRowSize();
|
||||
|
||||
AutoSizeColumns();
|
||||
}
|
||||
|
||||
void CRegisterView::Update()
|
||||
{
|
||||
ForceRefresh();
|
||||
((CRegTable *)GetTable())->UpdateCachedRegs();
|
||||
}
|
69
Source/Core/DolphinWX/Debugger/RegisterView.h
Normal file
69
Source/Core/DolphinWX/Debugger/RegisterView.h
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef __REGISTERVIEW_h__
|
||||
#define __REGISTERVIEW_h__
|
||||
|
||||
#include <wx/grid.h>
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
// New register view:
|
||||
// R0 0x8000000 F0 0.0000 F0_PS1 0.0000
|
||||
// R1 0x8000000 F1 0.0000 F1_PS1 0.0000
|
||||
// R31 0x8000000 F31 0.0000 F31_PS1 0.0000
|
||||
// PC (specials)
|
||||
// LR
|
||||
// CTR
|
||||
// CR0-7
|
||||
// FPSCR
|
||||
// MSR
|
||||
// SRR0
|
||||
// SRR1
|
||||
// Exceptions
|
||||
// Interrupt Mask (PI)
|
||||
// Interrupt Cause(PI)
|
||||
|
||||
class CRegTable : public wxGridTableBase
|
||||
{
|
||||
enum {
|
||||
NUM_SPECIALS = 11,
|
||||
};
|
||||
|
||||
public:
|
||||
CRegTable() {
|
||||
memset(m_CachedRegs, 0, sizeof(m_CachedRegs));
|
||||
memset(m_CachedSpecialRegs, 0, sizeof(m_CachedSpecialRegs));
|
||||
memset(m_CachedFRegs, 0, sizeof(m_CachedFRegs));
|
||||
memset(m_CachedRegHasChanged, 0, sizeof(m_CachedRegHasChanged));
|
||||
memset(m_CachedSpecialRegHasChanged, 0, sizeof(m_CachedSpecialRegHasChanged));
|
||||
memset(m_CachedFRegHasChanged, 0, sizeof(m_CachedFRegHasChanged));
|
||||
}
|
||||
int GetNumberCols(void) {return 5;}
|
||||
int GetNumberRows(void) {return 32 + NUM_SPECIALS;}
|
||||
bool IsEmptyCell(int row, int col) {return row > 31 && col > 2;}
|
||||
wxString GetValue(int row, int col);
|
||||
void SetValue(int row, int col, const wxString &);
|
||||
wxGridCellAttr *GetAttr(int, int, wxGridCellAttr::wxAttrKind);
|
||||
void UpdateCachedRegs();
|
||||
|
||||
private:
|
||||
u32 m_CachedRegs[32];
|
||||
u32 m_CachedSpecialRegs[NUM_SPECIALS];
|
||||
u64 m_CachedFRegs[32][2];
|
||||
bool m_CachedRegHasChanged[32];
|
||||
bool m_CachedSpecialRegHasChanged[NUM_SPECIALS];
|
||||
bool m_CachedFRegHasChanged[32][2];
|
||||
|
||||
DECLARE_NO_COPY_CLASS(CRegTable);
|
||||
};
|
||||
|
||||
class CRegisterView : public wxGrid
|
||||
{
|
||||
public:
|
||||
CRegisterView(wxWindow* parent, wxWindowID id);
|
||||
void Update();
|
||||
};
|
||||
|
||||
#endif
|
40
Source/Core/DolphinWX/Debugger/RegisterWindow.cpp
Normal file
40
Source/Core/DolphinWX/Debugger/RegisterWindow.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "RegisterWindow.h"
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "RegisterView.h"
|
||||
|
||||
extern const char* GetGRPName(unsigned int index);
|
||||
|
||||
BEGIN_EVENT_TABLE(CRegisterWindow, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
CRegisterWindow::CRegisterWindow(wxWindow* parent, wxWindowID id,
|
||||
const wxPoint& position, const wxSize& size,
|
||||
long style, const wxString& name)
|
||||
: wxPanel(parent, id, position, size, style, name)
|
||||
, m_GPRGridView(NULL)
|
||||
{
|
||||
CreateGUIControls();
|
||||
}
|
||||
|
||||
void CRegisterWindow::CreateGUIControls()
|
||||
{
|
||||
wxBoxSizer *sGrid = new wxBoxSizer(wxVERTICAL);
|
||||
m_GPRGridView = new CRegisterView(this, ID_GPR);
|
||||
sGrid->Add(m_GPRGridView, 1, wxGROW);
|
||||
SetSizer(sGrid);
|
||||
|
||||
NotifyUpdate();
|
||||
}
|
||||
|
||||
void CRegisterWindow::NotifyUpdate()
|
||||
{
|
||||
if (m_GPRGridView != NULL)
|
||||
m_GPRGridView->Update();
|
||||
}
|
37
Source/Core/DolphinWX/Debugger/RegisterWindow.h
Normal file
37
Source/Core/DolphinWX/Debugger/RegisterWindow.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifndef __REGISTERWINDOW_h__
|
||||
#define __REGISTERWINDOW_h__
|
||||
|
||||
class CRegisterView;
|
||||
class IniFile;
|
||||
|
||||
class CRegisterWindow
|
||||
: public wxPanel
|
||||
{
|
||||
public:
|
||||
CRegisterWindow(wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
|
||||
const wxString& name = _("Registers"));
|
||||
|
||||
void NotifyUpdate();
|
||||
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
enum
|
||||
{
|
||||
ID_GPR = 1002
|
||||
};
|
||||
|
||||
CRegisterView* m_GPRGridView;
|
||||
void CreateGUIControls();
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user