New DSP debugger: step one. (not ready yet, but try loading zelda WW and look at the dsp debugger..).

Had to shuffle around quite a lot of code to be able to extract the CodeView into a library nicely so it can be used from both the main dolphin and the LLE plugin...  also extracted the symboldb code.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3517 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-06-21 08:39:21 +00:00
parent 80217a6ed7
commit aecaf271f1
76 changed files with 1895 additions and 794 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="Bochs_disasm"
ProjectGUID="{29C2ABC1-ADA5-42CD-A5FC-96022D52A510}"
RootNamespace="Bochs_disasm"
@ -24,7 +24,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
@ -87,7 +87,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
@ -151,7 +151,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
CharacterSet="2"
WholeProgramOptimization="0"
>
<Tool
@ -213,7 +213,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
CharacterSet="2"
WholeProgramOptimization="0"
>
<Tool
@ -278,7 +278,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
CharacterSet="2"
WholeProgramOptimization="0"
>
<Tool
@ -340,7 +340,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
CharacterSet="2"
WholeProgramOptimization="0"
>
<Tool

View File

@ -23,7 +23,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="0"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
@ -85,7 +85,7 @@
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="0"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"

View File

@ -604,6 +604,10 @@
RelativePath=".\Src\CPUDetect.h"
>
</File>
<File
RelativePath=".\Src\DebugInterface.h"
>
</File>
<File
RelativePath=".\Src\DynamicLibrary.cpp"
>
@ -780,6 +784,14 @@
RelativePath=".\Src\StringUtil.h"
>
</File>
<File
RelativePath=".\Src\SymbolDB.cpp"
>
</File>
<File
RelativePath=".\Src\SymbolDB.h"
>
</File>
<File
RelativePath=".\Src\Thread.cpp"
>

View File

@ -20,6 +20,7 @@ public:
virtual void clearAllBreakpoints() {}
virtual void toggleBreakpoint(unsigned int /*address*/){}
virtual unsigned int readMemory(unsigned int /*address*/){return 0;}
virtual void writeExtraMemory(int memory, unsigned int value, unsigned int /*address*/) {}
virtual unsigned int readExtraMemory(int memory, unsigned int address){return 0;}
virtual unsigned int readInstruction(unsigned int /*address*/){return 0;}
virtual unsigned int getPC() {return 0;}

View File

@ -460,3 +460,32 @@ void NormalizeDirSep(std::string* str)
}
#endif
}
std::string TabsToSpaces(int tab_size, const std::string &in)
{
std::string out;
int len = 0;
// First, compute the size of the new string.
for (int i = 0; i < in.size(); i++)
{
if (in[i] == '\t')
len += tab_size;
else
len += 1;
}
out.resize(len);
int out_ctr = 0;
for (int i = 0; i < in.size(); i++)
{
if (in[i] == '\t')
{
for (int j = 0; j < tab_size; j++)
out[out_ctr++] = ' ';
}
else
{
out[out_ctr++] = in[i];
}
}
return out;
}

View File

@ -66,6 +66,8 @@ bool AsciiToHex(const char* _szValue, u32& result);
u32 Ascii2Hex(std::string _Text);
std::string Hex2Ascii(u32 _Text);
std::string TabsToSpaces(int tab_size, const std::string &in);
void SplitString(const std::string& str, const std::string& delim, std::vector<std::string>& output);
int ChooseStringFrom(const char* str, const char* * items);

View File

@ -0,0 +1,59 @@
// 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 "SymbolDB.h"
void SymbolDB::List()
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); iter++)
{
DEBUG_LOG(HLE,"%s @ %08x: %i bytes (hash %08x) : %i calls", iter->second.name.c_str(), iter->second.address, iter->second.size, iter->second.hash,iter->second.numCalls);
}
INFO_LOG(HLE,"%i functions known in this program above.", functions.size());
}
void SymbolDB::Clear(const char *prefix)
{
// TODO: honor prefix
functions.clear();
checksumToFunction.clear();
}
void SymbolDB::Index()
{
int i = 0;
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); iter++)
{
iter->second.index = i++;
}
}
Symbol *SymbolDB::GetSymbolFromName(const char *name)
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); iter++)
{
if (!strcmp(iter->second.name.c_str(), name))
return &iter->second;
}
return 0;
}
void SymbolDB::AddCompleteSymbol(const Symbol &symbol)
{
functions.insert(std::pair<u32, Symbol>(symbol.address, symbol));
}

View File

@ -1,131 +1,122 @@
// Copyright (C) 2003-2009 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 "Common.h"
#include <map>
#include <string>
#include <vector>
#include "../Debugger/PPCDebugInterface.h"
#include "../Debugger/DebugInterface.h"
struct SCall
{
SCall(u32 a, u32 b) :
function(a),
callAddress(b)
{}
u32 function;
u32 callAddress;
};
struct Symbol
{
enum {
SYMBOL_FUNCTION = 0,
SYMBOL_DATA = 1,
};
Symbol() :
hash(0),
address(0),
flags(0),
size(0),
numCalls(0),
type(SYMBOL_FUNCTION),
analyzed(0)
{}
std::string name;
std::vector<SCall> callers; //addresses of functions that call this function
std::vector<SCall> calls; //addresses of functions that are called by this function
u32 hash; //use for HLE function finding
u32 address;
u32 flags;
int size;
int numCalls;
int type;
int index; // only used for coloring the disasm view
int analyzed;
};
enum
{
FFLAG_TIMERINSTRUCTIONS=(1<<0),
FFLAG_LEAF=(1<<1),
FFLAG_ONLYCALLSNICELEAFS=(1<<2),
FFLAG_EVIL=(1<<3),
FFLAG_RFI=(1<<4),
FFLAG_STRAIGHT=(1<<5)
};
// This has functionality overlapping Debugger_Symbolmap. Should merge that stuff in here later.
class SymbolDB
{
public:
typedef std::map<u32, Symbol> XFuncMap;
typedef std::map<u32, Symbol*> XFuncPtrMap;
private:
XFuncMap functions;
XFuncPtrMap checksumToFunction;
DebugInterface* debugger;
public:
typedef void (*functionGetterCallback)(Symbol *f);
SymbolDB();
~SymbolDB();
Symbol *AddFunction(u32 startAddr);
void AddKnownSymbol(u32 startAddr, u32 size, const char *name, int type = Symbol::SYMBOL_FUNCTION);
Symbol *GetSymbolFromAddr(u32 addr);
Symbol *GetSymbolFromName(const char *name);
Symbol *GetSymbolFromHash(u32 hash) {
XFuncPtrMap::iterator iter = checksumToFunction.find(hash);
if (iter != checksumToFunction.end())
return iter->second;
else
return 0;
}
const XFuncMap &Symbols() const {return functions;}
XFuncMap &AccessSymbols() {return functions;}
// deprecated
XFuncMap::iterator GetIterator() { return functions.begin(); }
XFuncMap::const_iterator GetConstIterator() { return functions.begin(); }
XFuncMap::iterator End() { return functions.end(); }
const char *GetDescription(u32 addr);
void Clear(const char *prefix = "");
void List();
void Index();
void FillInCallers();
bool LoadMap(const char *filename);
bool SaveMap(const char *filename, bool WithCodes = false) const;
void PrintCalls(u32 funcAddr) const;
void PrintCallers(u32 funcAddr) const;
void LogFunctionCall(u32 addr);
};
extern SymbolDB g_symbolDB;
// 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/
// This file contains a generic symbol map implementation. For CPU-specific
// magic, derive and extend.
#ifndef _SYMBOL_DB_H
#define _SYMBOL_DB_H
#include <string>
#include <map>
#include "Common.h"
struct SCall
{
SCall(u32 a, u32 b) :
function(a),
callAddress(b)
{}
u32 function;
u32 callAddress;
};
struct Symbol
{
enum {
SYMBOL_FUNCTION = 0,
SYMBOL_DATA = 1,
};
Symbol() :
hash(0),
address(0),
flags(0),
size(0),
numCalls(0),
type(SYMBOL_FUNCTION),
analyzed(0)
{}
std::string name;
std::vector<SCall> callers; //addresses of functions that call this function
std::vector<SCall> calls; //addresses of functions that are called by this function
u32 hash; //use for HLE function finding
u32 address;
u32 flags;
int size;
int numCalls;
int type;
int index; // only used for coloring the disasm view
int analyzed;
};
enum
{
FFLAG_TIMERINSTRUCTIONS=(1<<0),
FFLAG_LEAF=(1<<1),
FFLAG_ONLYCALLSNICELEAFS=(1<<2),
FFLAG_EVIL=(1<<3),
FFLAG_RFI=(1<<4),
FFLAG_STRAIGHT=(1<<5)
};
class SymbolDB
{
public:
typedef std::map<u32, Symbol> XFuncMap;
typedef std::map<u32, Symbol*> XFuncPtrMap;
protected:
XFuncMap functions;
XFuncPtrMap checksumToFunction;
public:
SymbolDB() {}
virtual ~SymbolDB() {}
virtual Symbol *GetSymbolFromAddr(u32 addr) { return 0; }
virtual Symbol *AddFunction(u32 startAddr) { return 0;}
void AddCompleteSymbol(const Symbol &symbol);
Symbol *GetSymbolFromName(const char *name);
Symbol *GetSymbolFromHash(u32 hash) {
XFuncPtrMap::iterator iter = checksumToFunction.find(hash);
if (iter != checksumToFunction.end())
return iter->second;
else
return 0;
}
const XFuncMap &Symbols() const {return functions;}
XFuncMap &AccessSymbols() {return functions;}
// deprecated
XFuncMap::iterator GetIterator() { return functions.begin(); }
XFuncMap::const_iterator GetConstIterator() { return functions.begin(); }
XFuncMap::iterator End() { return functions.end(); }
void Clear(const char *prefix = "");
void List();
void Index();
};
#endif

View File

@ -963,6 +963,14 @@
RelativePath=".\Src\PowerPC\PPCAnalyst.h"
>
</File>
<File
RelativePath=".\Src\PowerPC\PPCSymbolDB.cpp"
>
</File>
<File
RelativePath=".\Src\PowerPC\PPCSymbolDB.h"
>
</File>
<File
RelativePath=".\Src\PowerPC\PPCTables.cpp"
>
@ -987,14 +995,6 @@
RelativePath=".\Src\PowerPC\SignatureDB.h"
>
</File>
<File
RelativePath=".\Src\PowerPC\SymbolDB.cpp"
>
</File>
<File
RelativePath=".\Src\PowerPC\SymbolDB.h"
>
</File>
<Filter
Name="Interpreter"
>

View File

@ -41,7 +41,7 @@
#include "../VolumeHandler.h"
#include "../PatchEngine.h"
#include "../PowerPC/SignatureDB.h"
#include "../PowerPC/SymbolDB.h"
#include "../PowerPC/PPCSymbolDB.h"
#include "../MemTools.h"
#include "../ConfigManager.h"
@ -314,7 +314,7 @@ bool CBoot::BootUp()
Boot_ELF(_StartupPara.m_strFilename.c_str());
UpdateDebugger_MapLoaded();
BreakPoints::AddAutoBreakpoints();
Debugger::AddAutoBreakpoints();
}
break;

View File

@ -20,7 +20,7 @@
#include "Common.h"
#include "../Debugger/Debugger_SymbolMap.h"
#include "../HW/Memmap.h"
#include "../PowerPC/SymbolDB.h"
#include "../PowerPC/PPCSymbolDB.h"
#include "ElfReader.h"
void bswap(Elf32_Word &w) {w = Common::swap32(w);}

View File

@ -26,7 +26,7 @@
#include "CoreTiming.h"
#include "Core.h"
#include "PowerPC/Jit64/Jit.h"
#include "PowerPC/SymbolDB.h"
#include "PowerPC/PPCSymbolDB.h"
#include "PowerPCDisasm.h"
#include "Console.h"

View File

@ -399,6 +399,7 @@ THREAD_RETURN EmuThread(void *pArg)
DSPInitialize dspInit;
dspInit.hWnd = g_pWindowHandle;
dspInit.pARAM_Read_U8 = (u8 (__cdecl *)(const u32))DSP::ReadARAM;
dspInit.pARAM_Write_U8 = (void (__cdecl *)(const u8, const u32))DSP::WriteARAM;
dspInit.pGetARAMPointer = DSP::GetARAMPtr;
dspInit.pGetMemoryPointer = Memory::GetPointer;
dspInit.pLog = Callback_DSPLog;

View File

@ -19,12 +19,11 @@
#include "../HW/CPU.h"
#include "../Host.h"
#include "../PowerPC/SymbolDB.h"
#include "../PowerPC/PPCSymbolDB.h"
#include "Debugger_BreakPoints.h"
BreakPoints::TBreakPoints BreakPoints::m_BreakPoints;
MemChecks::TMemChecks MemChecks::m_MemChecks;
BreakPoints g_breakpoints;
MemChecks g_memchecks;
void TMemCheck::Action(u32 iValue, u32 addr, bool write, int size, u32 pc)
{
@ -99,24 +98,6 @@ void BreakPoints::Clear()
Host_UpdateBreakPointView();
}
void BreakPoints::AddAutoBreakpoints()
{
#if defined(_DEBUG) || defined(DEBUGFAST)
#if 1
const char *bps[] = {
"PPCHalt",
};
for (u32 i = 0; i < sizeof(bps) / sizeof(const char *); i++)
{
Symbol *symbol = g_symbolDB.GetSymbolFromName(bps[i]);
if (symbol)
BreakPoints::Add(symbol->address, false);
}
#endif
#endif
}
void BreakPoints::DeleteByAddress(u32 _Address)
{
// first check breakpoints

View File

@ -51,52 +51,52 @@ struct TMemCheck
void Action(u32 _iValue, u32 addr, bool write, int size, u32 pc);
};
// Code breakpoints.
class BreakPoints
{
public:
typedef std::vector<TBreakPoint> TBreakPoints;
static const TBreakPoints& GetBreakPoints() { return m_BreakPoints; }
const TBreakPoints& GetBreakPoints() { return m_BreakPoints; }
// is address breakpoint
static bool IsAddressBreakPoint(u32 _iAddress);
static bool IsTempBreakPoint(u32 _iAddress);
bool IsAddressBreakPoint(u32 _iAddress);
bool IsTempBreakPoint(u32 _iAddress);
// AddBreakPoint
static bool Add(u32 em_address, bool temp=false);
bool Add(u32 em_address, bool temp=false);
// Remove Breakpoint
static bool Remove(u32 _iAddress);
static void Clear();
bool Remove(u32 _iAddress);
void Clear();
static void UpdateBreakPointView();
static void AddAutoBreakpoints();
static void DeleteByAddress(u32 _Address);
void DeleteByAddress(u32 _Address);
private:
static TBreakPoints m_BreakPoints;
static u32 m_iBreakOnCount;
TBreakPoints m_BreakPoints;
u32 m_iBreakOnCount;
};
extern BreakPoints g_breakpoints;
// Memory breakpoints
class MemChecks
{
public:
typedef std::vector<TMemCheck> TMemChecks;
static TMemChecks m_MemChecks;
static const TMemChecks& GetMemChecks() { return m_MemChecks; }
static void Add(const TMemCheck& _rMemoryCheck);
TMemChecks m_MemChecks;
const TMemChecks& GetMemChecks() { return m_MemChecks; }
void Add(const TMemCheck& _rMemoryCheck);
//memory breakpoint
static TMemCheck *GetMemCheck(u32 address);
static void DeleteByAddress(u32 _Address);
TMemCheck *GetMemCheck(u32 address);
void DeleteByAddress(u32 _Address);
void Clear();
};
extern MemChecks g_memchecks;
#endif

