Initial megacommit.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-07-12 17:40:22 +00:00
parent a3be5d89ae
commit 775dc8a9c0
1920 changed files with 734652 additions and 0 deletions

View File

@ -0,0 +1,417 @@
// 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 "CodeView.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(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;
align = debuginterface->getInstructionSize(0);
curAddress = debuginterface->getPC();
}
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::OnMouseUpL(wxMouseEvent& event)
{
if (event.m_x > 16)
{
curAddress = YToAddress(event.m_y);
selecting = false;
//ReleaseCapture();
redraw();
}
event.Skip(true);
}
void CCodeView::OnPopupMenu(wxCommandEvent& event)
{
#if wxUSE_CLIPBOARD
wxTheClipboard->Open();
#endif
switch (event.GetId())
{
case IDM_GOTOINMEMVIEW:
// CMemoryDlg::Goto(selection);
break;
#if wxUSE_CLIPBOARD
case IDM_COPYADDRESS:
{
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(_T("%08x"), selection)));
}
break;
case IDM_COPYCODE:
wxTheClipboard->SetData(new wxTextDataObject(debugger->disasm(selection)));
break;
case IDM_COPYHEX:
{
char temp[24];
sprintf(temp, "%08x", debugger->readMemory(selection));
wxTheClipboard->SetData(new wxTextDataObject(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 CCodeView::OnMouseUpR(wxMouseEvent& event)
{
// popup menu
wxMenu menu;
//menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
#if wxUSE_CLIPBOARD
menu.Append(IDM_COPYADDRESS, "Copy &address");
menu.Append(IDM_COPYCODE, "Copy &code");
menu.Append(IDM_COPYHEX, "Copy &hex");
#endif
menu.Append(IDM_RUNTOHERE, _T("&Run To Here"));
//menu.Append(IDM_DYNARECRESULTS, "Copy &address");
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);
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!!!!!
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);
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 i = 0; i < 8; i++)
{
bool found = false;
for (int j = 0; j < 22; j++)
{
if (mojs[i + 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), 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 (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 CODEVIEW_H_
#define CODEVIEW_H_
#include "Debugger.h"
#include "Common.h"
#include "Debugger/DebugInterface.h"
#include <wx/wx.h>
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;
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 /*CODEVIEW_H_*/

View File

@ -0,0 +1,453 @@
// 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 "LogWindow.h"
#include "wx/button.h"
#include "wx/textctrl.h"
#include "wx/listctrl.h"
#include "wx/thread.h"
#include "wx/listctrl.h"
#include "CodeWindow.h"
#include "HW/CPU.h"
#include "PowerPC/PowerPC.h"
#include "Host.h"
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "Core.h"
#include "LogManager.h"
// ugly that this lib included code from the main
#include "../../DolphinWX/src/globals.h"
class SymbolList
: public wxListCtrl
{
wxString OnGetItemText(long item, long column)
{
return(_T("hello"));
}
};
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
};
BEGIN_EVENT_TABLE(CCodeWindow, wxFrame)
EVT_BUTTON(IDM_DEBUG_GO, CCodeWindow::OnCodeStep)
EVT_BUTTON(IDM_STEP, CCodeWindow::OnCodeStep)
EVT_BUTTON(IDM_STEPOVER, CCodeWindow::OnCodeStep)
EVT_BUTTON(IDM_SKIP, CCodeWindow::OnCodeStep)
EVT_BUTTON(IDM_SETPC, CCodeWindow::OnCodeStep)
EVT_BUTTON(IDM_GOTOPC, CCodeWindow::OnCodeStep)
EVT_TEXT(IDM_ADDRBOX, CCodeWindow::OnAddrBoxChange)
EVT_LISTBOX(IDM_SYMBOLLIST, CCodeWindow::OnSymolListChange)
EVT_LISTBOX(IDM_CALLSTACKLIST, CCodeWindow::OnCallstackListChange)
EVT_HOST_COMMAND(wxID_ANY, CCodeWindow::OnHostMessage)
EVT_MENU(IDM_LOGWINDOW, CCodeWindow::OnToggleLogWindow)
EVT_MENU(IDM_REGISTERWINDOW, CCodeWindow::OnToggleRegisterWindow)
END_EVENT_TABLE()
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_RegisterWindow(NULL)
, m_logwindow(NULL)
{
CreateMenu(_LocalCoreStartupParameter);
wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizerRight = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
DebugInterface* di = new PPCDebugInterface();
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);
codeview = new CCodeView(di, this, wxID_ANY);
sizerBig->Add(sizerLeft, 2, wxEXPAND);
sizerBig->Add(codeview, 5, wxEXPAND);
sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3);
sizerRight->Add(buttonGo = new wxButton(this, IDM_DEBUG_GO, _T("&Go")));
sizerRight->Add(buttonStep = new wxButton(this, IDM_STEP, _T("&Step")));
sizerRight->Add(buttonStepOver = new wxButton(this, IDM_STEPOVER, _T("Step &Over")));
sizerRight->Add(buttonSkip = new wxButton(this, IDM_SKIP, _T("Ski&p")));
sizerRight->Add(buttonGotoPC = new wxButton(this, IDM_GOTOPC, _T("G&oto PC")));
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);
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);
UpdateButtonStates();
}
void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter)
{
wxMenuBar* pMenuBar = new wxMenuBar(wxMB_DOCKABLE);
{
wxMenu* pDebugMenu = new wxMenu;
wxMenuItem* interpreter = pDebugMenu->Append(IDM_INTERPRETER, _T("&Interpreter"), wxEmptyString, wxITEM_CHECK);
interpreter->Check(!_LocalCoreStartupParameter.bUseDynarec);
wxMenuItem* dualcore = pDebugMenu->Append(IDM_DUALCORE, _T("&DualCore"), wxEmptyString, wxITEM_CHECK);
dualcore->Check(_LocalCoreStartupParameter.bUseDualCore);
pMenuBar->Append(pDebugMenu, _T("&Core Startup"));
}
{
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);
pMenuBar->Append(pDebugDialogs, _T("&Dialogs"));
}
SetMenuBar(pMenuBar);
}
bool CCodeWindow::UseInterpreter()
{
return(GetMenuBar()->IsChecked(IDM_INTERPRETER));
}
bool CCodeWindow::UseDualCore()
{
return(GetMenuBar()->IsChecked(IDM_DUALCORE));
}
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 ...
codeview->Center(PC);
if (CCPU::IsStepping())
{
CCPU::EnableStepping(false);
}
else
{
CCPU::EnableStepping(true);
Host_UpdateLogDisplay();
}
Update();
}
break;
case IDM_STEP:
{
CCPU::StepOpcode(&sync_event);
// if (CCPU::IsStepping())
// sync_event.Wait();
wxThread::Sleep(20);
// need a short wait here
codeview->Center(PC);
Update();
Host_UpdateLogDisplay();
}
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:
codeview->Center(PC);
break;
}
UpdateButtonStates();
}
void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event)
{
wxString txt = addrbox->GetValue();
if (txt.size() == 8)
{
u32 addr;
sscanf(txt.mb_str(), "%08x", &addr);
codeview->Center(addr);
}
event.Skip(1);
}
void CCodeWindow::Update()
{
codeview->Refresh();
callstack->Clear();
std::vector<Debugger::SCallstackEntry>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("invalid callstack");
}
UpdateButtonStates();
codeview->Center(PC);
Host_UpdateLogDisplay();
}
void CCodeWindow::NotifyMapLoaded()
{
symbols->Show(false); // hide it for faster filling
symbols->Clear();
#ifdef _WIN32
const Debugger::XVectorSymbol& syms = Debugger::AccessSymbols();
for (int i = 0; i < (int)syms.size(); i++)
{
int idx = symbols->Append(syms[i].GetName().c_str());
symbols->SetClientData(idx, (void*)&syms[i]);
}
//
#endif
symbols->Show(true);
Update();
}
void CCodeWindow::UpdateButtonStates()
{
if (Core::GetState() == Core::CORE_UNINITIALIZED)
{
buttonGo->Enable(false);
buttonStep->Enable(false);
buttonStepOver->Enable(false);
buttonSkip->Enable(false);
}
else
{
if (!CCPU::IsStepping())
{
buttonGo->SetLabel(_T("&Pause"));
buttonGo->Enable(true);
buttonStep->Enable(false);
buttonStepOver->Enable(false);
buttonSkip->Enable(false);
}
else
{
buttonGo->SetLabel(_T("&Go"));
buttonGo->Enable(true);
buttonStep->Enable(true);
buttonStepOver->Enable(true);
buttonSkip->Enable(true);
}
}
}
void CCodeWindow::OnSymolListChange(wxCommandEvent& event)
{
int index = symbols->GetSelection();
Debugger::CSymbol* pSymbol = static_cast<Debugger::CSymbol*>(symbols->GetClientData(index));
if (pSymbol != NULL)
{
codeview->Center(pSymbol->vaddress);
}
}
void CCodeWindow::OnCallstackListChange(wxCommandEvent& event)
{
int index = callstack->GetSelection();
u32 address = (u32)(u64)(callstack->GetClientData(index));
if (address != 0x00)
{
codeview->Center(address);
}
}
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::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;
}
}

