Ok, part 2/2 of the symbol code rewrite. You can now create and use function signature files. A monkey ball signature file included. Now to add some cooler features...

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@294 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2008-08-24 18:50:51 +00:00
parent 23665a7b93
commit c0c6fc9e6d
29 changed files with 546 additions and 622 deletions

View File

@ -499,6 +499,54 @@
<File
RelativePath=".\src\CodeWindow.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\CodeWindow.h"

View File

@ -21,6 +21,7 @@
#include "BreakpointView.h"
#include "Debugger/Debugger_BreakPoints.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/SymbolDB.h"
BEGIN_EVENT_TABLE(CBreakPointView, wxListCtrl)
@ -35,8 +36,7 @@ CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id, const wx
}
void
CBreakPointView::Update()
void CBreakPointView::Update()
{
ClearAll();
@ -48,7 +48,7 @@ CBreakPointView::Update()
char szBuffer[64];
const CBreakPoints::TBreakPoints& rBreakPoints = CBreakPoints::GetBreakPoints();
for (size_t i=0; i<rBreakPoints.size(); i++)
for (size_t i = 0; i < rBreakPoints.size(); i++)
{
const TBreakPoint& rBP = rBreakPoints[i];
if (!rBP.bTemporary)
@ -59,10 +59,10 @@ CBreakPointView::Update()
temp = wxString::FromAscii("BP");
SetItem(Item, 1, temp);
Debugger::XSymbolIndex index = Debugger::FindSymbol(rBP.iAddress);
if (index > 0)
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rBP.iAddress);
if (symbol)
{
temp = wxString::FromAscii(Debugger::GetDescription(rBP.iAddress));
temp = wxString::FromAscii("halloj"); //Debugger::GetDescription(rBP.iAddress));
SetItem(Item, 2, temp);
}
@ -75,7 +75,7 @@ CBreakPointView::Update()
}
const CBreakPoints::TMemChecks& rMemChecks = CBreakPoints::GetMemChecks();
for (size_t i=0; i<rMemChecks.size(); i++)
for (size_t i = 0; i < rMemChecks.size(); i++)
{
const TMemCheck& rMemCheck = rMemChecks[i];
@ -85,10 +85,10 @@ CBreakPointView::Update()
temp = wxString::FromAscii("MC");
SetItem(Item, 1, temp);
Debugger::XSymbolIndex index = Debugger::FindSymbol(rMemCheck.StartAddress);
if (index > 0)
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(rMemCheck.StartAddress);
if (symbol)
{
temp = wxString::FromAscii(Debugger::GetDescription(rMemCheck.StartAddress));
temp = wxString::FromAscii("bjorn"); //Debugger::GetDescription(rMemCheck.StartAddress));
SetItem(Item, 2, temp);
}

View File

@ -17,7 +17,7 @@
#include "Debugger.h"
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/SymbolDB.h"
#include "Common.h"
#include "StringUtil.h"
@ -184,13 +184,13 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
break;
case IDM_COPYFUNCTION:
{
int sel = Debugger::FindSymbol(selection);
if (sel > 0) {
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(selection);
if (symbol) {
std::string text;
text = text + Debugger::GetSymbol(sel).GetName() + "\r\n";
text = text + symbol->name + "\r\n";
// we got a function
u32 start = Debugger::GetSymbol(sel).vaddress;
u32 end = start + Debugger::GetSymbol(sel).size;
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";
}
@ -217,11 +217,12 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
case IDM_RENAMESYMBOL:
{
int sel = Debugger::FindSymbol(selection);
if (sel > 0) {
wxTextEntryDialog input_symbol(this, wxString::FromAscii("Rename symbol:"), wxGetTextFromUserPromptStr, wxString::FromAscii(Debugger::GetSymbol(sel).GetName().c_str()));
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) {
Debugger::AccessSymbol(sel).SetName(input_symbol.GetValue().mb_str());
symbol->name = input_symbol.GetValue().mb_str();
}
// redraw();
Host_NotifyMapLoaded();

View File

@ -48,7 +48,7 @@
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/PPCAnalyst.h"
#include "PowerPC/FunctionDB.h"
#include "PowerPC/SymbolDB.h"
#include "PowerPC/SignatureDB.h"
#include "PowerPC/PPCTables.h"
#include "PowerPC/Jit64/Jit.h"
@ -73,6 +73,8 @@ BEGIN_EVENT_TABLE(CCodeWindow, wxFrame)
EVT_MENU(IDM_BREAKPOINTWINDOW, CCodeWindow::OnToggleBreakPointWindow)
EVT_MENU(IDM_MEMORYWINDOW, CCodeWindow::OnToggleMemoryWindow)
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)
@ -173,12 +175,13 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
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);
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);
SetSizer(sizerBig);
sizerLeft->SetSizeHints(this);
@ -246,7 +249,10 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
{
wxMenu *pSymbolsMenu = new wxMenu;
pSymbolsMenu->Append(IDM_SCANFUNCTIONS, _T("&Load/generate symbol map"));
pSymbolsMenu->Append(IDM_CLEARSYMBOLS, _T("&Clear symbols"));
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..."));
@ -305,23 +311,34 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
std::string mapfile = CBoot::GenerateMapFilename();
switch (event.GetId())
{
case IDM_CLEARSYMBOLS:
g_symbolDB.Clear();
Host_NotifyMapLoaded();
break;
case IDM_SCANFUNCTIONS:
{
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB);
SignatureDB db;
if (db.Load("data/totaldb.dsy"))
db.Apply(&g_symbolDB);
Host_NotifyMapLoaded();
break;
}
case IDM_LOADMAPFILE:
if (!File::Exists(mapfile))
{
g_funcDB.Clear();
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_funcDB);
g_symbolDB.Clear();
PPCAnalyst::FindFunctions(0x80000000, 0x80400000, &g_symbolDB);
SignatureDB db;
if (db.Load("data/totaldb.dsy"))
db.Apply(&g_funcDB);
Debugger::GetFromAnalyzer();
db.Apply(&g_symbolDB);
} else {
Debugger::LoadSymbolMap(mapfile.c_str());
Debugger::PushMapToFunctionDB(&g_funcDB);
g_symbolDB.LoadMap(mapfile.c_str());
}
Host_NotifyMapLoaded();
break;
case IDM_SAVEMAPFILE:
Debugger::SaveSymbolMap(mapfile.c_str());
g_symbolDB.SaveMap(mapfile.c_str());
break;
case IDM_CREATESIGNATUREFILE:
{
@ -331,7 +348,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
this);
if (path) {
SignatureDB db;
db.Initialize(&g_funcDB);
db.Initialize(&g_symbolDB);
std::string filename(path.ToAscii()); // PPCAnalyst::SaveSignatureDB(
db.Save(path.ToAscii());
}
@ -346,9 +363,7 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
if (path) {
SignatureDB db;
db.Load(path.ToAscii());
db.Apply(&g_funcDB);
Debugger::Reset();
Debugger::GetFromAnalyzer();
db.Apply(&g_symbolDB);
}
}
Host_NotifyMapLoaded();
@ -426,7 +441,6 @@ void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event)
void CCodeWindow::Update()
{
codeview->Refresh();
callstack->Clear();
std::vector<Debugger::CallstackEntry> stack;
@ -445,7 +459,6 @@ void CCodeWindow::Update()
}
UpdateButtonStates();
Host_UpdateLogDisplay();
}
@ -454,18 +467,12 @@ 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++)
for (SymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); iter++)
{
int idx = symbols->Append(syms[i].GetName().c_str());
symbols->SetClientData(idx, (void*)&syms[i]);
int idx = symbols->Append(iter->second.name.c_str());
symbols->SetClientData(idx, (void*)&iter->second);
}
//
#endif
symbols->Show(true);
Update();
}
@ -508,11 +515,11 @@ void CCodeWindow::UpdateButtonStates()
void CCodeWindow::OnSymbolListChange(wxCommandEvent& event)
{
int index = symbols->GetSelection();
Debugger::Symbol* pSymbol = static_cast<Debugger::Symbol *>(symbols->GetClientData(index));
Symbol* pSymbol = static_cast<Symbol *>(symbols->GetClientData(index));
if (pSymbol != NULL)
{
codeview->Center(pSymbol->vaddress);
codeview->Center(pSymbol->address);
}
}