View File

@ -18,16 +18,35 @@
#include "Common.h"
#include "StringUtil.h"
#include "Debugger_SymbolMap.h"
#include "Debugger_Breakpoints.h"
#include "../Core.h"
#include "../HW/Memmap.h"
#include "../PowerPC/PowerPC.h"
#include "../PowerPC/PPCAnalyst.h"
#include "../PowerPC/SymbolDB.h"
#include "../PowerPC/PPCSymbolDB.h"
#include "../../../../Externals/Bochs_disasm/PowerPCDisasm.h"
namespace Debugger
{
void AddAutoBreakpoints()
{
#if defined(_DEBUG) || defined(DEBUGFAST)
#if 1
const char *bps[] = {
"PPCHalt",
};
for (u32 i = 0; i < sizeof(bps) / sizeof(const char *); i++)
{
Symbol *symbol = g_symbolDB.GetSymbolFromName(bps[i]);
if (symbol)
g_breakpoints.Add(symbol->address, false);
}
#endif
#endif
}
bool GetCallstack(std::vector<CallstackEntry> &output)
{
if (Core::GetState() == Core::CORE_UNINITIALIZED)

View File

@ -36,6 +36,8 @@ bool GetCallstack(std::vector<CallstackEntry> &output);
void PrintCallstack();
void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level);
void PrintDataBuffer(LogTypes::LOG_TYPE _Log, u8* _pData, size_t _Size, const char* _title);
void AddAutoBreakpoints();
} // end of namespace Debugger

View File

@ -25,7 +25,7 @@
#include "../HW/Memmap.h"
#include "../PowerPC/PowerPC.h"
#include "../PowerPC/Jit64/Jit.h"
#include "../PowerPC/SymbolDB.h"
#include "../PowerPC/PPCSymbolDB.h"
void PPCDebugInterface::disasm(unsigned int address, char *dest, int max_size)
{
@ -104,18 +104,18 @@ bool PPCDebugInterface::isAlive()
bool PPCDebugInterface::isBreakpoint(unsigned int address)
{
return BreakPoints::IsAddressBreakPoint(address);
return g_breakpoints.IsAddressBreakPoint(address);
}
void PPCDebugInterface::setBreakpoint(unsigned int address)
{
if (BreakPoints::Add(address))
if (g_breakpoints.Add(address))
jit.NotifyBreakpoint(address, true);
}
void PPCDebugInterface::clearBreakpoint(unsigned int address)
{
if (BreakPoints::Remove(address))
if (g_breakpoints.Remove(address))
jit.NotifyBreakpoint(address, false);
}
@ -123,10 +123,10 @@ void PPCDebugInterface::clearAllBreakpoints() {}
void PPCDebugInterface::toggleBreakpoint(unsigned int address)
{
if (BreakPoints::IsAddressBreakPoint(address))
BreakPoints::Remove(address);
if (g_breakpoints.IsAddressBreakPoint(address))
g_breakpoints.Remove(address);
else
BreakPoints::Add(address);
g_breakpoints.Add(address);
}
void PPCDebugInterface::insertBLR(unsigned int address, unsigned int value)

View File

@ -21,7 +21,7 @@
#include "HLE.h"
#include "../PowerPC/PowerPC.h"
#include "../PowerPC/SymbolDB.h"
#include "../PowerPC/PPCSymbolDB.h"
#include "../HW/Memmap.h"
#include "../Debugger/Debugger_SymbolMap.h"
#include "../Debugger/Debugger_BreakPoints.h"
@ -132,7 +132,7 @@ void PatchFunctions()
Symbol *symbol = g_symbolDB.GetSymbolFromName(OSPatches[i].m_szPatchName);
if (symbol > 0)
{
BreakPoints::Add(symbol->address, false);
g_breakpoints.Add(symbol->address, false);
INFO_LOG(HLE,"Adding BP to %s %08x", OSBreakPoints[i].m_szPatchName, symbol->address);
}
}

View File

@ -474,7 +474,7 @@ void UpdateAudioDMA()
// Latch new parameters
g_audioDMA.BlocksLeft = g_audioDMA.AudioDMAControl.NumBlocks;
g_audioDMA.ReadAddress = g_audioDMA.SourceAddress;
DEBUG_LOG(DSPLLE, "ADMA read addresses: %08x", g_audioDMA.ReadAddress);
// DEBUG_LOG(DSPLLE, "ADMA read addresses: %08x", g_audioDMA.ReadAddress);
GenerateDSPInterrupt(DSP::INT_AID);
}
} else {
@ -647,11 +647,35 @@ u8 ReadARAM(u32 _iAddress)
return g_ARAM[_iAddress & ARAM_MASK];
}
void WriteARAM(u8 value, u32 _uAddress)
{
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
{
//LOGV(DSPINTERFACE, 0, "ARAM (w) 0x%08x 0x%08x 0x%08x", WII_MASK, _iAddress, (_iAddress & WII_MASK));
// Does this make any sense?
if (_uAddress > WII_MASK)
{
if (_uAddress > WII_MEM2)
_uAddress = (_uAddress & WII_MEM2);
g_MEM2[_uAddress] = value;
}
else
{
g_ARAM[_uAddress] = value;
}
}
else
g_ARAM[_uAddress & ARAM_MASK] = value;
}
u8 *GetARAMPtr()
{
return g_ARAM;
}
/*
// Should this really be a function? The hardware only supports block DMA.
void WriteARAM(u8 _iValue, u32 _iAddress)
{
@ -661,7 +685,7 @@ void WriteARAM(u8 _iValue, u32 _iAddress)
// rouge leader writes WAY outside
// not really surprising since it uses a totally different memory model :P
g_ARAM[_iAddress & ARAM_MASK] = _iValue;
}
}*/
} // end of namespace DSP
// ===================

View File

@ -48,6 +48,7 @@ void Write32(const u32 _uValue, const u32 _uAddress);
// Audio/DSP Plugin Helper
u8 ReadARAM(const u32 _uAddress);
void WriteARAM(u8 value, u32 _uAddress);
// Debugger Helper
u8* GetARAMPtr();

View File

