set svn:eol-style=native for **.cpp

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1442 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
bushing
2008-12-08 05:30:24 +00:00
parent 901fe7c00f
commit 49cfded60b
177 changed files with 53968 additions and 53968 deletions

View File

@ -1,88 +1,88 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "BreakPointDlg.h"
#include "Common.h"
#include "Debugger.h"
#include "StringUtil.h"
#include "Debugger/Debugger_BreakPoints.h"
BEGIN_EVENT_TABLE(BreakPointDlg,wxDialog)
EVT_CLOSE(BreakPointDlg::OnClose)
EVT_BUTTON(ID_OK, BreakPointDlg::OnOK)
EVT_BUTTON(ID_CANCEL, BreakPointDlg::OnCancel)
END_EVENT_TABLE()
BreakPointDlg::BreakPointDlg(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
CreateGUIControls();
}
BreakPointDlg::~BreakPointDlg()
{
}
void BreakPointDlg::CreateGUIControls()
{
SetIcon(wxNullIcon);
SetSize(8,8,279,121);
Center();
wxStaticText* WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Address"), wxPoint(8,24), wxDefaultSize, 0, wxT("WxStaticText1"));
WxStaticText1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pButtonOK = new wxButton(this, ID_OK, wxT("OK"), wxPoint(192,64), wxSize(73,25), 0, wxDefaultValidator, wxT("OK"));
m_pButtonOK->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pButtonCancel = new wxButton(this, ID_CANCEL, wxT("Cancel"), wxPoint(112,64), wxSize(73,25), 0, wxDefaultValidator, wxT("Cancel"));
m_pButtonCancel->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pEditAddress = new wxTextCtrl(this, ID_ADDRESS, wxT("80000000"), wxPoint(56,24), wxSize(197,20), 0, wxDefaultValidator, wxT("WxEdit1"));
m_pEditAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticBox* WxStaticBox1 = new wxStaticBox(this, ID_WXSTATICBOX1, wxT("Address"), wxPoint(0,0), wxSize(265,57));
WxStaticBox1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
}
void BreakPointDlg::OnClose(wxCloseEvent& /*event*/)
{
Destroy();
}
void BreakPointDlg::OnOK(wxCommandEvent& /*event*/)
{
wxString AddressString = m_pEditAddress->GetLineText(0);
u32 Address = 0;
if (AsciiToHex(AddressString.mb_str(), Address))
{
CBreakPoints::AddBreakPoint(Address);
CBreakPoints::UpdateBreakPointView();
Close();
}
}
void BreakPointDlg::OnCancel(wxCommandEvent& /*event*/)
{
Close();
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "BreakPointDlg.h"
#include "Common.h"
#include "Debugger.h"
#include "StringUtil.h"
#include "Debugger/Debugger_BreakPoints.h"
BEGIN_EVENT_TABLE(BreakPointDlg,wxDialog)
EVT_CLOSE(BreakPointDlg::OnClose)
EVT_BUTTON(ID_OK, BreakPointDlg::OnOK)
EVT_BUTTON(ID_CANCEL, BreakPointDlg::OnCancel)
END_EVENT_TABLE()
BreakPointDlg::BreakPointDlg(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
CreateGUIControls();
}
BreakPointDlg::~BreakPointDlg()
{
}
void BreakPointDlg::CreateGUIControls()
{
SetIcon(wxNullIcon);
SetSize(8,8,279,121);
Center();
wxStaticText* WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Address"), wxPoint(8,24), wxDefaultSize, 0, wxT("WxStaticText1"));
WxStaticText1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pButtonOK = new wxButton(this, ID_OK, wxT("OK"), wxPoint(192,64), wxSize(73,25), 0, wxDefaultValidator, wxT("OK"));
m_pButtonOK->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pButtonCancel = new wxButton(this, ID_CANCEL, wxT("Cancel"), wxPoint(112,64), wxSize(73,25), 0, wxDefaultValidator, wxT("Cancel"));
m_pButtonCancel->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pEditAddress = new wxTextCtrl(this, ID_ADDRESS, wxT("80000000"), wxPoint(56,24), wxSize(197,20), 0, wxDefaultValidator, wxT("WxEdit1"));
m_pEditAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticBox* WxStaticBox1 = new wxStaticBox(this, ID_WXSTATICBOX1, wxT("Address"), wxPoint(0,0), wxSize(265,57));
WxStaticBox1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
}
void BreakPointDlg::OnClose(wxCloseEvent& /*event*/)
{
Destroy();
}
void BreakPointDlg::OnOK(wxCommandEvent& /*event*/)
{
wxString AddressString = m_pEditAddress->GetLineText(0);
u32 Address = 0;
if (AsciiToHex(AddressString.mb_str(), Address))
{
CBreakPoints::AddBreakPoint(Address);
CBreakPoints::UpdateBreakPointView();
Close();
}
}
void BreakPointDlg::OnCancel(wxCommandEvent& /*event*/)
{
Close();
}

View File

@ -1,121 +1,121 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "Common.h"
#include "BreakpointView.h"
#include "Debugger/Debugger_BreakPoints.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/SymbolDB.h"
BEGIN_EVENT_TABLE(CBreakPointView, wxListCtrl)
END_EVENT_TABLE()
CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style)
{
SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Segoe UI")));
Refresh();
}
void CBreakPointView::Update()
{
ClearAll();
InsertColumn(0, wxT("Active"), wxLIST_FORMAT_LEFT, 50);
InsertColumn(1, wxT("Type"), wxLIST_FORMAT_LEFT, 50);
InsertColumn(2, wxT("Function"), wxLIST_FORMAT_CENTER, 200);
InsertColumn(3, wxT("Address"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(4, wxT("Flags"), wxLIST_FORMAT_CENTER, 100);
char szBuffer[64];
const CBreakPoints::TBreakPoints& rBreakPoints = CBreakPoints::GetBreakPoints();
for (size_t i = 0; i < rBreakPoints.size(); i++)
{
const TBreakPoint& rBP = rBreakPoints[i];
if (!rBP.bTemporary)
{
wxString temp;
temp = wxString::FromAscii(rBP.bOn ? "on" : " ");
int Item = InsertItem(0, temp);
temp = wxString::FromAscii("BP");
SetItem(Item, 1, temp);
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rBP.iAddress);
if (symbol)
{
temp = wxString::FromAscii(g_symbolDB.GetDescription(rBP.iAddress));
SetItem(Item, 2, temp);
}
sprintf(szBuffer, "0x%08x", rBP.iAddress);
temp = wxString::FromAscii(szBuffer);
SetItem(Item, 3, temp);
SetItemData(Item, rBP.iAddress);
}
}
const CBreakPoints::TMemChecks& rMemChecks = CBreakPoints::GetMemChecks();
for (size_t i = 0; i < rMemChecks.size(); i++)
{
const TMemCheck& rMemCheck = rMemChecks[i];
wxString temp;
temp = wxString::FromAscii(rMemCheck.Break ? "on" : " ");
int Item = InsertItem(0, temp);
temp = wxString::FromAscii("MC");
SetItem(Item, 1, temp);
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.StartAddress);
if (symbol)
{
temp = wxString::FromAscii(g_symbolDB.GetDescription(rMemCheck.StartAddress));
SetItem(Item, 2, temp);
}
sprintf(szBuffer, "0x%08x to 0%08x", rMemCheck.StartAddress, rMemCheck.EndAddress);
temp = wxString::FromAscii(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 = wxString::FromAscii(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);
CBreakPoints::DeleteElementByAddress(Address);
}
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "Common.h"
#include "BreakpointView.h"
#include "Debugger/Debugger_BreakPoints.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/SymbolDB.h"
BEGIN_EVENT_TABLE(CBreakPointView, wxListCtrl)
END_EVENT_TABLE()
CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style)
{
SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Segoe UI")));
Refresh();
}
void CBreakPointView::Update()
{
ClearAll();
InsertColumn(0, wxT("Active"), wxLIST_FORMAT_LEFT, 50);
InsertColumn(1, wxT("Type"), wxLIST_FORMAT_LEFT, 50);
InsertColumn(2, wxT("Function"), wxLIST_FORMAT_CENTER, 200);
InsertColumn(3, wxT("Address"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(4, wxT("Flags"), wxLIST_FORMAT_CENTER, 100);
char szBuffer[64];
const CBreakPoints::TBreakPoints& rBreakPoints = CBreakPoints::GetBreakPoints();
for (size_t i = 0; i < rBreakPoints.size(); i++)
{
const TBreakPoint& rBP = rBreakPoints[i];
if (!rBP.bTemporary)
{
wxString temp;
temp = wxString::FromAscii(rBP.bOn ? "on" : " ");
int Item = InsertItem(0, temp);
temp = wxString::FromAscii("BP");
SetItem(Item, 1, temp);
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rBP.iAddress);
if (symbol)
{
temp = wxString::FromAscii(g_symbolDB.GetDescription(rBP.iAddress));
SetItem(Item, 2, temp);
}
sprintf(szBuffer, "0x%08x", rBP.iAddress);
temp = wxString::FromAscii(szBuffer);
SetItem(Item, 3, temp);
SetItemData(Item, rBP.iAddress);
}
}
const CBreakPoints::TMemChecks& rMemChecks = CBreakPoints::GetMemChecks();
for (size_t i = 0; i < rMemChecks.size(); i++)
{
const TMemCheck& rMemCheck = rMemChecks[i];
wxString temp;
temp = wxString::FromAscii(rMemCheck.Break ? "on" : " ");
int Item = InsertItem(0, temp);
temp = wxString::FromAscii("MC");
SetItem(Item, 1, temp);
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.StartAddress);
if (symbol)
{
temp = wxString::FromAscii(g_symbolDB.GetDescription(rMemCheck.StartAddress));
SetItem(Item, 2, temp);
}
sprintf(szBuffer, "0x%08x to 0%08x", rMemCheck.StartAddress, rMemCheck.EndAddress);
temp = wxString::FromAscii(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 = wxString::FromAscii(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);
CBreakPoints::DeleteElementByAddress(Address);
}
}

View File

@ -1,376 +1,376 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "BreakpointWindow.h"
#include "BreakpointView.h"
#include "CodeWindow.h"
#include "HW/Memmap.h"
#include "BreakPointDlg.h"
#include "MemoryCheckDlg.h"
#include "IniFile.h"
#include "Debugger/Debugger_BreakPoints.h" // for TMemCheck
#include <wx/mstream.h>
extern "C" {
#include "../resources/toolbar_add_breakpoint.c"
#include "../resources/toolbar_add_memorycheck.c"
#include "../resources/toolbar_delete.c"
}
static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;
BEGIN_EVENT_TABLE(CBreakPointWindow, wxFrame)
EVT_CLOSE(CBreakPointWindow::OnClose)
EVT_MENU(IDM_DELETE, CBreakPointWindow::OnDelete)
EVT_MENU(IDM_CLEAR, CBreakPointWindow::OnClear)
EVT_MENU(IDM_ADD_BREAKPOINT, CBreakPointWindow::OnAddBreakPoint)
EVT_MENU(IDM_ADD_BREAKPOINTMANY, CBreakPointWindow::OnAddBreakPointMany)
EVT_MENU(IDM_ADD_MEMORYCHECK, CBreakPointWindow::OnAddMemoryCheck)
EVT_MENU(IDM_ADD_MEMORYCHECKMANY, CBreakPointWindow::OnAddMemoryCheckMany)
EVT_LIST_ITEM_ACTIVATED(ID_BPS, CBreakPointWindow::OnActivated)
END_EVENT_TABLE()
#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
{
wxMemoryInputStream is(data, length);
return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
}
CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
, m_BreakPointListView(NULL)
, m_pCodeWindow(_pCodeWindow)
{
InitBitmaps();
CreateGUIControls();
// Create the toolbar
RecreateToolbar();
}
CBreakPointWindow::~CBreakPointWindow()
{}
void
CBreakPointWindow::Save(IniFile& _IniFile) const
{
_IniFile.Set("BreakPoint", "x", GetPosition().x);
_IniFile.Set("BreakPoint", "y", GetPosition().y);
_IniFile.Set("BreakPoint", "w", GetSize().GetWidth());
_IniFile.Set("BreakPoint", "h", GetSize().GetHeight());
}
void
CBreakPointWindow::Load(IniFile& _IniFile)
{
int x,y,w,h;
_IniFile.Get("BreakPoint", "x", &x, GetPosition().x);
_IniFile.Get("BreakPoint", "y", &y, GetPosition().y);
_IniFile.Get("BreakPoint", "w", &w, GetSize().GetWidth());
_IniFile.Get("BreakPoint", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
}
void
CBreakPointWindow::CreateGUIControls()
{
SetTitle(wxT("Breakpoints"));
SetIcon(wxNullIcon);
SetSize(8, 8, 400, 370);
Center();
m_BreakPointListView = new CBreakPointView(this, ID_BPS, wxDefaultPosition, GetSize(),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
NotifyUpdate();
}
void
CBreakPointWindow::PopulateToolbar(wxToolBar* toolBar)
{
int w = m_Bitmaps[Toolbar_Delete].GetWidth(),
h = m_Bitmaps[Toolbar_Delete].GetHeight();
toolBar->SetToolBitmapSize(wxSize(w, h));
toolBar->AddTool(IDM_DELETE, _T("Delete"), m_Bitmaps[Toolbar_Delete], _T("Delete the selected BreakPoint or MemoryCheck"));
toolBar->AddTool(IDM_CLEAR, _T("Clear all"), m_Bitmaps[Toolbar_Delete], _T("Clear all BreakPoints and MemoryChecks"));
toolBar->AddSeparator();
toolBar->AddTool(IDM_ADD_BREAKPOINT, _T("BP"), m_Bitmaps[Toolbar_Add_BreakPoint], _T("Add BreakPoint..."));
toolBar->AddTool(IDM_ADD_BREAKPOINTMANY, _T("BPs"), m_Bitmaps[Toolbar_Add_BreakPoint], _T("Add BreakPoints..."));
// just add memory breakpoints if you can use them
if (Memory::AreMemoryBreakpointsActivated())
{
toolBar->AddTool(IDM_ADD_MEMORYCHECK, _T("MC"), m_Bitmaps[Toolbar_Add_Memcheck], _T("Add MemoryCheck..."));
toolBar->AddTool(IDM_ADD_MEMORYCHECKMANY, _T("MCs"), m_Bitmaps[Toolbar_Add_Memcheck], _T("Add MemoryChecks..."));
}
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
toolBar->Realize();
}
void
CBreakPointWindow::RecreateToolbar()
{
// delete and recreate the toolbar
wxToolBarBase* toolBar = GetToolBar();
long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
delete toolBar;
SetToolBar(NULL);
style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT | wxTB_TOP);
wxToolBar* theToolBar = CreateToolBar(style, ID_TOOLBAR);
PopulateToolbar(theToolBar);
SetToolBar(theToolBar);
}
void
CBreakPointWindow::InitBitmaps()
{
// load orignal size 48x48
m_Bitmaps[Toolbar_Delete] = wxGetBitmapFromMemory(toolbar_delete_png);
m_Bitmaps[Toolbar_Add_BreakPoint] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
m_Bitmaps[Toolbar_Add_Memcheck] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
// scale to 24x24 for toolbar
for (size_t n = Toolbar_Delete; n < WXSIZEOF(m_Bitmaps); n++)
{
m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16));
}
}
void
CBreakPointWindow::OnClose(wxCloseEvent& /*event*/)
{
Hide();
}
void CBreakPointWindow::NotifyUpdate()
{
if (m_BreakPointListView != NULL)
{
m_BreakPointListView->Update();
}
}
void
CBreakPointWindow::OnDelete(wxCommandEvent& event)
{
if (m_BreakPointListView)
{
m_BreakPointListView->DeleteCurrentSelection();
}
}
// ==========================================================================================
// Clear all breakpoints
// ------------
void
CBreakPointWindow::OnClear(wxCommandEvent& event)
{
CBreakPoints::ClearAllBreakPoints();
}
// ============
void
CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& event)
{
BreakPointDlg bpDlg(this);
bpDlg.ShowModal();
}
// ==========================================================================================
// Load breakpoints from file
// --------------
void
CBreakPointWindow::OnAddBreakPointMany(wxCommandEvent& event)
{
// load ini
IniFile ini;
std::string filename = std::string(FULL_GAMECONFIG_DIR "BreakPoints.ini");
if (ini.Load(filename.c_str())) // check if there is any file there
{
// get lines from a certain section
std::vector<std::string> lines;
if (!ini.GetLines("BreakPoints", lines))
{
wxMessageBox(_T("You have no [BreakPoints] line in your file"));
return;
}
for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
{
std::string line = StripSpaces(*iter);
u32 Address = 0;
if (AsciiToHex(line.c_str(), Address))
{
CBreakPoints::AddBreakPoint(Address);
}
}
// only update after we are done with the loop
CBreakPoints::UpdateBreakPointView();
}
else
{
wxMessageBox(_T("You have no GameIni/BreakPoints.ini file"));
}
}
// =================
void
CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& event)
{
MemoryCheckDlg memDlg(this);
memDlg.ShowModal();
}
// ==========================================================================================
// Load memory checks from file
// --------------
void
CBreakPointWindow::OnAddMemoryCheckMany(wxCommandEvent& event)
{
// load ini
IniFile ini;
std::string filename = std::string(FULL_GAMECONFIG_DIR "MemoryChecks.ini");
if (ini.Load(filename.c_str()))
{
// get lines from a certain section
std::vector<std::string> lines;
if (!ini.GetLines("MemoryChecks", lines))
{
wxMessageBox(_T("You have no [MemoryChecks] line in your file"));
return;
}
for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
{
std::string line = StripSpaces(*iter);
std::vector<std::string> pieces;
SplitString(line, " ", pieces); // split string
TMemCheck MemCheck;
u32 sAddress = 0;
u32 eAddress = 0;
bool doCommon = false;
// ------------------------------------------------------------------------------------------
// Decide if we have a range or just one address, and if we should break or not
// --------------
if (
pieces.size() == 1
&& AsciiToHex(pieces[0].c_str(), sAddress)
&& pieces[0].size() == 8
)
{
// address range
MemCheck.StartAddress = sAddress;
MemCheck.EndAddress = sAddress;
doCommon = true;
MemCheck.Break = false;
}
else if(
pieces.size() == 2
&& AsciiToHex(pieces[0].c_str(), sAddress) && AsciiToHex(pieces[1].c_str(), eAddress)
&& pieces[0].size() == 8 && pieces[1].size() == 8
)
{
// address range
MemCheck.StartAddress = sAddress;
MemCheck.EndAddress = eAddress;
doCommon = true;
MemCheck.Break = false;
}
else if(
pieces.size() == 3
&& AsciiToHex(pieces[0].c_str(), sAddress) && AsciiToHex(pieces[1].c_str(), eAddress)
&& pieces[0].size() == 8 && pieces[1].size() == 8 && pieces[2].size() == 1
)
{
// address range
MemCheck.StartAddress = sAddress;
MemCheck.EndAddress = eAddress;
doCommon = true;
MemCheck.Break = true;
}
if(doCommon)
{
// settings for the memory check
MemCheck.OnRead = true;
MemCheck.OnWrite = true;
MemCheck.Log = true;
//MemCheck.Break = false; // this is also what sets Active "on" in the breakpoint window
// so don't think it's off because we are only writing this to the log
CBreakPoints::AddMemoryCheck(MemCheck);
}
}
// update after we are done with the loop
CBreakPoints::UpdateBreakPointView();
}
else
{
wxMessageBox(_T("You have no " FULL_GAMECONFIG_DIR "MemoryChecks.ini file"));
}
}
// =================
void
CBreakPointWindow::OnActivated(wxListEvent& event)
{
long Index = event.GetIndex();
if (Index >= 0)
{
u32 Address = (u32)m_BreakPointListView->GetItemData(Index);
if (m_pCodeWindow != NULL)
{
m_pCodeWindow->JumpToAddress(Address);
}
}
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "BreakpointWindow.h"
#include "BreakpointView.h"
#include "CodeWindow.h"
#include "HW/Memmap.h"
#include "BreakPointDlg.h"
#include "MemoryCheckDlg.h"
#include "IniFile.h"
#include "Debugger/Debugger_BreakPoints.h" // for TMemCheck
#include <wx/mstream.h>
extern "C" {
#include "../resources/toolbar_add_breakpoint.c"
#include "../resources/toolbar_add_memorycheck.c"
#include "../resources/toolbar_delete.c"
}
static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;
BEGIN_EVENT_TABLE(CBreakPointWindow, wxFrame)
EVT_CLOSE(CBreakPointWindow::OnClose)
EVT_MENU(IDM_DELETE, CBreakPointWindow::OnDelete)
EVT_MENU(IDM_CLEAR, CBreakPointWindow::OnClear)
EVT_MENU(IDM_ADD_BREAKPOINT, CBreakPointWindow::OnAddBreakPoint)
EVT_MENU(IDM_ADD_BREAKPOINTMANY, CBreakPointWindow::OnAddBreakPointMany)
EVT_MENU(IDM_ADD_MEMORYCHECK, CBreakPointWindow::OnAddMemoryCheck)
EVT_MENU(IDM_ADD_MEMORYCHECKMANY, CBreakPointWindow::OnAddMemoryCheckMany)
EVT_LIST_ITEM_ACTIVATED(ID_BPS, CBreakPointWindow::OnActivated)
END_EVENT_TABLE()
#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
{
wxMemoryInputStream is(data, length);
return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
}
CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
, m_BreakPointListView(NULL)
, m_pCodeWindow(_pCodeWindow)
{
InitBitmaps();
CreateGUIControls();
// Create the toolbar
RecreateToolbar();
}
CBreakPointWindow::~CBreakPointWindow()
{}
void
CBreakPointWindow::Save(IniFile& _IniFile) const
{
_IniFile.Set("BreakPoint", "x", GetPosition().x);
_IniFile.Set("BreakPoint", "y", GetPosition().y);
_IniFile.Set("BreakPoint", "w", GetSize().GetWidth());
_IniFile.Set("BreakPoint", "h", GetSize().GetHeight());
}
void
CBreakPointWindow::Load(IniFile& _IniFile)
{
int x,y,w,h;
_IniFile.Get("BreakPoint", "x", &x, GetPosition().x);
_IniFile.Get("BreakPoint", "y", &y, GetPosition().y);
_IniFile.Get("BreakPoint", "w", &w, GetSize().GetWidth());
_IniFile.Get("BreakPoint", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
}
void
CBreakPointWindow::CreateGUIControls()
{
SetTitle(wxT("Breakpoints"));
SetIcon(wxNullIcon);
SetSize(8, 8, 400, 370);
Center();
m_BreakPointListView = new CBreakPointView(this, ID_BPS, wxDefaultPosition, GetSize(),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
NotifyUpdate();
}
void
CBreakPointWindow::PopulateToolbar(wxToolBar* toolBar)
{
int w = m_Bitmaps[Toolbar_Delete].GetWidth(),
h = m_Bitmaps[Toolbar_Delete].GetHeight();
toolBar->SetToolBitmapSize(wxSize(w, h));
toolBar->AddTool(IDM_DELETE, _T("Delete"), m_Bitmaps[Toolbar_Delete], _T("Delete the selected BreakPoint or MemoryCheck"));
toolBar->AddTool(IDM_CLEAR, _T("Clear all"), m_Bitmaps[Toolbar_Delete], _T("Clear all BreakPoints and MemoryChecks"));
toolBar->AddSeparator();
toolBar->AddTool(IDM_ADD_BREAKPOINT, _T("BP"), m_Bitmaps[Toolbar_Add_BreakPoint], _T("Add BreakPoint..."));
toolBar->AddTool(IDM_ADD_BREAKPOINTMANY, _T("BPs"), m_Bitmaps[Toolbar_Add_BreakPoint], _T("Add BreakPoints..."));
// just add memory breakpoints if you can use them
if (Memory::AreMemoryBreakpointsActivated())
{
toolBar->AddTool(IDM_ADD_MEMORYCHECK, _T("MC"), m_Bitmaps[Toolbar_Add_Memcheck], _T("Add MemoryCheck..."));
toolBar->AddTool(IDM_ADD_MEMORYCHECKMANY, _T("MCs"), m_Bitmaps[Toolbar_Add_Memcheck], _T("Add MemoryChecks..."));
}
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
toolBar->Realize();
}
void
CBreakPointWindow::RecreateToolbar()
{
// delete and recreate the toolbar
wxToolBarBase* toolBar = GetToolBar();
long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
delete toolBar;
SetToolBar(NULL);
style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT | wxTB_TOP);
wxToolBar* theToolBar = CreateToolBar(style, ID_TOOLBAR);
PopulateToolbar(theToolBar);
SetToolBar(theToolBar);
}
void
CBreakPointWindow::InitBitmaps()
{
// load orignal size 48x48
m_Bitmaps[Toolbar_Delete] = wxGetBitmapFromMemory(toolbar_delete_png);
m_Bitmaps[Toolbar_Add_BreakPoint] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
m_Bitmaps[Toolbar_Add_Memcheck] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
// scale to 24x24 for toolbar
for (size_t n = Toolbar_Delete; n < WXSIZEOF(m_Bitmaps); n++)
{
m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16));
}
}
void
CBreakPointWindow::OnClose(wxCloseEvent& /*event*/)
{
Hide();
}
void CBreakPointWindow::NotifyUpdate()
{
if (m_BreakPointListView != NULL)
{
m_BreakPointListView->Update();
}
}
void
CBreakPointWindow::OnDelete(wxCommandEvent& event)
{
if (m_BreakPointListView)
{
m_BreakPointListView->DeleteCurrentSelection();
}
}
// ==========================================================================================
// Clear all breakpoints
// ------------
void
CBreakPointWindow::OnClear(wxCommandEvent& event)
{
CBreakPoints::ClearAllBreakPoints();
}
// ============
void
CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& event)
{
BreakPointDlg bpDlg(this);
bpDlg.ShowModal();
}
// ==========================================================================================
// Load breakpoints from file
// --------------
void
CBreakPointWindow::OnAddBreakPointMany(wxCommandEvent& event)
{
// load ini
IniFile ini;
std::string filename = std::string(FULL_GAMECONFIG_DIR "BreakPoints.ini");
if (ini.Load(filename.c_str())) // check if there is any file there
{
// get lines from a certain section
std::vector<std::string> lines;
if (!ini.GetLines("BreakPoints", lines))
{
wxMessageBox(_T("You have no [BreakPoints] line in your file"));
return;
}
for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
{
std::string line = StripSpaces(*iter);
u32 Address = 0;
if (AsciiToHex(line.c_str(), Address))
{
CBreakPoints::AddBreakPoint(Address);
}
}
// only update after we are done with the loop
CBreakPoints::UpdateBreakPointView();
}
else
{
wxMessageBox(_T("You have no GameIni/BreakPoints.ini file"));
}
}
// =================
void
CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& event)
{
MemoryCheckDlg memDlg(this);
memDlg.ShowModal();
}
// ==========================================================================================
// Load memory checks from file
// --------------
void
CBreakPointWindow::OnAddMemoryCheckMany(wxCommandEvent& event)
{
// load ini
IniFile ini;
std::string filename = std::string(FULL_GAMECONFIG_DIR "MemoryChecks.ini");
if (ini.Load(filename.c_str()))
{
// get lines from a certain section
std::vector<std::string> lines;
if (!ini.GetLines("MemoryChecks", lines))
{
wxMessageBox(_T("You have no [MemoryChecks] line in your file"));
return;
}
for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter)
{
std::string line = StripSpaces(*iter);
std::vector<std::string> pieces;
SplitString(line, " ", pieces); // split string
TMemCheck MemCheck;
u32 sAddress = 0;
u32 eAddress = 0;
bool doCommon = false;
// ------------------------------------------------------------------------------------------
// Decide if we have a range or just one address, and if we should break or not
// --------------
if (
pieces.size() == 1
&& AsciiToHex(pieces[0].c_str(), sAddress)
&& pieces[0].size() == 8
)
{
// address range
MemCheck.StartAddress = sAddress;
MemCheck.EndAddress = sAddress;
doCommon = true;
MemCheck.Break = false;
}
else if(
pieces.size() == 2
&& AsciiToHex(pieces[0].c_str(), sAddress) && AsciiToHex(pieces[1].c_str(), eAddress)
&& pieces[0].size() == 8 && pieces[1].size() == 8
)
{
// address range
MemCheck.StartAddress = sAddress;
MemCheck.EndAddress = eAddress;
doCommon = true;
MemCheck.Break = false;
}
else if(
pieces.size() == 3
&& AsciiToHex(pieces[0].c_str(), sAddress) && AsciiToHex(pieces[1].c_str(), eAddress)
&& pieces[0].size() == 8 && pieces[1].size() == 8 && pieces[2].size() == 1
)
{
// address range
MemCheck.StartAddress = sAddress;
MemCheck.EndAddress = eAddress;
doCommon = true;
MemCheck.Break = true;
}
if(doCommon)
{
// settings for the memory check
MemCheck.OnRead = true;
MemCheck.OnWrite = true;
MemCheck.Log = true;
//MemCheck.Break = false; // this is also what sets Active "on" in the breakpoint window
// so don't think it's off because we are only writing this to the log
CBreakPoints::AddMemoryCheck(MemCheck);
}
}
// update after we are done with the loop
CBreakPoints::UpdateBreakPointView();
}
else
{
wxMessageBox(_T("You have no " FULL_GAMECONFIG_DIR "MemoryChecks.ini file"));
}
}
// =================
void
CBreakPointWindow::OnActivated(wxListEvent& event)
{
long Index = event.GetIndex();
if (Index >= 0)
{
u32 Address = (u32)m_BreakPointListView->GetItemData(Index);
if (m_pCodeWindow != NULL)
{
m_pCodeWindow->JumpToAddress(Address);
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,19 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"

View File

@ -1,211 +1,211 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "IniFile.h"
#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/Jit64/Jit.h"
#include "PowerPC/Jit64/JitCache.h"
#include "Host.h"
#include "disasm.h"
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "Core.h"
#include "StringUtil.h"
#include "LogManager.h"
// ugly that this lib included code from the main
#include "../../DolphinWX/Src/Globals.h"
// UGLY
namespace {
CJitWindow *the_jit_window;
}
enum
{
IDM_REFRESH_LIST = 23350,
IDM_PPC_BOX,
IDM_X86_BOX,
IDM_NEXT,
IDM_PREV,
IDM_BLOCKLIST,
};
BEGIN_EVENT_TABLE(CJitWindow, wxFrame)
// 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 wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(parent, id, title, pos, size, style)
{
the_jit_window = this;
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, _T("&Refresh")));
// sizerRight->Add(addrbox = new wxTextCtrl(this, IDM_ADDRBOX, _T("")));
// sizerRight->Add(new wxButton(this, IDM_SETPC, _T("S&et PC")));
SetSizer(sizerBig);
sizerSplit->SetSizeHints(this);
sizerSplit->Fit(this);
sizerBig->SetSizeHints(this);
sizerBig->Fit(this);
}
CJitWindow::~CJitWindow()
{
}
void CJitWindow::Save(IniFile& _IniFile) const
{
_IniFile.Set("JitWindow", "x", GetPosition().x);
_IniFile.Set("JitWindow", "y", GetPosition().y);
_IniFile.Set("JitWindow", "w", GetSize().GetWidth());
_IniFile.Set("JitWindow", "h", GetSize().GetHeight());
}
void CJitWindow::Load(IniFile& _IniFile)
{
int x,y,w,h;
_IniFile.Get("JitWindow", "x", &x, GetPosition().x);
_IniFile.Get("JitWindow", "y", &y, GetPosition().y);
_IniFile.Get("JitWindow", "w", &w, GetSize().GetWidth());
_IniFile.Get("JitWindow", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
}
void CJitWindow::OnRefresh(wxCommandEvent& /*event*/) {
block_list->Update();
}
void CJitWindow::ViewAddr(u32 em_address)
{
the_jit_window->Compare(em_address);
}
void CJitWindow::Compare(u32 em_address)
{
u8 *xDis = new u8[65536];
memset(xDis, 0, 65536);
disassembler x64disasm;
x64disasm.set_syntax_intel();
int block_num = Jit64::GetBlockNumberFromAddress(em_address);
if (block_num < 0)
{
ppc_box->SetValue(wxString::FromAscii(StringFromFormat("(non-code address: %08x)", em_address).c_str()));
x86_box->SetValue(wxString::FromAscii(StringFromFormat("(no translation)").c_str()));
return;
}
Jit64::JitBlock *block = Jit64::GetBlock(block_num);
const u8 *code = (const u8 *)Jit64::GetCompiledCodeFromBlock(block_num);
u64 disasmPtr = (u64)code;
int size = block->codeSize;
const u8 *end = code + size;
char *sptr = (char*)xDis;
while ((u8*)disasmPtr < end)
{
disasmPtr += x64disasm.disasm64(disasmPtr, disasmPtr, (u8*)disasmPtr, sptr);
sptr += strlen(sptr);
*sptr++ = 13;
*sptr++ = 10;
}
x86_box->SetValue(wxString::FromAscii((char*)xDis));
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, _T("Address"));
InsertColumn(COLUMN_PPCSIZE, _T("PPC Size"));
InsertColumn(COLUMN_X86SIZE, _T("x86 Size"));
InsertColumn(COLUMN_NAME, _T("Symbol"));
InsertColumn(COLUMN_FLAGS, _T("Flags"));
InsertColumn(COLUMN_NUMEXEC, _T("NumExec"));
InsertColumn(COLUMN_COST, _T("Cost"));
}
void JitBlockList::Update()
{
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "IniFile.h"
#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/Jit64/Jit.h"
#include "PowerPC/Jit64/JitCache.h"
#include "Host.h"
#include "disasm.h"
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "Core.h"
#include "StringUtil.h"
#include "LogManager.h"
// ugly that this lib included code from the main
#include "../../DolphinWX/Src/Globals.h"
// UGLY
namespace {
CJitWindow *the_jit_window;
}
enum
{
IDM_REFRESH_LIST = 23350,
IDM_PPC_BOX,
IDM_X86_BOX,
IDM_NEXT,
IDM_PREV,
IDM_BLOCKLIST,
};
BEGIN_EVENT_TABLE(CJitWindow, wxFrame)
// 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 wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(parent, id, title, pos, size, style)
{
the_jit_window = this;
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, _T("&Refresh")));
// sizerRight->Add(addrbox = new wxTextCtrl(this, IDM_ADDRBOX, _T("")));
// sizerRight->Add(new wxButton(this, IDM_SETPC, _T("S&et PC")));
SetSizer(sizerBig);
sizerSplit->SetSizeHints(this);
sizerSplit->Fit(this);
sizerBig->SetSizeHints(this);
sizerBig->Fit(this);
}
CJitWindow::~CJitWindow()
{
}
void CJitWindow::Save(IniFile& _IniFile) const
{
_IniFile.Set("JitWindow", "x", GetPosition().x);
_IniFile.Set("JitWindow", "y", GetPosition().y);
_IniFile.Set("JitWindow", "w", GetSize().GetWidth());
_IniFile.Set("JitWindow", "h", GetSize().GetHeight());
}
void CJitWindow::Load(IniFile& _IniFile)
{
int x,y,w,h;
_IniFile.Get("JitWindow", "x", &x, GetPosition().x);
_IniFile.Get("JitWindow", "y", &y, GetPosition().y);
_IniFile.Get("JitWindow", "w", &w, GetSize().GetWidth());
_IniFile.Get("JitWindow", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
}
void CJitWindow::OnRefresh(wxCommandEvent& /*event*/) {
block_list->Update();
}
void CJitWindow::ViewAddr(u32 em_address)
{
the_jit_window->Compare(em_address);
}
void CJitWindow::Compare(u32 em_address)
{
u8 *xDis = new u8[65536];
memset(xDis, 0, 65536);
disassembler x64disasm;
x64disasm.set_syntax_intel();
int block_num = Jit64::GetBlockNumberFromAddress(em_address);
if (block_num < 0)
{
ppc_box->SetValue(wxString::FromAscii(StringFromFormat("(non-code address: %08x)", em_address).c_str()));
x86_box->SetValue(wxString::FromAscii(StringFromFormat("(no translation)").c_str()));
return;
}
Jit64::JitBlock *block = Jit64::GetBlock(block_num);
const u8 *code = (const u8 *)Jit64::GetCompiledCodeFromBlock(block_num);
u64 disasmPtr = (u64)code;
int size = block->codeSize;
const u8 *end = code + size;
char *sptr = (char*)xDis;
while ((u8*)disasmPtr < end)
{
disasmPtr += x64disasm.disasm64(disasmPtr, disasmPtr, (u8*)disasmPtr, sptr);
sptr += strlen(sptr);
*sptr++ = 13;
*sptr++ = 10;
}
x86_box->SetValue(wxString::FromAscii((char*)xDis));
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, _T("Address"));
InsertColumn(COLUMN_PPCSIZE, _T("PPC Size"));
InsertColumn(COLUMN_X86SIZE, _T("x86 Size"));
InsertColumn(COLUMN_NAME, _T("Symbol"));
InsertColumn(COLUMN_FLAGS, _T("Flags"));
InsertColumn(COLUMN_NUMEXEC, _T("NumExec"));
InsertColumn(COLUMN_COST, _T("Cost"));
}
void JitBlockList::Update()
{
}

