change src to Src

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@604 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee
2008-09-22 06:50:27 +00:00
parent 1ecfba6692
commit 3a130d4263
28 changed files with 2 additions and 2 deletions

View File

@ -0,0 +1,87 @@
// 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);
Close();
}
}
void BreakPointDlg::OnCancel(wxCommandEvent& /*event*/)
{
Close();
}

View File

@ -0,0 +1,67 @@
// 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/
#ifndef __BREAKPOINTDLG_h__
#define __BREAKPOINTDLG_h__
#include <wx/wx.h>
#include <wx/dialog.h>
#include <wx/stattext.h>
#include <wx/button.h>
#include <wx/textctrl.h>
#include <wx/statbox.h>
#undef BreakPointDlg_STYLE
#define BreakPointDlg_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX
class BreakPointDlg : public wxDialog
{
private:
DECLARE_EVENT_TABLE();
public:
BreakPointDlg(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("BreakPoint"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = BreakPointDlg_STYLE);
virtual ~BreakPointDlg();
private:
wxButton *m_pButtonOK;
wxButton *m_pButtonCancel;
wxTextCtrl *m_pEditAddress;
private:
enum
{
ID_WXSTATICTEXT1 = 1006,
ID_OK = 1005,
ID_CANCEL = 1004,
ID_ADDRESS = 1003,
ID_WXSTATICBOX1 = 1001,
};
private:
void CreateGUIControls();
void OnClose(wxCloseEvent& event);
void OnCancel(wxCommandEvent& event);
void OnOK(wxCommandEvent& event);
};
#endif

View File

@ -0,0 +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 = GetItemData(Item);
CBreakPoints::DeleteElementByAddress(Address);
}
}

View File

@ -0,0 +1,41 @@
// 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/
#ifndef __BREAKPOINTVIEW_h__
#define __BREAKPOINTVIEW_h__
#include <wx/listctrl.h>
#include "Common.h"
class CBreakPointView
: public wxListCtrl
{
public:
CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
void Update();
void DeleteCurrentSelection();
private:
DECLARE_EVENT_TABLE()
};
#endif

View File

@ -0,0 +1,222 @@
// 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 <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_ADD_BREAKPOINT, CBreakPointWindow::OnAddBreakPoint)
EVT_MENU(IDM_ADD_MEMORYCHECK, CBreakPointWindow::OnAddMemoryCheck)
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->AddSeparator();
toolBar->AddTool(IDM_ADD_BREAKPOINT, _T("BP"), m_Bitmaps[Toolbar_Add_BreakPoint], _T("Add BreakPoint..."));
// 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..."));
}
// 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();
}
}
void
CBreakPointWindow::OnAddBreakPoint(wxCommandEvent& event)
{
BreakPointDlg bpDlg(this);
bpDlg.ShowModal();
}
void
CBreakPointWindow::OnAddMemoryCheck(wxCommandEvent& event)
{
MemoryCheckDlg memDlg(this);
memDlg.ShowModal();
}
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);
}
}
}

View File

@ -0,0 +1,87 @@
// 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/
#ifndef __BREAKPOINTWINDOW_h__
#define __BREAKPOINTWINDOW_h__
class CBreakPointView;
class CCodeWindow;
class wxListEvent;
class IniFile;
#undef BREAKPOINT_WINDOW_STYLE
#define BREAKPOINT_WINDOW_STYLE wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX | wxRESIZE_BORDER
class CBreakPointWindow
: public wxFrame
{
private:
DECLARE_EVENT_TABLE();
public:
CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent, wxWindowID id = 1, const wxString& title = wxT("Breakpoints"),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(400, 250),
long style = BREAKPOINT_WINDOW_STYLE);
virtual ~CBreakPointWindow();
void NotifyUpdate();
void Save(IniFile& _IniFile) const;
void Load(IniFile& _IniFile);
private:
enum
{
ID_TOOLBAR = 500,
ID_BPS = 1002,
IDM_DELETE,
IDM_ADD_BREAKPOINT,
IDM_ADD_MEMORYCHECK
};
enum
{
Toolbar_Delete,
Toolbar_Add_BreakPoint,
Toolbar_Add_Memcheck,
Bitmaps_max
};
CBreakPointView* m_BreakPointListView;
CCodeWindow* m_pCodeWindow;
wxBitmap m_Bitmaps[Bitmaps_max];
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
void RecreateToolbar();
void PopulateToolbar(wxToolBar* toolBar);
void InitBitmaps();
void OnDelete(wxCommandEvent& event);
void OnAddBreakPoint(wxCommandEvent& event);
void OnAddMemoryCheck(wxCommandEvent& event);
void OnActivated(wxListEvent& event);
};
#endif

View File