@ -254,7 +254,7 @@ u8 Read_U8(const u32 _Address)
u8 _var = 0;
ReadFromHardware<u8>(_var, _Address, _Address, FLAG_READ);
#ifndef NOCHECK
TMemCheck *mc = MemChecks::GetMemCheck(_Address);
TMemCheck *mc = g_memchecks.GetMemCheck(_Address);
if (mc)
{
mc->numHits++;
@ -269,7 +269,7 @@ u16 Read_U16(const u32 _Address)
u16 _var = 0;
ReadFromHardware<u16>(_var, _Address, _Address, FLAG_READ);
#ifndef NOCHECK
TMemCheck *mc = MemChecks::GetMemCheck(_Address);
TMemCheck *mc = g_memchecks.GetMemCheck(_Address);
if (mc)
{
mc->numHits++;
@ -291,7 +291,7 @@ u32 Read_U32(const u32 _Address)
u32 _var = 0;
ReadFromHardware<u32>(_var, _Address, _Address, FLAG_READ);
#ifndef NOCHECK
TMemCheck *mc = MemChecks::GetMemCheck(_Address);
TMemCheck *mc = g_memchecks.GetMemCheck(_Address);
if (mc)
{
mc->numHits++;
@ -307,7 +307,7 @@ u64 Read_U64(const u32 _Address)
u64 _var = 0;
ReadFromHardware<u64>(_var, _Address, _Address, FLAG_READ);
#ifndef NOCHECK
TMemCheck *mc = MemChecks::GetMemCheck(_Address);
TMemCheck *mc = g_memchecks.GetMemCheck(_Address);
if (mc)
{
mc->numHits++;
@ -321,7 +321,7 @@ u64 Read_U64(const u32 _Address)
void Write_U8(const u8 _Data, const u32 _Address)
{
#ifndef NOCHECK
TMemCheck *mc = MemChecks::GetMemCheck(_Address);
TMemCheck *mc = g_memchecks.GetMemCheck(_Address);
if (mc)
{
mc->numHits++;
@ -335,7 +335,7 @@ void Write_U8(const u8 _Data, const u32 _Address)
void Write_U16(const u16 _Data, const u32 _Address)
{
#ifndef NOCHECK
TMemCheck *mc = MemChecks::GetMemCheck(_Address);
TMemCheck *mc = g_memchecks.GetMemCheck(_Address);
if (mc)
{
mc->numHits++;
@ -350,7 +350,7 @@ void Write_U16(const u16 _Data, const u32 _Address)
void Write_U32(const u32 _Data, const u32 _Address)
{
#ifndef NOCHECK
TMemCheck *mc = MemChecks::GetMemCheck(_Address);
TMemCheck *mc = g_memchecks.GetMemCheck(_Address);
if (mc)
{
mc->numHits++;
@ -364,7 +364,7 @@ void Write_U32(const u32 _Data, const u32 _Address)
void Write_U64(const u64 _Data, const u32 _Address)
{
#ifndef NOCHECK
TMemCheck *mc = MemChecks::GetMemCheck(_Address);
TMemCheck *mc = g_memchecks.GetMemCheck(_Address);
if (mc)
{
mc->numHits++;

View File

@ -166,7 +166,7 @@ void Run()
#endif
//2: check for breakpoint
if (BreakPoints::IsAddressBreakPoint(PC))
if (g_breakpoints.IsAddressBreakPoint(PC))
{
#ifdef SHOW_HISTORY
NOTICE_LOG(POWERPC, "----------------------------");
@ -187,8 +187,8 @@ void Run()
#endif
INFO_LOG(POWERPC, "Hit Breakpoint - %08x", PC);
CCPU::Break();
if (BreakPoints::IsTempBreakPoint(PC))
BreakPoints::Remove(PC);
if (g_breakpoints.IsTempBreakPoint(PC))
g_breakpoints.Remove(PC);
Host_UpdateDisasmDialog();
return;

View File

@ -550,7 +550,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buffer, JitB
}
// If starting from the breakpointed instruction, we don't break.
if (em_address != ops[i].address && BreakPoints::IsAddressBreakPoint(ops[i].address))
if (em_address != ops[i].address && g_breakpoints.IsAddressBreakPoint(ops[i].address))
{
}

View File

@ -21,7 +21,7 @@
#include "Interpreter/Interpreter.h"
#include "../HW/Memmap.h"
#include "PPCTables.h"
#include "SymbolDB.h"
#include "PPCSymbolDB.h"
#include "SignatureDB.h"
#include "PPCAnalyst.h"
@ -582,11 +582,11 @@ void FindFunctionsFromBranches(u32 startAddr, u32 endAddr, SymbolDB *func_db)
}
}
void FindFunctionsAfterBLR(SymbolDB *func_db)
void FindFunctionsAfterBLR(PPCSymbolDB *func_db)
{
vector<u32> funcAddrs;
for (SymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); iter++)
for (PPCSymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); iter++)
funcAddrs.push_back(iter->second.address + iter->second.size);
for (vector<u32>::iterator iter = funcAddrs.begin(); iter != funcAddrs.end(); iter++)
@ -609,7 +609,7 @@ void FindFunctionsAfterBLR(SymbolDB *func_db)
}
}
void FindFunctions(u32 startAddr, u32 endAddr, SymbolDB *func_db)
void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB *func_db)
{
//Step 1: Find all functions
FindFunctionsFromBranches(startAddr, endAddr, func_db);
@ -621,7 +621,7 @@ void FindFunctions(u32 startAddr, u32 endAddr, SymbolDB *func_db)
int numLeafs = 0, numNice = 0, numUnNice = 0;
int numTimer = 0, numRFI = 0, numStraightLeaf = 0;
int leafSize = 0, niceSize = 0, unniceSize = 0;
for (SymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); iter++)
for (PPCSymbolDB::XFuncMap::iterator iter = func_db->GetIterator(); iter != func_db->End(); iter++)
{
if (iter->second.address == 4)
{

View File

@ -26,7 +26,7 @@
#include "Common.h"
#include "Gekko.h"
class SymbolDB;
class PPCSymbolDB;
struct Symbol;
namespace PPCAnalyst
@ -94,7 +94,7 @@ public:
bool Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa, BlockRegStats *fpa, CodeBuffer *buffer);
void LogFunctionCall(u32 addr);
void FindFunctions(u32 startAddr, u32 endAddr, SymbolDB *func_db);
void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB *func_db);
bool AnalyzeFunction(u32 startAddr, Symbol &func, int max_size = 0);
} // namespace

View File

@ -22,49 +22,24 @@
#include <vector>
#include "../HW/Memmap.h"
#include "SymbolDB.h"
#include "PPCSymbolDB.h"
#include "SignatureDB.h"
#include "PPCAnalyst.h"
SymbolDB g_symbolDB;
PPCSymbolDB g_symbolDB;
SymbolDB::SymbolDB()
PPCSymbolDB::PPCSymbolDB()
{
// Get access to the disasm() fgnction
debugger = new PPCDebugInterface();
}
SymbolDB::~SymbolDB()
PPCSymbolDB::~PPCSymbolDB()
{
}
void SymbolDB::List()
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); iter++)
{
DEBUG_LOG(HLE,"%s @ %08x: %i bytes (hash %08x) : %i calls", iter->second.name.c_str(), iter->second.address, iter->second.size, iter->second.hash,iter->second.numCalls);
}
INFO_LOG(HLE,"%i functions known in this program above.", functions.size());
}
void SymbolDB::Clear(const char *prefix)
{
// TODO: honor prefix
functions.clear();
checksumToFunction.clear();
}
void SymbolDB::Index()
{
int i = 0;
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); iter++)
{
iter->second.index = i++;
}
}
// Adds the function to the list, unless it's already there
Symbol *SymbolDB::AddFunction(u32 startAddr)
Symbol *PPCSymbolDB::AddFunction(u32 startAddr)
{
if (startAddr < 0x80000010)
return 0;
@ -88,7 +63,7 @@ Symbol *SymbolDB::AddFunction(u32 startAddr)
}
}
void SymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const char *name, int type)
void PPCSymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const char *name, int type)
{
XFuncMap::iterator iter = functions.find(startAddr);
if (iter != functions.end())
@ -116,7 +91,7 @@ void SymbolDB::AddKnownSymbol(u32 startAddr, u32 size, const char *name, int typ
}
}
Symbol *SymbolDB::GetSymbolFromAddr(u32 addr)
Symbol *PPCSymbolDB::GetSymbolFromAddr(u32 addr)
{
if (!Memory::IsRAMAddress(addr))
return 0;
@ -134,17 +109,7 @@ Symbol *SymbolDB::GetSymbolFromAddr(u32 addr)
return 0;
}
Symbol *SymbolDB::GetSymbolFromName(const char *name)
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); iter++)
{
if (!strcmp(iter->second.name.c_str(), name))
return &iter->second;
}
return 0;
}
const char *SymbolDB::GetDescription(u32 addr)
const char *PPCSymbolDB::GetDescription(u32 addr)
{
Symbol *symbol = GetSymbolFromAddr(addr);
if (symbol)
@ -153,7 +118,7 @@ const char *SymbolDB::GetDescription(u32 addr)
return " --- ";
}
void SymbolDB::FillInCallers()
void PPCSymbolDB::FillInCallers()
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); iter++)
{
@ -183,7 +148,7 @@ void SymbolDB::FillInCallers()
}
}
void SymbolDB::PrintCalls(u32 funcAddr) const
void PPCSymbolDB::PrintCalls(u32 funcAddr) const
{
XFuncMap::const_iterator iter = functions.find(funcAddr);
if (iter != functions.end())
@ -205,7 +170,7 @@ void SymbolDB::PrintCalls(u32 funcAddr) const
}
}
void SymbolDB::PrintCallers(u32 funcAddr) const
void PPCSymbolDB::PrintCallers(u32 funcAddr) const
{
XFuncMap::const_iterator iter = functions.find(funcAddr);
if (iter != functions.end())
@ -223,7 +188,7 @@ void SymbolDB::PrintCallers(u32 funcAddr) const
}
}
void SymbolDB::LogFunctionCall(u32 addr)
void PPCSymbolDB::LogFunctionCall(u32 addr)
{
//u32 from = PC;
XFuncMap::iterator iter = functions.find(addr);
@ -236,7 +201,7 @@ void SymbolDB::LogFunctionCall(u32 addr)
// This one can load both leftover map files on game discs (like Zelda), and mapfiles
// produced by SaveSymbolMap below.
bool SymbolDB::LoadMap(const char *filename)
bool PPCSymbolDB::LoadMap(const char *filename)
{
FILE *f = fopen(filename, "r");
if (!f)
@ -302,7 +267,7 @@ bool SymbolDB::LoadMap(const char *filename)
// ===================================================
/* Save the map file and save a code file */
// ----------------
bool SymbolDB::SaveMap(const char *filename, bool WithCodes) const
bool PPCSymbolDB::SaveMap(const char *filename, bool WithCodes) const
{
// Format the name for the codes version
std::string mapFile = filename;

View File

@ -0,0 +1,56 @@
// Copyright (C) 2003-2009 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 "Common.h"
#include <map>
#include <string>
#include <vector>
#include "../Debugger/PPCDebugInterface.h"
#include "SymbolDB.h"
// This has functionality overlapping Debugger_Symbolmap. Should merge that stuff in here later.
class PPCSymbolDB : public SymbolDB
{
private:
DebugInterface* debugger;
public:
typedef void (*functionGetterCallback)(Symbol *f);
PPCSymbolDB();
~PPCSymbolDB();
Symbol *AddFunction(u32 startAddr);
void AddKnownSymbol(u32 startAddr, u32 size, const char *name, int type = Symbol::SYMBOL_FUNCTION);
Symbol *GetSymbolFromAddr(u32 addr);
const char *GetDescription(u32 addr);
void FillInCallers();
bool LoadMap(const char *filename);
bool SaveMap(const char *filename, bool WithCodes = false) const;
void PrintCalls(u32 funcAddr) const;
void PrintCallers(u32 funcAddr) const;
void LogFunctionCall(u32 addr);
};
extern PPCSymbolDB g_symbolDB;

View File

@ -20,7 +20,7 @@
#include <vector>
#include <algorithm>
#include "SymbolDB.h"
#include "PPCSymbolDB.h"
namespace Profiler
{

View File

@ -20,7 +20,7 @@
#include "../HW/Memmap.h"
#include "SignatureDB.h"
#include "SymbolDB.h"
#include "PPCSymbolDB.h"
namespace {
@ -111,7 +111,7 @@ void SignatureDB::Clear()
database.clear();
}
void SignatureDB::Apply(SymbolDB *symbol_db)
void SignatureDB::Apply(PPCSymbolDB *symbol_db)
{
for (FuncDB::const_iterator iter = database.begin(); iter != database.end(); iter++)
{
@ -135,10 +135,10 @@ void SignatureDB::Apply(SymbolDB *symbol_db)
symbol_db->Index();
}
void SignatureDB::Initialize(SymbolDB *symbol_db, const char *prefix)
void SignatureDB::Initialize(PPCSymbolDB *symbol_db, const char *prefix)
{
std::string prefix_str(prefix);
for (SymbolDB::XFuncMap::const_iterator iter = symbol_db->GetConstIterator(); iter != symbol_db->End(); iter++)
for (PPCSymbolDB::XFuncMap::const_iterator iter = symbol_db->GetConstIterator(); iter != symbol_db->End(); iter++)
{
if (iter->second.name.substr(0, prefix_str.size()) == prefix_str)
{

View File

@ -22,7 +22,7 @@
// You're not meant to keep around SignatureDB objects persistently. Use 'em, throw them away.
class SymbolDB;
class PPCSymbolDB;
class SignatureDB
{
@ -50,8 +50,8 @@ public:
void Clear();
void List();
void Initialize(SymbolDB *func_db, const char *prefix = "");
void Apply(SymbolDB *func_db);
void Initialize(PPCSymbolDB *func_db, const char *prefix = "");
void Apply(PPCSymbolDB *func_db);
static u32 ComputeCodeChecksum(u32 offsetStart, u32 offsetEnd);
};

View File

@ -75,7 +75,7 @@ files = ["ActionReplay.cpp",
"PowerPC/PPCTables.cpp",
"PowerPC/Profiler.cpp",
"PowerPC/SignatureDB.cpp",
"PowerPC/SymbolDB.cpp",
"PowerPC/PPCSymbolDB.cpp",
"PowerPC/Interpreter/Interpreter.cpp",
"PowerPC/Interpreter/Interpreter_Branch.cpp",
"PowerPC/Interpreter/Interpreter_Integer.cpp",

View File

@ -299,7 +299,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\Common\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
PreprocessorDefinitions="LOGGING;WIN32;NDEBUG;_LIB;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@ -363,7 +363,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\Common\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
PreprocessorDefinitions="LOGGING;WIN32;NDEBUG;_LIB;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@ -426,6 +426,10 @@
>
</File>
</Filter>
<Filter
Name="Debugger"
>
</Filter>
<File
RelativePath=".\Src\assemble.cpp"
>

View File

@ -155,6 +155,8 @@ void DSPCore_CheckExternalInterrupt()
{
// level 7 is the interrupt exception
DSPCore_SetException(7);
// Uh, confusing. Can this really be right?
g_dsp.cr &= ~0x0002;
}
}

View File

@ -24,6 +24,7 @@
// can be stubbed out.
u8 DSPHost_ReadHostMemory(u32 addr);
void DSPHost_WriteHostMemory(u8 value, u32 addr);
bool DSPHost_OnThread();
bool DSPHost_Running();
u32 DSPHost_CodeLoaded(const u8 *ptr, int size);

View File

@ -364,15 +364,42 @@ const pdlabel_t pdlabels[] =
{0xffad, "COEF_A2_6", "COEF_A2_6",},
{0xffae, "COEF_A1_7", "COEF_A1_7",},
{0xffaf, "COEF_A2_7", "COEF_A2_7",},
{0xffb0, 0, 0,},
{0xffb1, 0, 0,},
{0xffb2, 0, 0,},
{0xffb3, 0, 0,},
{0xffb4, 0, 0,},
{0xffb5, 0, 0,},
{0xffb6, 0, 0,},
{0xffb7, 0, 0,},
{0xffb8, 0, 0,},
{0xffb9, 0, 0,},
{0xffba, 0, 0,},
{0xffbb, 0, 0,},
{0xffbc, 0, 0,},
{0xffbd, 0, 0,},
{0xffbe, 0, 0,},
{0xffbf, 0, 0,},
{0xffc0, 0, 0,},
{0xffc1, 0, 0,},
{0xffc2, 0, 0,},
{0xffc3, 0, 0,},
{0xffc4, 0, 0,},
{0xffc5, 0, 0,},
{0xffc6, 0, 0,},
{0xffc7, 0, 0,},
{0xffc8, 0, 0,},
{0xffc9, "DSCR", "DSP DMA Control Reg",},
{0xffca, 0, 0,},
{0xffcb, "DSBL", "DSP DMA Block Length",},
{0xffcc, 0, 0,},
{0xffcd, "DSPA", "DSP DMA DMEM Address",},
{0xffce, "DSMAH", "DSP DMA Mem Address H",},
{0xffcf, "DSMAL", "DSP DMA Mem Address L",},
{0xffd0, 0,0,},
{0xffd1, "SampleFormat", "SampleFormat",},
{0xffd3, "Unk Zelda", "Unk Zelda writes to it",},
{0xffd2, 0,0,},
{0xffd3, "UnkZelda", "Unk Zelda reads/writes from/to it",},
{0xffd4, "ACSAH", "Accelerator start address H",},
{0xffd5, "ACSAL", "Accelerator start address L",},
{0xffd6, "ACEAH", "Accelerator end address H",},
@ -384,7 +411,34 @@ const pdlabel_t pdlabels[] =
{0xffdc, "yn2", "yn2",},
{0xffdd, "ARAM", "Direct Read from ARAM (uses ADPCM)",},
{0xffde, "GAIN", "Gain",},
{0xffdf, 0,0,},
{0xffe0, 0,0,},
{0xffe1, 0,0,},
{0xffe2, 0,0,},
{0xffe3, 0,0,},
{0xffe4, 0,0,},
{0xffe5, 0,0,},
{0xffe6, 0,0,},
{0xffe7, 0,0,},
{0xffe8, 0,0,},
{0xffe9, 0,0,},
{0xffea, 0,0,},
{0xffeb, 0,0,},
{0xffec, 0,0,},
{0xffed, 0,0,},
{0xffee, 0,0,},
{0xffef, "AMDM", "ARAM DMA Request Mask",},
{0xfff0, 0,0,},
{0xfff1, 0,0,},
{0xfff2, 0,0,},
{0xfff3, 0,0,},
{0xfff4, 0,0,},
{0xfff5, 0,0,},
{0xfff6, 0,0,},
{0xfff7, 0,0,},
{0xfff8, 0,0,},
{0xfff9, 0,0,},
{0xfffa, 0,0,},
{0xfffb, "DIRQ", "DSP IRQ Request",},
{0xfffc, "DMBH", "DSP Mailbox H",},
{0xfffd, "DMBL", "DSP Mailbox L",},

View File

@ -82,7 +82,7 @@ bool DSPDisassembler::Disassemble(int start_pc, const std::vector<u16> &code, in
fclose(f);
// Run the two passes.
return DisFile(tmp1, 1, text) && DisFile(tmp1, 2, text);
return DisFile(tmp1, base_addr, 1, text) && DisFile(tmp1, base_addr, 2, text);
}
char *DSPDisassembler::DisParams(const DSPOPCTemplate& opc, u16 op1, u16 op2, char *strbuf)
@ -186,7 +186,7 @@ static void MakeLowerCase(char *ptr)
}
}
void DSPDisassembler::DisOpcode(const u16 *binbuf, int base_addr, int pass, u16 *pc, std::string &dest)
bool DSPDisassembler::DisOpcode(const u16 *binbuf, int base_addr, int pass, u16 *pc, std::string &dest)
{
char buffer[256];
char *buf = buffer;
@ -200,11 +200,10 @@ void DSPDisassembler::DisOpcode(const u16 *binbuf, int base_addr, int pass, u16
{
*pc++;
dest.append("; outside memory");
return;
return false;
}
*pc &= 0x0fff;
const u32 op1 = binbuf[*pc];
const u32 op1 = binbuf[*pc & 0x0fff];
const DSPOPCTemplate *opc = NULL;
const DSPOPCTemplate *opc_ext = NULL;
@ -259,7 +258,7 @@ void DSPDisassembler::DisOpcode(const u16 *binbuf, int base_addr, int pass, u16
// Size 2 - the op has a large immediate.
if ((opc->size & ~P_EXT) == 2)
{
op2 = binbuf[*pc + 1];
op2 = binbuf[(*pc + 1) & 0x0fff];
if (settings_.show_hex)
buf += sprintf(buf, "%04x %04x ", op1, op2);
}
@ -318,9 +317,10 @@ void DSPDisassembler::DisOpcode(const u16 *binbuf, int base_addr, int pass, u16
if (pass == 2)
dest.append(buffer);
return true;
}
bool DSPDisassembler::DisFile(const char* name, int pass, std::string &output)
bool DSPDisassembler::DisFile(const char* name, int base_addr, int pass, std::string &output)
{
FILE* in = fopen(name, "rb");
if (in == NULL)
@ -339,7 +339,7 @@ bool DSPDisassembler::DisFile(const char* name, int pass, std::string &output)
// Actually do the disassembly.
for (u16 pc = 0; pc < (size / 2);)
{
DisOpcode(binbuf, 0x0000, pass, &pc, output);
DisOpcode(binbuf, base_addr, pass, &pc, output);
if (pass == 2)
output.append("\n");
}

View File

@ -67,11 +67,11 @@ public:
// Warning - this one is trickier to use right.
// Use pass == 2 if you're just using it by itself.
void DisOpcode(const u16 *binbuf, int base_addr, int pass, u16 *pc, std::string &dest);
bool DisOpcode(const u16 *binbuf, int base_addr, int pass, u16 *pc, std::string &dest);
private:
// Moves PC forward and writes the result to dest.
bool DisFile(const char* name, int pass, std::string &output);
bool DisFile(const char* name, int base_addr, int pass, std::string &output);
char* DisParams(const DSPOPCTemplate& opc, u16 op1, u16 op2, char* strbuf);
std::map<u16, int> unk_opcodes;

View File

@ -64,6 +64,18 @@ s16 ADPCM_Step(u32& _rSamplePos)
return val;
}
void dsp_write_aram_d3(u16 value)
{
// Not sure about this one but it sure looks like Zelda is writing to ARAM
// through 0xFFd3...
const u32 EndAddress = (gdsp_ifx_regs[DSP_ACEAH] << 16) | gdsp_ifx_regs[DSP_ACEAL];
u32 Address = (gdsp_ifx_regs[DSP_ACCAH] << 16) | gdsp_ifx_regs[DSP_ACCAL];
DSPHost_WriteHostMemory(value >> 8, Address);
DSPHost_WriteHostMemory(value & 0xFF, Address + 1);
}
u16 dsp_read_aram()
{
const u32 EndAddress = (gdsp_ifx_regs[DSP_ACEAH] << 16) | gdsp_ifx_regs[DSP_ACEAL];

View File

@ -19,5 +19,6 @@
#define _GDSP_ARAM_H
u16 dsp_read_aram();
void dsp_write_aram_d3(u16 value);
#endif

View File

@ -30,6 +30,7 @@
#include "DSPCore.h"
#include "DSPHost.h"
#include "DSPTables.h"
#include "DSPAnalyzer.h"
#include "gdsp_aram.h"
#include "gdsp_interpreter.h"
@ -89,6 +90,8 @@ void gdsp_mbox_write_l(u8 mbx, u16 val)
if (mbx == GDSP_MBOX_DSP)
{
DEBUG_LOG(DSPLLE, " - DSP writes mail to mbx %i: 0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.pc);
} else {
// Trigger exception?
}
}
@ -138,6 +141,11 @@ void gdsp_ifx_write(u16 addr, u16 val)
gdsp_ifx_regs[DSP_DSCR] &= ~0x0004;
break;
case 0xd3: // ZeldaUnk (accelerator WRITE)
ERROR_LOG(DSPLLE, "Write To ZeldaUnk pc=%04x (%04x)\n", g_dsp.pc, val);
dsp_write_aram_d3(val);
break;
case 0xde:
//if (val)
// PanicAlert("Gain written: %04x", val); // BMX XXX does, and sounds HORRIBLE.
@ -149,10 +157,17 @@ void gdsp_ifx_write(u16 addr, u16 val)
break;
default:
/* if ((addr & 0xff) >= 0xa0 && reg_names[addr - 0xa0])
DEBUG_LOG(DSPLLE, "%04x MW %s (%04x)\n", g_dsp.pc, reg_names[addr - 0xa0], val);
else
DEBUG_LOG(DSPLLE, "%04x MW %04x (%04x)\n", g_dsp.pc, addr, val);*/
if ((addr & 0xff) >= 0xa0) {
if (pdlabels[(addr & 0xFF) - 0xa0].name) {
INFO_LOG(DSPLLE, "%04x MW %s (%04x)\n", g_dsp.pc, pdlabels[(addr & 0xFF) - 0xa0].name, val);
}
else {
ERROR_LOG(DSPLLE, "%04x MW %04x (%04x)\n", g_dsp.pc, addr, val);
}
}
else {
ERROR_LOG(DSPLLE, "%04x MW %04x (%04x)\n", g_dsp.pc, addr, val);
}
gdsp_ifx_regs[addr & 0xFF] = val;
break;
}
@ -176,14 +191,22 @@ u16 gdsp_ifx_read(u16 addr)
return gdsp_ifx_regs[addr & 0xFF];
case 0xdd:
// ERROR_LOG(DSPLLE, "Accelerator");
return dsp_read_aram();
default:
if ((addr & 0xff) >= 0xa0) {
if (pdlabels[(addr & 0xFF) - 0xa0].name) {
INFO_LOG(DSPLLE, "%04x MR %s (%04x)\n", g_dsp.pc, pdlabels[(addr & 0xFF) - 0xa0].name, gdsp_ifx_regs[addr & 0xFF]);
}
else {
ERROR_LOG(DSPLLE, "%04x MR %04x (%04x)\n", g_dsp.pc, addr, gdsp_ifx_regs[addr & 0xFF]);
}
}
else {
ERROR_LOG(DSPLLE, "%04x MR %04x (%04x)\n", g_dsp.pc, addr, gdsp_ifx_regs[addr & 0xFF]);
}
return gdsp_ifx_regs[addr & 0xFF];
/* if ((addr & 0xff) >= 0xc0 && reg_names[addr & 0x3f])
printf("%04x MR %s (%04x)\n", g_dsp.pc, reg_names[addr & 0x3f], val);
else
printf("%04x MR %04x (%04x)\n", g_dsp.pc, addr, val);*/
}
}

View File

@ -78,10 +78,12 @@ void HandleLoop()
const u16 rCallAddress = g_dsp.r[DSP_REG_ST0];
const u16 rLoopAddress = g_dsp.r[DSP_REG_ST2];
// This does not always work correctly!
// The loop end tends to point to the second part of
// two-byte instructions!
if (g_dsp.pc == (rLoopAddress + 1))
{
rLoopCounter--;
if (rLoopCounter > 0)
{
g_dsp.pc = rCallAddress;
@ -147,6 +149,21 @@ void Run()
// Used by non-thread mode.
void RunCycles(int cycles)
{
if (cycles < 18)
{
for (int i = 0; i < cycles; i++)
{
if (g_dsp.cr & CR_HALT)
return;
if (DSPAnalyzer::code_flags[g_dsp.pc] & DSPAnalyzer::CODE_IDLE_SKIP)
return;
Step();
cycles--;
}
return;
}
DSPCore_CheckExternalInterrupt();
// First, let's run a few cycles with no idle skipping so that things can progress a bit.
@ -158,7 +175,7 @@ void RunCycles(int cycles)
cycles--;
}
// Next, let's run a few cycles with idle skipping, so that we can skip loops.
// Next, let's run a few cycles with idle skipping, so that we can skip idle loops.
for (int i = 0; i < 8; i++)
{
if (g_dsp.cr & CR_HALT)

View File

@ -0,0 +1,429 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="DebuggerUICommon"
ProjectGUID="{F81AE75C-3D17-4D8C-A201-82FA5351C123}"
RootNamespace="DebuggerUICommon"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="DebugFast|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="DebugFast|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\Src\CodeView.cpp"
>
</File>
<File
RelativePath=".\Src\CodeView.h"
>
</File>
<File
RelativePath=".\Src\DebuggerUIUtil.cpp"
>
</File>
<File
RelativePath=".\Src\DebuggerUIUtil.h"
>
</File>
<File
RelativePath=".\Src\SConscript"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -15,17 +15,19 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//#include "Debugger.h"
#include "Debugger/PPCDebugInterface.h"
#include "PowerPC/SymbolDB.h"
#include "HW/Memmap.h" // for Write_U32
// #include "Debugger.h"
// #include "Debugger/PPCDebugInterface.h"
// #include "PowerPC/SymbolDB.h"
#include "Common.h"
#include "StringUtil.h"
#include "Debugger/DebugInterface.h"
#include "DebuggerUIUtil.h"
#include "DebugInterface.h"
#include "Host.h"
// #include "Host.h"
#include "CodeView.h"
#include "JitWindow.h"
#include "SymbolDB.h"
// #include "JitWindow.h"
#include <wx/event.h>
#include <wx/clipbrd.h>
@ -61,9 +63,11 @@ BEGIN_EVENT_TABLE(CCodeView, wxControl)
EVT_MENU(-1, CCodeView::OnPopupMenu)
END_EVENT_TABLE()
CCodeView::CCodeView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id, const wxSize& Size)
CCodeView::CCodeView(DebugInterface* debuginterface, SymbolDB *symboldb, wxWindow* parent, wxWindowID Id, const wxSize& Size)
: wxControl(parent, Id, wxDefaultPosition, Size),
debugger(debuginterface),
symbol_db(symboldb),
plain(false),
rowHeight(13),
selection(0),
oldSelection(0),
@ -121,7 +125,7 @@ void CCodeView::OnMouseDown(wxMouseEvent& event)
{
debugger->toggleBreakpoint(YToAddress(y));
redraw();
Host_UpdateBreakPointView();
// Host_UpdateBreakPointView();
}
event.Skip(true);
@ -202,9 +206,9 @@ void CCodeView::InsertBlrNop(int Blr)
}
// Save the old value
if(find >= 0)
if (find >= 0)
{
Memory::Write_U32(BlrList.at(find).OldValue, selection);
debugger->writeExtraMemory(0, BlrList.at(find).OldValue, selection);
BlrList.erase(BlrList.begin() + find);
}
else
@ -257,7 +261,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
case IDM_COPYFUNCTION:
{
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(selection);
Symbol *symbol = symbol_db->GetSymbolFromAddr(selection);
if (symbol) {
std::string text;
text = text + symbol->name + "\r\n";
@ -292,7 +296,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
break;
case IDM_JITRESULTS:
CJitWindow::ViewAddr(selection);
// CJitWindow::ViewAddr(selection);
break;
case IDM_FOLLOWBRANCH:
@ -306,14 +310,14 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
case IDM_ADDFUNCTION:
{
g_symbolDB.AddFunction(selection);
Host_NotifyMapLoaded();
symbol_db->AddFunction(selection);
// Host_NotifyMapLoaded();
}
break;
case IDM_RENAMESYMBOL:
{
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(selection);
Symbol *symbol = symbol_db->GetSymbolFromAddr(selection);
if (symbol) {
wxTextEntryDialog input_symbol(this, wxString::FromAscii("Rename symbol:"), wxGetTextFromUserPromptStr,
wxString::FromAscii(symbol->name.c_str()));
@ -321,7 +325,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
symbol->name = input_symbol.GetValue().mb_str();
}
// redraw();
Host_NotifyMapLoaded();
// Host_NotifyMapLoaded();
}
}
break;
@ -342,7 +346,7 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event)
void CCodeView::OnMouseUpR(wxMouseEvent& event)
{
bool isSymbol = g_symbolDB.GetSymbolFromAddr(selection) != 0;
bool isSymbol = symbol_db->GetSymbolFromAddr(selection) != 0;
// popup menu
wxMenu menu;
//menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view");
@ -379,7 +383,9 @@ void CCodeView::OnPaint(wxPaintEvent& event)
// -------------------------
wxPaintDC dc(this);
wxRect rc = GetClientRect();
dc.SetFont(DebuggerFont);
struct branch
{
int src, dst, srcAddr;
@ -448,9 +454,11 @@ void CCodeView::OnPaint(wxPaintEvent& event)
dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1);
dc.SetBrush(currentBrush);
dc.SetTextForeground(_T("#600000")); // the address text is dark red
dc.DrawText(temp, 17, rowY1);
dc.SetTextForeground(_T("#000000"));
if (!plain) {
dc.SetTextForeground(_T("#600000")); // the address text is dark red
dc.DrawText(temp, 17, rowY1);
dc.SetTextForeground(_T("#000000"));
}
if (debugger->isAlive())
{
@ -464,23 +472,17 @@ void CCodeView::OnPaint(wxPaintEvent& event)
{
*dis2 = 0;
dis2++;
// look for hex strings to decode branches
const char* mojs = strstr(dis2, "0x8");
// --------------------------------------------------------------------
// Colors and brushes
// -------------------------
if (mojs)
{
for (int k = 0; k < 8; k++)
{
bool found = false;
for (int j = 0; j < 22; j++)
{
if (mojs[k + 2] == "0123456789ABCDEFabcdef"[j])
{
found = true;
}
}
if (!found)
{
@ -489,12 +491,6 @@ void CCodeView::OnPaint(wxPaintEvent& event)
}
}
}
// ------------
// --------------------------------------------------------------------
// Colors and brushes
// -------------------------
if (mojs)
{
int offs;
@ -520,20 +516,22 @@ void CCodeView::OnPaint(wxPaintEvent& event)
else
dc.SetTextForeground(_T("#8000FF")); // purple
dc.DrawText(wxString::FromAscii(dis), 80, rowY1);
dc.DrawText(wxString::FromAscii(dis), plain ? 25 : 80, rowY1);
if (desc[0] == 0)
{
strcpy(desc, debugger->getDescription(address).c_str());
}
dc.SetTextForeground(_T("#0000FF")); // blue
if (!plain) {
dc.SetTextForeground(_T("#0000FF")); // blue
//char temp[256];
//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
if (strlen(desc))
{
dc.DrawText(wxString::FromAscii(desc), 270, rowY1);
//char temp[256];
//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
if (strlen(desc))
{
dc.DrawText(wxString::FromAscii(desc), 270, rowY1);
}
}
// Show red breakpoint dot
@ -541,7 +539,6 @@ void CCodeView::OnPaint(wxPaintEvent& event)
{
dc.SetBrush(bpBrush);
dc.DrawRectangle(2, rowY1 + 1, 11, 11);
//DrawIconEx(hdc, 2, rowY1, breakPoint, 32, 32, 0, 0, DI_NORMAL);
}
}
} // end of for

View File

@ -18,7 +18,12 @@
#ifndef CODEVIEW_H_
#define CODEVIEW_H_
#include "Debugger.h"
#define wxUSE_XPM_IN_MSW 1
#define USE_XPM_BITMAPS 1
#include <wx/wx.h>
// #include "Debugger.h"
#include "Common.h"
#include <vector>
@ -26,11 +31,12 @@
DECLARE_EVENT_TYPE(wxEVT_CODEVIEW_CHANGE, -1);
class DebugInterface;
class SymbolDB;
class CCodeView : public wxControl
{
public:
CCodeView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id = -1, const wxSize& Size = wxDefaultSize);
CCodeView(DebugInterface* debuginterface, SymbolDB *symbol_db, wxWindow* parent, wxWindowID Id = -1, const wxSize& Size = wxDefaultSize);
wxSize DoGetBestSize() const;
void OnPaint(wxPaintEvent& event);
void OnErase(wxEraseEvent& event);
@ -57,6 +63,10 @@ public:
redraw();
}
void SetPlain() {
plain = true;
}
private:
void RaiseEvent();
int YToAddress(int y);
@ -66,6 +76,9 @@ private:
void redraw() {Refresh();}
DebugInterface* debugger;
SymbolDB* symbol_db;
bool plain;
int curAddress;
int align;

View File

@ -0,0 +1,23 @@
// 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 "DebuggerUIUtil.h"
// The default font
wxFont DebuggerFont = wxFont(9, wxMODERN, wxNORMAL, wxNORMAL, false, wxT("monospace"));

View File

@ -0,0 +1,36 @@
// 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_UI_UTIL_H
#define _DEBUGGER_UI_UTIL_H
#include <wx/wx.h>
#define wxUSE_XPM_IN_MSW 1
#define USE_XPM_BITMAPS 1
// Defined in CodeWindow.cpp
extern wxFont DebuggerFont;
// 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,13 @@
# -*- python -*-
Import('env')
files = [
'CodeView.cpp',
'DebuggerUIUtil.cpp',
]
acenv = env.Clone()
acenv.Append(CXXFLAGS = [ '-fPIC' ])
acenv.StaticLibrary(env['local_libs'] + 'debugger_ui_util', files)

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="Debugger"
ProjectGUID="{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}"
RootNamespace="DebuggerWX"
@ -46,7 +46,7 @@
Name="VCCLCompilerTool"
Optimization="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerUICommon\Src"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -112,7 +112,7 @@
Name="VCCLCompilerTool"
Optimization="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerUICommon\Src"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
ExceptionHandling="2"
@ -177,7 +177,7 @@
<Tool
Name="VCCLCompilerTool"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerUICommon\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
BufferSecurityCheck="false"
@ -242,7 +242,7 @@
<Tool
Name="VCCLCompilerTool"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerUICommon\Src"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__WXMSW__;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="0"
BufferSecurityCheck="false"
@ -306,7 +306,7 @@
Name="VCCLCompilerTool"
Optimization="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerUICommon\Src"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;DEBUGFAST"
MinimalRebuild="true"
BasicRuntimeChecks="0"
@ -372,9 +372,8 @@
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\InputCommon\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerUICommon\Src"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;DEBUGFAST"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -427,14 +426,6 @@
RelativePath=".\src\BreakpointView.h"
>
</File>
<File
RelativePath=".\src\CodeView.cpp"
>
</File>
<File
RelativePath=".\src\CodeView.h"
>
</File>
<File
RelativePath=".\src\MemoryView.cpp"
>

View File

@ -72,7 +72,7 @@ void BreakPointDlg::OnOK(wxCommandEvent& /*event*/)
u32 Address = 0;
if (AsciiToHex(AddressString.mb_str(), Address))
{
BreakPoints::Add(Address);
g_breakpoints.Add(Address);
Host_UpdateBreakPointView();
Close();
}

View File

@ -21,7 +21,7 @@
#include "BreakpointView.h"
#include "Debugger/Debugger_BreakPoints.h"
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/SymbolDB.h"
#include "PowerPC/PPCSymbolDB.h"
BEGIN_EVENT_TABLE(CBreakPointView, wxListCtrl)
@ -47,7 +47,7 @@ void CBreakPointView::Update()
InsertColumn(4, wxT("Flags"), wxLIST_FORMAT_CENTER, 100);
char szBuffer[64];
const BreakPoints::TBreakPoints& rBreakPoints = BreakPoints::GetBreakPoints();
const BreakPoints::TBreakPoints& rBreakPoints = g_breakpoints.GetBreakPoints();
for (size_t i = 0; i < rBreakPoints.size(); i++)
{
const TBreakPoint& rBP = rBreakPoints[i];
@ -74,7 +74,7 @@ void CBreakPointView::Update()
}
}
const MemChecks::TMemChecks& rMemChecks = MemChecks::GetMemChecks();
const MemChecks::TMemChecks& rMemChecks = g_memchecks.GetMemChecks();
for (size_t i = 0; i < rMemChecks.size(); i++)
{
const TMemCheck& rMemCheck = rMemChecks[i];
@ -115,8 +115,8 @@ void CBreakPointView::DeleteCurrentSelection()
if (Item >= 0)
{
u32 Address = (u32)GetItemData(Item);
BreakPoints::DeleteByAddress(Address);
MemChecks::DeleteByAddress(Address);
g_breakpoints.DeleteByAddress(Address);
g_memchecks.DeleteByAddress(Address);
Update();
}
}

View File

@ -205,7 +205,7 @@ CBreakPointWindow::OnDelete(wxCommandEvent& event)
void
CBreakPointWindow::OnClear(wxCommandEvent& event)
{
BreakPoints::Clear();
g_breakpoints.Clear();
}
// ============
@ -244,7 +244,7 @@ CBreakPointWindow::OnAddBreakPointMany(wxCommandEvent& event)
u32 Address = 0;
if (AsciiToHex(line.c_str(), Address))
{
BreakPoints::Add(Address);
g_breakpoints.Add(Address);
}
}
// only update after we are done with the loop
@ -346,7 +346,7 @@ CBreakPointWindow::OnAddMemoryCheckMany(wxCommandEvent& event)
MemCheck.Log = true;
//MemCheck.Break = false; // this is also what sets Active "on" in the breakpoint window
// so don't think it's off because we are only writing this to the log
MemChecks::Add(MemCheck);
g_memchecks.Add(MemCheck);
}
}
// update after we are done with the loop

View File

@ -54,7 +54,7 @@
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/PPCAnalyst.h"
#include "PowerPC/Profiler.h"
#include "PowerPC/SymbolDB.h"
#include "PowerPC/PPCSymbolDB.h"
#include "PowerPC/SignatureDB.h"
#include "PowerPC/PPCTables.h"
#include "PowerPC/Jit64/Jit.h"
@ -79,9 +79,6 @@ class CPluginManager;
static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT;
// The default font
wxFont DebuggerFont = wxFont(9, wxMODERN, wxNORMAL, wxNORMAL, false, wxT("monospace"));
#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
@ -358,7 +355,7 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
DebugInterface* di = new PPCDebugInterface();
codeview = new CCodeView(di, this, ID_CODEVIEW);
codeview = new CCodeView(di, &g_symbolDB, this, ID_CODEVIEW);
sizerBig->Add(sizerLeft, 2, wxEXPAND);
sizerBig->Add(codeview, 5, wxEXPAND);
@ -375,8 +372,6 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
sizerBig->Fit(this);
sync_event.Init();
if (bRegisterWindow)
{

View File

@ -39,6 +39,7 @@
#include "Host.h"
#include "Debugger.h"
#include "DebuggerUIUtil.h"
#include "RegisterWindow.h"
#include "BreakpointWindow.h"
@ -59,7 +60,7 @@
#include "Debugger/Debugger_SymbolMap.h"
#include "PowerPC/PPCAnalyst.h"
#include "PowerPC/Profiler.h"
#include "PowerPC/SymbolDB.h"
#include "PowerPC/PPCSymbolDB.h"
#include "PowerPC/SignatureDB.h"
#include "PowerPC/PPCTables.h"
#include "PowerPC/Jit64/Jit.h"
@ -273,7 +274,7 @@ void CCodeWindow::NotifyMapLoaded()
//symbols->Show(false); // hide it for faster filling
symbols->Freeze(); // HyperIris: wx style fast filling
symbols->Clear();
for (SymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); iter++)
for (PPCSymbolDB::XFuncMap::iterator iter = g_symbolDB.GetIterator(); iter != g_symbolDB.End(); iter++)
{
int idx = symbols->Append(wxString::FromAscii(iter->second.name.c_str()));
symbols->SetClientData(idx, (void*)&iter->second);

View File

@ -18,23 +18,10 @@
#ifndef _DEBUGGER_H
#define _DEBUGGER_H
#define wxUSE_XPM_IN_MSW 1
#define USE_XPM_BITMAPS 1
#include <wx/wx.h>
#include "DebuggerUIUtil.h"
#include "IniFile.h"
// Defined in CodeWindow.cpp
extern wxFont DebuggerFont;
// 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

@ -91,7 +91,7 @@ void MemoryCheckDlg::OnOK(wxCommandEvent& /*event*/)
MemCheck.Log = true;
MemCheck.Break = true;
MemChecks::Add(MemCheck);
g_memchecks.Add(MemCheck);
Host_UpdateBreakPointView();
Close();
}

View File

@ -20,7 +20,7 @@
#include "Debugger.h"
#include "Common.h"
#include "Debugger/DebugInterface.h"
#include "DebugInterface.h"
class CMemoryView : public wxControl
{

View File

@ -29,7 +29,7 @@
#include "Host.h"
#include "Debugger/PPCDebugInterface.h"
#include "PowerPC/SymbolDB.h"
#include "PowerPC/PPCSymbolDB.h"
#include "Core.h"
#include "LogManager.h"

View File

@ -8,11 +8,9 @@ if not env['HAVE_WX']:
files = [
"BreakPointDlg.cpp",
"BreakpointView.cpp",
"CodeView.cpp",
"BreakpointWindow.cpp",
"CodeWindow.cpp",
"CodeWindowSJP.cpp",
"CodeView.cpp",
"MemoryCheckDlg.cpp",
"MemoryView.cpp",
"MemoryWindow.cpp",

View File

@ -54,6 +54,9 @@ u8 DSPHost_ReadHostMemory(u32 address)
return *ptr;
}
void DSPHost_WriteHostMemory(u8 value, u32 addr) {}
void DSPHost_CodeLoaded(const u8 *code, int size)
{
}

View File

@ -23,6 +23,7 @@
// Stub out the dsplib host stuff, since this is just a simple cmdline tools.
u8 DSPHost_ReadHostMemory(u32 addr) { return 0; }
void DSPHost_WriteHostMemory(u8 value, u32 addr) {}
bool DSPHost_OnThread() { return false; }
bool DSPHost_Running() { return true; }
u32 DSPHost_CodeLoaded(const u8 *ptr, int size) {return 0x1337c0de;}

View File

@ -53,11 +53,17 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\DolphinWX.vcproj", "{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}"
ProjectSection(ProjectDependencies) = postProject
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} = {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}
{D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} = {D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8}
{8D612734-FAA5-4B8A-804F-4DEA2367D495} = {8D612734-FAA5-4B8A-804F-4DEA2367D495}
{9A183B48-ECC2-4121-876A-9B3793686073} = {9A183B48-ECC2-4121-876A-9B3793686073}
{636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} = {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}
{33546D62-7F34-4EA6-A88E-D538B36E16BF} = {33546D62-7F34-4EA6-A88E-D538B36E16BF}
{11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED}
{3E03C179-8251-46E4-81F4-466F114BAC63} = {3E03C179-8251-46E4-81F4-466F114BAC63}
{823DDC98-42D5-4A38-88CF-9DC06C788AE4} = {823DDC98-42D5-4A38-88CF-9DC06C788AE4}
{0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E}
{521498BE-6089-4780-8223-E67C22F4E068} = {521498BE-6089-4780-8223-E67C22F4E068}
{E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA} = {E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA}
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}
{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77} = {4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}
@ -69,6 +75,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\D
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Debugger", "Core\DebuggerWX\DebuggerWX.vcproj", "{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}"
ProjectSection(ProjectDependencies) = postProject
{F81AE75C-3D17-4D8C-A201-82FA5351C123} = {F81AE75C-3D17-4D8C-A201-82FA5351C123}
{11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED}
{0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E}
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}
@ -153,6 +160,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AudioCommon", "Core\AudioCo
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_DSP_LLE", "Plugins\Plugin_DSP_LLE\Plugin_DSP_LLE.vcproj", "{3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}"
ProjectSection(ProjectDependencies) = postProject
{F81AE75C-3D17-4D8C-A201-82FA5351C123} = {F81AE75C-3D17-4D8C-A201-82FA5351C123}
{11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED}
{FBAFB369-07EB-4460-9CAD-08BE5789DAB6} = {FBAFB369-07EB-4460-9CAD-08BE5789DAB6}
{838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} = {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}
@ -187,6 +195,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTests", "UnitTests\Unit
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DebuggerUICommon", "Core\DebuggerUICommon\DebuggerUICommon.vcproj", "{F81AE75C-3D17-4D8C-A201-82FA5351C123}"
ProjectSection(ProjectDependencies) = postProject
{11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED}
{0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E}
{1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -629,16 +645,35 @@ Global
{823DDC98-42D5-4A38-88CF-9DC06C788AE4}.Release|x64.ActiveCfg = Release|x64
{823DDC98-42D5-4A38-88CF-9DC06C788AE4}.Release|x64.Build.0 = Release|x64
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Debug|Win32.ActiveCfg = Debug|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Debug|x64.ActiveCfg = Debug|x64
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Debug|Win32.Build.0 = Debug|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Debug|x64.ActiveCfg = Debug|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.DebugFast|Win32.ActiveCfg = Debug|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.DebugFast|x64.ActiveCfg = Debug|x64
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.DebugFast|Win32.Build.0 = Debug|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.DebugFast|x64.ActiveCfg = DebugFast|x64
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.DebugFast|x64.Build.0 = DebugFast|x64
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Release_JITIL|Win32.ActiveCfg = Release|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Release_JITIL|Win32.Build.0 = Release|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Release_JITIL|x64.ActiveCfg = Release|x64
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Release_JITIL|x64.ActiveCfg = Release|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Release|Win32.ActiveCfg = Release|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Release|Win32.Build.0 = Release|Win32
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Release|x64.ActiveCfg = Release|x64
{40C636FA-B5BF-4D67-ABC8-376B524A7551}.Release|x64.Build.0 = Release|x64
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Debug|Win32.ActiveCfg = Debug|Win32
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Debug|Win32.Build.0 = Debug|Win32
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Debug|x64.ActiveCfg = Debug|x64
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Debug|x64.Build.0 = Debug|x64
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.DebugFast|Win32.ActiveCfg = Debug|Win32
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.DebugFast|Win32.Build.0 = Debug|Win32
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.DebugFast|x64.ActiveCfg = DebugFast|x64
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.DebugFast|x64.Build.0 = DebugFast|x64
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Release_JITIL|Win32.ActiveCfg = Release|Win32
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Release_JITIL|Win32.Build.0 = Release|Win32
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Release_JITIL|x64.ActiveCfg = Release|x64
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Release_JITIL|x64.Build.0 = Release|x64
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Release|Win32.ActiveCfg = Release|Win32
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Release|Win32.Build.0 = Release|Win32
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Release|x64.ActiveCfg = Release|x64
{F81AE75C-3D17-4D8C-A201-82FA5351C123}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -9,6 +9,7 @@
#include "ExportProlog.h"
typedef unsigned char (*TARAM_Read_U8)(const unsigned int _uAddress);
typedef void (*TARAM_Write_U8)(const unsigned char _uValue, const unsigned int _uAddress);
typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _uAddress);
typedef unsigned char* (*TGetARAMPointer)(void);
typedef void (*TLogv)(const char* _szMessage, int _v);
@ -21,6 +22,7 @@ typedef struct
{
void *hWnd;
TARAM_Read_U8 pARAM_Read_U8;
TARAM_Write_U8 pARAM_Write_U8;
TGetMemoryPointer pGetMemoryPointer;
TGetARAMPointer pGetARAMPointer;
TLogv pLog;

View File

@ -120,19 +120,22 @@ void CUCode_Zelda::UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _
{
u16* pTest = (u16*)&_rPB;
// Checks at 0293
if (pTest[0x00] == 0)
return;
if (pTest[0x01] != 0)
return;
if (pTest[0x06] != 0x00)
{
// probably pTest[0x06] == 0 -> AFC (and variants)
// See 02a4
}
else
{
switch(_rPB.type) // or Bytes per Sample
switch (_rPB.type) // or Bytes per Sample
{
case 0x05:
case 0x09:
@ -140,6 +143,10 @@ void CUCode_Zelda::UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _
// initialize "decoder" if the sample is played the first time
if (pTest[0x04] != 0)
{
// This is 0717_ReadOutPBStuff
// increment 4fb
// zelda:
// perhaps init or "has played before"
pTest[0x32] = 0x00;
@ -151,7 +158,7 @@ void CUCode_Zelda::UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _
pTest[0x3a] = pTest[0x8a];
pTest[0x3b] = pTest[0x8b];
// copy ARAM addr from r to rw area
// Copy ARAM addr from r to rw area.
pTest[0x38] = pTest[0x8c];
pTest[0x39] = pTest[0x8d];
}
@ -177,20 +184,19 @@ void CUCode_Zelda::UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _
// Then, resample from this buffer to the output as you go. When it needs
// wrapping, decode more.
#define USE_RESAMPLE 1
#if USE_RESAMPLE != 1
for (int s=0; s<(_Size/16);s++)
#define USE_RESAMPLE
#if !defined(USE_RESAMPLE)
for (int s = 0; s < _Size/16; s++)
{
for (int i=0; i<9; i++)
for (int i = 0; i < 9; i++)
{
inBuffer[i] = g_dspInitialize.pARAM_Read_U8(ARAMAddr);
inBuffer[i] = g_dspInitialize.pARAM_Read_U8(ARAMAddr);
ARAMAddr++;
}
AFCdecodebuffer((char*)inBuffer, outbuf, (short*)&pTest[0x66], (short*)&pTest[0x67]);
for (int i=0; i<16; i++)
for (int i = 0; i < 16; i++)
{
templbuffer[sampleCount] += outbuf[i];
temprbuffer[sampleCount] += outbuf[i];
@ -218,7 +224,7 @@ void CUCode_Zelda::UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _
{
int sample = Sampler.sample_queue.front();
Sampler.sample_queue.pop();
Sampler.m_queueSize-=1;
Sampler.m_queueSize -= 1;
templbuffer[sampleCount] += sample;
temprbuffer[sampleCount] += sample;
@ -273,10 +279,17 @@ void CUCode_Zelda::UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _
// end of block (Zelda 03b2)
if (pTest[0x06] == 0)
{
// 02a4
//
pTest[0x04] = 0;
}
}
break;
default:
ERROR_LOG(DSPHLE, "Zelda Ucode: Unknown PB type %i", _rPB.type);
break;
}
}
}

View File

@ -61,7 +61,7 @@ IUCode* UCodeFactory(u32 _CRC, CMailHandler& _rMailHandler)
// return new CUCode_Zelda(_rMailHandler, false);
case 0x6CA33A6D: // DK Jungle Beat
case 0x86840740: // Zelda WW
case 0x86840740: // Zelda WW - US
case 0x56d36052: // Mario Sunshine
case 0x2fcdf1ec: // Mario Kart, zelda 4 swords
INFO_LOG(CONSOLE, "Zelda ucode chosen\n");

View File

@ -45,7 +45,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Debugger\Src;../../Core/DebuggerUICommon/Src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DSP_LLE_TEST_EXPORTS;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -132,7 +132,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Debugger\Src;../../Core/DebuggerUICommon/Src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DSP_LLE_TEST_EXPORTS;_SECURE_SCL=0"
MinimalRebuild="false"
BasicRuntimeChecks="0"
@ -222,7 +222,7 @@
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Debugger\Src;../../Core/DebuggerUICommon/Src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSP_LLE_TEST_EXPORTS;_SECURE_SCL=0"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="2"
@ -314,7 +314,7 @@
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Debugger\Src;../../Core/DebuggerUICommon/Src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSP_LLE_TEST_EXPORTS;_SECURE_SCL=0"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
@ -403,8 +403,8 @@
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSP_LLE_TEST_EXPORTS;DEBUGFAST;_SECURE_SCL=0"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Debugger\Src;../../Core/DebuggerUICommon/Src"
PreprocessorDefinitions="LOGGING;WIN32;NDEBUG;_WINDOWS;_USRDLL;DSP_LLE_TEST_EXPORTS;DEBUGFAST;_SECURE_SCL=0"
RuntimeLibrary="0"
EnableEnhancedInstructionSet="2"
UsePrecompiledHeader="2"
@ -495,8 +495,8 @@
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSP_LLE_TEST_EXPORTS;DEBUGFAST;_SECURE_SCL=0"
AdditionalIncludeDirectories="../../Core/DSPCore/Src;../../Core/Common/Src;../../PluginSpecs;../../Core/AudioCommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\Core\Debugger\Src;../../Core/DebuggerUICommon/Src"
PreprocessorDefinitions="LOGGING;WIN32;NDEBUG;_WINDOWS;_USRDLL;DSP_LLE_TEST_EXPORTS;DEBUGFAST;_SECURE_SCL=0"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
AssemblerListingLocation="$(IntDir)\"
@ -826,6 +826,14 @@
RelativePath=".\Src\Debugger\DSPRegisterView.h"
>
</File>
<File
RelativePath=".\Src\DSPSymbols.cpp"
>
</File>
<File
RelativePath=".\Src\DSPSymbols.h"
>
</File>
</Filter>
<File
RelativePath=".\Src\Config.cpp"
@ -835,14 +843,6 @@
RelativePath=".\Src\Config.h"
>
</File>
<File
RelativePath="..\..\Core\DSPCore\Src\DSPConfigDlgLLE.cpp"
>
</File>
<File
RelativePath="..\..\Core\DSPCore\Src\DSPConfigDlgLLE.h"
>
</File>
<File
RelativePath=".\Src\DSPHost.cpp"
>

View File

@ -20,69 +20,42 @@
#include "DSPCore.h"
#include "disassemble.h"
#include "DSPSymbols.h"
#include "gdsp_memory.h"
void DSPDebugInterface::disasm(unsigned int address, char *dest, int max_size)
{
AssemblerSettings settings;
settings.print_tabs = true;
u16 pc = address;
DSPDisassembler dis(settings);
u16 base = 0;
const u16 *binbuf = g_dsp.iram;
if (pc & 0x8000)
{
binbuf = g_dsp.irom;
base = 0x8000;
}
std::string text;
dis.DisOpcode(binbuf, base, 2, &pc, text);
strncpy(dest, text.c_str(), max_size);
dest[max_size - 1] = '\0';
/*
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
if (Memory::IsRAMAddress(address, true))
{
u32 op = Memory::Read_Instruction(address);
DisassembleGekko(op, address, dest, max_size);
UGeckoInstruction inst;
inst.hex = Memory::ReadUnchecked_U32(address);
if (inst.OPCD == 1) {
strcat(dest, " (hle)");
}
}
else
{
strcpy(dest, "(No RAM here)");
}
}
else
{
strcpy(dest, "<unknown>");
}*/
// we'll treat addresses as line numbers.
strncpy(dest, DSPSymbols::GetLineText(address), max_size);
dest[max_size-1] = 0;
}
void DSPDebugInterface::getRawMemoryString(int memory, unsigned int address, char *dest, int max_size)
{
/*
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
if (Memory::IsRAMAddress(address, true))
{
snprintf(dest, max_size, "%08X", readMemory(address));
switch (memory) {
case 0: // IMEM
switch (address >> 12) {
case 0:
case 0x8:
sprintf(dest, "%04x", dsp_imem_read(address));
break;
default:
sprintf(dest, "----");
break;
}
else
{
strcpy(dest, "--------");
break;
case 1: // DMEM
switch (address >> 12) {
case 0:
case 1:
sprintf(dest, "%04x", dsp_dmem_read(address));
break;
default:
sprintf(dest, "----");
break;
}
break;
}
else
{
strcpy(dest, "<unknwn>"); // bad spelling - 8 chars
}*/
}
unsigned int DSPDebugInterface::readMemory(unsigned int address)
@ -129,19 +102,14 @@ void DSPDebugInterface::toggleBreakpoint(unsigned int address)
void DSPDebugInterface::insertBLR(unsigned int address)
{
// Memory::Write_U32(0x4e800020, address);
}
// =======================================================
// Separate the blocks with colors.
// -------------
int DSPDebugInterface::getColor(unsigned int address)
{
return 0xEEEEEE;
/*
if (!Memory::IsRAMAddress(address, true))
return 0xeeeeee;
static const int colors[6] =
{
0xd0FFFF, // light cyan
@ -152,29 +120,42 @@ int DSPDebugInterface::getColor(unsigned int address)
0xFFFFd0, // light yellow
};
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(address);
// Scan backwards so we don't miss it. Hm, actually, let's not - it looks pretty good.
int addr = -1;
for (int i = 0; i < 1; i++)
{
addr = DSPSymbols::Line2Addr(address - i);
if (addr >= 0)
break;
}
if (addr == -1)
return 0xFFFFFF;
Symbol *symbol = DSPSymbols::g_dsp_symbol_db.GetSymbolFromAddr(addr);
if (!symbol)
return 0xFFFFFF;
if (symbol->type != Symbol::SYMBOL_FUNCTION)
return 0xEEEEFF;
return colors[symbol->index % 6];*/
return colors[symbol->index % 6];
}
// =============
std::string DSPDebugInterface::getDescription(unsigned int address)
{
return "asdf"; // g_symbolDB.GetDescription(address);
return ""; // g_symbolDB.GetDescription(address);
}
unsigned int DSPDebugInterface::getPC()
{
return 0;
return DSPSymbols::Addr2Line(g_dsp.pc);
}
void DSPDebugInterface::setPC(unsigned int address)
{
//PowerPC::ppcState.pc = address;
int new_pc = DSPSymbols::Line2Addr(address);
if (new_pc > 0)
g_dsp.pc = new_pc;
}
void DSPDebugInterface::runToBreakpoint()

View File

@ -3,7 +3,7 @@
#include <string>
#include "../../../Core/Core/Src/Debugger/DebugInterface.h"
#include "DebugInterface.h"
class DSPDebugInterface : public DebugInterface
{
@ -11,7 +11,7 @@ public:
DSPDebugInterface(){}
virtual void disasm(unsigned int address, char *dest, int max_size);
virtual void getRawMemoryString(int memory, unsigned int address, char *dest, int max_size);
virtual int getInstructionSize(int instruction) {return 2;}
virtual int getInstructionSize(int instruction) {return 1;}
virtual bool isAlive();
virtual bool isBreakpoint(unsigned int address);
virtual void setBreakpoint(unsigned int address);

View File

@ -17,6 +17,7 @@
#include "Common.h"
#include "DSPHost.h"
#include "DSPSymbols.h"
#include "Tools.h"
#include "pluginspecs_dsp.h"
@ -32,6 +33,11 @@ u8 DSPHost_ReadHostMemory(u32 addr)
return g_dspInitialize.pARAM_Read_U8(addr);
}
void DSPHost_WriteHostMemory(u8 value, u32 addr)
{
g_dspInitialize.pARAM_Write_U8(value, addr);
}
bool DSPHost_OnThread()
{
return g_dspInitialize.bOnThread;
@ -46,5 +52,29 @@ u32 DSPHost_CodeLoaded(const u8 *ptr, int size)
{
u32 crc = GenerateCRC(ptr, size);
DumpDSPCode(ptr, size, crc);
// this crc is comparable with the HLE plugin
u32 ector_crc = 0;
for (u32 i = 0; i < size; i++)
{
ector_crc ^= ptr[i];
//let's rol
ector_crc = (ector_crc << 3) | (ector_crc >> 29);
}
DSPSymbols::Clear();
// Auto load text file - if none just disassemble.
// TODO: Don't hardcode for Zelda.
NOTICE_LOG(DSPLLE, "CRC: %08x", ector_crc);
if (!DSPSymbols::ReadAnnotatedAssembly("../../Docs/DSP/DSP_UC_Zelda.txt"))
{
DSPSymbols::Clear();
DSPSymbols::AutoDisassembly(0x0, 0x1000);
}
// Always add the ROM.
DSPSymbols::AutoDisassembly(0x8000, 0x9000);
return crc;
}

View File

@ -0,0 +1,287 @@
// Copyright (C) 2003-2009 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 <iostream> // I hope this doesn't break anything
#include <stdio.h>
#include <stdarg.h>
#include <list>
#include <map>
#include <string>
#include "Common.h"
#include "StringUtil.h"
#include "DSPCore.h"
#include "DSPSymbols.h"
#include "disassemble.h"
namespace DSPSymbols {
DSPSymbolDB g_dsp_symbol_db;
std::map<u16, int> addr_to_line;
std::map<int, u16> line_to_addr;
std::map<int, const char *> line_to_symbol;
std::vector<std::string> lines;
int line_counter = 0;
int Addr2Line(u16 address) // -1 for not found
{
std::map<u16, int>::iterator iter = addr_to_line.find(address);
if (iter != addr_to_line.end())
return iter->second;
else
return -1;
}
int Line2Addr(int line) // -1 for not found
{
std::map<int, u16>::iterator iter = line_to_addr.find(line);
if (iter != line_to_addr.end())
return iter->second;
else
return -1;
}
const char *GetLineText(int line)
{
if (line > 0 && line < (int)lines.size())
{
return lines[line].c_str();
}
else
return "----";
}
Symbol *DSPSymbolDB::GetSymbolFromAddr(u32 addr)
{
XFuncMap::iterator it = functions.find(addr);
if (it != functions.end())
return &it->second;
else
{
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); iter++)
{
if (addr >= iter->second.address && addr < iter->second.address + iter->second.size)
return &iter->second;
}
}
return 0;
}
// lower case only
bool IsHexDigit(char c) {
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
return true;
default:
return false;
}
}
bool IsAlpha(char c) {
return (c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z');
}
void DisasssembleRange(u16 start, u16 end)
{
}
bool ReadAnnotatedAssembly(const char *filename)
{
FILE *f = fopen(filename, "r");
if (!f) {
ERROR_LOG(DSPLLE, "Bah! ReadAnnotatedAssembly couldn't find the file %s", filename);
return false;
}
char line[512];
int last_addr = 0;
lines.reserve(3000);
// Symbol generation
int brace_count = 0;
bool symbol_in_progress = false;
int symbol_count = 0;
Symbol current_symbol;
while (fgets(line, 512, f))
{
// Scan string for the first 4-digit hex string.
size_t len = strlen(line);
int first_hex = -1;
bool hex_found = false;
for (unsigned int i = 0; i < strlen(line); i++)
{
const char c = line[i];
if (IsHexDigit(c))
{
if (first_hex == -1)
{
first_hex = i;
}
else
{
// Remove hex notation
if (i == first_hex + 3 &&
(first_hex == 0 || line[first_hex - 1] != 'x') &&
(i >= len - 1 || line[i + 1] == ' '))
{
hex_found = true;
break;
}
}
} else {
if (i - first_hex < 3)
{
first_hex = -1;
}
if (IsAlpha(c))
break;
}
}
// Scan for function starts
if (!memcmp(line, "void", 4)) {
char temp[256];
for (int i = 6; i < len; i++) {
if (line[i] == '(') {
// Yep, got one.
memcpy(temp, line + 5, i - 5);
temp[i - 5] = 0;
// Mark symbol so the next hex sets the address
current_symbol.name = temp;
current_symbol.address = 0xFFFF;
current_symbol.index = symbol_count++;
symbol_in_progress = true;
// Reset brace count.
brace_count = 0;
}
}
}
// Scan for braces
for (int i = 0; i < (int)len; i++) {
if (line[i] == '{')
brace_count++;
if (line[i] == '}')
{
brace_count--;
if (brace_count == 0 && symbol_in_progress) {
// Commit this symbol.
current_symbol.size = last_addr - current_symbol.address + 1;
g_dsp_symbol_db.AddCompleteSymbol(current_symbol);
current_symbol.address = 0xFFFF;
symbol_in_progress = false;
}
}
}
if (hex_found)
{
int hex = 0;
sscanf(line + first_hex, "%04x", &hex);
// Sanity check
if (hex > last_addr + 3 || hex < last_addr - 3) {
static int errors = 0;
ERROR_LOG(DSPLLE, "Got Insane Hex Digit %04x (%04x) from %s", hex, last_addr, line);
errors++;
if (errors > 10)
{
fclose(f);
return false;
}
}
else
{
// if (line_counter >= 200 && line_counter <= 220)
// NOTICE_LOG(DSPLLE, "Got Hex Digit %04x from %s, line %i", hex, line, line_counter);
if (symbol_in_progress && current_symbol.address == 0xFFFF)
current_symbol.address = hex;
line_to_addr[line_counter] = hex;
addr_to_line[hex] = line_counter;
last_addr = hex;
}
}
lines.push_back(TabsToSpaces(4, line));
line_counter++;
}
fclose(f);
return true;
}
void AutoDisassembly(u16 start_addr, u16 end_addr)
{
AssemblerSettings settings;
settings.show_pc = true;
settings.show_hex = true;
DSPDisassembler disasm(settings);
u16 addr = start_addr;
const u16 *ptr = (start_addr >> 15) ? g_dsp.irom : g_dsp.iram;
while (addr < end_addr)
{
line_to_addr[line_counter] = addr;
addr_to_line[addr] = line_counter;
std::string buf;
if (!disasm.DisOpcode(ptr, 0, 2, &addr, buf))
{
ERROR_LOG(DSPLLE, "disasm failed at %04x", addr);
break;
}
//NOTICE_LOG(DSPLLE, "added %04x %i %s", addr, line_counter, buf.c_str());
lines.push_back(buf);
line_counter++;
}
}
void Clear()
{
addr_to_line.clear();
line_to_addr.clear();
lines.clear();
line_counter = 0;
}
} // namespace DSPSymbols

View File

@ -0,0 +1,54 @@
// Copyright (C) 2003-2009 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 _DSPSYMBOLS_H
#define _DSPSYMBOLS_H
#include "Common.h"
#include "SymbolDB.h"
#include "AudioCommon.h"
#include <stdio.h>
namespace DSPSymbols {
class DSPSymbolDB : public SymbolDB
{
public:
DSPSymbolDB() {}
~DSPSymbolDB() {}
Symbol *GetSymbolFromAddr(u32 addr);
};
extern DSPSymbolDB g_dsp_symbol_db;
bool ReadAnnotatedAssembly(const char *filename);
void AutoDisassembly(u16 start_addr, u16 end_addr);
void Clear();
int Addr2Line(u16 address);
int Line2Addr(int line); // -1 for not found
const char *GetLineText(int line);
} // namespace DSPSymbols
#endif

View File

@ -22,6 +22,8 @@
#include "Debugger.h"
#include "DSPRegisterView.h"
#include "CodeView.h"
#include "../DSPSymbols.h"
// Event table and class
BEGIN_EVENT_TABLE(DSPDebuggerLLE, wxFrame)
@ -29,9 +31,8 @@ BEGIN_EVENT_TABLE(DSPDebuggerLLE, wxFrame)
EVT_MENU_RANGE(ID_RUNTOOL, ID_STEPTOOL, DSPDebuggerLLE::OnChangeState)
EVT_MENU(ID_SHOWPCTOOL, DSPDebuggerLLE::OnShowPC)
EVT_LIST_ITEM_RIGHT_CLICK(ID_DISASM, DSPDebuggerLLE::OnRightClick)
EVT_LIST_ITEM_ACTIVATED(ID_DISASM, DSPDebuggerLLE::OnDoubleClick)
EVT_TEXT(ID_ADDRBOX, DSPDebuggerLLE::OnAddrBoxChange)
EVT_LISTBOX(ID_SYMBOLLIST, DSPDebuggerLLE::OnSymbolListChange)
END_EVENT_TABLE()
DSPDebuggerLLE::DSPDebuggerLLE(wxWindow *parent, wxWindowID id, const wxString &title,
@ -59,18 +60,29 @@ void DSPDebuggerLLE::CreateGUIControls()
m_Toolbar = CreateToolBar(wxTB_NODIVIDER|wxTB_NOICONS|wxTB_HORZ_TEXT|wxTB_DOCKABLE, ID_TOOLBAR);
m_Toolbar->AddTool(ID_RUNTOOL, wxT("Run"), wxNullBitmap, wxEmptyString, wxITEM_NORMAL);
m_Toolbar->AddTool(ID_STEPTOOL, wxT("Step"), wxNullBitmap, wxT("Step Code "), wxITEM_NORMAL);
m_Toolbar->AddTool(ID_SHOWPCTOOL, wxT("Show Pc"), wxNullBitmap, wxT("Reset To PC counter"), wxITEM_NORMAL);
m_Toolbar->AddTool(ID_SHOWPCTOOL, wxT("Show Pc"), wxNullBitmap, wxT("Show where PC is"), wxITEM_NORMAL);
m_Toolbar->AddTool(ID_JUMPTOTOOL, wxT("Jump"), wxNullBitmap, wxT("Jump to a specific Address"), wxITEM_NORMAL);
m_Toolbar->AddSeparator();
m_Toolbar->AddCheckTool(ID_CHECK_ASSERTINT, wxT("AssertInt"), wxNullBitmap, wxNullBitmap, wxEmptyString);
m_Toolbar->AddCheckTool(ID_CHECK_HALT, wxT("Halt"), wxNullBitmap, wxNullBitmap, wxEmptyString);
m_Toolbar->AddCheckTool(ID_CHECK_INIT, wxT("Init"), wxNullBitmap, wxNullBitmap, wxEmptyString);
m_Toolbar->AddSeparator();
m_Toolbar->AddControl(new wxTextCtrl(m_Toolbar, ID_ADDRBOX, _T("")));
m_Toolbar->Realize();
wxBoxSizer* sMain = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
sizerLeft->Add(m_SymbolList = new wxListBox(this, ID_SYMBOLLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND);
m_Disasm = new wxListCtrl(this, ID_DISASM, wxDefaultPosition, wxDefaultSize, wxLC_REPORT);
sMain->Add(m_Disasm, 4, wxALL|wxEXPAND, 5);
m_CodeView = new CCodeView(&debug_interface, &DSPSymbols::g_dsp_symbol_db, this, ID_CODEVIEW);
m_CodeView->SetPlain();
sMain->Add(sizerLeft, 1, wxALL|wxEXPAND, 0);
sMain->Add(m_CodeView, 4, wxALL|wxEXPAND, 5);
wxStaticLine* m_staticline = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL);
sMain->Add(m_staticline, 0, wxEXPAND|wxALL, 5);
@ -80,15 +92,6 @@ void DSPDebuggerLLE::CreateGUIControls()
this->SetSizer(sMain);
this->Layout();
// Add the disasm columns
m_Disasm->InsertColumn(COLUMN_BP, wxT("BP"), wxLIST_FORMAT_LEFT, 25);
m_Disasm->InsertColumn(COLUMN_FUNCTION, wxT("Function"), wxLIST_FORMAT_LEFT, 160);
m_Disasm->InsertColumn(COLUMN_ADDRESS, wxT("Address"), wxLIST_FORMAT_LEFT, 55);
m_Disasm->InsertColumn(COLUMN_MNEMONIC, wxT("Mnemonic"), wxLIST_FORMAT_LEFT, 55);
m_Disasm->InsertColumn(COLUMN_OPCODE, wxT("Opcode"), wxLIST_FORMAT_LEFT, 60);
m_Disasm->InsertColumn(COLUMN_EXT, wxT("Ext"), wxLIST_FORMAT_LEFT, 40);
m_Disasm->InsertColumn(COLUMN_PARAM, wxT("Param"), wxLIST_FORMAT_LEFT, 500);
}
void DSPDebuggerLLE::OnClose(wxCloseEvent& event)
@ -110,6 +113,9 @@ void DSPDebuggerLLE::OnChangeState(wxCommandEvent& event)
case ID_STEPTOOL:
m_State = STEP;
break;
case ID_SHOWPCTOOL:
FocusOnPC();
break;
}
UpdateState();
@ -121,27 +127,6 @@ void DSPDebuggerLLE::OnShowPC(wxCommandEvent& event)
FocusOnPC();
}
void DSPDebuggerLLE::OnRightClick(wxListEvent& event)
{
long item = m_Disasm->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
u16 SelectedPC = static_cast<u16>(m_Disasm->GetItemData(item));
g_dsp.pc = SelectedPC;
Refresh();
}
void DSPDebuggerLLE::OnDoubleClick(wxListEvent& event)
{
long item = m_Disasm->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
u16 SelectedPC = static_cast<u16>(m_Disasm->GetItemData(item));
ToggleBreakPoint(SelectedPC);
if (IsBreakPoint(SelectedPC))
m_Disasm->SetItem(item, COLUMN_BP, wxT("*"));
else
m_Disasm->SetItem(item, COLUMN_BP, wxT(""));
}
void DSPDebuggerLLE::Refresh()
{
UpdateSymbolMap();
@ -152,26 +137,7 @@ void DSPDebuggerLLE::Refresh()
void DSPDebuggerLLE::FocusOnPC()
{
UnselectAll();
for (int i = 0; i < m_Disasm->GetItemCount(); i++)
{
if (m_Disasm->GetItemData(i) == g_dsp.pc)
{
m_Disasm->EnsureVisible(i - 5);
m_Disasm->EnsureVisible(i + 5);
m_Disasm->SetItemState(i, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED);
break;
}
}
}
void DSPDebuggerLLE::UnselectAll()
{
for (int i = 0; i < m_Disasm->GetItemCount(); i++)
{
m_Disasm->SetItemState(i, 0, wxLIST_STATE_SELECTED);
}
JumpToAddress(g_dsp.pc);
}
void DSPDebuggerLLE::UpdateState()
@ -183,129 +149,14 @@ void DSPDebuggerLLE::UpdateState()
m_Toolbar->Realize();
}
void DSPDebuggerLLE::RebuildDisAsmListView()
{
m_Disasm->Freeze();
m_Disasm->DeleteAllItems();
AssemblerSettings settings;
const u16 *binbuf;
if (g_dsp.pc & 0x8000)
binbuf = g_dsp.irom;
else
binbuf = g_dsp.iram;
settings.ext_separator = (char)0xff;
settings.show_pc = false;
settings.show_hex = false;
settings.print_tabs = true;
settings.decode_names = true;
settings.decode_registers = true;
for (settings.pc = 0; settings.pc < DSP_IROM_SIZE;)
{
u16 CurrentPC = settings.pc;
if (g_dsp.pc & 0x8000)
CurrentPC |= 0x8000;
char Temp[256];
sprintf(Temp, "0x%04x", CurrentPC);
char Temp2[256];
sprintf(Temp2, "0x%04x", dsp_imem_read(CurrentPC));
DSPDisassembler disasm(settings);
std::string op_str;
disasm.DisOpcode(binbuf, settings.pc & 0x8000, 2, &settings.pc, op_str);
const char* pParameter = NULL;
const char* pExtension = NULL;
size_t WholeString = op_str.size();
/*
for (size_t i = 0; i < WholeString; i++)
{
if (pOpcode[i] == (char)0xff)
{
pOpcode[i] = 0x00;
pExtension = &pOpcode[i + 1];
}
if (pOpcode[i] == 0x09)
{
pOpcode[i] = 0x00;
pParameter = &pOpcode[i + 1];
}
}*/
const char* pFunctionName = NULL;
if (m_SymbolMap.find(CurrentPC) != m_SymbolMap.end())
{
pFunctionName = m_SymbolMap[CurrentPC].Name.c_str();
}
int Item = m_Disasm->InsertItem(settings.pc, wxEmptyString);
m_Disasm->SetItem(Item, COLUMN_BP, wxEmptyString);
m_Disasm->SetItem(Item, COLUMN_FUNCTION, wxString::FromAscii(pFunctionName));
m_Disasm->SetItem(Item, COLUMN_ADDRESS, wxString::FromAscii(Temp));
m_Disasm->SetItem(Item, COLUMN_MNEMONIC, wxString::FromAscii(Temp2));
m_Disasm->SetItem(Item, COLUMN_OPCODE, wxString::FromAscii(op_str.c_str()));
m_Disasm->SetItem(Item, COLUMN_EXT, wxString::FromAscii(pExtension));
if (!strcasecmp(op_str.c_str(), "CALL"))
{
u32 FunctionAddress = -1;
sscanf(pParameter, "0x%04x", &FunctionAddress);
if (m_SymbolMap.find(FunctionAddress) != m_SymbolMap.end())
{
pParameter = m_SymbolMap[FunctionAddress].Name.c_str();
}
}
m_Disasm->SetItem(Item, COLUMN_PARAM, wxString::FromAscii(pParameter));
m_Disasm->SetItemData(Item, CurrentPC);
}
// m_Disasm->SortItems(CompareFunc, this); // TODO verify
m_Disasm->Thaw();
}
void DSPDebuggerLLE::UpdateDisAsmListView()
{
if (g_dsp.dram == NULL)
return;
// check if we have to rebuild the list view
if (m_Disasm->GetItemCount() == 0)
{
RebuildDisAsmListView();
}
else
{
u16 FirstPC = static_cast<u16>(m_Disasm->GetItemData(0)); // TODO verify
if ((FirstPC & 0x8000) != (g_dsp.pc & 0x8000))
{
RebuildDisAsmListView();
}
}
if (m_CachedStepCounter == g_dsp.step_counter)
return;
// show PC
FocusOnPC();
m_CachedStepCounter = g_dsp.step_counter;
m_Regs->Update();
}
@ -320,10 +171,36 @@ void DSPDebuggerLLE::UpdateSymbolMap()
m_CachedUCodeCRC = g_dsp.iram_crc;
char FileName[256];
sprintf(FileName, "%sDSP_%08x.map", FULL_MAPS_DIR, m_CachedUCodeCRC);
LoadSymbolMap(FileName);
// LoadSymbolMap(FileName);
m_SymbolList->Freeze(); // HyperIris: wx style fast filling
m_SymbolList->Clear();
for (SymbolDB::XFuncMap::iterator iter = DSPSymbols::g_dsp_symbol_db.GetIterator();
iter != DSPSymbols::g_dsp_symbol_db.End(); iter++)
{
int idx = m_SymbolList->Append(wxString::FromAscii(iter->second.name.c_str()));
m_SymbolList->SetClientData(idx, (void*)&iter->second);
}
m_SymbolList->Thaw();
// rebuild the disasm
RebuildDisAsmListView();
// RebuildDisAsmListView();
}
}
void DSPDebuggerLLE::OnSymbolListChange(wxCommandEvent& event)
{
int index = m_SymbolList->GetSelection();
if (index >= 0) {
Symbol* pSymbol = static_cast<Symbol *>(m_SymbolList->GetClientData(index));
if (pSymbol != NULL)
{
if (pSymbol->type == Symbol::SYMBOL_FUNCTION)
{
JumpToAddress(pSymbol->address);
}
}
}
}
@ -351,13 +228,13 @@ bool DSPDebuggerLLE::CanDoStep()
return true;
case RUN:
/*
if (IsBreakPoint(g_dsp.pc))
{
Refresh();
m_State = PAUSE;
return false;
}
}*/
return true;
@ -379,89 +256,32 @@ void DSPDebuggerLLE::DebugBreak()
m_State = PAUSE;
}
bool DSPDebuggerLLE::IsBreakPoint(u16 _Address)
void DSPDebuggerLLE::OnAddrBoxChange(wxCommandEvent& event)
{
return(std::find(m_BreakPoints.begin(), m_BreakPoints.end(), _Address) != m_BreakPoints.end());
}
wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(ID_ADDRBOX);
wxString txt = pAddrCtrl->GetValue();
void DSPDebuggerLLE::ToggleBreakPoint(u16 _Address)
{
if (IsBreakPoint(_Address))
RemoveBreakPoint(_Address);
else
AddBreakPoint(_Address);
}
void DSPDebuggerLLE::RemoveBreakPoint(u16 _Address)
{
CBreakPointList::iterator itr = std::find(m_BreakPoints.begin(), m_BreakPoints.end(), _Address);
if (itr != m_BreakPoints.end())
m_BreakPoints.erase(itr);
}
void DSPDebuggerLLE::AddBreakPoint(u16 _Address)
{
CBreakPointList::iterator itr = std::find(m_BreakPoints.begin(), m_BreakPoints.end(), _Address);
if (itr == m_BreakPoints.end())
m_BreakPoints.push_back(_Address);
}
void DSPDebuggerLLE::ClearBreakPoints()
{
m_BreakPoints.clear();
}
bool DSPDebuggerLLE::LoadSymbolMap(const char* _pFileName)
{
m_SymbolMap.clear();
FILE* pFile = fopen(_pFileName, "r");
if (!pFile)
return false;
char Name[1024];
u32 AddressStart, AddressEnd;
while (!feof(pFile))
std::string text(txt.mb_str());
text = StripSpaces(text);
if (text.size())
{
char line[512];
fgets(line, 511, pFile);
if (strlen(line) < 2)
continue;
// check for comment
if (line[0] == '.')
continue;
// clear all breakpoints
if (line[0] == 'C')
{
ClearBreakPoints();
continue;
}
// add breakpoint
if (line[0] == 'B')
{
sscanf(line, "B %04x", &AddressStart);
AddBreakPoint(static_cast<u16>(AddressStart));
continue;
}
// default add new symbol
sscanf(line, "%04x %04x %s", &AddressStart, &AddressEnd, Name);
if (m_SymbolMap.find(AddressStart) == m_SymbolMap.end())
m_SymbolMap.insert(std::pair<u16, SSymbol>(AddressStart, SSymbol(AddressStart, AddressEnd, Name)));
u32 addr;
sscanf(text.c_str(), "%04x", &addr);
if (JumpToAddress(addr))
pAddrCtrl->SetBackgroundColour(*wxWHITE);
else
m_SymbolMap[AddressStart] = SSymbol(AddressStart, AddressEnd, Name);
pAddrCtrl->SetBackgroundColour(*wxRED);
}
event.Skip(1);
}
bool DSPDebuggerLLE::JumpToAddress(u16 addr)
{
int new_line = DSPSymbols::Addr2Line(addr);
if (new_line >= 0) {
m_CodeView->Center(new_line);
return true;
} else {
return false;
}
fclose(pFile);
return true;
}

View File

@ -37,8 +37,10 @@
#include "disassemble.h"
#include "gdsp_interpreter.h"
#include "gdsp_memory.h"
#include "../DSPDebugInterface.h"
class DSPRegisterView;
class CCodeView;
class DSPDebuggerLLE : public wxFrame
{
@ -66,14 +68,16 @@ private:
ID_RUNTOOL,
ID_STEPTOOL,
ID_SHOWPCTOOL,
ID_ADDRBOX,
ID_JUMPTOTOOL,
ID_DISASMDUMPTOOL,
ID_CHECK_ASSERTINT,
ID_CHECK_HALT,
ID_CHECK_INIT,
ID_SYMBOLLIST,
// Disasm view
ID_DISASM,
// Code view
ID_CODEVIEW,
// Register View
ID_DSP_REGS,
@ -100,58 +104,32 @@ private:
};
EState m_State;
DSPDebugInterface debug_interface;
u64 m_CachedStepCounter;
u16 m_CachedCR;
u32 m_CachedUCodeCRC;
// Break point handling
typedef std::list<u16>CBreakPointList;
CBreakPointList m_BreakPoints;
bool IsBreakPoint(u16 _Address);
void ToggleBreakPoint(u16 _Address);
void RemoveBreakPoint(u16 _Address);
void AddBreakPoint(u16 _Address);
void ClearBreakPoints();
// Symbols
struct SSymbol
{
u32 AddressStart;
u32 AddressEnd;
std::string Name;
SSymbol(u32 _AddressStart = 0, u32 _AddressEnd = 0, char* _Name = NULL)
: AddressStart(_AddressStart)
, AddressEnd(_AddressEnd)
, Name(_Name)
{
}
};
typedef std::map<u16, SSymbol>CSymbolMap;
CSymbolMap m_SymbolMap;
bool LoadSymbolMap(const char* _pFileName);
// GUI updaters
void UpdateDisAsmListView();
void UpdateRegisterFlags();
void UpdateSymbolMap();
void UpdateState();
void RebuildDisAsmListView();
// GUI items
wxToolBar* m_Toolbar;
wxListCtrl* m_Disasm;
CCodeView* m_CodeView;
DSPRegisterView* m_Regs;
wxListBox* m_SymbolList;
void OnClose(wxCloseEvent& event);
void OnChangeState(wxCommandEvent& event);
void OnShowPC(wxCommandEvent& event);
void OnRightClick(wxListEvent& event);
void OnDoubleClick(wxListEvent& event);
void OnAddrBoxChange(wxCommandEvent& event);
void OnSymbolListChange(wxCommandEvent& event);
bool JumpToAddress(u16 addr);
void CreateGUIControls();
void FocusOnPC();

View File

@ -24,6 +24,7 @@
#include "gdsp_interpreter.h"
#include "gdsp_interface.h"
#include "disassemble.h"
#include "DSPSymbols.h"
#include "Config.h"
#include "AudioCommon.h"
@ -163,10 +164,10 @@ void DoState(unsigned char **ptr, int mode)
void DllDebugger(HWND _hParent, bool Show)
{
#if defined(HAVE_WX) && HAVE_WX
if(!m_DebuggerFrame)
if (!m_DebuggerFrame)
m_DebuggerFrame = new DSPDebuggerLLE(NULL);
if(Show)
if (Show)
m_DebuggerFrame->Show();
else
m_DebuggerFrame->Hide();
@ -231,7 +232,7 @@ void Initialize(void *init)
soundStream = AudioCommon::InitSoundStream();
#if defined(HAVE_WX) && HAVE_WX
if(m_DebuggerFrame)
if (m_DebuggerFrame)
m_DebuggerFrame->Refresh();
#endif
}

View File

@ -96,6 +96,7 @@ void StringTests()
EXPECT_EQ(StripNewline(" abc \n "), " abc \n ");
EXPECT_EQ(StripQuotes("\"abc\""), "abc");
EXPECT_EQ(StripQuotes("\"abc\" "), "\"abc\" ");
EXPECT_EQ(TabsToSpaces(4, "a\tb"), "a b");
}
int main(int argc, _TCHAR* argv[])

View File

@ -323,6 +323,161 @@
ExcludedFromBuild="true"
/>
</Configuration>
<Configuration
Name="DebugFast|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="xcopy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\Binary\$(PlatformName)\&quot; /e /s /y /d"
ExcludedFromBuild="true"
/>
</Configuration>
<Configuration
Name="DebugFast|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../Core/Core/Src;../Core/Common/Src;../PluginSpecs;../Core/InputCommon/Src"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="xcopy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)..\Binary\$(PlatformName)\&quot; /e /s /y /d"
ExcludedFromBuild="true"
/>
</Configuration>
</Configurations>
<References>
</References>