File diff suppressed because it is too large Load Diff

View File

@ -1,112 +1,112 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "MemoryCheckDlg.h"
#include "Common.h"
#include "Debugger.h"
#include "StringUtil.h"
#include "Debugger/Debugger_BreakPoints.h"
BEGIN_EVENT_TABLE(MemoryCheckDlg,wxDialog)
EVT_CLOSE(MemoryCheckDlg::OnClose)
EVT_BUTTON(ID_OK, MemoryCheckDlg::OnOK)
EVT_BUTTON(ID_CANCEL, MemoryCheckDlg::OnCancel)
END_EVENT_TABLE()
MemoryCheckDlg::MemoryCheckDlg(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
CreateGUIControls();
}
MemoryCheckDlg::~MemoryCheckDlg()
{
}
void MemoryCheckDlg::CreateGUIControls()
{
SetIcon(wxNullIcon);
SetSize(8,8,415,122);
Center();
m_pButtonCancel = new wxButton(this, ID_CANCEL, wxT("Cancel"), wxPoint(248,64), wxSize(73,25), 0, wxDefaultValidator, wxT("Cancel"));
m_pButtonCancel->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pButtonOK = new wxButton(this, ID_OK, wxT("OK"), wxPoint(328,64), wxSize(73,25), 0, wxDefaultValidator, wxT("OK"));
m_pButtonOK->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pReadFlag = new wxCheckBox(this, ID_READ_FLAG, wxT("Read"), wxPoint(336,33), wxSize(57,15), 0, wxDefaultValidator, wxT("Read"));
m_pReadFlag->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pWriteFlag = new wxCheckBox(this, ID_WRITE_FLAG, wxT("Write"), wxPoint(336,16), wxSize(57,17), 0, wxDefaultValidator, wxT("WxCheckBox1"));
m_pWriteFlag->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticBox* WxStaticBox2 = new wxStaticBox(this, ID_WXSTATICBOX2, wxT("Break On"), wxPoint(328,0), wxSize(73,57));
WxStaticBox2->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticText* WxStaticText2 = new wxStaticText(this, ID_WXSTATICTEXT2, wxT("End"), wxPoint(168,24), wxDefaultSize, 0, wxT("WxStaticText2"));
WxStaticText2->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticText* WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Start"), wxPoint(8,24), wxDefaultSize, 0, wxT("WxStaticText1"));
WxStaticText1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pEditStartAddress = new wxTextCtrl(this, ID_EDIT_START_ADDR, wxT("80000000"), wxPoint(40,24), wxSize(109,20), 0, wxDefaultValidator, wxT("WxEdit1"));
m_pEditStartAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pEditEndAddress = new wxTextCtrl(this, ID_EDIT_END_ADDRESS, wxT("80000000"), wxPoint(200,24), wxSize(109,20), 0, wxDefaultValidator, wxT("WxEdit2"));
m_pEditEndAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticBox* WxStaticBox1 = new wxStaticBox(this, ID_WXSTATICBOX1, wxT("Address Range"), wxPoint(0,0), wxSize(321,57));
WxStaticBox1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
}
void MemoryCheckDlg::OnClose(wxCloseEvent& /*event*/)
{
Destroy();
}
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();
u32 StartAddress, EndAddress;
if (AsciiToHex(StartAddressString.mb_str(), StartAddress) &&
AsciiToHex(EndAddressString.mb_str(), EndAddress))
{
TMemCheck MemCheck;
MemCheck.StartAddress = StartAddress;
MemCheck.EndAddress = EndAddress;
MemCheck.OnRead = OnRead;
MemCheck.OnWrite = OnWrite;
MemCheck.Log = true;
MemCheck.Break = true;
CBreakPoints::AddMemoryCheck(MemCheck);
CBreakPoints::UpdateBreakPointView();
Close();
}
}
void MemoryCheckDlg::OnCancel(wxCommandEvent& /*event*/)
{
Close();
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "MemoryCheckDlg.h"
#include "Common.h"
#include "Debugger.h"
#include "StringUtil.h"
#include "Debugger/Debugger_BreakPoints.h"
BEGIN_EVENT_TABLE(MemoryCheckDlg,wxDialog)
EVT_CLOSE(MemoryCheckDlg::OnClose)
EVT_BUTTON(ID_OK, MemoryCheckDlg::OnOK)
EVT_BUTTON(ID_CANCEL, MemoryCheckDlg::OnCancel)
END_EVENT_TABLE()
MemoryCheckDlg::MemoryCheckDlg(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
CreateGUIControls();
}
MemoryCheckDlg::~MemoryCheckDlg()
{
}
void MemoryCheckDlg::CreateGUIControls()
{
SetIcon(wxNullIcon);
SetSize(8,8,415,122);
Center();
m_pButtonCancel = new wxButton(this, ID_CANCEL, wxT("Cancel"), wxPoint(248,64), wxSize(73,25), 0, wxDefaultValidator, wxT("Cancel"));
m_pButtonCancel->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pButtonOK = new wxButton(this, ID_OK, wxT("OK"), wxPoint(328,64), wxSize(73,25), 0, wxDefaultValidator, wxT("OK"));
m_pButtonOK->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pReadFlag = new wxCheckBox(this, ID_READ_FLAG, wxT("Read"), wxPoint(336,33), wxSize(57,15), 0, wxDefaultValidator, wxT("Read"));
m_pReadFlag->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pWriteFlag = new wxCheckBox(this, ID_WRITE_FLAG, wxT("Write"), wxPoint(336,16), wxSize(57,17), 0, wxDefaultValidator, wxT("WxCheckBox1"));
m_pWriteFlag->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticBox* WxStaticBox2 = new wxStaticBox(this, ID_WXSTATICBOX2, wxT("Break On"), wxPoint(328,0), wxSize(73,57));
WxStaticBox2->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticText* WxStaticText2 = new wxStaticText(this, ID_WXSTATICTEXT2, wxT("End"), wxPoint(168,24), wxDefaultSize, 0, wxT("WxStaticText2"));
WxStaticText2->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticText* WxStaticText1 = new wxStaticText(this, ID_WXSTATICTEXT1, wxT("Start"), wxPoint(8,24), wxDefaultSize, 0, wxT("WxStaticText1"));
WxStaticText1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pEditStartAddress = new wxTextCtrl(this, ID_EDIT_START_ADDR, wxT("80000000"), wxPoint(40,24), wxSize(109,20), 0, wxDefaultValidator, wxT("WxEdit1"));
m_pEditStartAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
m_pEditEndAddress = new wxTextCtrl(this, ID_EDIT_END_ADDRESS, wxT("80000000"), wxPoint(200,24), wxSize(109,20), 0, wxDefaultValidator, wxT("WxEdit2"));
m_pEditEndAddress->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
wxStaticBox* WxStaticBox1 = new wxStaticBox(this, ID_WXSTATICBOX1, wxT("Address Range"), wxPoint(0,0), wxSize(321,57));
WxStaticBox1->SetFont(wxFont(8, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")));
}
void MemoryCheckDlg::OnClose(wxCloseEvent& /*event*/)
{
Destroy();
}
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();
u32 StartAddress, EndAddress;
if (AsciiToHex(StartAddressString.mb_str(), StartAddress) &&
AsciiToHex(EndAddressString.mb_str(), EndAddress))
{
TMemCheck MemCheck;
MemCheck.StartAddress = StartAddress;
MemCheck.EndAddress = EndAddress;
MemCheck.OnRead = OnRead;
MemCheck.OnWrite = OnWrite;
MemCheck.Log = true;
MemCheck.Break = true;
CBreakPoints::AddMemoryCheck(MemCheck);
CBreakPoints::UpdateBreakPointView();
Close();
}
}
void MemoryCheckDlg::OnCancel(wxCommandEvent& /*event*/)
{
Close();
}

View File

@ -1,430 +1,430 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "Common.h"
#include "MemoryView.h"
#include <wx/event.h>
#include <wx/clipbrd.h>
enum
{
IDM_GOTOINMEMVIEW = 12000,
IDM_COPYADDRESS,
IDM_COPYHEX,
IDM_COPYCODE,
IDM_RUNTOHERE,
IDM_DYNARECRESULTS,
};
BEGIN_EVENT_TABLE(CMemoryView, wxControl)
EVT_ERASE_BACKGROUND(CMemoryView::OnErase)
EVT_PAINT(CMemoryView::OnPaint)
EVT_LEFT_DOWN(CMemoryView::OnMouseDown)
EVT_LEFT_UP(CMemoryView::OnMouseUpL)
EVT_MOTION(CMemoryView::OnMouseMove)
EVT_RIGHT_DOWN(CMemoryView::OnMouseDown)
EVT_RIGHT_UP(CMemoryView::OnMouseUpR)
EVT_MENU(-1, CMemoryView::OnPopupMenu)
END_EVENT_TABLE()
CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id, const wxSize& Size)
: wxControl(parent, Id, wxDefaultPosition, Size),
debugger(debuginterface),
rowHeight(13),
selection(0),
oldSelection(0),
selectionChanged(false),
selecting(false),
hasFocus(false),
showHex(false)
{
rowHeight = 13;
align = debuginterface->getInstructionSize(0);
curAddress = debuginterface->getPC();
}
wxSize CMemoryView::DoGetBestSize() const
{
wxSize bestSize;
bestSize.x = 300;
bestSize.y = 300;
return(bestSize);
}
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::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))
{
redraw();
}
}
else
{
debugger->toggleBreakpoint(YToAddress(y));
redraw();
}
event.Skip(true);
}
void CMemoryView::OnMouseMove(wxMouseEvent& event)
{
wxRect rc = GetClientRect();
if (event.m_leftDown)
{
if (event.m_x > 16)
{
if (event.m_y < 0)
{
curAddress -= align;
redraw();
}
else if (event.m_y > rc.height)
{
curAddress += align;
redraw();
}
else
{
OnMouseDown(event);
}
}
}
event.Skip(true);
}
void CMemoryView::OnMouseUpL(wxMouseEvent& event)
{
if (event.m_x > 16)
{
curAddress = YToAddress(event.m_y);
selecting = false;
//ReleaseCapture();
redraw();
}
event.Skip(true);
}
void CMemoryView::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:
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(debugger->disasm(selection)))); //Have to manually convert from char* to wxString, don't have to in Windows?
break;
case IDM_COPYHEX:
{
char temp[24];
sprintf(temp, "%08x", debugger->readMemory(selection));
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(temp)));
}
break;
#endif
case IDM_RUNTOHERE:
{
debugger->setBreakpoint(selection);
debugger->runToBreakpoint();
redraw();
}
break;
case IDM_DYNARECRESULTS:
{
// CDynaViewDlg::ViewAddr(selection);
// CDynaViewDlg::Show(TRUE);
// MessageBox(NULL, "not impl", "CtrlDisAsmView", MB_OK);
}
break;
}
#if wxUSE_CLIPBOARD
wxTheClipboard->Close();
#endif
event.Skip(true);
}
void CMemoryView::OnMouseUpR(wxMouseEvent& event)
{
// popup menu
wxMenu menu;
//menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
#if wxUSE_CLIPBOARD
menu.Append(IDM_COPYADDRESS, wxString::FromAscii("Copy &address"));
menu.Append(IDM_COPYCODE, wxString::FromAscii("Copy &code"));
menu.Append(IDM_COPYHEX, wxString::FromAscii("Copy &hex"));
#endif
menu.Append(IDM_RUNTOHERE, _T("&Run To Here"));
//menu.Append(IDM_DYNARECRESULTS, "Copy &address");
PopupMenu(&menu);
event.Skip(true);
}
void CMemoryView::OnErase(wxEraseEvent& event)
{}
void CMemoryView::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
int fontSize = 8;
wxRect rc = GetClientRect();
wxFont font(fontSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT);
dc.SetFont(font);
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;
//numRows=(numRows&(~1)) + 1;
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")); // ligh 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+8);
// TODO - clean up this freaking mess!!!!!
int i;
for (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);
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 - 1);
dc.SetBrush(currentBrush);
dc.SetTextForeground(_T("#600000"));
dc.DrawText(temp, 17, rowY1);
char mem[256] = {0};
strcpy(mem, debugger->getRawMemoryString(address));
dc.SetTextForeground(_T("#000080"));
dc.DrawText(wxString::FromAscii(mem), 17+fontSize*(8), rowY1);
dc.SetTextForeground(_T("#000000"));
if (debugger->isAlive())
{
char dis[256] = {0};
strcpy(dis, debugger->disasm(address));
char* dis2 = strchr(dis, '\t');
char desc[256] = "";
if (dis2)
{
*dis2 = 0;
dis2++;
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)offs - (s64)address) * rowHeight / align + rowHeight / 2);
sprintf(desc, "-->%s", debugger->getDescription(offs).c_str());
dc.SetTextForeground(_T("#600060"));
}
else
{
dc.SetTextForeground(_T("#000000"));
}
dc.DrawText(wxString::FromAscii(dis2), 17+fontSize*(8+8+8), rowY1);
}
if (strcmp(dis, "blr"))
{
dc.SetTextForeground(_T("#007000"));
}
else
{
dc.SetTextForeground(_T("#8000FF"));
}
dc.DrawText(wxString::FromAscii(dis), 17+fontSize*(8+8), rowY1);
if (desc[0] == 0)
{
strcpy(desc, debugger->getDescription(address).c_str());
}
dc.SetTextForeground(_T("#0000FF"));
//char temp[256];
//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
if (strlen(desc))
{
dc.DrawText(wxString::FromAscii(desc), 17+fontSize*(8+8+8+30), rowY1);
}
if (debugger->isBreakpoint(address))
{
dc.SetBrush(bpBrush);
dc.DrawRectangle(2, rowY1, 7, 7);
// DrawIconEx(hdc, 2, rowY1, breakPoint, 32, 32, 0, 0, DI_NORMAL);
}
}
}
dc.SetPen(currentPen);
/*
for (i = 0; i < numBranches; i++)
{
int x = 250 + (branches[i].srcAddr % 9) * 8;
MoveToEx(hdc, x-2, branches[i].src, 0);
if (branches[i].dst < rect.bottom + 200 && branches[i].dst > -200)
{
LineTo(hdc, x+2, branches[i].src);
LineTo(hdc, x+2, branches[i].dst);
LineTo(hdc, x-4, branches[i].dst);
MoveToEx(hdc, x, branches[i].dst - 4,0);
LineTo(hdc, x-4, branches[i].dst);
LineTo(hdc, x+1, branches[i].dst+5);
}
else
{
LineTo(hdc, x+4, branches[i].src);
//MoveToEx(hdc,x+2,branches[i].dst-4,0);
//LineTo(hdc,x+6,branches[i].dst);
//LineTo(hdc,x+1,branches[i].dst+5);
}
//LineTo(hdc,x,branches[i].dst+4);
//LineTo(hdc,x-2,branches[i].dst);
}*/
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "Common.h"
#include "MemoryView.h"
#include <wx/event.h>
#include <wx/clipbrd.h>
enum
{
IDM_GOTOINMEMVIEW = 12000,
IDM_COPYADDRESS,
IDM_COPYHEX,
IDM_COPYCODE,
IDM_RUNTOHERE,
IDM_DYNARECRESULTS,
};
BEGIN_EVENT_TABLE(CMemoryView, wxControl)
EVT_ERASE_BACKGROUND(CMemoryView::OnErase)
EVT_PAINT(CMemoryView::OnPaint)
EVT_LEFT_DOWN(CMemoryView::OnMouseDown)
EVT_LEFT_UP(CMemoryView::OnMouseUpL)
EVT_MOTION(CMemoryView::OnMouseMove)
EVT_RIGHT_DOWN(CMemoryView::OnMouseDown)
EVT_RIGHT_UP(CMemoryView::OnMouseUpR)
EVT_MENU(-1, CMemoryView::OnPopupMenu)
END_EVENT_TABLE()
CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id, const wxSize& Size)
: wxControl(parent, Id, wxDefaultPosition, Size),
debugger(debuginterface),
rowHeight(13),
selection(0),
oldSelection(0),
selectionChanged(false),
selecting(false),
hasFocus(false),
showHex(false)
{
rowHeight = 13;
align = debuginterface->getInstructionSize(0);
curAddress = debuginterface->getPC();
}
wxSize CMemoryView::DoGetBestSize() const
{
wxSize bestSize;
bestSize.x = 300;
bestSize.y = 300;
return(bestSize);
}
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::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))
{
redraw();
}
}
else
{
debugger->toggleBreakpoint(YToAddress(y));
redraw();
}
event.Skip(true);
}
void CMemoryView::OnMouseMove(wxMouseEvent& event)
{
wxRect rc = GetClientRect();
if (event.m_leftDown)
{
if (event.m_x > 16)
{
if (event.m_y < 0)
{
curAddress -= align;
redraw();
}
else if (event.m_y > rc.height)
{
curAddress += align;
redraw();
}
else
{
OnMouseDown(event);
}
}
}
event.Skip(true);
}
void CMemoryView::OnMouseUpL(wxMouseEvent& event)
{
if (event.m_x > 16)
{
curAddress = YToAddress(event.m_y);
selecting = false;
//ReleaseCapture();
redraw();
}
event.Skip(true);
}
void CMemoryView::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:
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(debugger->disasm(selection)))); //Have to manually convert from char* to wxString, don't have to in Windows?
break;
case IDM_COPYHEX:
{
char temp[24];
sprintf(temp, "%08x", debugger->readMemory(selection));
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(temp)));
}
break;
#endif
case IDM_RUNTOHERE:
{
debugger->setBreakpoint(selection);
debugger->runToBreakpoint();
redraw();
}
break;
case IDM_DYNARECRESULTS:
{
// CDynaViewDlg::ViewAddr(selection);
// CDynaViewDlg::Show(TRUE);
// MessageBox(NULL, "not impl", "CtrlDisAsmView", MB_OK);
}
break;
}
#if wxUSE_CLIPBOARD
wxTheClipboard->Close();
#endif
event.Skip(true);
}
void CMemoryView::OnMouseUpR(wxMouseEvent& event)
{
// popup menu
wxMenu menu;
//menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
#if wxUSE_CLIPBOARD
menu.Append(IDM_COPYADDRESS, wxString::FromAscii("Copy &address"));
menu.Append(IDM_COPYCODE, wxString::FromAscii("Copy &code"));
menu.Append(IDM_COPYHEX, wxString::FromAscii("Copy &hex"));
#endif
menu.Append(IDM_RUNTOHERE, _T("&Run To Here"));
//menu.Append(IDM_DYNARECRESULTS, "Copy &address");
PopupMenu(&menu);
event.Skip(true);
}
void CMemoryView::OnErase(wxEraseEvent& event)
{}
void CMemoryView::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
int fontSize = 8;
wxRect rc = GetClientRect();
wxFont font(fontSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT);
dc.SetFont(font);
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;
//numRows=(numRows&(~1)) + 1;
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")); // ligh 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+8);
// TODO - clean up this freaking mess!!!!!
int i;
for (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);
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 - 1);
dc.SetBrush(currentBrush);
dc.SetTextForeground(_T("#600000"));
dc.DrawText(temp, 17, rowY1);
char mem[256] = {0};
strcpy(mem, debugger->getRawMemoryString(address));
dc.SetTextForeground(_T("#000080"));
dc.DrawText(wxString::FromAscii(mem), 17+fontSize*(8), rowY1);
dc.SetTextForeground(_T("#000000"));
if (debugger->isAlive())
{
char dis[256] = {0};
strcpy(dis, debugger->disasm(address));
char* dis2 = strchr(dis, '\t');
char desc[256] = "";
if (dis2)
{
*dis2 = 0;
dis2++;
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)offs - (s64)address) * rowHeight / align + rowHeight / 2);
sprintf(desc, "-->%s", debugger->getDescription(offs).c_str());
dc.SetTextForeground(_T("#600060"));
}
else
{
dc.SetTextForeground(_T("#000000"));
}
dc.DrawText(wxString::FromAscii(dis2), 17+fontSize*(8+8+8), rowY1);
}
if (strcmp(dis, "blr"))
{
dc.SetTextForeground(_T("#007000"));
}
else
{
dc.SetTextForeground(_T("#8000FF"));
}
dc.DrawText(wxString::FromAscii(dis), 17+fontSize*(8+8), rowY1);
if (desc[0] == 0)
{
strcpy(desc, debugger->getDescription(address).c_str());
}
dc.SetTextForeground(_T("#0000FF"));
//char temp[256];
//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
if (strlen(desc))
{
dc.DrawText(wxString::FromAscii(desc), 17+fontSize*(8+8+8+30), rowY1);
}
if (debugger->isBreakpoint(address))
{
dc.SetBrush(bpBrush);
dc.DrawRectangle(2, rowY1, 7, 7);
// DrawIconEx(hdc, 2, rowY1, breakPoint, 32, 32, 0, 0, DI_NORMAL);
}
}
}
dc.SetPen(currentPen);
/*
for (i = 0; i < numBranches; i++)
{
int x = 250 + (branches[i].srcAddr % 9) * 8;
MoveToEx(hdc, x-2, branches[i].src, 0);
if (branches[i].dst < rect.bottom + 200 && branches[i].dst > -200)
{
LineTo(hdc, x+2, branches[i].src);
LineTo(hdc, x+2, branches[i].dst);
LineTo(hdc, x-4, branches[i].dst);
MoveToEx(hdc, x, branches[i].dst - 4,0);
LineTo(hdc, x-4, branches[i].dst);
LineTo(hdc, x+1, branches[i].dst+5);
}
else
{
LineTo(hdc, x+4, branches[i].src);
//MoveToEx(hdc,x+2,branches[i].dst-4,0);
//LineTo(hdc,x+6,branches[i].dst);
//LineTo(hdc,x+1,branches[i].dst+5);
}
//LineTo(hdc,x,branches[i].dst+4);
//LineTo(hdc,x-2,branches[i].dst);
}*/
}