@ -0,0 +1,517 @@
// 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 "Debugger/PPCDebugInterface.h"
#include "PowerPC/SymbolDB.h"
#include "Common.h"
#include "StringUtil.h"
#include "Host.h"
#include "CodeView.h"
#include "JitWindow.h"
#include <wx/event.h>
#include <wx/clipbrd.h>
#include <wx/textdlg.h>
DEFINE_EVENT_TYPE(wxEVT_CODEVIEW_CHANGE);
enum
{
IDM_GOTOINMEMVIEW = 12000,
IDM_COPYADDRESS,
IDM_COPYHEX,
IDM_COPYCODE,
IDM_INSERTBLR,
IDM_RUNTOHERE,
IDM_JITRESULTS,
IDM_FOLLOWBRANCH,
IDM_RENAMESYMBOL,
IDM_PATCHALERT,
IDM_COPYFUNCTION,
};
BEGIN_EVENT_TABLE(CCodeView, wxControl)
EVT_ERASE_BACKGROUND(CCodeView::OnErase)
EVT_PAINT(CCodeView::OnPaint)
EVT_LEFT_DOWN(CCodeView::OnMouseDown)
EVT_LEFT_UP(CCodeView::OnMouseUpL)
EVT_MOTION(CCodeView::OnMouseMove)
EVT_RIGHT_DOWN(CCodeView::OnMouseDown)
EVT_RIGHT_UP(CCodeView::OnMouseUpR)
EVT_MENU(-1, CCodeView::OnPopupMenu)
END_EVENT_TABLE()
CCodeView::CCodeView(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),
lx(-1),
ly(-1)
{
rowHeight = 13;
align = debuginterface->getInstructionSize(0);
curAddress = debuginterface->getPC();
selection = 0;
}
wxSize CCodeView::DoGetBestSize() const
{
wxSize bestSize;
bestSize.x = 400;
bestSize.y = 800;
return(bestSize);
}
int CCodeView::YToAddress(int y)
{
wxRect rc = GetClientRect();
int ydiff = y - rc.height / 2 - rowHeight / 2;
ydiff = (int)(floorf((float)ydiff / (float)rowHeight)) + 1;
return(curAddress + ydiff * align);
}
void CCodeView::OnMouseDown(wxMouseEvent& event)
{
int x = event.m_x;
int y = event.m_y;
if (x > 16)
{
oldSelection = selection;
selection = YToAddress(y);
// SetCapture(wnd);
bool oldselecting = selecting;
selecting = true;
if (!oldselecting || (selection != oldSelection))
{
redraw();
}
}
else
{
debugger->toggleBreakpoint(YToAddress(y));
redraw();
}
event.Skip(true);
}
void CCodeView::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 CCodeView::RaiseEvent()
{
wxCommandEvent ev(wxEVT_CODEVIEW_CHANGE, GetId());
ev.SetEventObject(this);
ev.SetInt(selection);
GetEventHandler()->ProcessEvent(ev);
}
void CCodeView::OnMouseUpL(wxMouseEvent& event)
{
if (event.m_x > 16)
{
curAddress = YToAddress(event.m_y);
selecting = false;
//ReleaseCapture();
redraw();
}
RaiseEvent();
event.Skip(true);
}
u32 CCodeView::AddrToBranch(u32 addr)
{
const char *temp = debugger->disasm(addr);
const char *mojs = strstr(temp, "->0x");
if (mojs)
{
u32 dest;
sscanf(mojs+4,"%08x", &dest);
return dest;
}
return 0;
}
void CCodeView::OnPopupMenu(wxCommandEvent& event)
{
#if wxUSE_CLIPBOARD
wxTheClipboard->Open();
#endif
switch (event.GetId())
{
case IDM_GOTOINMEMVIEW:
// CMemoryDlg::Goto(selection);
break;
#if wxUSE_CLIPBOARD
case IDM_COPYADDRESS:
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(_T("%08x"), selection)));
break;
case IDM_COPYCODE:
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;
case IDM_COPYFUNCTION:
{
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(selection);
if (symbol) {
std::string text;
text = text + symbol->name + "\r\n";
// we got a function
u32 start = symbol->address;
u32 end = start + symbol->size;
for (u32 addr = start; addr != end; addr += 4) {
text = text + StringFromFormat("%08x: ", addr) + debugger->disasm(addr) + "\r\n";
}
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(text.c_str())));
}
}
break;
#endif
case IDM_RUNTOHERE:
debugger->setBreakpoint(selection);
debugger->runToBreakpoint();
redraw();
break;
case IDM_INSERTBLR:
debugger->insertBLR(selection);
redraw();
break;
case IDM_JITRESULTS:
CJitWindow::ViewAddr(selection);
break;
case IDM_FOLLOWBRANCH:
{
u32 dest = AddrToBranch(selection);
if (dest)
Center(dest);
RaiseEvent();
}
break;
case IDM_RENAMESYMBOL:
{
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(selection);
if (symbol) {
wxTextEntryDialog input_symbol(this, wxString::FromAscii("Rename symbol:"), wxGetTextFromUserPromptStr,
wxString::FromAscii(symbol->name.c_str()));
if (input_symbol.ShowModal() == wxID_OK) {
symbol->name = input_symbol.GetValue().mb_str();
}
// redraw();
Host_NotifyMapLoaded();
}
}
break;
case IDM_PATCHALERT:
{
}
break;
}
#if wxUSE_CLIPBOARD
wxTheClipboard->Close();
#endif
event.Skip(true);
}
void CCodeView::OnMouseUpR(wxMouseEvent& event)
{
bool isSymbol = g_symbolDB.GetSymbolFromAddr(selection) != 0;
// popup menu
wxMenu menu;
//menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
menu.Append(IDM_FOLLOWBRANCH, wxString::FromAscii("&Follow branch"))->Enable(AddrToBranch(selection) ? true : false);
menu.AppendSeparator();
#if wxUSE_CLIPBOARD
menu.Append(IDM_COPYADDRESS, wxString::FromAscii("Copy &address"));
menu.Append(IDM_COPYFUNCTION, wxString::FromAscii("Copy &function"))->Enable(isSymbol);
menu.Append(IDM_COPYCODE, wxString::FromAscii("Copy &code line"));
menu.Append(IDM_COPYHEX, wxString::FromAscii("Copy &hex"));
menu.AppendSeparator();
#endif
menu.Append(IDM_RENAMESYMBOL, wxString::FromAscii("Rename &symbol"))->Enable(isSymbol);
menu.AppendSeparator();
menu.Append(IDM_RUNTOHERE, _T("&Run To Here"));
menu.Append(IDM_JITRESULTS, wxString::FromAscii("PPC vs X86"));
menu.Append(IDM_INSERTBLR, wxString::FromAscii("Insert &blr"));
menu.Append(IDM_PATCHALERT, wxString::FromAscii("Patch alert"));
PopupMenu(&menu);
event.Skip(true);
}
void CCodeView::OnErase(wxEraseEvent& event)
{}
void CCodeView::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
wxRect rc = GetClientRect();
wxFont font(7, wxFONTFAMILY_SWISS, 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"));
nullPen.SetStyle(wxTRANSPARENT);
currentPen.SetStyle(wxSOLID);
wxBrush currentBrush(_T("#FFEfE8"));
wxBrush pcBrush(_T("#70FF70"));
wxBrush bpBrush(_T("#FF3311"));
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);
// TODO - clean up this freaking mess!!!!!
for (int i = -numRows; i <= numRows; i++)
{
unsigned int address = curAddress + i * align;
int rowY1 = rc.height / 2 + rowHeight * i - rowHeight / 2;
int rowY2 = rc.height / 2 + rowHeight * i + rowHeight / 2;
wxString temp = wxString::Format(_T("%08x"), address);
u32 col = debugger->getColor(address);
wxBrush rowBrush(wxColor(col >> 16, col >> 8, col));
dc.SetBrush(nullBrush);
dc.SetPen(nullPen);
dc.DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2);
if (selecting && (address == selection))
{
dc.SetPen(selPen);
}
else
{
dc.SetPen(i == 0 ? currentPen : nullPen);
}
if (address == debugger->getPC())
{
dc.SetBrush(pcBrush);
}
else
{
dc.SetBrush(rowBrush);
}
dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1);
dc.SetBrush(currentBrush);
dc.SetTextForeground(_T("#600000"));
dc.DrawText(temp, 17, 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)(u32)offs - (s64)(u32)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), 126, rowY1);
}
if (strcmp(dis, "blr"))
{
dc.SetTextForeground(_T("#007000"));
}
else
{
dc.SetTextForeground(_T("#8000FF"));
}
dc.DrawText(wxString::FromAscii(dis), 70, 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), 235, 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 (int i = 0; i < numBranches; i++)
{
int x = 300 + (branches[i].srcAddr % 9) * 8;
_MoveTo(x-2, branches[i].src);
if (branches[i].dst < rc.height + 400 && branches[i].dst > -400)
{
_LineTo(dc, x+2, branches[i].src);
_LineTo(dc, x+2, branches[i].dst);
_LineTo(dc, x-4, branches[i].dst);
_MoveTo(x, branches[i].dst - 4);
_LineTo(dc, x-4, branches[i].dst);
_LineTo(dc, x+1, branches[i].dst+5);
}
else
{
_LineTo(dc, 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);
}
}
void CCodeView::_LineTo(wxPaintDC &dc, int x, int y)
{
dc.DrawLine(lx, ly, x, y);
lx = x;
ly = y;
}

View File

@ -0,0 +1,82 @@
// 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/
#ifndef CODEVIEW_H_
#define CODEVIEW_H_
#include "Debugger.h"
#include "Common.h"
#include "Debugger/DebugInterface.h"
#include <wx/wx.h>
DECLARE_EVENT_TYPE(wxEVT_CODEVIEW_CHANGE, -1);
class CCodeView
: public wxControl
{
public:
CCodeView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id = -1, const wxSize& Size = wxDefaultSize);
wxSize DoGetBestSize() const;
void OnPaint(wxPaintEvent& event);
void OnErase(wxEraseEvent& event);
void OnMouseDown(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event);
void OnMouseUpL(wxMouseEvent& event);
void OnMouseUpR(wxMouseEvent& event);
void OnPopupMenu(wxCommandEvent& event);
u32 GetSelection() {return(selection);}
void Center(u32 addr)
{
curAddress = addr;
selection = addr;
redraw();
}
private:
void RaiseEvent();
int YToAddress(int y);
u32 AddrToBranch(u32 addr);
void redraw() {Refresh();}
DebugInterface* debugger;
int curAddress;
int align;
int rowHeight;
u32 selection;
u32 oldSelection;
bool selectionChanged;
bool selecting;
bool hasFocus;
bool showHex;
int lx, ly;
void _MoveTo(int x, int y) {lx = x; ly = y;}
void _LineTo(wxPaintDC &dc, int x, int y);
DECLARE_EVENT_TABLE()
};
#endif /*CODEVIEW_H_*/

View File

