Very basic JIT results viewer.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@254 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-08-21 17:22:55 +00:00
parent 4e9b5a40fd
commit 5e4da92d42
8 changed files with 329 additions and 34 deletions

View File

@ -34,8 +34,8 @@ void HLE_OSPanic()
std::string Error;
GetStringVA(Error);
PanicAlert("PanicAlert: %s", Error.c_str());
LOG(OSREPORT,"(PC=%08x), PanicAlert: %s", LR, Error.c_str());
PanicAlert("OSPanic: %s", Error.c_str());
LOG(OSREPORT,"(PC=%08x), OSPanic: %s", LR, Error.c_str());
NPC = LR;
}

View File

@ -365,8 +365,6 @@ void UpdateTiming()
void Update()
{
// This stuff is not right - what if more than TicksPerLine ticks occur between
// calls to this function, say if we run with fairly inaccurate timing?
while ((CoreTiming::GetTicks() - LastTime) > (TicksPerFrame / LineCount))
{
LastTime += (TicksPerFrame / LineCount);

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="DebuggerWX"
ProjectGUID="{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}"
RootNamespace="DebuggerWX"
@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src;..\..\..\Externals\Bochs_disasm"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -111,7 +111,7 @@
Name="VCCLCompilerTool"
Optimization="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src;..\..\..\Externals\Bochs_disasm"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -175,7 +175,7 @@
<Tool
Name="VCCLCompilerTool"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src;..\..\..\Externals\Bochs_disasm"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__WXMSW__"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@ -238,7 +238,7 @@
<Tool
Name="VCCLCompilerTool"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src;..\..\..\Externals\Bochs_disasm"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__WXMSW__"
RuntimeLibrary="0"
BufferSecurityCheck="false"
@ -302,7 +302,7 @@
Name="VCCLCompilerTool"
Optimization="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src;..\..\..\Externals\Bochs_disasm"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="0"
@ -368,7 +368,7 @@
Name="VCCLCompilerTool"
Optimization="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src"
AdditionalIncludeDirectories="..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\Core\Src;;..\Common\Src;..\..\..\Externals\Bochs_disasm"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -502,6 +502,14 @@
RelativePath=".\src\Debugger.h"
>
</File>
<File
RelativePath=".\src\JitWindow.cpp"
>
</File>
<File
RelativePath=".\src\JitWindow.h"
>
</File>
<File
RelativePath=".\src\LogWindow.cpp"
>

View File

@ -19,6 +19,8 @@
#include "Common.h"
#include "CodeView.h"
#include "JitWindow.h"
#include <wx/event.h>
#include <wx/clipbrd.h>
@ -31,7 +33,7 @@ enum
IDM_COPYCODE,
IDM_INSERTBLR,
IDM_RUNTOHERE,
IDM_DYNARECRESULTS,
IDM_JITRESULTS,
};
@ -158,9 +160,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
#if wxUSE_CLIPBOARD
case IDM_COPYADDRESS:
{
wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(_T("%08x"), selection)));
}
break;
case IDM_COPYCODE:
@ -168,35 +168,27 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
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_INSERTBLR:
{
debugger->insertBLR(selection);
redraw();
break;
}
case IDM_DYNARECRESULTS:
{
// CDynaViewDlg::ViewAddr(selection);
// CDynaViewDlg::Show(TRUE);
// MessageBox(NULL, "not impl", "CtrlDisAsmView", MB_OK);
}
case IDM_JITRESULTS:
CJitWindow::ViewAddr(selection);
break;
}
@ -219,7 +211,7 @@ void CCodeView::OnMouseUpR(wxMouseEvent& event)
#endif
menu.Append(IDM_RUNTOHERE, _T("&Run To Here"));
menu.Append(IDM_INSERTBLR, wxString::FromAscii("Insert &blr"));
//menu.Append(IDM_DYNARECRESULTS, "Copy &address");
menu.Append(IDM_JITRESULTS, wxString::FromAscii("PPC vs X86"));
PopupMenu(&menu);
event.Skip(true);
}

View File

@ -15,13 +15,16 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "IniFile.h"
#include "Host.h"
#include "Debugger.h"
#include "RegisterWindow.h"
#include "LogWindow.h"
#include "BreakpointWindow.h"
#include "MemoryWindow.h"
#include "IniFile.h"
#include "JitWindow.h"
#include "wx/button.h"
#include "wx/textctrl.h"
@ -32,20 +35,17 @@
#include "CodeWindow.h"
#include "CodeView.h"
#include "Core.h"
#include "LogManager.h"
#include "HW/CPU.h"
#include "PowerPC/PowerPC.h"
#include "Host.h"
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/PPCAnalyst.h"
#include "PowerPC/Jit64/Jit.h"
#include "PowerPC/Jit64/JitCache.h"
#include "Core.h"
#include "LogManager.h"
// ugly that this lib included code from the main
#include "../../DolphinWX/src/Globals.h"
@ -194,6 +194,9 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
m_MemoryWindow = new CMemoryWindow(this);
m_MemoryWindow->Show(true);
m_JitWindow = new CJitWindow(this);
m_JitWindow->Show(true);
}

View File

@ -31,6 +31,7 @@ class CRegisterWindow;
class CLogWindow;
class CBreakPointWindow;
class CMemoryWindow;
class CJitWindow;
class CCodeView;
class IniFile;
@ -101,6 +102,7 @@ class CCodeWindow
CRegisterWindow* m_RegisterWindow;
CBreakPointWindow* m_BreakpointWindow;
CMemoryWindow* m_MemoryWindow;
CJitWindow* m_JitWindow;
CCodeView* codeview;
wxListBox* callstack;

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 = 33350,
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, "(ppc)", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE), 1, wxEXPAND);
sizerSplit->Add(x86_box = new wxTextCtrl(this, IDM_X86_BOX, "(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(StringFromFormat("(non-code address: %08x)", em_address).c_str()));
x86_box->SetValue(wxString(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((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, "Address");
InsertColumn(COLUMN_PPCSIZE, "PPC Size");
InsertColumn(COLUMN_X86SIZE, "x86 Size");
InsertColumn(COLUMN_NAME, "Symbol");
InsertColumn(COLUMN_FLAGS, "Flags");
InsertColumn(COLUMN_NUMEXEC, "NumExec");
InsertColumn(COLUMN_COST, "Cost");
}
void JitBlockList::Update()
{
}

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_*/