View File

@ -0,0 +1,86 @@
// 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 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);
void Update();
void NotifyMapLoaded();
bool UseInterpreter();
bool UseDualCore();
private:
// sub dialogs
CLogWindow* m_logwindow;
CRegisterWindow* m_RegisterWindow;
CCodeView* codeview;
wxListBox* callstack;
wxListBox* symbols;
Common::Event sync_event;
wxButton* buttonGo;
wxButton* buttonStep;
wxButton* buttonStepOver;
wxButton* buttonSkip;
wxButton* buttonGotoPC;
wxTextCtrl* addrbox;
DECLARE_EVENT_TABLE()
void OnSymolListChange(wxCommandEvent& event);
void OnCallstackListChange(wxCommandEvent& event);
void OnCodeStep(wxCommandEvent& event);
void OnAddrBoxChange(wxCommandEvent& event);
void OnToggleRegisterWindow(wxCommandEvent& event);
void OnToggleLogWindow(wxCommandEvent& event);
void OnHostMessage(wxCommandEvent& event);
void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter);
void UpdateButtonStates();
};
#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,42 @@
// 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_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,225 @@
// 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_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")));
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::OnSubmit(wxCommandEvent& event)
{
Console_Submit(m_cmdline->GetValue().c_str());
m_cmdline->SetValue(_T(""));
NotifyUpdate();
}
void CLogWindow::OnClear(wxCommandEvent& event)
{
LogManager::Clear();
LOG(MASTER_LOG, "(log cleared).");
NotifyUpdate();
}
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(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(m_logBuffer);
m_log->SetInsertionPoint(p - m_logBuffer - 1);
}

