mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-22 20:17:16 +01:00
make all disassembler calls threadsafe .. hopefully.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1462 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
6bf333c893
commit
d01e05b7b5
15
Externals/Bochs_disasm/PowerPCDisasm.cpp
vendored
15
Externals/Bochs_disasm/PowerPCDisasm.cpp
vendored
@ -2204,16 +2204,17 @@ namespace PPCDisasm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// What were MS thinking?
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define snprintf _snprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
// simplified interface
|
// simplified interface
|
||||||
|
void DisassembleGekko(unsigned int opcode, unsigned int curInstAddr, char *dest, int max_size)
|
||||||
const char *DisassembleGekko(unsigned int opcode, unsigned int curInstAddr)
|
|
||||||
{
|
{
|
||||||
char opcodeStr[64], operandStr[64];
|
char opcodeStr[64], operandStr[64];
|
||||||
PPCDisasm::DisasmPara_PPC dp;
|
PPCDisasm::DisasmPara_PPC dp;
|
||||||
static char buf[128];
|
unsigned int opc, adr;
|
||||||
static unsigned int opc, adr;
|
|
||||||
|
|
||||||
opc = opcode;
|
opc = opcode;
|
||||||
adr = curInstAddr;
|
adr = curInstAddr;
|
||||||
@ -2225,9 +2226,7 @@ const char *DisassembleGekko(unsigned int opcode, unsigned int curInstAddr)
|
|||||||
|
|
||||||
PPCDisasm::PPC_Disassemble(&dp);
|
PPCDisasm::PPC_Disassemble(&dp);
|
||||||
|
|
||||||
//sprintf(buf, "%-10s %s", opcodeStr, operandStr);
|
snprintf(dest, max_size, "%s\t%s", opcodeStr, operandStr);
|
||||||
sprintf(buf, "%s\t%s", opcodeStr, operandStr);
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
2
Externals/Bochs_disasm/PowerPCDisasm.h
vendored
2
Externals/Bochs_disasm/PowerPCDisasm.h
vendored
@ -22,7 +22,7 @@
|
|||||||
#ifndef _POWERPC_DISASM
|
#ifndef _POWERPC_DISASM
|
||||||
#define _POWERPC_DISASM
|
#define _POWERPC_DISASM
|
||||||
|
|
||||||
const char *DisassembleGekko(unsigned int opcode, unsigned int curInstAddr);
|
void DisassembleGekko(unsigned int opcode, unsigned int curInstAddr, char *dest, int max_size);
|
||||||
const char *GetGRPName(unsigned int index);
|
const char *GetGRPName(unsigned int index);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#define unlink _unlink
|
#define unlink _unlink
|
||||||
|
#define snprintf _snprintf
|
||||||
#else
|
#else
|
||||||
#define _stricmp strcasecmp
|
#define _stricmp strcasecmp
|
||||||
#define _unlink unlink
|
#define _unlink unlink
|
||||||
|
@ -125,9 +125,11 @@ void Console_Submit(const char *cmd)
|
|||||||
u32 end;
|
u32 end;
|
||||||
TCHAR temp[256];
|
TCHAR temp[256];
|
||||||
sscanf(cmd, "%s %08x %08x", temp, &start, &end);
|
sscanf(cmd, "%s %08x %08x", temp, &start, &end);
|
||||||
|
char disasm[256];
|
||||||
for (u32 addr = start; addr <= end; addr += 4) {
|
for (u32 addr = start; addr <= end; addr += 4) {
|
||||||
u32 data = Memory::ReadUnchecked_U32(addr);
|
u32 data = Memory::ReadUnchecked_U32(addr);
|
||||||
printf("%08x: %08x: %s\n", addr, data, DisassembleGekko(data, addr));
|
DisassembleGekko(data, addr, disasm, 256);
|
||||||
|
printf("%08x: %08x: %s\n", addr, data, disasm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CASE("help")
|
CASE("help")
|
||||||
|
@ -8,8 +8,8 @@ class DebugInterface
|
|||||||
protected:
|
protected:
|
||||||
virtual ~DebugInterface() {}
|
virtual ~DebugInterface() {}
|
||||||
public:
|
public:
|
||||||
virtual const char *disasm(unsigned int /*address*/) {return "NODEBUGGER";}
|
virtual void disasm(unsigned int /*address*/, char *dest, int max_size) {strcpy(dest, "NODEBUGGER");}
|
||||||
virtual const char *getRawMemoryString(unsigned int /*address*/){return "NODEBUGGER";}
|
virtual void getRawMemoryString(unsigned int /*address*/, char *dest, int max_size) {strcpy(dest, "NODEBUGGER");}
|
||||||
virtual int getInstructionSize(int /*instruction*/) {return 1;}
|
virtual int getInstructionSize(int /*instruction*/) {return 1;}
|
||||||
|
|
||||||
virtual bool isAlive() {return true;}
|
virtual bool isAlive() {return true;}
|
||||||
|
@ -26,39 +26,43 @@
|
|||||||
#include "../PowerPC/SymbolDB.h"
|
#include "../PowerPC/SymbolDB.h"
|
||||||
|
|
||||||
// Not thread safe.
|
// Not thread safe.
|
||||||
const char *PPCDebugInterface::disasm(unsigned int address)
|
void PPCDebugInterface::disasm(unsigned int address, char *dest, int max_size)
|
||||||
{
|
{
|
||||||
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||||
{
|
{
|
||||||
if (Memory::IsRAMAddress(address))
|
if (Memory::IsRAMAddress(address))
|
||||||
{
|
{
|
||||||
u32 op = Memory::Read_Instruction(address);
|
u32 op = Memory::Read_Instruction(address);
|
||||||
return DisassembleGekko(op, address);
|
DisassembleGekko(op, address, dest, max_size);
|
||||||
}
|
}
|
||||||
return "No RAM here - invalid";
|
else
|
||||||
|
{
|
||||||
|
strcpy(dest, "No RAM here - invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(dest, "<unknown>");
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char tmp[] = "<unknown>";
|
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *PPCDebugInterface::getRawMemoryString(unsigned int address)
|
void PPCDebugInterface::getRawMemoryString(unsigned int address, char *dest, int max_size)
|
||||||
{
|
{
|
||||||
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||||
{
|
{
|
||||||
if (address < 0xE0000000)
|
if (address < 0xE0000000)
|
||||||
{
|
{
|
||||||
static char str[256] ={0};
|
snprintf(dest, max_size, "%08X", readMemory(address));
|
||||||
if (sprintf(str,"%08X",readMemory(address))!=8) {
|
|
||||||
PanicAlert("getRawMemoryString -> WTF! ( as read somewhere;) )");
|
|
||||||
return ":(";
|
|
||||||
}
|
}
|
||||||
return str;
|
else
|
||||||
|
{
|
||||||
|
strcpy(dest, "--------");
|
||||||
}
|
}
|
||||||
return "No RAM";
|
|
||||||
}
|
}
|
||||||
static const char tmp[] = "<unknown>";
|
else
|
||||||
return tmp;
|
{
|
||||||
|
strcpy(dest, "<unknwn>"); // bad spelling - 8 chars
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int PPCDebugInterface::readMemory(unsigned int address)
|
unsigned int PPCDebugInterface::readMemory(unsigned int address)
|
||||||
|
@ -11,8 +11,8 @@ class PPCDebugInterface : public DebugInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PPCDebugInterface(){}
|
PPCDebugInterface(){}
|
||||||
virtual const char *disasm(unsigned int address);
|
virtual void disasm(unsigned int address, char *dest, int max_size);
|
||||||
virtual const char *getRawMemoryString(unsigned int address);
|
virtual void getRawMemoryString(unsigned int address, char *dest, int max_size);
|
||||||
virtual int getInstructionSize(int instruction) {return 4;}
|
virtual int getInstructionSize(int instruction) {return 4;}
|
||||||
virtual bool isAlive();
|
virtual bool isAlive();
|
||||||
virtual bool isBreakpoint(unsigned int address);
|
virtual bool isBreakpoint(unsigned int address);
|
||||||
|
@ -158,7 +158,9 @@ void Run()
|
|||||||
void unknown_instruction(UGeckoInstruction _inst)
|
void unknown_instruction(UGeckoInstruction _inst)
|
||||||
{
|
{
|
||||||
CCPU::Break();
|
CCPU::Break();
|
||||||
printf("Last PC = %08x : %s\n", last_pc, DisassembleGekko(Memory::ReadUnchecked_U32(last_pc), last_pc));
|
char disasm[256];
|
||||||
|
DisassembleGekko(Memory::ReadUnchecked_U32(last_pc), last_pc, disasm, 256);
|
||||||
|
printf("Last PC = %08x : %s\n", last_pc, disasm);
|
||||||
Debugger::PrintCallstack();
|
Debugger::PrintCallstack();
|
||||||
_dbg_assert_msg_(GEKKO, 0, "\nIntCPU: Unknown instr %08x at PC = %08x last_PC = %08x LR = %08x\n", _inst.hex, PC, last_pc, LR);
|
_dbg_assert_msg_(GEKKO, 0, "\nIntCPU: Unknown instr %08x at PC = %08x last_PC = %08x LR = %08x\n", _inst.hex, PC, last_pc, LR);
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ bool SymbolDB::SaveMap(const char *filename, bool WithCodes) const
|
|||||||
{
|
{
|
||||||
// Save a map file
|
// Save a map file
|
||||||
const Symbol &rSymbol = itr->second;
|
const Symbol &rSymbol = itr->second;
|
||||||
if(!WithCodes)
|
if (!WithCodes)
|
||||||
{
|
{
|
||||||
fprintf(f,"%08x %08x %08x %i %s\n", rSymbol.address, rSymbol.size, rSymbol.address,
|
fprintf(f,"%08x %08x %08x %i %s\n", rSymbol.address, rSymbol.size, rSymbol.address,
|
||||||
0, rSymbol.name.c_str());
|
0, rSymbol.name.c_str());
|
||||||
@ -345,9 +345,9 @@ bool SymbolDB::SaveMap(const char *filename, bool WithCodes) const
|
|||||||
/* To make nice straight lines we fill out the name with spaces, we also cut off
|
/* To make nice straight lines we fill out the name with spaces, we also cut off
|
||||||
all names longer than 25 letters */
|
all names longer than 25 letters */
|
||||||
std::string TempSym;
|
std::string TempSym;
|
||||||
for(u32 i = 0; i < 25; i++)
|
for (u32 i = 0; i < 25; i++)
|
||||||
{
|
{
|
||||||
if(i < LastSymbolName.size())
|
if (i < LastSymbolName.size())
|
||||||
TempSym += LastSymbolName[i];
|
TempSym += LastSymbolName[i];
|
||||||
else
|
else
|
||||||
TempSym += " ";
|
TempSym += " ";
|
||||||
@ -355,16 +355,17 @@ bool SymbolDB::SaveMap(const char *filename, bool WithCodes) const
|
|||||||
|
|
||||||
// We currently skip the last block because we don't know how long it goes
|
// We currently skip the last block because we don't know how long it goes
|
||||||
int space;
|
int space;
|
||||||
if(itr != functions.end())
|
if (itr != functions.end())
|
||||||
space = itr->second.address - LastAddress;
|
space = itr->second.address - LastAddress;
|
||||||
else
|
else
|
||||||
space = 0;
|
space = 0;
|
||||||
|
|
||||||
for(int i = 0; i < space; i+=4)
|
for (int i = 0; i < space; i += 4)
|
||||||
{
|
{
|
||||||
int Address = LastAddress + i;
|
int Address = LastAddress + i;
|
||||||
fprintf(f,"%08x %i %20s %s\n", Address,
|
char disasm[256];
|
||||||
0, TempSym.c_str(), debugger->disasm(Address));
|
debugger->disasm(Address, disasm, 256);
|
||||||
|
fprintf(f,"%08x %i %20s %s\n", Address, 0, TempSym.c_str(), disasm);
|
||||||
}
|
}
|
||||||
fprintf(f, "\n"); // Write a blank line after each block
|
fprintf(f, "\n"); // Write a blank line after each block
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,9 @@ void CCodeView::OnMouseUpL(wxMouseEvent& event)
|
|||||||
|
|
||||||
u32 CCodeView::AddrToBranch(u32 addr)
|
u32 CCodeView::AddrToBranch(u32 addr)
|
||||||
{
|
{
|
||||||
const char *temp = debugger->disasm(addr);
|
char disasm[256];
|
||||||
const char *mojs = strstr(temp, "->0x");
|
debugger->disasm(addr, disasm, 256);
|
||||||
|
const char *mojs = strstr(disasm, "->0x");
|
||||||
if (mojs)
|
if (mojs)
|
||||||
{
|
{
|
||||||
u32 dest;
|
u32 dest;
|
||||||
@ -205,7 +206,11 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_COPYCODE:
|
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?
|
{
|
||||||
|
char disasm[256];
|
||||||
|
debugger->disasm(selection, disasm, 256);
|
||||||
|
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(disasm))); //Have to manually convert from char* to wxString, don't have to in Windows?
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_COPYHEX:
|
case IDM_COPYHEX:
|
||||||
@ -225,7 +230,9 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
|
|||||||
u32 start = symbol->address;
|
u32 start = symbol->address;
|
||||||
u32 end = start + symbol->size;
|
u32 end = start + symbol->size;
|
||||||
for (u32 addr = start; addr != end; addr += 4) {
|
for (u32 addr = start; addr != end; addr += 4) {
|
||||||
text = text + StringFromFormat("%08x: ", addr) + debugger->disasm(addr) + "\r\n";
|
char disasm[256];
|
||||||
|
debugger->disasm(addr, disasm, 256);
|
||||||
|
text = text + StringFromFormat("%08x: ", addr) + disasm + "\r\n";
|
||||||
}
|
}
|
||||||
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(text.c_str())));
|
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(text.c_str())));
|
||||||
}
|
}
|
||||||
@ -423,8 +430,8 @@ void CCodeView::OnPaint(wxPaintEvent& event)
|
|||||||
|
|
||||||
if (debugger->isAlive())
|
if (debugger->isAlive())
|
||||||
{
|
{
|
||||||
char dis[256] = {0};
|
char dis[256];
|
||||||
strcpy(dis, debugger->disasm(address));
|
debugger->disasm(address, dis, 256);
|
||||||
char* dis2 = strchr(dis, '\t');
|
char* dis2 = strchr(dis, '\t');
|
||||||
char desc[256] = "";
|
char desc[256] = "";
|
||||||
|
|
||||||
|
@ -301,25 +301,25 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
|
|||||||
m_RegisterWindow->Show(true);
|
m_RegisterWindow->Show(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bBreakpointWindow)
|
if (bBreakpointWindow)
|
||||||
{
|
{
|
||||||
m_BreakpointWindow = new CBreakPointWindow(this, this);
|
m_BreakpointWindow = new CBreakPointWindow(this, this);
|
||||||
m_BreakpointWindow->Show(true);
|
m_BreakpointWindow->Show(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bMemoryWindow)
|
if (bMemoryWindow)
|
||||||
{
|
{
|
||||||
m_MemoryWindow = new CMemoryWindow(this);
|
m_MemoryWindow = new CMemoryWindow(this);
|
||||||
m_MemoryWindow->Show(true);
|
m_MemoryWindow->Show(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bJitWindow)
|
if (bJitWindow)
|
||||||
{
|
{
|
||||||
m_JitWindow = new CJitWindow(this);
|
m_JitWindow = new CJitWindow(this);
|
||||||
m_JitWindow->Show(true);
|
m_JitWindow->Show(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bSoundWindow)
|
if (bSoundWindow)
|
||||||
{
|
{
|
||||||
// possible todo: add some kind of if here to? can it fail?
|
// possible todo: add some kind of if here to? can it fail?
|
||||||
CPluginManager::GetInstance().OpenDebug(
|
CPluginManager::GetInstance().OpenDebug(
|
||||||
@ -329,7 +329,7 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
|
|||||||
);
|
);
|
||||||
} // don't have any else, just ignore it
|
} // don't have any else, just ignore it
|
||||||
|
|
||||||
if(bVideoWindow)
|
if (bVideoWindow)
|
||||||
{
|
{
|
||||||
// possible todo: add some kind of if here to? can it fail?
|
// possible todo: add some kind of if here to? can it fail?
|
||||||
CPluginManager::GetInstance().OpenDebug(
|
CPluginManager::GetInstance().OpenDebug(
|
||||||
|
@ -171,8 +171,12 @@ void CMemoryView::OnPopupMenu(wxCommandEvent& event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_COPYCODE:
|
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?
|
{
|
||||||
|
char disasm[256];
|
||||||
|
debugger->disasm(selection, disasm, 256);
|
||||||
|
wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(disasm))); //Have to manually convert from char* to wxString, don't have to in Windows?
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case IDM_COPYHEX:
|
case IDM_COPYHEX:
|
||||||
{
|
{
|
||||||
@ -303,8 +307,8 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
|
|||||||
dc.SetBrush(currentBrush);
|
dc.SetBrush(currentBrush);
|
||||||
dc.SetTextForeground(_T("#600000"));
|
dc.SetTextForeground(_T("#600000"));
|
||||||
dc.DrawText(temp, 17, rowY1);
|
dc.DrawText(temp, 17, rowY1);
|
||||||
char mem[256] = {0};
|
char mem[256];
|
||||||
strcpy(mem, debugger->getRawMemoryString(address));
|
debugger->getRawMemoryString(address, mem, 256);
|
||||||
dc.SetTextForeground(_T("#000080"));
|
dc.SetTextForeground(_T("#000080"));
|
||||||
dc.DrawText(wxString::FromAscii(mem), 17+fontSize*(8), rowY1);
|
dc.DrawText(wxString::FromAscii(mem), 17+fontSize*(8), rowY1);
|
||||||
dc.SetTextForeground(_T("#000000"));
|
dc.SetTextForeground(_T("#000000"));
|
||||||
@ -312,7 +316,7 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
|
|||||||
if (debugger->isAlive())
|
if (debugger->isAlive())
|
||||||
{
|
{
|
||||||
char dis[256] = {0};
|
char dis[256] = {0};
|
||||||
strcpy(dis, debugger->disasm(address));
|
debugger->disasm(address, dis, 256);
|
||||||
char* dis2 = strchr(dis, '\t');
|
char* dis2 = strchr(dis, '\t');
|
||||||
char desc[256] = "";
|
char desc[256] = "";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user