Debugger: added save code option and darkened the code view colors so I can see them on my screen
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1359 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
327662bce3
commit
c05b7df3ef
|
@ -103,17 +103,31 @@ void PPCDebugInterface::insertBLR(unsigned int address)
|
|||
Memory::Write_U32(0x4e800020, address);
|
||||
}
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Separate the blocks with colors.
|
||||
// -------------
|
||||
int PPCDebugInterface::getColor(unsigned int address)
|
||||
{
|
||||
if (!Memory::IsRAMAddress(address))
|
||||
return 0xeeeeee;
|
||||
int colors[6] = {0xe0FFFF, 0xFFe0e0, 0xe8e8FF, 0xFFe0FF, 0xe0FFe0, 0xFFFFe0};
|
||||
int colors[6] =
|
||||
{
|
||||
0xd0FFFF // light cyan
|
||||
,0xFFd0d0 // light red
|
||||
,0xd8d8FF // light blue
|
||||
,0xFFd0FF // light purple
|
||||
,0xd0FFd0 // light green
|
||||
,0xFFFFd0 // light yellow
|
||||
};
|
||||
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
if (!symbol) return 0xFFFFFF;
|
||||
if (symbol->type != Symbol::SYMBOL_FUNCTION)
|
||||
return 0xEEEEFF;
|
||||
return colors[symbol->index % 6];
|
||||
}
|
||||
// =============
|
||||
|
||||
|
||||
std::string PPCDebugInterface::getDescription(unsigned int address)
|
||||
{
|
||||
|
|
|
@ -26,10 +26,15 @@
|
|||
#include "SignatureDB.h"
|
||||
#include "PPCAnalyst.h"
|
||||
|
||||
#include <wx/textdlg.h>
|
||||
#include <wx/msgdlg.h>
|
||||
|
||||
SymbolDB g_symbolDB;
|
||||
|
||||
SymbolDB::SymbolDB()
|
||||
{
|
||||
// Get access to the disasm() fgnction
|
||||
debugger = new PPCDebugInterface();
|
||||
}
|
||||
|
||||
SymbolDB::~SymbolDB()
|
||||
|
@ -294,20 +299,78 @@ bool SymbolDB::LoadMap(const char *filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool SymbolDB::SaveMap(const char *filename) const
|
||||
{
|
||||
FILE *f = fopen(filename, "w");
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
fprintf(f,".text\n");
|
||||
// ===================================================
|
||||
/* Save the map file and save a code file */
|
||||
// ----------------
|
||||
bool SymbolDB::SaveMap(const char *filename, bool WithCodes) const
|
||||
{
|
||||
// Format the name for the codes version
|
||||
std::string Temp = filename;
|
||||
if(WithCodes) Temp = Temp.substr(0, Temp.find_last_of(".")) + "_code.map";
|
||||
|
||||
// Make a file
|
||||
FILE *f = fopen(Temp.c_str(), "w");
|
||||
if (!f) return false;
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Walk through every code row
|
||||
// -------------------------
|
||||
fprintf(f, ".text\n"); // Write ".text" at the top
|
||||
XFuncMap::const_iterator itr = functions.begin();
|
||||
u32 LastAddress = 0x80004000;
|
||||
std::string LastSymbolName;
|
||||
while (itr != functions.end())
|
||||
{
|
||||
// Save a map file
|
||||
const Symbol &rSymbol = itr->second;
|
||||
fprintf(f,"%08x %08x %08x %i %s\n", rSymbol.address, rSymbol.size, rSymbol.address, 0, rSymbol.name.c_str());
|
||||
if(!WithCodes)
|
||||
fprintf(f,"%08x %08x %08x %i %s\n", rSymbol.address, rSymbol.size, rSymbol.address,
|
||||
0, rSymbol.name.c_str());
|
||||
|
||||
// Save a code file
|
||||
else
|
||||
{
|
||||
// Get the current and next address
|
||||
LastAddress = rSymbol.address;
|
||||
LastSymbolName = rSymbol.name;
|
||||
itr++;
|
||||
|
||||
/* To make nice straight lines we fill out the name with spaces, we also cut off
|
||||
all names longer than 25 letters */
|
||||
std::string Temp;
|
||||
for(int i = 0; i < 25; i++)
|
||||
{
|
||||
if(i < LastSymbolName.size())
|
||||
Temp += LastSymbolName[i];
|
||||
else
|
||||
Temp += " ";
|
||||
}
|
||||
|
||||
// We currently skip the last block because we don't know how long it goes
|
||||
int space;
|
||||
if(itr != functions.end())
|
||||
space = itr->second.address - LastAddress;
|
||||
else
|
||||
space = 0;
|
||||
|
||||
for(int i = 0; i < space; i+=4)
|
||||
{
|
||||
int Address = LastAddress + i;
|
||||
fprintf(f,"%08x %i %20s %s\n", Address,
|
||||
0, Temp.c_str(), debugger->disasm(Address));
|
||||
}
|
||||
}
|
||||
fprintf(f, "\n"); // Write a blank line after each block
|
||||
}
|
||||
// ---------------
|
||||
|
||||
// Show success message
|
||||
wxMessageBox(wxString::Format("Saved %s", Temp.c_str()));
|
||||
|
||||
// Close the file and return
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
// ===========
|
|
@ -20,6 +20,8 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../Debugger/PPCDebugInterface.h"
|
||||
#include "../Debugger/DebugInterface.h"
|
||||
|
||||
struct SCall
|
||||
{
|
||||
|
@ -82,6 +84,7 @@ public:
|
|||
private:
|
||||
XFuncMap functions;
|
||||
XFuncPtrMap checksumToFunction;
|
||||
DebugInterface* debugger;
|
||||
|
||||
public:
|
||||
typedef void (*functionGetterCallback)(Symbol *f);
|
||||
|
@ -118,7 +121,7 @@ public:
|
|||
void FillInCallers();
|
||||
|
||||
bool LoadMap(const char *filename);
|
||||
bool SaveMap(const char *filename) const;
|
||||
bool SaveMap(const char *filename, bool WithCodes = false) const;
|
||||
|
||||
void PrintCalls(u32 funcAddr) const;
|
||||
void PrintCallers(u32 funcAddr) const;
|
||||
|
|
|
@ -342,6 +342,9 @@ void CCodeView::OnErase(wxEraseEvent& event)
|
|||
|
||||
void CCodeView::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
// General settings
|
||||
// -------------------------
|
||||
wxPaintDC dc(this);
|
||||
wxRect rc = GetClientRect();
|
||||
wxFont font(7, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT);
|
||||
|
@ -357,17 +360,23 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
int width = rc.width;
|
||||
int numRows = (rc.height / rowHeight) / 2 + 2;
|
||||
//numRows=(numRows&(~1)) + 1;
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
// ------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Colors and brushes
|
||||
// -------------------------
|
||||
dc.SetBackgroundMode(wxTRANSPARENT); // the text background
|
||||
const wxChar* bgColor = _T("#ffffff");
|
||||
wxPen nullPen(bgColor);
|
||||
wxPen currentPen(_T("#000000"));
|
||||
wxPen selPen(_T("#808080"));
|
||||
wxPen selPen(_T("#808080")); // gray
|
||||
nullPen.SetStyle(wxTRANSPARENT);
|
||||
currentPen.SetStyle(wxSOLID);
|
||||
wxBrush currentBrush(_T("#FFEfE8")); // the ... ? ... is light gray
|
||||
wxBrush pcBrush(_T("#70FF70")); // the selected code line is green
|
||||
wxBrush bpBrush(_T("#FF3311")); // red
|
||||
|
||||
wxBrush currentBrush(_T("#FFEfE8"));
|
||||
wxBrush pcBrush(_T("#70FF70"));
|
||||
wxBrush bpBrush(_T("#FF3311"));
|
||||
wxBrush bgBrush(bgColor);
|
||||
wxBrush nullBrush(bgColor);
|
||||
nullBrush.SetStyle(wxTRANSPARENT);
|
||||
|
@ -376,8 +385,12 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
dc.SetBrush(bgBrush);
|
||||
dc.DrawRectangle(0, 0, 16, rc.height);
|
||||
dc.DrawRectangle(0, 0, rc.width, 5);
|
||||
// TODO - clean up this freaking mess!!!!!
|
||||
// ------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Walk through all visible rows
|
||||
// -------------------------
|
||||
for (int i = -numRows; i <= numRows; i++)
|
||||
{
|
||||
unsigned int address = curAddress + i * align;
|
||||
|
@ -393,26 +406,18 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
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.SetTextForeground(_T("#600000")); // the address text is dark red
|
||||
dc.DrawText(temp, 17, rowY1);
|
||||
dc.SetTextForeground(_T("#000000"));
|
||||
|
||||
|
@ -423,12 +428,16 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
char* dis2 = strchr(dis, '\t');
|
||||
char desc[256] = "";
|
||||
|
||||
// If we have a code
|
||||
if (dis2)
|
||||
{
|
||||
*dis2 = 0;
|
||||
dis2++;
|
||||
const char* mojs = strstr(dis2, "0x8");
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Colors and brushes
|
||||
// -------------------------
|
||||
if (mojs)
|
||||
{
|
||||
for (int k = 0; k < 8; k++)
|
||||
|
@ -449,7 +458,12 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
}
|
||||
}
|
||||
}
|
||||
// ------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Colors and brushes
|
||||
// -------------------------
|
||||
if (mojs)
|
||||
{
|
||||
int offs;
|
||||
|
@ -458,7 +472,7 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
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"));
|
||||
dc.SetTextForeground(_T("#600060")); // the -> arrow illustrations are purple
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -466,16 +480,14 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
}
|
||||
|
||||
dc.DrawText(wxString::FromAscii(dis2), 126, rowY1);
|
||||
// ------------
|
||||
}
|
||||
|
||||
// Show blr as its' own color
|
||||
if (strcmp(dis, "blr"))
|
||||
{
|
||||
dc.SetTextForeground(_T("#007000"));
|
||||
}
|
||||
dc.SetTextForeground(_T("#007000")); // dark green
|
||||
else
|
||||
{
|
||||
dc.SetTextForeground(_T("#8000FF"));
|
||||
}
|
||||
dc.SetTextForeground(_T("#8000FF")); // purple
|
||||
|
||||
dc.DrawText(wxString::FromAscii(dis), 70, rowY1);
|
||||
|
||||
|
@ -484,7 +496,7 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
strcpy(desc, debugger->getDescription(address).c_str());
|
||||
}
|
||||
|
||||
dc.SetTextForeground(_T("#0000FF"));
|
||||
dc.SetTextForeground(_T("#0000FF")); // blue
|
||||
|
||||
//char temp[256];
|
||||
//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
|
||||
|
@ -493,6 +505,7 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
dc.DrawText(wxString::FromAscii(desc), 235, rowY1);
|
||||
}
|
||||
|
||||
// Show red breakpoint dot
|
||||
if (debugger->isBreakpoint(address))
|
||||
{
|
||||
dc.SetBrush(bpBrush);
|
||||
|
@ -500,8 +513,13 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
//DrawIconEx(hdc, 2, rowY1, breakPoint, 32, 32, 0, 0, DI_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end of for
|
||||
// ------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Colors and brushes
|
||||
// -------------------------
|
||||
dc.SetPen(currentPen);
|
||||
|
||||
for (int i = 0; i < numBranches; i++)
|
||||
|
@ -526,10 +544,11 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||
//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,branches[i].dst+4);
|
||||
//LineTo(hdc,x-2,branches[i].dst);
|
||||
}
|
||||
// ------------
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ BEGIN_EVENT_TABLE(CCodeWindow, wxFrame)
|
|||
EVT_MENU(IDM_LOADMAPFILE, CCodeWindow::OnSymbolsMenu)
|
||||
EVT_MENU(IDM_SCANFUNCTIONS, CCodeWindow::OnSymbolsMenu)
|
||||
EVT_MENU(IDM_SAVEMAPFILE, CCodeWindow::OnSymbolsMenu)
|
||||
EVT_MENU(IDM_SAVEMAPFILEWITHCODES, CCodeWindow::OnSymbolsMenu)
|
||||
EVT_MENU(IDM_CREATESIGNATUREFILE, CCodeWindow::OnSymbolsMenu)
|
||||
EVT_MENU(IDM_USESIGNATUREFILE, CCodeWindow::OnSymbolsMenu)
|
||||
EVT_MENU(IDM_PATCHHLEFUNCTIONS, CCodeWindow::OnSymbolsMenu)
|
||||
|
@ -401,6 +402,7 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
|
|||
pSymbolsMenu->AppendSeparator();
|
||||
pSymbolsMenu->Append(IDM_LOADMAPFILE, _T("&Load symbol map"));
|
||||
pSymbolsMenu->Append(IDM_SAVEMAPFILE, _T("&Save symbol map"));
|
||||
pSymbolsMenu->Append(IDM_SAVEMAPFILEWITHCODES, _T("Save code"));
|
||||
pSymbolsMenu->AppendSeparator();
|
||||
pSymbolsMenu->Append(IDM_CREATESIGNATUREFILE, _T("&Create signature file..."));
|
||||
pSymbolsMenu->Append(IDM_USESIGNATUREFILE, _T("&Use signature file..."));
|
||||
|
@ -585,6 +587,9 @@ void CCodeWindow::OnSymbolsMenu(wxCommandEvent& event)
|
|||
case IDM_SAVEMAPFILE:
|
||||
g_symbolDB.SaveMap(mapfile.c_str());
|
||||
break;
|
||||
case IDM_SAVEMAPFILEWITHCODES:
|
||||
g_symbolDB.SaveMap(mapfile.c_str(), true);
|
||||
break;
|
||||
case IDM_CREATESIGNATUREFILE:
|
||||
{
|
||||
wxTextEntryDialog input_prefix(this, wxString::FromAscii("Only export symbols with prefix:"), wxGetTextFromUserPromptStr, _T("."));
|
||||
|
|
|
@ -99,7 +99,7 @@ class CCodeWindow
|
|||
IDM_SCANFUNCTIONS,
|
||||
IDM_LOGINSTRUCTIONS,
|
||||
IDM_LOADMAPFILE,
|
||||
IDM_SAVEMAPFILE,
|
||||
IDM_SAVEMAPFILE, IDM_SAVEMAPFILEWITHCODES,
|
||||
IDM_CLEARSYMBOLS,
|
||||
IDM_CLEANSYMBOLS,
|
||||
IDM_CREATESIGNATUREFILE,
|
||||
|
|
|
@ -250,12 +250,12 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
|
|||
const wxChar* bgColor = _T("#ffffff");
|
||||
wxPen nullPen(bgColor);
|
||||
wxPen currentPen(_T("#000000"));
|
||||
wxPen selPen(_T("#808080"));
|
||||
wxPen selPen(_T("#808080")); // gray
|
||||
nullPen.SetStyle(wxTRANSPARENT);
|
||||
|
||||
wxBrush currentBrush(_T("#FFEfE8"));
|
||||
wxBrush pcBrush(_T("#70FF70"));
|
||||
wxBrush bpBrush(_T("#FF3311"));
|
||||
wxBrush currentBrush(_T("#FFEfE8")); // ligh gray
|
||||
wxBrush pcBrush(_T("#70FF70")); // green
|
||||
wxBrush bpBrush(_T("#FF3311")); // red
|
||||
wxBrush bgBrush(bgColor);
|
||||
wxBrush nullBrush(bgColor);
|
||||
nullBrush.SetStyle(wxTRANSPARENT);
|
||||
|
|
Loading…
Reference in New Issue