View File

@ -81,7 +81,9 @@ class CCodeWindow
IDM_MEMORYWINDOW,
IDM_SCANFUNCTIONS,
IDM_LOGINSTRUCTIONS,
IDM_LOADMAPFILE,
IDM_SAVEMAPFILE,
IDM_CLEARSYMBOLS,
IDM_CREATESIGNATUREFILE,
IDM_USESIGNATUREFILE,
IDM_USESYMBOLFILE,

View File

@ -49,7 +49,7 @@ CJitWindow *the_jit_window;
enum
{
IDM_REFRESH_LIST = 33350,
IDM_REFRESH_LIST = 23350,
IDM_PPC_BOX,
IDM_X86_BOX,
IDM_NEXT,

View File

@ -30,7 +30,7 @@
#include "Host.h"
#include "Debugger/PPCDebugInterface.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/SymbolDB.h"
#include "Core.h"
#include "LogManager.h"
@ -148,18 +148,18 @@ void CMemoryWindow::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++)
const FunctionDB::XFuncMap &syms = g_symbolDB.Symbols();
for (FuntionDB::XFuncMap::iterator iter = syms.begin(); iter != syms.end(); ++iter)
{
int idx = symbols->Append(syms[i].GetName().c_str());
symbols->SetClientData(idx, (void*)&syms[i]);
int idx = symbols->Append(iter->second.name.c_str());
symbols->SetClientData(idx, (void*)&iter->second);
}
//
#endif
*/
symbols->Show(true);
Update();
}
@ -167,11 +167,11 @@ void CMemoryWindow::NotifyMapLoaded()
void CMemoryWindow::OnSymbolListChange(wxCommandEvent& event)
{
int index = symbols->GetSelection();
Debugger::Symbol* pSymbol = static_cast<Debugger::Symbol*>(symbols->GetClientData(index));
Symbol* pSymbol = static_cast<Symbol *>(symbols->GetClientData(index));
if (pSymbol != NULL)
{
memview->Center(pSymbol->vaddress);
memview->Center(pSymbol->address);
}
}