@ -0,0 +1,894 @@
// 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 <wx/button.h>
#include <wx/textctrl.h>
#include <wx/textdlg.h>
#include <wx/listctrl.h>
#include <wx/thread.h>
#include <wx/mstream.h>
// ugly that this lib included code from the main
#include "../../DolphinWX/Src/Globals.h"
#include "IniFile.h"
#include "Host.h"
#include "Debugger.h"
#include "RegisterWindow.h"
#include "LogWindow.h"
#include "BreakpointWindow.h"
#include "MemoryWindow.h"
#include "JitWindow.h"
#include "CodeWindow.h"
#include "CodeView.h"
#include "FileUtil.h"
#include "Core.h"
#include "Boot/Boot.h"
#include "LogManager.h"
#include "HW/CPU.h"
#include "PowerPC/PowerPC.h"
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/PPCAnalyst.h"
#include "PowerPC/Profiler.h"
#include "PowerPC/SymbolDB.h"
#include "PowerPC/SignatureDB.h"
#include "PowerPC/PPCTables.h"
#include "PowerPC/Jit64/Jit.h"
#include "PowerPC/Jit64/JitCache.h"
extern "C" {
#include "../resources/toolbar_play.c"
#include "../resources/toolbar_pause.c"
#include "../resources/toolbar_add_memorycheck.c"
#include "../resources/toolbar_delete.c"
#include "../resources/toolbar_add_breakpoint.c"
}
static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;
BEGIN_EVENT_TABLE(CCodeWindow, wxFrame)
EVT_LISTBOX(IDM_SYMBOLLIST, CCodeWindow::OnSymbolListChange)
EVT_LISTBOX(IDM_CALLSTACKLIST, CCodeWindow::OnCallstackListChange)
EVT_LISTBOX(IDM_CALLERSLIST, CCodeWindow::OnCallersListChange)
EVT_LISTBOX(IDM_CALLSLIST, CCodeWindow::OnCallsListChange)
EVT_HOST_COMMAND(wxID_ANY, CCodeWindow::OnHostMessage)
EVT_MENU(IDM_LOGWINDOW, CCodeWindow::OnToggleLogWindow)
EVT_MENU(IDM_REGISTERWINDOW, CCodeWindow::OnToggleRegisterWindow)
EVT_MENU(IDM_BREAKPOINTWINDOW, CCodeWindow::OnToggleBreakPointWindow)
EVT_MENU(IDM_MEMORYWINDOW, CCodeWindow::OnToggleMemoryWindow)
EVT_MENU(IDM_INTERPRETER, CCodeWindow::OnInterpreter)
EVT_MENU(IDM_CLEARSYMBOLS, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_LOADMAPFILE, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_SCANFUNCTIONS, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_SAVEMAPFILE, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_CREATESIGNATUREFILE, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_USESIGNATUREFILE, CCodeWindow::OnSymbolsMenu)
EVT_MENU(IDM_CLEARCODECACHE, CCodeWindow::OnJitMenu)
EVT_MENU(IDM_LOGINSTRUCTIONS, CCodeWindow::OnJitMenu)
EVT_MENU(IDM_PROFILEBLOCKS, CCodeWindow::OnProfilerMenu)
EVT_MENU(IDM_WRITEPROFILE, CCodeWindow::OnProfilerMenu)
// toolbar
EVT_MENU(IDM_DEBUG_GO, CCodeWindow::OnCodeStep)
EVT_MENU(IDM_STEP, CCodeWindow::OnCodeStep)
EVT_MENU(IDM_STEPOVER, CCodeWindow::OnCodeStep)
EVT_MENU(IDM_SKIP, CCodeWindow::OnCodeStep)
EVT_MENU(IDM_SETPC, CCodeWindow::OnCodeStep)
EVT_MENU(IDM_GOTOPC, CCodeWindow::OnCodeStep)
EVT_TEXT(IDM_ADDRBOX, CCodeWindow::OnAddrBoxChange)
EVT_COMMAND(IDM_CODEVIEW, wxEVT_CODEVIEW_CHANGE, CCodeWindow::OnCodeViewChange)
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));
}
CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, wxWindow* parent, wxWindowID id,
const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(parent, id, title, pos, size, style)
, m_LogWindow(NULL)
, m_RegisterWindow(NULL)
{
InitBitmaps();
CreateGUIControls(_LocalCoreStartupParameter);
// Create the toolbar
RecreateToolbar();
UpdateButtonStates();
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN,
wxKeyEventHandler(CCodeWindow::OnKeyDown),
(wxObject*)0, this);
// load ini...
IniFile file;
file.Load("Debugger.ini");
this->Load(file);
if (m_BreakpointWindow) m_BreakpointWindow->Load(file);
if (m_LogWindow) m_LogWindow->Load(file);
if (m_RegisterWindow) m_RegisterWindow->Load(file);
if (m_MemoryWindow) m_MemoryWindow->Load(file);
}
CCodeWindow::~CCodeWindow()
{
IniFile file;
file.Load("Debugger.ini");
this->Save(file);
if (m_BreakpointWindow) m_BreakpointWindow->Save(file);
if (m_LogWindow) m_LogWindow->Save(file);
if (m_RegisterWindow) m_RegisterWindow->Save(file);
if (m_MemoryWindow) m_MemoryWindow->Save(file);
file.Save("Debugger.ini");
}
void CCodeWindow::Load( IniFile &file )
{
int x,y,w,h;
file.Get("Code", "x", &x, GetPosition().x);
file.Get("Code", "y", &y, GetPosition().y);
file.Get("Code", "w", &w, GetSize().GetWidth());
file.Get("Code", "h", &h, GetSize().GetHeight());
this->SetSize(x, y, w, h);
}
void CCodeWindow::Save(IniFile &file) const
{
file.Set("Code", "x", GetPosition().x);
file.Set("Code", "y", GetPosition().y);
file.Set("Code", "w", GetSize().GetWidth());
file.Set("Code", "h", GetSize().GetHeight());
}
void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter)
{
CreateMenu(_LocalCoreStartupParameter);
wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
DebugInterface* di = new PPCDebugInterface();
codeview = new CCodeView(di, this, IDM_CODEVIEW);
sizerBig->Add(sizerLeft, 2, wxEXPAND);
sizerBig->Add(codeview, 5, wxEXPAND);
sizerLeft->Add(callstack = new wxListBox(this, IDM_CALLSTACKLIST, wxDefaultPosition, wxSize(90, 100)), 0, wxEXPAND);
sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND);
sizerLeft->Add(calls = new wxListBox(this, IDM_CALLSLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 0, wxEXPAND);
sizerLeft->Add(callers = new wxListBox(this, IDM_CALLERSLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 0, wxEXPAND);
SetSizer(sizerBig);
sizerLeft->SetSizeHints(this);
sizerLeft->Fit(this);
sizerBig->SetSizeHints(this);
sizerBig->Fit(this);
sync_event.Init();
// additional dialogs
if (IsLoggingActivated())
{
m_LogWindow = new CLogWindow(this);
m_LogWindow->Show(true);
}
m_RegisterWindow = new CRegisterWindow(this);
m_RegisterWindow->Show(true);
m_BreakpointWindow = new CBreakPointWindow(this, this);
m_BreakpointWindow->Show(true);
m_MemoryWindow = new CMemoryWindow(this);
m_MemoryWindow->Show(true);
m_JitWindow = new CJitWindow(this);
m_JitWindow->Show(true);
}
void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter)
{
wxMenuBar* pMenuBar = new wxMenuBar(wxMB_DOCKABLE);
{
wxMenu* pCoreMenu = new wxMenu;
wxMenuItem* interpreter = pCoreMenu->Append(IDM_INTERPRETER, _T("&Interpreter"), wxEmptyString, wxITEM_CHECK);
interpreter->Check(!_LocalCoreStartupParameter.bUseJIT);
// wxMenuItem* dualcore = pDebugMenu->Append(IDM_DUALCORE, _T("&DualCore"), wxEmptyString, wxITEM_CHECK);
// dualcore->Check(_LocalCoreStartupParameter.bUseDualCore);
pMenuBar->Append(pCoreMenu, _T("&CPU Mode"));
}
{
wxMenu* pDebugDialogs = new wxMenu;
if (IsLoggingActivated())
{
wxMenuItem* pLogWindow = pDebugDialogs->Append(IDM_LOGWINDOW, _T("&LogManager"), wxEmptyString, wxITEM_CHECK);
pLogWindow->Check(true);
}
wxMenuItem* pRegister = pDebugDialogs->Append(IDM_REGISTERWINDOW, _T("&Registers"), wxEmptyString, wxITEM_CHECK);
pRegister->Check(true);
wxMenuItem* pBreakPoints = pDebugDialogs->Append(IDM_BREAKPOINTWINDOW, _T("&BreakPoints"), wxEmptyString, wxITEM_CHECK);
pBreakPoints->Check(true);
wxMenuItem* pMemory = pDebugDialogs->Append(IDM_MEMORYWINDOW, _T("&Memory"), wxEmptyString, wxITEM_CHECK);
pMemory->Check(true);
pMenuBar->Append(pDebugDialogs, _T("&Views"));
}
{
wxMenu *pSymbolsMenu = new wxMenu;
pSymbolsMenu->Append(IDM_CLEARSYMBOLS, _T("&Clear symbols"));
// pSymbolsMenu->Append(IDM_CLEANSYMBOLS, _T("&Clean symbols (zz)"));
pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _T("&Generate symbol map"));
pSymbolsMenu->AppendSeparator();
pSymbolsMenu->Append(IDM_LOADMAPFILE, _T("&Load symbol map"));
pSymbolsMenu->Append(IDM_SAVEMAPFILE, _T("&Save symbol map"));
pSymbolsMenu->AppendSeparator();
pSymbolsMenu->Append(IDM_CREATESIGNATUREFILE, _T("&Create signature file..."));
pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _T("&Use signature file..."));
pMenuBar->Append(pSymbolsMenu, _T("&Symbols"));
}
{
wxMenu *pJitMenu = new wxMenu;
pJitMenu->Append(IDM_CLEARCODECACHE, _T("&Clear code cache"));
pJitMenu->Append(IDM_LOGINSTRUCTIONS, _T("&Log JIT instruction coverage"));
pMenuBar->Append(pJitMenu, _T("&JIT"));
}
{
wxMenu *pProfilerMenu = new wxMenu;
pProfilerMenu->Append(IDM_PROFILEBLOCKS, _T("&Profile blocks"), wxEmptyString, wxITEM_CHECK);
pProfilerMenu->AppendSeparator();
pProfilerMenu->Append(IDM_WRITEPROFILE, _T("&Write to profile.txt, show"));
pMenuBar->Append(pProfilerMenu, _T("&Profiler"));
}
SetMenuBar(pMenuBar);
}
bool CCodeWindow::UseInterpreter()
{
return(GetMenuBar()->IsChecked(IDM_INTERPRETER));
}
bool CCodeWindow::UseDualCore()
{
return(GetMenuBar()->IsChecked(IDM_DUALCORE));
}
void CCodeWindow::OnInterpreter(wxCommandEvent& event)
{
if (Core::GetState() != Core::CORE_RUN) {
PowerPC::SetMode(UseInterpreter() ? PowerPC::MODE_INTERPRETER : PowerPC::MODE_JIT);
} else {
event.Skip();
wxMessageBox(_T("Please pause the emulator before changing mode."));
}
}
void CCodeWindow::OnJitMenu(wxCommandEvent& event)
{
switch (event.GetId())
{
case IDM_CLEARCODECACHE:
Jit64::ClearCache();
break;
case IDM_LOGINSTRUCTIONS:
PPCTables::LogCompiledInstructions();
break;
}
}
void CCodeWindow::OnProfilerMenu(wxCommandEvent& event)
{
if (Core::GetState() == Core::CORE_RUN) {
event.Skip();
return;
}
switch (event.GetId())
{
case IDM_PROFILEBLOCKS:
Jit64::ClearCache();
Profiler::g_ProfileBlocks = GetMenuBar()->IsChecked(IDM_PROFILEBLOCKS);
break;
case IDM_WRITEPROFILE:
Profiler::WriteProfileResults("profiler.txt");
break;
}
}
void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
{
if (Core::GetState() == Core::CORE_UNINITIALIZED)
{
// TODO: disable menu items instead :P
return;
}
std::string mapfile = CBoot::GenerateMapFilename();
switch (event.GetId())
{
case IDM_CLEARSYMBOLS:
g_symbolDB.Clear();
Host_NotifyMapLoaded();
break;
case IDM_CLEANSYMBOLS:
g_symbolDB.Clear("zz");
Host_NotifyMapLoaded();
break;
case IDM_SCANFUNCTIONS:
{
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB);
SignatureDB db;
if (db.Load("data/totaldb.dsy"))
db.Apply(&g_symbolDB);
NotifyMapLoaded();
break;
}
case IDM_LOADMAPFILE:
if (!File::Exists(mapfile))
{
g_symbolDB.Clear();
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB);
SignatureDB db;
if (db.Load("data/totaldb.dsy"))
db.Apply(&g_symbolDB);
} else {
g_symbolDB.LoadMap(mapfile.c_str());
}
NotifyMapLoaded();
break;
case IDM_SAVEMAPFILE:
g_symbolDB.SaveMap(mapfile.c_str());
break;
case IDM_CREATESIGNATUREFILE:
{
wxTextEntryDialog input_prefix(this, wxString::FromAscii("Only export symbols with prefix:"), wxGetTextFromUserPromptStr, _T("."));
if (input_prefix.ShowModal() == wxID_OK) {
std::string prefix(input_prefix.GetValue().mb_str());
wxString path = wxFileSelector(
_T("Save signature as"), wxEmptyString, wxEmptyString, wxEmptyString,
_T("Dolphin Signature File (*.dsy)|*.dsy;"), wxFD_SAVE,
this);
if (path) {
SignatureDB db;
db.Initialize(&g_symbolDB, prefix.c_str());
std::string filename(path.ToAscii()); // PPCAnalyst::SaveSignatureDB(
db.Save(path.ToAscii());
}
}
}
break;
case IDM_USESIGNATUREFILE:
{
wxString path = wxFileSelector(
_T("Apply signature file"), wxEmptyString, wxEmptyString, wxEmptyString,
_T("Dolphin Signature File (*.dsy)|*.dsy;"), wxFD_OPEN | wxFD_FILE_MUST_EXIST,
this);
if (path) {
SignatureDB db;
db.Load(path.ToAscii());
db.Apply(&g_symbolDB);
}
}
NotifyMapLoaded();
break;
}
}
void CCodeWindow::OnCodeStep(wxCommandEvent& event)
{
switch (event.GetId())
{
case IDM_DEBUG_GO:
{
// [F|RES] prolly we should disable the other buttons in go mode too ...
JumpToAddress(PC);
if (CCPU::IsStepping())
{
CCPU::EnableStepping(false);
}
else
{
CCPU::EnableStepping(true);
Host_UpdateLogDisplay();
}
Update();
}
break;
case IDM_STEP:
SingleCPUStep();
break;
case IDM_STEPOVER:
CCPU::EnableStepping(true);
break;
case IDM_SKIP:
PC += 4;
Update();
break;
case IDM_SETPC:
PC = codeview->GetSelection();
Update();
break;
case IDM_GOTOPC:
JumpToAddress(PC);
break;
}
UpdateButtonStates();
}
void CCodeWindow::JumpToAddress(u32 _Address)
{
codeview->Center(_Address);
UpdateLists();
}
void CCodeWindow::UpdateLists()
{
callers->Clear();
u32 addr = codeview->GetSelection();
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(addr);
if (!symbol)
return;
for (int i = 0; i < (int)symbol->callers.size(); i++)
{
u32 caller_addr = symbol->callers[i].callAddress;
Symbol *caller_symbol = g_symbolDB.GetSymbolFromAddr(caller_addr);
if (caller_symbol) {
int idx = callers->Append(wxString::Format( _T("< %s (%08x)"), caller_symbol->name.c_str(), caller_addr));
callers->SetClientData(idx, (void*)caller_addr);
}
}
calls->Clear();
for (int i = 0; i < (int)symbol->calls.size(); i++)
{
u32 call_addr = symbol->calls[i].function;
Symbol *call_symbol = g_symbolDB.GetSymbolFromAddr(call_addr);
if (call_symbol) {
int idx = calls->Append(wxString::Format(_T("> %s (%08x)"), call_symbol->name.c_str(), call_addr));
calls->SetClientData(idx, (void*)call_addr);
}
}
}
void CCodeWindow::OnCodeViewChange(wxCommandEvent &event)
{
//PanicAlert("boo");
UpdateLists();
}
void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event)
{
wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(IDM_ADDRBOX);
wxString txt = pAddrCtrl->GetValue();
std::string text(txt.mb_str());
text = StripSpaces(text);
if (text.size() == 8)
{
u32 addr;
sscanf(text.c_str(), "%08x", &addr);
JumpToAddress(addr);
}
event.Skip(1);
}
void CCodeWindow::OnCallstackListChange(wxCommandEvent& event)
{
int index = callstack->GetSelection();
if (index >= 0) {
u32 address = (u32)(u64)(callstack->GetClientData(index));
if (address)
JumpToAddress(address);
}
}
void CCodeWindow::OnCallersListChange(wxCommandEvent& event)
{
int index = callers->GetSelection();
if (index >= 0) {
u32 address = (u32)(u64)(callers->GetClientData(index));
if (address)
JumpToAddress(address);
}
}
void CCodeWindow::OnCallsListChange(wxCommandEvent& event)
{
int index = calls->GetSelection();
if (index >= 0) {
u32 address = (u32)(u64)(calls->GetClientData(index));
if (address)
JumpToAddress(address);
}
}
void CCodeWindow::Update()
{
codeview->Refresh();
callstack->Clear();
std::vector<Debugger::CallstackEntry> stack;
if (Debugger::GetCallstack(stack))
{
for (size_t i = 0; i < stack.size(); i++)
{
int idx = callstack->Append(wxString::FromAscii(stack[i].Name.c_str()));
callstack->SetClientData(idx, (void*)(u64)stack[i].vAddress);
}
}
else
{
callstack->Append(wxString::FromAscii("invalid callstack"));
}
UpdateButtonStates();
}
void CCodeWindow::NotifyMapLoaded()
{
g_symbolDB.FillInCallers();
symbols->Show(false); // hide it for faster filling
symbols->Clear();
for (SymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); iter++)
{
int idx = symbols->Append(wxString::FromAscii(iter->second.name.c_str()));
symbols->SetClientData(idx, (void*)&iter->second);
}
symbols->Show(true);
Update();
}
void CCodeWindow::UpdateButtonStates()
{
wxToolBar* toolBar = GetToolBar();
if (Core::GetState() == Core::CORE_UNINITIALIZED)
{
toolBar->EnableTool(IDM_DEBUG_GO, false);
toolBar->EnableTool(IDM_STEP, false);
toolBar->EnableTool(IDM_STEPOVER, false);
toolBar->EnableTool(IDM_SKIP, false);
}
else
{
if (!CCPU::IsStepping())
{
toolBar->SetToolShortHelp(IDM_DEBUG_GO, _T("&Pause"));
toolBar->SetToolNormalBitmap(IDM_DEBUG_GO, m_Bitmaps[Toolbar_Pause]);
toolBar->EnableTool(IDM_DEBUG_GO, true);
toolBar->EnableTool(IDM_STEP, false);
toolBar->EnableTool(IDM_STEPOVER, false);
toolBar->EnableTool(IDM_SKIP, false);
}
else
{
toolBar->SetToolShortHelp(IDM_DEBUG_GO, _T("&Play"));
toolBar->SetToolNormalBitmap(IDM_DEBUG_GO, m_Bitmaps[Toolbar_DebugGo]);
toolBar->EnableTool(IDM_DEBUG_GO, true);
toolBar->EnableTool(IDM_STEP, true);
toolBar->EnableTool(IDM_STEPOVER, true);
toolBar->EnableTool(IDM_SKIP, true);
}
}
}
void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
{
int index = symbols->GetSelection();
if (index >= 0) {
Symbol* pSymbol = static_cast<Symbol *>(symbols->GetClientData(index));
if (pSymbol != NULL)
{
JumpToAddress(pSymbol->address);
}
}
}
void CCodeWindow::OnSymbolListContextMenu(wxContextMenuEvent& event)
{
}
void CCodeWindow::OnToggleLogWindow(wxCommandEvent& event)
{
if (IsLoggingActivated())
{
bool show = GetMenuBar()->IsChecked(event.GetId());
if (show)
{
if (!m_LogWindow)
{
m_LogWindow = new CLogWindow(this);
}
m_LogWindow->Show(true);
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT(m_LogWindow != NULL);
if (m_LogWindow)
{
m_LogWindow->Hide();
}
}
}
}
void CCodeWindow::OnToggleRegisterWindow(wxCommandEvent& event)
{
bool show = GetMenuBar()->IsChecked(event.GetId());
if (show)
{
if (!m_RegisterWindow)
{
m_RegisterWindow = new CRegisterWindow(this);
}
m_RegisterWindow->Show(true);
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT(m_RegisterWindow != NULL);
if (m_RegisterWindow)
{
m_RegisterWindow->Hide();
}
}
}
void CCodeWindow::OnToggleBreakPointWindow(wxCommandEvent& event)
{
bool show = GetMenuBar()->IsChecked(event.GetId());
if (show)
{
if (!m_BreakpointWindow)
{
m_BreakpointWindow = new CBreakPointWindow(this, this);
}
m_BreakpointWindow->Show(true);
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT(m_BreakpointWindow != NULL);
if (m_BreakpointWindow)
{
m_BreakpointWindow->Hide();
}
}
}
void CCodeWindow::OnToggleMemoryWindow(wxCommandEvent& event)
{
bool show = GetMenuBar()->IsChecked(event.GetId());
if (show)
{
if (!m_MemoryWindow)
{
m_MemoryWindow = new CMemoryWindow(this);
}
m_MemoryWindow->Show(true);
}
else // hide
{
// If m_dialog is NULL, then possibly the system
// didn't report the checked menu item status correctly.
// It should be true just after the menu item was selected,
// if there was no modeless dialog yet.
wxASSERT(m_MemoryWindow != NULL);
if (m_MemoryWindow)
{
m_MemoryWindow->Hide();
}
}
}
void CCodeWindow::OnHostMessage(wxCommandEvent& event)
{
switch (event.GetId())
{
case IDM_NOTIFYMAPLOADED:
NotifyMapLoaded();
break;
case IDM_UPDATELOGDISPLAY:
if (m_LogWindow)
{
m_LogWindow->NotifyUpdate();
}
break;
case IDM_UPDATEDISASMDIALOG:
Update();
if (m_RegisterWindow)
{
m_RegisterWindow->NotifyUpdate();
}
break;
case IDM_UPDATEBREAKPOINTS:
Update();
if (m_BreakpointWindow)
{
m_BreakpointWindow->NotifyUpdate();
}
break;
}
}
void CCodeWindow::PopulateToolbar(wxToolBar* toolBar)
{
int w = m_Bitmaps[Toolbar_DebugGo].GetWidth(),
h = m_Bitmaps[Toolbar_DebugGo].GetHeight();
toolBar->SetToolBitmapSize(wxSize(w, h));
toolBar->AddTool(IDM_DEBUG_GO, _T("Play"), m_Bitmaps[Toolbar_DebugGo]);
toolBar->AddTool(IDM_STEP, _T("Step"), m_Bitmaps[Toolbar_Step]);
toolBar->AddTool(IDM_STEPOVER, _T("Step Over"), m_Bitmaps[Toolbar_StepOver]);
toolBar->AddTool(IDM_SKIP, _T("Skip"), m_Bitmaps[Toolbar_Skip]);
toolBar->AddSeparator();
toolBar->AddTool(IDM_GOTOPC, _T("Show PC"), m_Bitmaps[Toolbar_GotoPC]);
toolBar->AddTool(IDM_SETPC, _T("Set PC"), m_Bitmaps[Toolbar_SetPC]);
toolBar->AddSeparator();
toolBar->AddControl(new wxTextCtrl(toolBar, IDM_ADDRBOX, _T("")));
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
toolBar->Realize();
}
void CCodeWindow::RecreateToolbar()
{
// delete and recreate the toolbar
wxToolBarBase* toolBar = GetToolBar();
delete toolBar;
SetToolBar(NULL);
long style = TOOLBAR_STYLE;
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 CCodeWindow::InitBitmaps()
{
// load original size 48x48
m_Bitmaps[Toolbar_DebugGo] = wxGetBitmapFromMemory(toolbar_play_png);
m_Bitmaps[Toolbar_Step] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
m_Bitmaps[Toolbar_StepOver] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
m_Bitmaps[Toolbar_Skip] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
m_Bitmaps[Toolbar_GotoPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
m_Bitmaps[Toolbar_SetPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
m_Bitmaps[Toolbar_Pause] = wxGetBitmapFromMemory(toolbar_pause_png);
// scale to 16x16 for toolbar
for (size_t n = Toolbar_DebugGo; n < Bitmaps_max; n++)
{
m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16));
}
}
void CCodeWindow::OnKeyDown(wxKeyEvent& event)
{
if ((event.GetKeyCode() == WXK_SPACE) && IsActive())
{
SingleCPUStep();
}
else
{
event.Skip();
}
}
void CCodeWindow::SingleCPUStep()
{
CCPU::StepOpcode(&sync_event);
// if (CCPU::IsStepping())
// sync_event.Wait();
wxThread::Sleep(20);
// need a short wait here
JumpToAddress(PC);
Update();
Host_UpdateLogDisplay();
}

View File

@ -0,0 +1,165 @@
// 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/
#ifndef CODEWINDOW_H_
#define CODEWINDOW_H_
#include <wx/dialog.h>
#include <wx/textctrl.h>
#include <wx/listbox.h>
#include "Debugger.h"
#include "CodeView.h"
#include "Thread.h"
#include "CoreParameter.h"
class CRegisterWindow;
class CLogWindow;
class CBreakPointWindow;
class CMemoryWindow;
class CJitWindow;
class CCodeView;
class IniFile;
class CCodeWindow
: public wxFrame
{
public:
CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxString& title = _T("Dolphin-Debugger"),
const wxPoint& pos = wxPoint(950, 100),
const wxSize& size = wxSize(400, 500),
long style = wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE);
~CCodeWindow();
void Load(IniFile &file);
void Save(IniFile &file) const;
void Update();
void NotifyMapLoaded();
bool UseInterpreter();
bool UseDualCore();
void JumpToAddress(u32 _Address);
private:
enum
{
ID_TOOLBAR = 500,
IDM_CODEVIEW,
IDM_DEBUG_GO,
IDM_STEP,
IDM_STEPOVER,
IDM_SKIP,
IDM_SETPC,
IDM_GOTOPC,
IDM_ADDRBOX,
IDM_CALLSTACKLIST,
IDM_CALLERSLIST,
IDM_CALLSLIST,
IDM_SYMBOLLIST,
IDM_INTERPRETER,
IDM_DUALCORE,
IDM_LOGWINDOW,
IDM_REGISTERWINDOW,
IDM_BREAKPOINTWINDOW,
IDM_MEMORYWINDOW,
IDM_SCANFUNCTIONS,
IDM_LOGINSTRUCTIONS,
IDM_LOADMAPFILE,
IDM_SAVEMAPFILE,
IDM_CLEARSYMBOLS,
IDM_CLEANSYMBOLS,
IDM_CREATESIGNATUREFILE,
IDM_USESIGNATUREFILE,
IDM_USESYMBOLFILE,
IDM_CLEARCODECACHE,
IDM_PROFILEBLOCKS,
IDM_WRITEPROFILE,
};
enum
{
Toolbar_DebugGo,
Toolbar_Pause,
Toolbar_Step,
Toolbar_StepOver,
Toolbar_Skip,
Toolbar_GotoPC,
Toolbar_SetPC,
Bitmaps_max
};
// sub dialogs
CLogWindow* m_LogWindow;
CRegisterWindow* m_RegisterWindow;
CBreakPointWindow* m_BreakpointWindow;
CMemoryWindow* m_MemoryWindow;
CJitWindow* m_JitWindow;
CCodeView* codeview;
wxListBox* callstack;
wxListBox* symbols;
wxListBox* callers;
wxListBox* calls;
Common::Event sync_event;
wxBitmap m_Bitmaps[Bitmaps_max];
DECLARE_EVENT_TABLE()
void OnSymbolListChange(wxCommandEvent& event);
void OnSymbolListContextMenu(wxContextMenuEvent& event);
void OnCallstackListChange(wxCommandEvent& event);
void OnCallersListChange(wxCommandEvent& event);
void OnCallsListChange(wxCommandEvent& event);
void OnCodeStep(wxCommandEvent& event);
void OnCodeViewChange(wxCommandEvent &event);
void SingleCPUStep();
void OnAddrBoxChange(wxCommandEvent& event);
void OnToggleRegisterWindow(wxCommandEvent& event);
void OnToggleBreakPointWindow(wxCommandEvent& event);
void OnToggleLogWindow(wxCommandEvent& event);
void OnToggleMemoryWindow(wxCommandEvent& event);
void OnHostMessage(wxCommandEvent& event);
void OnSymbolsMenu(wxCommandEvent& event);
void OnJitMenu(wxCommandEvent& event);
void OnProfilerMenu(wxCommandEvent& event);
void OnInterpreter(wxCommandEvent& event);
void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter);
void UpdateButtonStates();
void UpdateLists();
void RecreateToolbar();
void PopulateToolbar(wxToolBar* toolBar);
void InitBitmaps();
void CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter);
void OnKeyDown(wxKeyEvent& event);
};
#endif /*CODEWINDOW_*/