View File

@ -1,221 +1,221 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "IniFile.h"
#include <wx/button.h>
#include <wx/textctrl.h>
#include <wx/listctrl.h>
#include <wx/thread.h>
#include <wx/listctrl.h>
#include "MemoryWindow.h"
#include "HW/CPU.h"
#include "PowerPC/PowerPC.h"
#include "Host.h"
#include "Debugger/PPCDebugInterface.h"
#include "PowerPC/SymbolDB.h"
#include "Core.h"
#include "LogManager.h"
#include "HW/Memmap.h"
// ugly that this lib included code from the main
#include "../../DolphinWX/Src/Globals.h"
enum
{
IDM_DEBUG_GO = 350,
IDM_STEP,
IDM_STEPOVER,
IDM_SKIP,
IDM_SETPC,
IDM_GOTOPC,
IDM_ADDRBOX,
IDM_CALLSTACKLIST,
IDM_SYMBOLLIST,
IDM_INTERPRETER,
IDM_DUALCORE,
IDM_LOGWINDOW,
IDM_REGISTERWINDOW,
IDM_BREAKPOINTWINDOW,
IDM_VALBOX,
IDM_SETVALBUTTON
};
BEGIN_EVENT_TABLE(CMemoryWindow, wxFrame)
EVT_TEXT(IDM_ADDRBOX, CMemoryWindow::OnAddrBoxChange)
EVT_LISTBOX(IDM_SYMBOLLIST, CMemoryWindow::OnSymbolListChange)
EVT_HOST_COMMAND(wxID_ANY, CMemoryWindow::OnHostMessage)
EVT_BUTTON(IDM_SETVALBUTTON, CMemoryWindow::SetMemoryValue)
END_EVENT_TABLE()
CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id,
const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(parent, id, title, pos, size, style)
{
wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizerRight = new wxBoxSizer(wxVERTICAL);
// didn't see anything usefull in the left part
//wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
DebugInterface* di = new PPCDebugInterface();
//sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(20, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND);
memview = new CMemoryView(di, this, wxID_ANY);
//sizerBig->Add(sizerLeft, 1, wxEXPAND);
sizerBig->Add(memview, 20, wxEXPAND);
sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3);
sizerRight->Add(buttonGo = new wxButton(this, IDM_DEBUG_GO, _T("&Go")));
sizerRight->Add(addrbox = new wxTextCtrl(this, IDM_ADDRBOX, _T("")));
sizerRight->Add(new wxButton(this, IDM_SETPC, _T("S&et PC")));
sizerRight->Add(valbox = new wxTextCtrl(this, IDM_VALBOX, _T("")));
sizerRight->Add(new wxButton(this, IDM_SETVALBUTTON, _T("Set &Value")));
SetSizer(sizerBig);
//sizerLeft->SetSizeHints(this);
//sizerLeft->Fit(this);
sizerRight->SetSizeHints(this);
sizerRight->Fit(this);
sizerBig->SetSizeHints(this);
sizerBig->Fit(this);
}
CMemoryWindow::~CMemoryWindow()
{
}
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 = std::string(addrbox->GetValue().mb_str());
std::string str_val = std::string(valbox->GetValue().mb_str());
u32 addr;
u32 val;
if (!TryParseUInt(std::string("0x") + str_addr, &addr)) {
PanicAlert("Invalid Address: %s", str_addr.c_str());
return;
}
if (!TryParseUInt(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() == 8)
{
u32 addr;
sscanf(txt.mb_str(), "%08x", &addr);
memview->Center(addr);
}
event.Skip(1);
}
void CMemoryWindow::Update()
{
memview->Refresh();
memview->Center(PC);
}
void CMemoryWindow::NotifyMapLoaded()
{
symbols->Show(false); // hide it for faster filling
symbols->Clear();
/*
#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
*/
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;
}
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "IniFile.h"
#include <wx/button.h>
#include <wx/textctrl.h>
#include <wx/listctrl.h>
#include <wx/thread.h>
#include <wx/listctrl.h>
#include "MemoryWindow.h"
#include "HW/CPU.h"
#include "PowerPC/PowerPC.h"
#include "Host.h"
#include "Debugger/PPCDebugInterface.h"
#include "PowerPC/SymbolDB.h"
#include "Core.h"
#include "LogManager.h"
#include "HW/Memmap.h"
// ugly that this lib included code from the main
#include "../../DolphinWX/Src/Globals.h"
enum
{
IDM_DEBUG_GO = 350,
IDM_STEP,
IDM_STEPOVER,
IDM_SKIP,
IDM_SETPC,
IDM_GOTOPC,
IDM_ADDRBOX,
IDM_CALLSTACKLIST,
IDM_SYMBOLLIST,
IDM_INTERPRETER,
IDM_DUALCORE,
IDM_LOGWINDOW,
IDM_REGISTERWINDOW,
IDM_BREAKPOINTWINDOW,
IDM_VALBOX,
IDM_SETVALBUTTON
};
BEGIN_EVENT_TABLE(CMemoryWindow, wxFrame)
EVT_TEXT(IDM_ADDRBOX, CMemoryWindow::OnAddrBoxChange)
EVT_LISTBOX(IDM_SYMBOLLIST, CMemoryWindow::OnSymbolListChange)
EVT_HOST_COMMAND(wxID_ANY, CMemoryWindow::OnHostMessage)
EVT_BUTTON(IDM_SETVALBUTTON, CMemoryWindow::SetMemoryValue)
END_EVENT_TABLE()
CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id,
const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(parent, id, title, pos, size, style)
{
wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizerRight = new wxBoxSizer(wxVERTICAL);
// didn't see anything usefull in the left part
//wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
DebugInterface* di = new PPCDebugInterface();
//sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(20, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND);
memview = new CMemoryView(di, this, wxID_ANY);
//sizerBig->Add(sizerLeft, 1, wxEXPAND);
sizerBig->Add(memview, 20, wxEXPAND);
sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3);
sizerRight->Add(buttonGo = new wxButton(this, IDM_DEBUG_GO, _T("&Go")));
sizerRight->Add(addrbox = new wxTextCtrl(this, IDM_ADDRBOX, _T("")));
sizerRight->Add(new wxButton(this, IDM_SETPC, _T("S&et PC")));
sizerRight->Add(valbox = new wxTextCtrl(this, IDM_VALBOX, _T("")));
sizerRight->Add(new wxButton(this, IDM_SETVALBUTTON, _T("Set &Value")));
SetSizer(sizerBig);
//sizerLeft->SetSizeHints(this);
//sizerLeft->Fit(this);
sizerRight->SetSizeHints(this);
sizerRight->Fit(this);
sizerBig->SetSizeHints(this);
sizerBig->Fit(this);
}
CMemoryWindow::~CMemoryWindow()
{
}
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 = std::string(addrbox->GetValue().mb_str());
std::string str_val = std::string(valbox->GetValue().mb_str());
u32 addr;
u32 val;
if (!TryParseUInt(std::string("0x") + str_addr, &addr)) {
PanicAlert("Invalid Address: %s", str_addr.c_str());
return;
}
if (!TryParseUInt(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() == 8)
{
u32 addr;
sscanf(txt.mb_str(), "%08x", &addr);
memview->Center(addr);
}
event.Skip(1);
}
void CMemoryWindow::Update()
{
memview->Refresh();
memview->Center(PC);
}
void CMemoryWindow::NotifyMapLoaded()
{
symbols->Show(false); // hide it for faster filling
symbols->Clear();
/*
#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
*/
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;
}
}

