1
// Copyright 2013 Dolphin Emulator Project
2
// Licensed under GPLv2
3
// Refer to the license.txt file included.
5
#include "DSPDebugInterface.h"
7
#include "DSP/DSPCore.h"
8
#include "DSP/disassemble.h"
10
#include "DSPSymbols.h"
11
#include "DSP/DSPMemoryMap.h"
13
void DSPDebugInterface::disasm(unsigned int address, char *dest, int max_size)
15
// we'll treat addresses as line numbers.
16
strncpy(dest, DSPSymbols::GetLineText(address), max_size);
20
void DSPDebugInterface::getRawMemoryString(int memory, unsigned int address, char *dest, int max_size)
22
if (DSPCore_GetState() == DSPCORE_STOP)
31
switch (address >> 12)
35
sprintf(dest, "%04x", dsp_imem_read(address));
38
sprintf(dest, "--IMEM--");
43
switch (address >> 12)
47
sprintf(dest, "%04x (DMEM)", dsp_dmem_read(address));
50
sprintf(dest, "%04x (MMIO)", g_dsp.ifx_regs[address & 0xFF]);
53
sprintf(dest, "--DMEM--");
60
unsigned int DSPDebugInterface::readMemory(unsigned int address)
62
return 0; //Memory::ReadUnchecked_U32(address);
65
unsigned int DSPDebugInterface::readInstruction(unsigned int address)
67
return 0; //Memory::Read_Instruction(address);
70
bool DSPDebugInterface::isAlive()
72
return true; //Core::GetState() != Core::CORE_UNINITIALIZED;
75
bool DSPDebugInterface::isBreakpoint(unsigned int address)
77
int real_addr = DSPSymbols::Line2Addr(address);
79
return dsp_breakpoints.IsAddressBreakPoint(real_addr);
84
void DSPDebugInterface::setBreakpoint(unsigned int address)
86
int real_addr = DSPSymbols::Line2Addr(address);
90
if (dsp_breakpoints.Add(real_addr))
97
void DSPDebugInterface::clearBreakpoint(unsigned int address)
99
int real_addr = DSPSymbols::Line2Addr(address);
103
if (dsp_breakpoints.Remove(real_addr))
110
void DSPDebugInterface::clearAllBreakpoints()
112
dsp_breakpoints.Clear();
115
void DSPDebugInterface::toggleBreakpoint(unsigned int address)
117
int real_addr = DSPSymbols::Line2Addr(address);
120
if (dsp_breakpoints.IsAddressBreakPoint(real_addr))
121
dsp_breakpoints.Remove(real_addr);
123
dsp_breakpoints.Add(real_addr);
127
bool DSPDebugInterface::isMemCheck(unsigned int address)
132
void DSPDebugInterface::toggleMemCheck(unsigned int address)
134
PanicAlert("MemCheck functionality not supported in DSP module.");
137
void DSPDebugInterface::insertBLR(unsigned int address, unsigned int value)
139
PanicAlert("insertBLR functionality not supported in DSP module.");
142
// =======================================================
143
// Separate the blocks with colors.
145
int DSPDebugInterface::getColor(unsigned int address)
147
static const int colors[6] =
149
0xd0FFFF, // light cyan
150
0xFFd0d0, // light red
151
0xd8d8FF, // light blue
152
0xFFd0FF, // light purple
153
0xd0FFd0, // light green
154
0xFFFFd0, // light yellow
157
// Scan backwards so we don't miss it. Hm, actually, let's not - it looks pretty good.
159
for (int i = 0; i < 1; i++)
161
addr = DSPSymbols::Line2Addr(address - i);
168
Symbol *symbol = DSPSymbols::g_dsp_symbol_db.GetSymbolFromAddr(addr);
171
if (symbol->type != Symbol::SYMBOL_FUNCTION)
173
return colors[symbol->index % 6];
178
std::string DSPDebugInterface::getDescription(unsigned int address)
180
return ""; // g_symbolDB.GetDescription(address);
183
unsigned int DSPDebugInterface::getPC()
185
return DSPSymbols::Addr2Line(g_dsp.pc);
188
void DSPDebugInterface::setPC(unsigned int address)
190
int new_pc = DSPSymbols::Line2Addr(address);
195
void DSPDebugInterface::runToBreakpoint()