View File

@ -0,0 +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"

View File

@ -0,0 +1,43 @@
// 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/
#ifndef _DEBUGGER_H
#define _DEBUGGER_H
enum
{
IDM_LOG,
IDM_UPDATELOG,
IDM_CLEARLOG,
IDM_LOGCHECKS,
IDM_ENABLEALL,
IDM_SUBMITCMD = 300,
};
#define wxUSE_XPM_IN_MSW 1
#define USE_XPM_BITMAPS 1
#include <wx/wx.h>
// define this to use XPMs everywhere (by default, BMPs are used under Win)
// BMPs use less space, but aren't compiled into the executable on other platforms
#if USE_XPM_BITMAPS && defined (__WXMSW__) && !wxUSE_XPM_IN_MSW
#error You need to enable XPM support to use XPM bitmaps with toolbar!
#endif // USE_XPM_BITMAPS
#endif

View File

@ -0,0 +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()
{
}

View File

@ -0,0 +1,81 @@
// 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/
#ifndef JITWINDOW_H_
#define JITWINDOW_H_
#include <vector>
#include <wx/dialog.h>
#include <wx/textctrl.h>
#include <wx/listctrl.h>
#include <wx/listbox.h>
#include "Debugger.h"
#include "MemoryView.h"
#include "Thread.h"
#include "IniFile.h"
#include "CoreParameter.h"
class JitBlockList : public wxListCtrl
{
std::vector<int> block_ranking;
public:
JitBlockList(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
void Init();
void Update();
};
class CJitWindow : public wxFrame
{
public:
CJitWindow(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxString& title = _T("JIT block viewer"),
const wxPoint& pos = wxPoint(950, 100),
const wxSize& size = wxSize(400, 500),
long style = wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE);
~CJitWindow();
void Save(IniFile& _IniFile) const;
void Load(IniFile& _IniFile);
static void ViewAddr(u32 em_address);
void Update();
private:
void OnRefresh(wxCommandEvent& /*event*/);
void Compare(u32 em_address);
JitBlockList* block_list;
wxButton* button_refresh;
wxTextCtrl* ppc_box;
wxTextCtrl* x86_box;
wxListBox* top_instructions;
DECLARE_EVENT_TABLE()
void OnSymbolListChange(wxCommandEvent& event);
void OnCallstackListChange(wxCommandEvent& event);
void OnAddrBoxChange(wxCommandEvent& event);
void OnHostMessage(wxCommandEvent& event);
};
#endif /*MEMORYWINDOW_*/

View File

@ -0,0 +1,262 @@
// 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 "LogManager.h"
#include <wx/button.h>
#include <wx/textctrl.h>
#include <wx/listbox.h>
#include <wx/checklst.h>
#include "LogWindow.h"
#include "Console.h"
#include "IniFile.h"
BEGIN_EVENT_TABLE(CLogWindow, wxDialog)
EVT_BUTTON(IDM_SUBMITCMD, CLogWindow::OnSubmit)
EVT_BUTTON(IDM_UPDATELOG, CLogWindow::OnUpdateLog)
EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear)
EVT_BUTTON(IDM_ENABLEALL, CLogWindow::OnEnableAll)
EVT_CHECKLISTBOX(IDM_LOGCHECKS, CLogWindow::OnLogCheck)
END_EVENT_TABLE()
CLogWindow::CLogWindow(wxWindow* parent)
: wxDialog(parent, wxID_ANY, _T("Log/Console"), wxPoint(100, 700), wxSize(800, 270),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
wxBoxSizer* sizerTop = new wxBoxSizer(wxHORIZONTAL),
* sizerUber = new wxBoxSizer(wxHORIZONTAL),
* sizerBig = new wxBoxSizer(wxVERTICAL),
* sizerBottom = new wxBoxSizer(wxHORIZONTAL);
m_log = new wxTextCtrl(this, IDM_LOG, _T(""), wxDefaultPosition, wxSize(600, 120), wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
m_cmdline = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition);
wxButton* btn = new wxButton(this, IDM_SUBMITCMD, _T("Submit"));
sizerTop->Add(new wxButton(this, IDM_UPDATELOG, _T("Update")));
sizerTop->Add(new wxButton(this, IDM_CLEARLOG, _T("Clear")));
sizerTop->Add(new wxButton(this, IDM_ENABLEALL, _T("Enable all")));
m_checks = new wxCheckListBox(this, IDM_LOGCHECKS, wxDefaultPosition, wxSize(120, 280));
sizerBottom->Add(m_cmdline, 8, wxGROW | wxRIGHT, 5);
sizerBottom->Add(btn, 1, wxGROW, 0);
sizerBig->Add(sizerTop, 0, wxGROW);
sizerBig->Add(m_log, 1, wxGROW | wxSHRINK);
sizerBig->Add(sizerBottom, 0, wxGROW);
sizerUber->Add(m_checks, 0, wxGROW);
sizerUber->Add(sizerBig, 1, wxGROW);
SetSizer(sizerUber);
SetAffirmativeId(IDM_SUBMITCMD);
//sizerTop->SetSizeHints(this);
//sizerTop->Fit(this);
UpdateChecks();
m_cmdline->SetFocus();
m_bCheckDirty = false;
}
void CLogWindow::Save(IniFile& _IniFile) const
{
_IniFile.Set("LogWindow", "x", GetPosition().x);
_IniFile.Set("LogWindow", "y", GetPosition().y);
_IniFile.Set("LogWindow", "w", GetSize().GetWidth());
_IniFile.Set("LogWindow", "h", GetSize().GetHeight());
}
void CLogWindow::Load(IniFile& _IniFile)
{
int x,y,w,h;
_IniFile.Get("LogWindow", "x", &x, GetPosition().x);
_IniFile.Get("LogWindow", "y", &y, GetPosition().y);
_IniFile.Get("LogWindow", "w", &w, GetSize().GetWidth());
_IniFile.Get("LogWindow", "h", &h, GetSize().GetHeight());
SetSize(x, y, w, h);
}
void CLogWindow::OnSubmit(wxCommandEvent& event)
{
Console_Submit(m_cmdline->GetValue().To8BitData());
m_cmdline->SetValue(_T(""));
NotifyUpdate();
}
void CLogWindow::OnClear(wxCommandEvent& event)
{
LogManager::Clear();
LOG(MASTER_LOG, "(log cleared).");
NotifyUpdate();
}
void CLogWindow::OnEnableAll(wxCommandEvent& event)
{
static bool enable = true;
IniFile ini;
ini.Load("Dolphin.ini");
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
m_checks->Check(i, enable);
LogManager::m_Log[i]->m_bEnable = enable;
LogManager::m_Log[i]->m_bShowInLog = enable;
ini.Set("LogManager", LogManager::m_Log[i]->m_szShortName, enable);
}
ini.Save("Dolphin.ini");
enable = !enable;
}
void CLogWindow::OnLogCheck(wxCommandEvent& event)
{
if (!LogManager::m_bInitialized)
{
return;
}
IniFile ini;
ini.Load("Dolphin.ini");
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
bool Enabled = m_checks->IsChecked(i);
LogManager::m_Log[i]->m_bEnable = Enabled;
LogManager::m_Log[i]->m_bShowInLog = Enabled;
ini.Set("LogManager", LogManager::m_Log[i]->m_szShortName, Enabled);
}
ini.Save("Dolphin.ini");
m_bCheckDirty = true;
UpdateLog();
}
void CLogWindow::UpdateChecks()
{
if (!LogManager::m_bInitialized)
{
return;
}
if (m_checks->GetCount() == 0)
{
// [F|RES] hide the window while we fill it... wxwidgets gets trouble if you don't do it (at least the win version)
m_checks->Show(false);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
m_checks->Append(wxString::FromAscii(LogManager::m_Log[i]->m_szName));
}
m_checks->Show(true);
}
IniFile ini;
ini.Load("Dolphin.ini");
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
bool Enabled = false;
ini.Get("LogManager", LogManager::m_Log[i]->m_szShortName, &Enabled, false);
m_checks->Check(i, Enabled);
LogManager::m_Log[i]->m_bEnable = Enabled;
LogManager::m_Log[i]->m_bShowInLog = Enabled;
}
m_bCheckDirty = true;
UpdateLog();
}
void CLogWindow::OnUpdateLog(wxCommandEvent& event)
{
NotifyUpdate();
}
void CLogWindow::NotifyUpdate()
{
UpdateChecks();
UpdateLog();
}
void CLogWindow::UpdateLog()
{
static int last = -1;
int i = LogManager::m_nextMessages;
if ((last == i) && !m_bCheckDirty)
{
return;
}
m_bCheckDirty = false;
last = i;
//bash together a log buffer really fast (no slow strcpy here, just memcpys)
int count = 0;
char* p = m_logBuffer;
while (count < MAX_MESSAGES)
{
count++;
const LogManager::SMessage& message = LogManager::m_Messages[i];
if (message.m_bInUse)
{
int len = message.m_dwMsgLen;
if (LogManager::m_activeLog == LogTypes::MASTER_LOG)
{
if (LogManager::m_Log[message.m_type]->m_bShowInLog)
{
memcpy(p, message.m_szMessage, len);
p += len;
}
}
else
{
if (message.m_type == LogManager::m_activeLog)
{
memcpy(p, message.m_szMessage, len);
p += len;
}
}
}
i++;
if (i >= MAX_MESSAGES)
{
i = 0;
}
}
*p = 0; //end the string
m_log->SetValue(wxString::FromAscii(m_logBuffer));
m_log->SetInsertionPoint(p - m_logBuffer - 1);
}

View File

@ -0,0 +1,55 @@
// 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/
#ifndef LOGWINDOW_H_
#define LOGWINDOW_H_
class wxTextCtrl;
class wxCheckListBox;
class IniFile;
class CLogWindow
: public wxDialog
{
public:
CLogWindow(wxWindow* parent);
void NotifyUpdate();
void Save(IniFile& _IniFile) const;
void Load(IniFile& _IniFile);
private:
enum { LogBufferSize = 8 * 1024 * 1024};
char m_logBuffer[LogBufferSize];
wxTextCtrl* m_log, * m_cmdline;
wxCheckListBox* m_checks;
bool m_bCheckDirty;
DECLARE_EVENT_TABLE()
void OnSubmit(wxCommandEvent& event);
void OnUpdateLog(wxCommandEvent& event);
void OnLogCheck(wxCommandEvent& event);
void OnClear(wxCommandEvent& event);
void OnEnableAll(wxCommandEvent& event);
void UpdateChecks();
void UpdateLog();
};
#endif /*LOGWINDOW_H_*/

View File

@ -0,0 +1,111 @@
// 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);
Close();
}
}
void MemoryCheckDlg::OnCancel(wxCommandEvent& /*event*/)
{
Close();
}

View File

@ -0,0 +1,73 @@
// 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/
#ifndef __MEMORYCHECKDLG_h__
#define __MEMORYCHECKDLG_h__
#include <wx/wx.h>
#include <wx/dialog.h>
#include <wx/button.h>
#include <wx/checkbox.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/statbox.h>
#undef MemoryCheckDlg_STYLE
#define MemoryCheckDlg_STYLE wxCAPTION | wxSYSTEM_MENU | wxSTAY_ON_TOP | wxDIALOG_NO_PARENT | wxCLOSE_BOX
class MemoryCheckDlg : public wxDialog
{
private:
DECLARE_EVENT_TABLE();
public:
MemoryCheckDlg(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("Memory Check"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = MemoryCheckDlg_STYLE);
virtual ~MemoryCheckDlg();
private:
wxButton* m_pButtonCancel;
wxButton* m_pButtonOK;
wxCheckBox* m_pReadFlag;
wxCheckBox* m_pWriteFlag;
wxTextCtrl* m_pEditEndAddress;
wxTextCtrl* m_pEditStartAddress;
private:
enum
{
ID_CANCEL = 1016,
ID_OK = 1015,
ID_READ_FLAG = 1014,
ID_WRITE_FLAG = 1013,
ID_WXSTATICBOX2 = 1012,
ID_EDIT_END_ADDRESS = 1011,
ID_WXSTATICTEXT2 = 1010,
ID_WXSTATICTEXT1 = 1009,
ID_EDIT_START_ADDR = 1008,
ID_WXSTATICBOX1 = 1007,
};
private:
void OnClose(wxCloseEvent& event);
void OnOK(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
void CreateGUIControls();
};
#endif

View File

@ -0,0 +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"));
nullPen.SetStyle(wxTRANSPARENT);
wxBrush currentBrush(_T("#FFEfE8"));
wxBrush pcBrush(_T("#70FF70"));
wxBrush bpBrush(_T("#FF3311"));
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

@ -0,0 +1,77 @@
// 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/
#ifndef MEMORYVIEW_H_
#define MEMORYVIEW_H_
#include "Debugger.h"
#include "Common.h"
#include "Debugger/DebugInterface.h"
#include <wx/wx.h>
class CMemoryView
: public wxControl
{
public:
CMemoryView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id = -1, const wxSize& Size = wxDefaultSize);
wxSize DoGetBestSize() const;
void OnPaint(wxPaintEvent& event);
void OnErase(wxEraseEvent& event);
void OnMouseDown(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event);
void OnMouseUpL(wxMouseEvent& event);
void OnMouseUpR(wxMouseEvent& event);
void OnPopupMenu(wxCommandEvent& event);
u32 GetSelection() {return(selection);}
void Center(u32 addr)
{
curAddress = addr;
redraw();
}
private:
int YToAddress(int y);
void redraw() {Refresh();}
DebugInterface* debugger;
int curAddress;
int align;
int rowHeight;
u32 selection;
u32 oldSelection;
bool selectionChanged;
bool selecting;
bool hasFocus;
bool showHex;
DECLARE_EVENT_TABLE()
};
#endif /*MEMORYVIEW_H_*/

View File

@ -0,0 +1,190 @@
// 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"
// 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
};
BEGIN_EVENT_TABLE(CMemoryWindow, wxFrame)
EVT_TEXT(IDM_ADDRBOX, CMemoryWindow::OnAddrBoxChange)
EVT_LISTBOX(IDM_SYMBOLLIST, CMemoryWindow::OnSymbolListChange)
EVT_HOST_COMMAND(wxID_ANY, CMemoryWindow::OnHostMessage)
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")));
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
{
_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::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

@ -0,0 +1,71 @@
// 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/
#ifndef MEMORYWINDOW_H_
#define MEMORYWINDOW_H_
#include <wx/dialog.h>
#include <wx/textctrl.h>
#include <wx/listbox.h>
#include "Debugger.h"
#include "MemoryView.h"
#include "Thread.h"
#include "CoreParameter.h"
class CRegisterWindow;
class CLogWindow;
class CBreakPointWindow;
class CMemoryWindow
: public wxFrame
{
public:
CMemoryWindow(wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxString& title = _T("Dolphin-Memory"),
const wxPoint& pos = wxPoint(950, 100),
const wxSize& size = wxSize(400, 500),
long style = wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE);
~CMemoryWindow();
void Save(IniFile& _IniFile) const;
void Load(IniFile& _IniFile);
void Update();
void NotifyMapLoaded();
void JumpToAddress(u32 _Address);
private:
CMemoryView* memview;
wxListBox* symbols;
wxButton* buttonGo;
wxTextCtrl* addrbox;
DECLARE_EVENT_TABLE()
void OnSymbolListChange(wxCommandEvent& event);
void OnCallstackListChange(wxCommandEvent& event);
void OnAddrBoxChange(wxCommandEvent& event);
void OnHostMessage(wxCommandEvent& event);
};
#endif /*MEMORYWINDOW_*/

View File

@ -0,0 +1,140 @@
// 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();
}
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);
}

View File

@ -0,0 +1,45 @@
// 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/
#ifndef __REGISTERVIEW_h__
#define __REGISTERVIEW_h__
#include <wx/listctrl.h>
#include "Common.h"
class CRegisterView
: public wxListCtrl
{
public:
CRegisterView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
void Update();
private:
DECLARE_EVENT_TABLE()
u32 m_CachedRegs[32];
bool m_CachedRegHasChanged[32];
virtual bool MSWDrawSubItem(wxPaintDC& rPainDC, int item, int subitem);
};
#endif

View File

@ -0,0 +1,90 @@
// 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)
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::NotifyUpdate()
{
if (m_GPRListView != NULL)
{
m_GPRListView->Update();
}
}

View File

@ -0,0 +1,58 @@
// 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/
#ifndef __REGISTERWINDOW_h__
#define __REGISTERWINDOW_h__
class CRegisterView;
class IniFile;
#undef RegisterWindow_STYLE
#define RegisterWindow_STYLE wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX
class CRegisterWindow
: public wxDialog
{
private:
DECLARE_EVENT_TABLE();
public:
CRegisterWindow(wxWindow* parent, wxWindowID id = 1, const wxString& title = wxT("Registers"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = RegisterWindow_STYLE);
virtual ~CRegisterWindow();
void Save(IniFile& _IniFile) const;
void Load(IniFile& _IniFile);
void NotifyUpdate();
private:
enum
{
ID_GPR = 1002
};
CRegisterView* m_GPRListView;
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
};
#endif

View File

@ -0,0 +1,34 @@
# -*- python -*-
Import('env')
files = ["LogWindow.cpp",
"BreakPointDlg.cpp",
"BreakpointView.cpp",
"CodeView.cpp",
"BreakpointWindow.cpp",
"CodeWindow.cpp",
"CodeView.cpp",
"Debugger.cpp",
"MemoryCheckDlg.cpp",
"MemoryView.cpp",
"MemoryWindow.cpp",
"RegisterWindow.cpp",
"RegisterView.cpp",
"JitWindow.cpp",
]
wxenv = env.Clone()
wxenv.Append(
CPPDEFINES = [
'USE_XPM_BITMAPS',
'wxNEEDS_CHARPP'
],
LINKFLAGS = [
'-pthread',
]
)
libs = [
'common'
]
wxenv.StaticLibrary("debwx", files, LIBS = libs)