View File

@ -1,158 +1,158 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "RegisterView.h"
#include "PowerPC/PowerPC.h"
extern const char* GetGRPName(unsigned int index);
BEGIN_EVENT_TABLE(CRegisterView, wxListCtrl)
END_EVENT_TABLE()
CRegisterView::CRegisterView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style)
{
InsertColumn(1, wxT("Reg 16-31"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(0, wxT("Value"), wxLIST_FORMAT_CENTER, 80);
InsertColumn(0, wxT("Reg 0-15"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(0, wxT("Value"), wxLIST_FORMAT_CENTER, 80);
SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Segoe UI")));
for (int i = 0; i < 16; i++)
{
// 0-15
int Item = InsertItem(0, wxString::FromAscii(GetGRPName(i)));
// 16-31
SetItem(Item, 2, wxString::FromAscii(GetGRPName(16 + i)));
// just for easy sort
wxListItem item;
item.SetId(Item);
item.SetBackgroundColour(0xFFFFFF);
item.SetData(i);
SetItem(item);
}
Refresh();
}
void
CRegisterView::Update()
{
for (size_t i = 0; i < 16; i++)
{
// 0-15
if (m_CachedRegs[i] != GPR(i))
{
m_CachedRegHasChanged[i] = true;
}
else
{
m_CachedRegHasChanged[i] = false;
}
m_CachedRegs[i] = GPR(i);
// 16-31
if (m_CachedRegs[16 + i] != GPR(16 + i))
{
m_CachedRegHasChanged[16 + i] = true;
}
else
{
m_CachedRegHasChanged[16 + i] = false;
}
m_CachedRegs[16 + i] = GPR(16 + i);
}
Refresh();
}
void CRegisterView::Refresh()
{
for (size_t i = 0; i < 16; i++)
{
wxListItem item;
item.SetId(i);
item.SetColumn(1);
char temp[16];
sprintf(temp, "0x%08x",m_CachedRegs[i]);
item.SetText(wxString::FromAscii(temp));
SetItem(item);
}
for (size_t i = 0; i < 16; i++)
{
wxListItem item;
item.SetId(i);
item.SetColumn(3);
char temp[16];
sprintf(temp, "0x%08x",m_CachedRegs[16 + i]);
item.SetText(wxString::FromAscii(temp));
SetItem(item);
}
}
#ifdef _WIN32
bool
CRegisterView::MSWDrawSubItem(wxPaintDC& rPainDC, int item, int subitem)
{
bool Result = false;
#ifdef __WXMSW__
switch (subitem)
{
case 1:
case 3:
{
int Register = (subitem == 1) ? item : item + 16;
const wxChar* bgColor = _T("#ffffff");
wxBrush bgBrush(bgColor);
wxPen bgPen(bgColor);
wxRect SubItemRect;
this->GetSubItemRect(item, subitem, SubItemRect);
rPainDC.SetBrush(bgBrush);
rPainDC.SetPen(bgPen);
rPainDC.DrawRectangle(SubItemRect);
if (m_CachedRegHasChanged[Register])
{
rPainDC.SetTextForeground(_T("#FF0000"));
}
else
{
rPainDC.SetTextForeground(_T("#000000"));
}
wxString text;
text.Printf(wxT("0x%08x"), m_CachedRegs[Register]);
rPainDC.DrawText(text, SubItemRect.GetLeft() + 10, SubItemRect.GetTop() + 4);
return(true);
}
break;
}
#endif
return(Result);
}
#endif
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "RegisterView.h"
#include "PowerPC/PowerPC.h"
extern const char* GetGRPName(unsigned int index);
BEGIN_EVENT_TABLE(CRegisterView, wxListCtrl)
END_EVENT_TABLE()
CRegisterView::CRegisterView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style)
{
InsertColumn(1, wxT("Reg 16-31"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(0, wxT("Value"), wxLIST_FORMAT_CENTER, 80);
InsertColumn(0, wxT("Reg 0-15"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(0, wxT("Value"), wxLIST_FORMAT_CENTER, 80);
SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Segoe UI")));
for (int i = 0; i < 16; i++)
{
// 0-15
int Item = InsertItem(0, wxString::FromAscii(GetGRPName(i)));
// 16-31
SetItem(Item, 2, wxString::FromAscii(GetGRPName(16 + i)));
// just for easy sort
wxListItem item;
item.SetId(Item);
item.SetBackgroundColour(0xFFFFFF);
item.SetData(i);
SetItem(item);
}
Refresh();
}
void
CRegisterView::Update()
{
for (size_t i = 0; i < 16; i++)
{
// 0-15
if (m_CachedRegs[i] != GPR(i))
{
m_CachedRegHasChanged[i] = true;
}
else
{
m_CachedRegHasChanged[i] = false;
}
m_CachedRegs[i] = GPR(i);
// 16-31
if (m_CachedRegs[16 + i] != GPR(16 + i))
{
m_CachedRegHasChanged[16 + i] = true;
}
else
{
m_CachedRegHasChanged[16 + i] = false;
}
m_CachedRegs[16 + i] = GPR(16 + i);
}
Refresh();
}
void CRegisterView::Refresh()
{
for (size_t i = 0; i < 16; i++)
{
wxListItem item;
item.SetId(i);
item.SetColumn(1);
char temp[16];
sprintf(temp, "0x%08x",m_CachedRegs[i]);
item.SetText(wxString::FromAscii(temp));
SetItem(item);
}
for (size_t i = 0; i < 16; i++)
{
wxListItem item;
item.SetId(i);
item.SetColumn(3);
char temp[16];
sprintf(temp, "0x%08x",m_CachedRegs[16 + i]);
item.SetText(wxString::FromAscii(temp));
SetItem(item);
}
}
#ifdef _WIN32
bool
CRegisterView::MSWDrawSubItem(wxPaintDC& rPainDC, int item, int subitem)
{
bool Result = false;
#ifdef __WXMSW__
switch (subitem)
{
case 1:
case 3:
{
int Register = (subitem == 1) ? item : item + 16;
const wxChar* bgColor = _T("#ffffff");
wxBrush bgBrush(bgColor);
wxPen bgPen(bgColor);
wxRect SubItemRect;
this->GetSubItemRect(item, subitem, SubItemRect);
rPainDC.SetBrush(bgBrush);
rPainDC.SetPen(bgPen);
rPainDC.DrawRectangle(SubItemRect);
if (m_CachedRegHasChanged[Register])
{
rPainDC.SetTextForeground(_T("#FF0000"));
}
else
{
rPainDC.SetTextForeground(_T("#000000"));
}
wxString text;
text.Printf(wxT("0x%08x"), m_CachedRegs[Register]);
rPainDC.DrawText(text, SubItemRect.GetLeft() + 10, SubItemRect.GetTop() + 4);
return(true);
}
break;
}
#endif
return(Result);
}
#endif

View File

@ -1,97 +1,97 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "RegisterWindow.h"
#include "PowerPC/PowerPC.h"
#include "RegisterView.h"
#include "IniFile.h"
extern const char* GetGRPName(unsigned int index);
BEGIN_EVENT_TABLE(CRegisterWindow, wxDialog)
EVT_CLOSE(CRegisterWindow::OnClose)
EVT_MENU(wxID_REFRESH, CRegisterWindow::OnRefresh)
END_EVENT_TABLE()
CRegisterWindow::CRegisterWindow(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
, m_GPRListView(NULL)
{
CreateGUIControls();
}
CRegisterWindow::~CRegisterWindow()
{}
void CRegisterWindow::Save(IniFile& _IniFile) const
{
_IniFile.Set("RegisterWindow", "x", GetPosition().x);
_IniFile.Set("RegisterWindow", "y", GetPosition().y);
_IniFile.Set("RegisterWindow", "w", GetSize().GetWidth());
_IniFile.Set("RegisterWindow", "h", GetSize().GetHeight());
}
void CRegisterWindow::Load(IniFile& _IniFile)
{
int x,y,w,h;
_IniFile.Get("RegisterWindow", "x", &x, GetPosition().x);
_IniFile.Get("RegisterWindow", "y", &y, GetPosition().y);
_IniFile.Get("RegisterWindow", "w", &w, GetSize().GetWidth());
_IniFile.Get("RegisterWindow", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
}
void CRegisterWindow::CreateGUIControls()
{
SetTitle(wxT("Registers"));
SetIcon(wxNullIcon);
SetSize(8, 8, 400, 370);
Center();
m_GPRListView = new CRegisterView(this, ID_GPR, wxDefaultPosition, GetSize(),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
NotifyUpdate();
}
void CRegisterWindow::OnClose(wxCloseEvent& /*event*/)
{
Hide();
}
void CRegisterWindow::OnRefresh(wxCommandEvent& WXUNUSED (event))
{
m_GPRListView->Refresh();
m_GPRListView->Update();
}
void CRegisterWindow::NotifyUpdate()
{
if (m_GPRListView != NULL)
{
m_GPRListView->Update();
}
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Debugger.h"
#include "RegisterWindow.h"
#include "PowerPC/PowerPC.h"
#include "RegisterView.h"
#include "IniFile.h"
extern const char* GetGRPName(unsigned int index);
BEGIN_EVENT_TABLE(CRegisterWindow, wxDialog)
EVT_CLOSE(CRegisterWindow::OnClose)
EVT_MENU(wxID_REFRESH, CRegisterWindow::OnRefresh)
END_EVENT_TABLE()
CRegisterWindow::CRegisterWindow(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
, m_GPRListView(NULL)
{
CreateGUIControls();
}
CRegisterWindow::~CRegisterWindow()
{}
void CRegisterWindow::Save(IniFile& _IniFile) const
{
_IniFile.Set("RegisterWindow", "x", GetPosition().x);
_IniFile.Set("RegisterWindow", "y", GetPosition().y);
_IniFile.Set("RegisterWindow", "w", GetSize().GetWidth());
_IniFile.Set("RegisterWindow", "h", GetSize().GetHeight());
}
void CRegisterWindow::Load(IniFile& _IniFile)
{
int x,y,w,h;
_IniFile.Get("RegisterWindow", "x", &x, GetPosition().x);
_IniFile.Get("RegisterWindow", "y", &y, GetPosition().y);
_IniFile.Get("RegisterWindow", "w", &w, GetSize().GetWidth());
_IniFile.Get("RegisterWindow", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
}
void CRegisterWindow::CreateGUIControls()
{
SetTitle(wxT("Registers"));
SetIcon(wxNullIcon);
SetSize(8, 8, 400, 370);
Center();
m_GPRListView = new CRegisterView(this, ID_GPR, wxDefaultPosition, GetSize(),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
NotifyUpdate();
}
void CRegisterWindow::OnClose(wxCloseEvent& /*event*/)
{
Hide();
}
void CRegisterWindow::OnRefresh(wxCommandEvent& WXUNUSED (event))
{
m_GPRListView->Refresh();
m_GPRListView->Update();
}
void CRegisterWindow::NotifyUpdate()
{
if (m_GPRListView != NULL)
{
m_GPRListView->Update();
}
}