View File

@ -0,0 +1,53 @@
// 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_
#include "wx/dialog.h"
#include "wx/textctrl.h"
#include "wx/checklst.h"
#include "Debugger.h"
class CLogWindow
: public wxDialog
{
public:
CLogWindow(wxWindow* parent);
void NotifyUpdate();
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 UpdateChecks();
void UpdateLog();
};
#endif /*LOGWINDOW_H_*/

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, GetGRPName(i));
// 16-31
SetItem(Item, 2, 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,70 @@
// 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"
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::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,54 @@
// 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;
#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 NotifyUpdate();
private:
enum
{
ID_GPR = 1002
};
CRegisterView* m_GPRListView;
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
};
#endif

View File

@ -0,0 +1,13 @@
Import('env')
files = ["LogWindow.cpp",
"CodeWindow.cpp",
"CodeView.cpp",
"Debugger.cpp",
"RegisterWindow.cpp",
"RegisterView.cpp",
]
wxenv = env.Copy(CXXFLAGS = "`wx-config --cppflags --debug` -DUSE_XPM_BITMAPS -DwxNEEDS_CHARPP",
LINKFLAGS = "-L/usr/local/lib -pthread `wx-config --libs --debug`")
wxenv.StaticLibrary("debwx", files, LIBS = ["common"])