mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-25 19:55:50 +00:00
Reformat all the things. Have fun with merge conflicts.
This commit is contained in:
parent
2115e8a4a6
commit
3570c7f03a
1116 changed files with 187405 additions and 180344 deletions
|
@ -11,27 +11,26 @@
|
|||
#include "Core/Core.h"
|
||||
#include "Core/Debugger/Debugger_SymbolMap.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/PowerPC/PPCAnalyst.h"
|
||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
namespace Dolphin_Debugger
|
||||
{
|
||||
|
||||
void AddAutoBreakpoints()
|
||||
{
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#if 1
|
||||
const char *bps[] = {
|
||||
"PPCHalt",
|
||||
};
|
||||
const char* bps[] = {
|
||||
"PPCHalt",
|
||||
};
|
||||
|
||||
for (const char* bp : bps)
|
||||
{
|
||||
Symbol *symbol = g_symbolDB.GetSymbolFromName(bp);
|
||||
if (symbol)
|
||||
PowerPC::breakpoints.Add(symbol->address, false);
|
||||
}
|
||||
for (const char* bp : bps)
|
||||
{
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromName(bp);
|
||||
if (symbol)
|
||||
PowerPC::breakpoints.Add(symbol->address, false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -39,127 +38,123 @@ void AddAutoBreakpoints()
|
|||
// Returns true if the address is not a valid RAM address or NULL.
|
||||
static bool IsStackBottom(u32 addr)
|
||||
{
|
||||
return !addr || !PowerPC::HostIsRAMAddress(addr);
|
||||
return !addr || !PowerPC::HostIsRAMAddress(addr);
|
||||
}
|
||||
|
||||
static void WalkTheStack(const std::function<void(u32)>& stack_step)
|
||||
{
|
||||
if (!IsStackBottom(PowerPC::ppcState.gpr[1]))
|
||||
{
|
||||
u32 addr = PowerPC::HostRead_U32(PowerPC::ppcState.gpr[1]); // SP
|
||||
if (!IsStackBottom(PowerPC::ppcState.gpr[1]))
|
||||
{
|
||||
u32 addr = PowerPC::HostRead_U32(PowerPC::ppcState.gpr[1]); // SP
|
||||
|
||||
// Walk the stack chain
|
||||
for (int count = 0;
|
||||
!IsStackBottom(addr + 4) && (count++ < 20);
|
||||
++count)
|
||||
{
|
||||
u32 func_addr = PowerPC::HostRead_U32(addr + 4);
|
||||
stack_step(func_addr);
|
||||
// Walk the stack chain
|
||||
for (int count = 0; !IsStackBottom(addr + 4) && (count++ < 20); ++count)
|
||||
{
|
||||
u32 func_addr = PowerPC::HostRead_U32(addr + 4);
|
||||
stack_step(func_addr);
|
||||
|
||||
if (IsStackBottom(addr))
|
||||
break;
|
||||
if (IsStackBottom(addr))
|
||||
break;
|
||||
|
||||
addr = PowerPC::HostRead_U32(addr);
|
||||
}
|
||||
}
|
||||
addr = PowerPC::HostRead_U32(addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns callstack "formatted for debugging" - meaning that it
|
||||
// includes LR as the last item, and all items are the last step,
|
||||
// instead of "pointing ahead"
|
||||
bool GetCallstack(std::vector<CallstackEntry> &output)
|
||||
bool GetCallstack(std::vector<CallstackEntry>& output)
|
||||
{
|
||||
if (!Core::IsRunning() || !PowerPC::HostIsRAMAddress(PowerPC::ppcState.gpr[1]))
|
||||
return false;
|
||||
if (!Core::IsRunning() || !PowerPC::HostIsRAMAddress(PowerPC::ppcState.gpr[1]))
|
||||
return false;
|
||||
|
||||
if (LR == 0)
|
||||
{
|
||||
CallstackEntry entry;
|
||||
entry.Name = "(error: LR=0)";
|
||||
entry.vAddress = 0x0;
|
||||
output.push_back(entry);
|
||||
return false;
|
||||
}
|
||||
if (LR == 0)
|
||||
{
|
||||
CallstackEntry entry;
|
||||
entry.Name = "(error: LR=0)";
|
||||
entry.vAddress = 0x0;
|
||||
output.push_back(entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
CallstackEntry entry;
|
||||
entry.Name = StringFromFormat(" * %s [ LR = %08x ]\n", g_symbolDB.GetDescription(LR).c_str(), LR - 4);
|
||||
entry.vAddress = LR - 4;
|
||||
output.push_back(entry);
|
||||
CallstackEntry entry;
|
||||
entry.Name =
|
||||
StringFromFormat(" * %s [ LR = %08x ]\n", g_symbolDB.GetDescription(LR).c_str(), LR - 4);
|
||||
entry.vAddress = LR - 4;
|
||||
output.push_back(entry);
|
||||
|
||||
WalkTheStack([&entry, &output](u32 func_addr) {
|
||||
std::string func_desc = g_symbolDB.GetDescription(func_addr);
|
||||
if (func_desc.empty() || func_desc == "Invalid")
|
||||
func_desc = "(unknown)";
|
||||
entry.Name = StringFromFormat(" * %s [ addr = %08x ]\n",
|
||||
func_desc.c_str(), func_addr - 4);
|
||||
entry.vAddress = func_addr - 4;
|
||||
output.push_back(entry);
|
||||
});
|
||||
WalkTheStack([&entry, &output](u32 func_addr) {
|
||||
std::string func_desc = g_symbolDB.GetDescription(func_addr);
|
||||
if (func_desc.empty() || func_desc == "Invalid")
|
||||
func_desc = "(unknown)";
|
||||
entry.Name = StringFromFormat(" * %s [ addr = %08x ]\n", func_desc.c_str(), func_addr - 4);
|
||||
entry.vAddress = func_addr - 4;
|
||||
output.push_back(entry);
|
||||
});
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrintCallstack()
|
||||
{
|
||||
printf("== STACK TRACE - SP = %08x ==", PowerPC::ppcState.gpr[1]);
|
||||
printf("== STACK TRACE - SP = %08x ==", PowerPC::ppcState.gpr[1]);
|
||||
|
||||
if (LR == 0)
|
||||
{
|
||||
printf(" LR = 0 - this is bad");
|
||||
}
|
||||
if (LR == 0)
|
||||
{
|
||||
printf(" LR = 0 - this is bad");
|
||||
}
|
||||
|
||||
if (g_symbolDB.GetDescription(PC) != g_symbolDB.GetDescription(LR))
|
||||
{
|
||||
printf(" * %s [ LR = %08x ]", g_symbolDB.GetDescription(LR).c_str(), LR);
|
||||
}
|
||||
if (g_symbolDB.GetDescription(PC) != g_symbolDB.GetDescription(LR))
|
||||
{
|
||||
printf(" * %s [ LR = %08x ]", g_symbolDB.GetDescription(LR).c_str(), LR);
|
||||
}
|
||||
|
||||
WalkTheStack([](u32 func_addr) {
|
||||
std::string func_desc = g_symbolDB.GetDescription(func_addr);
|
||||
if (func_desc.empty() || func_desc == "Invalid")
|
||||
func_desc = "(unknown)";
|
||||
printf(" * %s [ addr = %08x ]", func_desc.c_str(), func_addr);
|
||||
});
|
||||
WalkTheStack([](u32 func_addr) {
|
||||
std::string func_desc = g_symbolDB.GetDescription(func_addr);
|
||||
if (func_desc.empty() || func_desc == "Invalid")
|
||||
func_desc = "(unknown)";
|
||||
printf(" * %s [ addr = %08x ]", func_desc.c_str(), func_addr);
|
||||
});
|
||||
}
|
||||
|
||||
void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)
|
||||
{
|
||||
GENERIC_LOG(type, level, "== STACK TRACE - SP = %08x ==",
|
||||
PowerPC::ppcState.gpr[1]);
|
||||
GENERIC_LOG(type, level, "== STACK TRACE - SP = %08x ==", PowerPC::ppcState.gpr[1]);
|
||||
|
||||
if (LR == 0)
|
||||
{
|
||||
GENERIC_LOG(type, level, " LR = 0 - this is bad");
|
||||
}
|
||||
if (LR == 0)
|
||||
{
|
||||
GENERIC_LOG(type, level, " LR = 0 - this is bad");
|
||||
}
|
||||
|
||||
if (g_symbolDB.GetDescription(PC) != g_symbolDB.GetDescription(LR))
|
||||
{
|
||||
GENERIC_LOG(type, level, " * %s [ LR = %08x ]",
|
||||
g_symbolDB.GetDescription(LR).c_str(), LR);
|
||||
}
|
||||
if (g_symbolDB.GetDescription(PC) != g_symbolDB.GetDescription(LR))
|
||||
{
|
||||
GENERIC_LOG(type, level, " * %s [ LR = %08x ]", g_symbolDB.GetDescription(LR).c_str(), LR);
|
||||
}
|
||||
|
||||
WalkTheStack([type, level](u32 func_addr) {
|
||||
std::string func_desc = g_symbolDB.GetDescription(func_addr);
|
||||
if (func_desc.empty() || func_desc == "Invalid")
|
||||
func_desc = "(unknown)";
|
||||
GENERIC_LOG(type, level, " * %s [ addr = %08x ]", func_desc.c_str(), func_addr);
|
||||
});
|
||||
WalkTheStack([type, level](u32 func_addr) {
|
||||
std::string func_desc = g_symbolDB.GetDescription(func_addr);
|
||||
if (func_desc.empty() || func_desc == "Invalid")
|
||||
func_desc = "(unknown)";
|
||||
GENERIC_LOG(type, level, " * %s [ addr = %08x ]", func_desc.c_str(), func_addr);
|
||||
});
|
||||
}
|
||||
|
||||
void PrintDataBuffer(LogTypes::LOG_TYPE type, const u8* data, size_t size, const std::string& title)
|
||||
{
|
||||
GENERIC_LOG(type, LogTypes::LDEBUG, "%s", title.c_str());
|
||||
for (u32 j = 0; j < size;)
|
||||
{
|
||||
std::string hex_line = "";
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
hex_line += StringFromFormat("%02x ", data[j++]);
|
||||
GENERIC_LOG(type, LogTypes::LDEBUG, "%s", title.c_str());
|
||||
for (u32 j = 0; j < size;)
|
||||
{
|
||||
std::string hex_line = "";
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
hex_line += StringFromFormat("%02x ", data[j++]);
|
||||
|
||||
if (j >= size)
|
||||
break;
|
||||
}
|
||||
GENERIC_LOG(type, LogTypes::LDEBUG, " Data: %s", hex_line.c_str());
|
||||
}
|
||||
if (j >= size)
|
||||
break;
|
||||
}
|
||||
GENERIC_LOG(type, LogTypes::LDEBUG, " Data: %s", hex_line.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace Debugger
|
||||
|
|
|
@ -12,18 +12,17 @@
|
|||
|
||||
namespace Dolphin_Debugger
|
||||
{
|
||||
|
||||
struct CallstackEntry
|
||||
{
|
||||
std::string Name;
|
||||
u32 vAddress;
|
||||
std::string Name;
|
||||
u32 vAddress;
|
||||
};
|
||||
|
||||
bool GetCallstack(std::vector<CallstackEntry> &output);
|
||||
bool GetCallstack(std::vector<CallstackEntry>& output);
|
||||
void PrintCallstack();
|
||||
void PrintCallstack(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level);
|
||||
void PrintDataBuffer(LogTypes::LOG_TYPE type, const u8* data, size_t size, const std::string& title);
|
||||
void PrintDataBuffer(LogTypes::LOG_TYPE type, const u8* data, size_t size,
|
||||
const std::string& title);
|
||||
void AddAutoBreakpoints();
|
||||
|
||||
|
||||
} // end of namespace Debugger
|
||||
} // end of namespace Debugger
|
||||
|
|
|
@ -10,60 +10,57 @@
|
|||
|
||||
#include "Core/Debugger/Dump.h"
|
||||
|
||||
CDump::CDump(const std::string& filename) :
|
||||
m_pData(nullptr)
|
||||
CDump::CDump(const std::string& filename) : m_pData(nullptr)
|
||||
{
|
||||
File::IOFile pStream(filename, "rb");
|
||||
if (pStream)
|
||||
{
|
||||
m_size = (size_t)pStream.GetSize();
|
||||
File::IOFile pStream(filename, "rb");
|
||||
if (pStream)
|
||||
{
|
||||
m_size = (size_t)pStream.GetSize();
|
||||
|
||||
m_pData = new u8[m_size];
|
||||
m_pData = new u8[m_size];
|
||||
|
||||
pStream.ReadArray(m_pData, m_size);
|
||||
}
|
||||
pStream.ReadArray(m_pData, m_size);
|
||||
}
|
||||
}
|
||||
|
||||
CDump::~CDump()
|
||||
{
|
||||
if (m_pData != nullptr)
|
||||
{
|
||||
delete[] m_pData;
|
||||
m_pData = nullptr;
|
||||
}
|
||||
if (m_pData != nullptr)
|
||||
{
|
||||
delete[] m_pData;
|
||||
m_pData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
int CDump::GetNumberOfSteps()
|
||||
{
|
||||
return (int)(m_size / STRUCTUR_SIZE);
|
||||
return (int)(m_size / STRUCTUR_SIZE);
|
||||
}
|
||||
|
||||
u32 CDump::GetGPR(int _step, int _gpr)
|
||||
{
|
||||
u32 offset = _step * STRUCTUR_SIZE;
|
||||
u32 offset = _step * STRUCTUR_SIZE;
|
||||
|
||||
if (offset >= m_size)
|
||||
return -1;
|
||||
if (offset >= m_size)
|
||||
return -1;
|
||||
|
||||
return Read32(offset + OFFSET_GPR + (_gpr * 4));
|
||||
return Read32(offset + OFFSET_GPR + (_gpr * 4));
|
||||
}
|
||||
|
||||
u32 CDump::GetPC(int _step)
|
||||
{
|
||||
u32 offset = _step * STRUCTUR_SIZE;
|
||||
u32 offset = _step * STRUCTUR_SIZE;
|
||||
|
||||
if (offset >= m_size)
|
||||
return -1;
|
||||
if (offset >= m_size)
|
||||
return -1;
|
||||
|
||||
return Read32(offset + OFFSET_PC);
|
||||
return Read32(offset + OFFSET_PC);
|
||||
}
|
||||
|
||||
u32 CDump::Read32(u32 _pos)
|
||||
{
|
||||
u32 result = (m_pData[_pos+0] << 24) |
|
||||
(m_pData[_pos+1] << 16) |
|
||||
(m_pData[_pos+2] << 8) |
|
||||
(m_pData[_pos+3] << 0);
|
||||
u32 result = (m_pData[_pos + 0] << 24) | (m_pData[_pos + 1] << 16) | (m_pData[_pos + 2] << 8) |
|
||||
(m_pData[_pos + 3] << 0);
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
|
||||
// Purpose: uncompress the dumps from costis GC-Debugger tool
|
||||
//
|
||||
//
|
||||
|
@ -14,25 +13,24 @@
|
|||
class CDump
|
||||
{
|
||||
public:
|
||||
CDump(const std::string& filename);
|
||||
~CDump();
|
||||
|
||||
CDump(const std::string& filename);
|
||||
~CDump();
|
||||
|
||||
int GetNumberOfSteps();
|
||||
u32 GetGPR(int _step, int _gpr);
|
||||
u32 GetPC(int _step);
|
||||
int GetNumberOfSteps();
|
||||
u32 GetGPR(int _step, int _gpr);
|
||||
u32 GetPC(int _step);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
OFFSET_GPR = 0x4,
|
||||
OFFSET_PC = 0x194,
|
||||
STRUCTUR_SIZE = 0x2BC
|
||||
};
|
||||
enum
|
||||
{
|
||||
OFFSET_GPR = 0x4,
|
||||
OFFSET_PC = 0x194,
|
||||
STRUCTUR_SIZE = 0x2BC
|
||||
};
|
||||
|
||||
u8 *m_pData;
|
||||
u8* m_pData;
|
||||
|
||||
size_t m_size;
|
||||
size_t m_size;
|
||||
|
||||
u32 Read32(u32 _pos);
|
||||
u32 Read32(u32 _pos);
|
||||
};
|
||||
|
|
|
@ -5,108 +5,107 @@
|
|||
#pragma once
|
||||
|
||||
// ELF File Types
|
||||
#define ET_NONE 0 // No file type
|
||||
#define ET_REL 1 // Relocatable file
|
||||
#define ET_EXEC 2 // Executable file
|
||||
#define ET_DYN 3 // Shared object file
|
||||
#define ET_CORE 4 // Core file
|
||||
#define ET_LOPROC 0xFF00 // Processor specific
|
||||
#define ET_HIPROC 0xFFFF // Processor specific
|
||||
#define ET_NONE 0 // No file type
|
||||
#define ET_REL 1 // Relocatable file
|
||||
#define ET_EXEC 2 // Executable file
|
||||
#define ET_DYN 3 // Shared object file
|
||||
#define ET_CORE 4 // Core file
|
||||
#define ET_LOPROC 0xFF00 // Processor specific
|
||||
#define ET_HIPROC 0xFFFF // Processor specific
|
||||
|
||||
// ELF Machine Types
|
||||
#define EM_NONE 0 // No machine
|
||||
#define EM_M32 1 // AT&T WE 32100
|
||||
#define EM_SPARC 2 // SPARC
|
||||
#define EM_386 3 // Intel Architecture
|
||||
#define EM_68K 4 // Motorola 68000
|
||||
#define EM_88K 5 // Motorola 88000
|
||||
#define EM_860 6 // Intel 80860
|
||||
#define EM_MIPS 7 // MIPS RS3000 Big-Endian
|
||||
#define EM_MIPS_RS4_BE 8 // MIPS RS4000 Big-Endian
|
||||
#define EM_ARM 40 // ARM/Thumb Architecture
|
||||
#define EM_NONE 0 // No machine
|
||||
#define EM_M32 1 // AT&T WE 32100
|
||||
#define EM_SPARC 2 // SPARC
|
||||
#define EM_386 3 // Intel Architecture
|
||||
#define EM_68K 4 // Motorola 68000
|
||||
#define EM_88K 5 // Motorola 88000
|
||||
#define EM_860 6 // Intel 80860
|
||||
#define EM_MIPS 7 // MIPS RS3000 Big-Endian
|
||||
#define EM_MIPS_RS4_BE 8 // MIPS RS4000 Big-Endian
|
||||
#define EM_ARM 40 // ARM/Thumb Architecture
|
||||
|
||||
// ELF Version Types
|
||||
#define EV_NONE 0 // Invalid version
|
||||
#define EV_CURRENT 1 // Current version
|
||||
#define EV_NONE 0 // Invalid version
|
||||
#define EV_CURRENT 1 // Current version
|
||||
|
||||
// ELF Section Header Types
|
||||
#define SHT_NULL 0
|
||||
#define SHT_PROGBITS 1
|
||||
#define SHT_SYMTAB 2
|
||||
#define SHT_STRTAB 3
|
||||
#define SHT_RELA 4
|
||||
#define SHT_HASH 5
|
||||
#define SHT_DYNAMIC 6
|
||||
#define SHT_NOTE 7
|
||||
#define SHT_NOBITS 8
|
||||
#define SHT_REL 9
|
||||
#define SHT_SHLIB 10
|
||||
#define SHT_DYNSYM 11
|
||||
|
||||
#define SHT_NULL 0
|
||||
#define SHT_PROGBITS 1
|
||||
#define SHT_SYMTAB 2
|
||||
#define SHT_STRTAB 3
|
||||
#define SHT_RELA 4
|
||||
#define SHT_HASH 5
|
||||
#define SHT_DYNAMIC 6
|
||||
#define SHT_NOTE 7
|
||||
#define SHT_NOBITS 8
|
||||
#define SHT_REL 9
|
||||
#define SHT_SHLIB 10
|
||||
#define SHT_DYNSYM 11
|
||||
|
||||
struct ELF_Header
|
||||
{
|
||||
unsigned char ID[4];
|
||||
unsigned char clazz;
|
||||
unsigned char data;
|
||||
unsigned char version;
|
||||
unsigned char pad[9];
|
||||
unsigned short e_type; // ELF file type
|
||||
unsigned short e_machine; // ELF target machine
|
||||
unsigned int e_version; // ELF file version number
|
||||
unsigned int e_entry;
|
||||
unsigned int e_phoff;
|
||||
unsigned int e_shoff;
|
||||
unsigned int e_flags;
|
||||
unsigned short e_ehsize;
|
||||
unsigned short e_phentsize;
|
||||
unsigned short e_phnum;
|
||||
unsigned short e_shentsize;
|
||||
unsigned short e_shnum;
|
||||
unsigned short e_shtrndx;
|
||||
unsigned char ID[4];
|
||||
unsigned char clazz;
|
||||
unsigned char data;
|
||||
unsigned char version;
|
||||
unsigned char pad[9];
|
||||
unsigned short e_type; // ELF file type
|
||||
unsigned short e_machine; // ELF target machine
|
||||
unsigned int e_version; // ELF file version number
|
||||
unsigned int e_entry;
|
||||
unsigned int e_phoff;
|
||||
unsigned int e_shoff;
|
||||
unsigned int e_flags;
|
||||
unsigned short e_ehsize;
|
||||
unsigned short e_phentsize;
|
||||
unsigned short e_phnum;
|
||||
unsigned short e_shentsize;
|
||||
unsigned short e_shnum;
|
||||
unsigned short e_shtrndx;
|
||||
};
|
||||
|
||||
struct Program_Header
|
||||
{
|
||||
unsigned int type;
|
||||
unsigned int offset;
|
||||
unsigned int vaddr;
|
||||
unsigned int paddr;
|
||||
unsigned int filesz;
|
||||
unsigned int memsz;
|
||||
unsigned int flags;
|
||||
unsigned int align;
|
||||
unsigned int type;
|
||||
unsigned int offset;
|
||||
unsigned int vaddr;
|
||||
unsigned int paddr;
|
||||
unsigned int filesz;
|
||||
unsigned int memsz;
|
||||
unsigned int flags;
|
||||
unsigned int align;
|
||||
};
|
||||
|
||||
struct Section_Header
|
||||
{
|
||||
unsigned int name;
|
||||
unsigned int type;
|
||||
unsigned int flags;
|
||||
unsigned int addr;
|
||||
unsigned int offset;
|
||||
unsigned int size;
|
||||
unsigned int link;
|
||||
unsigned int info;
|
||||
unsigned int addralign;
|
||||
unsigned int entsize;
|
||||
unsigned int name;
|
||||
unsigned int type;
|
||||
unsigned int flags;
|
||||
unsigned int addr;
|
||||
unsigned int offset;
|
||||
unsigned int size;
|
||||
unsigned int link;
|
||||
unsigned int info;
|
||||
unsigned int addralign;
|
||||
unsigned int entsize;
|
||||
};
|
||||
|
||||
struct Symbol_Header
|
||||
{
|
||||
unsigned int name;
|
||||
unsigned int value;
|
||||
unsigned int size;
|
||||
unsigned char info;
|
||||
unsigned char other;
|
||||
unsigned short shndx;
|
||||
unsigned int name;
|
||||
unsigned int value;
|
||||
unsigned int size;
|
||||
unsigned char info;
|
||||
unsigned char other;
|
||||
unsigned short shndx;
|
||||
};
|
||||
|
||||
struct Rela_Header
|
||||
{
|
||||
unsigned int offset;
|
||||
unsigned int info;
|
||||
signed int addend;
|
||||
unsigned int offset;
|
||||
unsigned int info;
|
||||
signed int addend;
|
||||
};
|
||||
|
||||
const char ELFID[4] = {0x7F, 'E', 'L', 'F'};
|
||||
|
|
|
@ -7,212 +7,205 @@
|
|||
#include "Common/GekkoDisassembler.h"
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Host.h"
|
||||
#include "Core/Debugger/Debugger_SymbolMap.h"
|
||||
#include "Core/Debugger/PPCDebugInterface.h"
|
||||
#include "Core/HW/DSP.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||
#include "Core/Host.h"
|
||||
#include "Core/PowerPC/JitCommon/JitBase.h"
|
||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
std::string PPCDebugInterface::Disassemble(unsigned int address)
|
||||
{
|
||||
// PowerPC::HostRead_U32 seemed to crash on shutdown
|
||||
if (!IsAlive())
|
||||
return "";
|
||||
// PowerPC::HostRead_U32 seemed to crash on shutdown
|
||||
if (!IsAlive())
|
||||
return "";
|
||||
|
||||
if (Core::GetState() == Core::CORE_PAUSE)
|
||||
{
|
||||
if (!PowerPC::HostIsRAMAddress(address))
|
||||
{
|
||||
return "(No RAM here)";
|
||||
}
|
||||
if (Core::GetState() == Core::CORE_PAUSE)
|
||||
{
|
||||
if (!PowerPC::HostIsRAMAddress(address))
|
||||
{
|
||||
return "(No RAM here)";
|
||||
}
|
||||
|
||||
u32 op = PowerPC::HostRead_Instruction(address);
|
||||
std::string disasm = GekkoDisassembler::Disassemble(op, address);
|
||||
u32 op = PowerPC::HostRead_Instruction(address);
|
||||
std::string disasm = GekkoDisassembler::Disassemble(op, address);
|
||||
|
||||
UGeckoInstruction inst;
|
||||
inst.hex = PowerPC::HostRead_U32(address);
|
||||
UGeckoInstruction inst;
|
||||
inst.hex = PowerPC::HostRead_U32(address);
|
||||
|
||||
if (inst.OPCD == 1)
|
||||
{
|
||||
disasm += " (hle)";
|
||||
}
|
||||
if (inst.OPCD == 1)
|
||||
{
|
||||
disasm += " (hle)";
|
||||
}
|
||||
|
||||
return disasm;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<unknown>";
|
||||
}
|
||||
return disasm;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
void PPCDebugInterface::GetRawMemoryString(int memory, unsigned int address, char *dest, int max_size)
|
||||
void PPCDebugInterface::GetRawMemoryString(int memory, unsigned int address, char* dest,
|
||||
int max_size)
|
||||
{
|
||||
if (IsAlive())
|
||||
{
|
||||
if (memory || PowerPC::HostIsRAMAddress(address))
|
||||
{
|
||||
snprintf(dest, max_size, "%08X%s", ReadExtraMemory(memory, address), memory ? " (ARAM)" : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(dest, memory ? "--ARAM--" : "--------");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(dest, "<unknwn>"); // bad spelling - 8 chars
|
||||
}
|
||||
if (IsAlive())
|
||||
{
|
||||
if (memory || PowerPC::HostIsRAMAddress(address))
|
||||
{
|
||||
snprintf(dest, max_size, "%08X%s", ReadExtraMemory(memory, address), memory ? " (ARAM)" : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(dest, memory ? "--ARAM--" : "--------");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(dest, "<unknwn>"); // bad spelling - 8 chars
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int PPCDebugInterface::ReadMemory(unsigned int address)
|
||||
{
|
||||
return PowerPC::HostRead_U32(address);
|
||||
return PowerPC::HostRead_U32(address);
|
||||
}
|
||||
|
||||
unsigned int PPCDebugInterface::ReadExtraMemory(int memory, unsigned int address)
|
||||
{
|
||||
switch (memory)
|
||||
{
|
||||
case 0:
|
||||
return PowerPC::HostRead_U32(address);
|
||||
case 1:
|
||||
return (DSP::ReadARAM(address) << 24) |
|
||||
(DSP::ReadARAM(address + 1) << 16) |
|
||||
(DSP::ReadARAM(address + 2) << 8) |
|
||||
(DSP::ReadARAM(address + 3));
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
switch (memory)
|
||||
{
|
||||
case 0:
|
||||
return PowerPC::HostRead_U32(address);
|
||||
case 1:
|
||||
return (DSP::ReadARAM(address) << 24) | (DSP::ReadARAM(address + 1) << 16) |
|
||||
(DSP::ReadARAM(address + 2) << 8) | (DSP::ReadARAM(address + 3));
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int PPCDebugInterface::ReadInstruction(unsigned int address)
|
||||
{
|
||||
return PowerPC::HostRead_Instruction(address);
|
||||
return PowerPC::HostRead_Instruction(address);
|
||||
}
|
||||
|
||||
bool PPCDebugInterface::IsAlive()
|
||||
{
|
||||
return Core::IsRunning();
|
||||
return Core::IsRunning();
|
||||
}
|
||||
|
||||
bool PPCDebugInterface::IsBreakpoint(unsigned int address)
|
||||
{
|
||||
return PowerPC::breakpoints.IsAddressBreakPoint(address);
|
||||
return PowerPC::breakpoints.IsAddressBreakPoint(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::SetBreakpoint(unsigned int address)
|
||||
{
|
||||
PowerPC::breakpoints.Add(address);
|
||||
PowerPC::breakpoints.Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearBreakpoint(unsigned int address)
|
||||
{
|
||||
PowerPC::breakpoints.Remove(address);
|
||||
PowerPC::breakpoints.Remove(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearAllBreakpoints()
|
||||
{
|
||||
PowerPC::breakpoints.Clear();
|
||||
PowerPC::breakpoints.Clear();
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ToggleBreakpoint(unsigned int address)
|
||||
{
|
||||
if (PowerPC::breakpoints.IsAddressBreakPoint(address))
|
||||
PowerPC::breakpoints.Remove(address);
|
||||
else
|
||||
PowerPC::breakpoints.Add(address);
|
||||
if (PowerPC::breakpoints.IsAddressBreakPoint(address))
|
||||
PowerPC::breakpoints.Remove(address);
|
||||
else
|
||||
PowerPC::breakpoints.Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::AddWatch(unsigned int address)
|
||||
{
|
||||
PowerPC::watches.Add(address);
|
||||
PowerPC::watches.Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearAllMemChecks()
|
||||
{
|
||||
PowerPC::memchecks.Clear();
|
||||
PowerPC::memchecks.Clear();
|
||||
}
|
||||
|
||||
bool PPCDebugInterface::IsMemCheck(unsigned int address)
|
||||
{
|
||||
return (Memory::AreMemoryBreakpointsActivated() &&
|
||||
PowerPC::memchecks.GetMemCheck(address));
|
||||
return (Memory::AreMemoryBreakpointsActivated() && PowerPC::memchecks.GetMemCheck(address));
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ToggleMemCheck(unsigned int address)
|
||||
{
|
||||
if (Memory::AreMemoryBreakpointsActivated() &&
|
||||
!PowerPC::memchecks.GetMemCheck(address))
|
||||
{
|
||||
// Add Memory Check
|
||||
TMemCheck MemCheck;
|
||||
MemCheck.StartAddress = address;
|
||||
MemCheck.EndAddress = address;
|
||||
MemCheck.OnRead = true;
|
||||
MemCheck.OnWrite = true;
|
||||
if (Memory::AreMemoryBreakpointsActivated() && !PowerPC::memchecks.GetMemCheck(address))
|
||||
{
|
||||
// Add Memory Check
|
||||
TMemCheck MemCheck;
|
||||
MemCheck.StartAddress = address;
|
||||
MemCheck.EndAddress = address;
|
||||
MemCheck.OnRead = true;
|
||||
MemCheck.OnWrite = true;
|
||||
|
||||
MemCheck.Log = true;
|
||||
MemCheck.Break = true;
|
||||
MemCheck.Log = true;
|
||||
MemCheck.Break = true;
|
||||
|
||||
PowerPC::memchecks.Add(MemCheck);
|
||||
}
|
||||
else
|
||||
PowerPC::memchecks.Remove(address);
|
||||
PowerPC::memchecks.Add(MemCheck);
|
||||
}
|
||||
else
|
||||
PowerPC::memchecks.Remove(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::InsertBLR(unsigned int address, unsigned int value)
|
||||
{
|
||||
PowerPC::HostWrite_U32(value, address);
|
||||
PowerPC::HostWrite_U32(value, address);
|
||||
}
|
||||
|
||||
|
||||
// =======================================================
|
||||
// Separate the blocks with colors.
|
||||
// -------------
|
||||
int PPCDebugInterface::GetColor(unsigned int address)
|
||||
{
|
||||
if (!IsAlive())
|
||||
return 0xFFFFFF;
|
||||
if (!PowerPC::HostIsRAMAddress(address))
|
||||
return 0xeeeeee;
|
||||
static const int colors[6] =
|
||||
{
|
||||
0xd0FFFF, // light cyan
|
||||
0xFFd0d0, // light red
|
||||
0xd8d8FF, // light blue
|
||||
0xFFd0FF, // light purple
|
||||
0xd0FFd0, // light green
|
||||
0xFFFFd0, // light yellow
|
||||
};
|
||||
Symbol *symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
if (!symbol)
|
||||
return 0xFFFFFF;
|
||||
if (symbol->type != Symbol::SYMBOL_FUNCTION)
|
||||
return 0xEEEEFF;
|
||||
return colors[symbol->index % 6];
|
||||
if (!IsAlive())
|
||||
return 0xFFFFFF;
|
||||
if (!PowerPC::HostIsRAMAddress(address))
|
||||
return 0xeeeeee;
|
||||
static const int colors[6] = {
|
||||
0xd0FFFF, // light cyan
|
||||
0xFFd0d0, // light red
|
||||
0xd8d8FF, // light blue
|
||||
0xFFd0FF, // light purple
|
||||
0xd0FFd0, // light green
|
||||
0xFFFFd0, // light yellow
|
||||
};
|
||||
Symbol* symbol = g_symbolDB.GetSymbolFromAddr(address);
|
||||
if (!symbol)
|
||||
return 0xFFFFFF;
|
||||
if (symbol->type != Symbol::SYMBOL_FUNCTION)
|
||||
return 0xEEEEFF;
|
||||
return colors[symbol->index % 6];
|
||||
}
|
||||
// =============
|
||||
|
||||
|
||||
std::string PPCDebugInterface::GetDescription(unsigned int address)
|
||||
{
|
||||
return g_symbolDB.GetDescription(address);
|
||||
return g_symbolDB.GetDescription(address);
|
||||
}
|
||||
|
||||
unsigned int PPCDebugInterface::GetPC()
|
||||
{
|
||||
return PowerPC::ppcState.pc;
|
||||
return PowerPC::ppcState.pc;
|
||||
}
|
||||
|
||||
void PPCDebugInterface::SetPC(unsigned int address)
|
||||
{
|
||||
PowerPC::ppcState.pc = address;
|
||||
PowerPC::ppcState.pc = address;
|
||||
}
|
||||
|
||||
void PPCDebugInterface::RunToBreakpoint()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -8,39 +8,39 @@
|
|||
|
||||
#include "Common/DebugInterface.h"
|
||||
|
||||
//wrapper between disasm control and Dolphin debugger
|
||||
// wrapper between disasm control and Dolphin debugger
|
||||
|
||||
class PPCDebugInterface final : public DebugInterface
|
||||
{
|
||||
public:
|
||||
PPCDebugInterface(){}
|
||||
std::string Disassemble(unsigned int address) override;
|
||||
void GetRawMemoryString(int memory, unsigned int address, char *dest, int max_size) override;
|
||||
int GetInstructionSize(int /*instruction*/) override {return 4;}
|
||||
bool IsAlive() override;
|
||||
bool IsBreakpoint(unsigned int address) override;
|
||||
void SetBreakpoint(unsigned int address) override;
|
||||
void ClearBreakpoint(unsigned int address) override;
|
||||
void ClearAllBreakpoints() override;
|
||||
void AddWatch(unsigned int address) override;
|
||||
void ToggleBreakpoint(unsigned int address) override;
|
||||
void ClearAllMemChecks() override;
|
||||
bool IsMemCheck(unsigned int address) override;
|
||||
void ToggleMemCheck(unsigned int address) override;
|
||||
unsigned int ReadMemory(unsigned int address) override;
|
||||
PPCDebugInterface() {}
|
||||
std::string Disassemble(unsigned int address) override;
|
||||
void GetRawMemoryString(int memory, unsigned int address, char* dest, int max_size) override;
|
||||
int GetInstructionSize(int /*instruction*/) override { return 4; }
|
||||
bool IsAlive() override;
|
||||
bool IsBreakpoint(unsigned int address) override;
|
||||
void SetBreakpoint(unsigned int address) override;
|
||||
void ClearBreakpoint(unsigned int address) override;
|
||||
void ClearAllBreakpoints() override;
|
||||
void AddWatch(unsigned int address) override;
|
||||
void ToggleBreakpoint(unsigned int address) override;
|
||||
void ClearAllMemChecks() override;
|
||||
bool IsMemCheck(unsigned int address) override;
|
||||
void ToggleMemCheck(unsigned int address) override;
|
||||
unsigned int ReadMemory(unsigned int address) override;
|
||||
|
||||
enum
|
||||
{
|
||||
EXTRAMEM_ARAM = 1,
|
||||
};
|
||||
enum
|
||||
{
|
||||
EXTRAMEM_ARAM = 1,
|
||||
};
|
||||
|
||||
unsigned int ReadExtraMemory(int memory, unsigned int address) override;
|
||||
unsigned int ReadInstruction(unsigned int address) override;
|
||||
unsigned int GetPC() override;
|
||||
void SetPC(unsigned int address) override;
|
||||
void Step() override {}
|
||||
void RunToBreakpoint() override;
|
||||
void InsertBLR(unsigned int address, unsigned int value) override;
|
||||
int GetColor(unsigned int address) override;
|
||||
std::string GetDescription(unsigned int address) override;
|
||||
unsigned int ReadExtraMemory(int memory, unsigned int address) override;
|
||||
unsigned int ReadInstruction(unsigned int address) override;
|
||||
unsigned int GetPC() override;
|
||||
void SetPC(unsigned int address) override;
|
||||
void Step() override {}
|
||||
void RunToBreakpoint() override;
|
||||
void InsertBLR(unsigned int address, unsigned int value) override;
|
||||
int GetColor(unsigned int address) override;
|
||||
std::string GetDescription(unsigned int address) override;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue