~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Source/Core/Core/Src/HW/DSPLLE/DSPDebugInterface.cpp

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Dolphin Emulator Project
 
2
// Licensed under GPLv2
 
3
// Refer to the license.txt file included.
 
4
 
 
5
#include "DSPDebugInterface.h"
 
6
 
 
7
#include "DSP/DSPCore.h"
 
8
#include "DSP/disassemble.h"
 
9
 
 
10
#include "DSPSymbols.h"
 
11
#include "DSP/DSPMemoryMap.h"
 
12
 
 
13
void DSPDebugInterface::disasm(unsigned int address, char *dest, int max_size) 
 
14
{
 
15
        // we'll treat addresses as line numbers.
 
16
        strncpy(dest, DSPSymbols::GetLineText(address), max_size);
 
17
        dest[max_size-1] = 0;
 
18
}
 
19
 
 
20
void DSPDebugInterface::getRawMemoryString(int memory, unsigned int address, char *dest, int max_size)
 
21
{
 
22
        if (DSPCore_GetState() == DSPCORE_STOP)
 
23
        {
 
24
                dest[0] = 0;
 
25
                return;
 
26
        }
 
27
 
 
28
        switch (memory)
 
29
        {
 
30
        case 0:  // IMEM
 
31
                switch (address >> 12)
 
32
                {
 
33
                case 0:
 
34
                case 0x8:
 
35
                        sprintf(dest, "%04x", dsp_imem_read(address));
 
36
                        break;
 
37
                default:
 
38
                        sprintf(dest, "--IMEM--");
 
39
                        break;
 
40
                }
 
41
                break;
 
42
        case 1:  // DMEM
 
43
                switch (address >> 12)
 
44
                {
 
45
                case 0:
 
46
                case 1:
 
47
                        sprintf(dest, "%04x (DMEM)", dsp_dmem_read(address));
 
48
                        break;
 
49
                case 0xf:
 
50
                        sprintf(dest, "%04x (MMIO)", g_dsp.ifx_regs[address & 0xFF]);
 
51
                        break;
 
52
                default:
 
53
                        sprintf(dest, "--DMEM--");
 
54
                        break;
 
55
                }
 
56
                break;
 
57
        }
 
58
}
 
59
 
 
60
unsigned int DSPDebugInterface::readMemory(unsigned int address)
 
61
{
 
62
        return 0; //Memory::ReadUnchecked_U32(address);
 
63
}
 
64
 
 
65
unsigned int DSPDebugInterface::readInstruction(unsigned int address)
 
66
{
 
67
        return 0; //Memory::Read_Instruction(address);
 
68
}
 
69
 
 
70
bool DSPDebugInterface::isAlive()
 
71
{
 
72
        return true; //Core::GetState() != Core::CORE_UNINITIALIZED;
 
73
}
 
74
 
 
75
bool DSPDebugInterface::isBreakpoint(unsigned int address) 
 
76
{
 
77
        int real_addr = DSPSymbols::Line2Addr(address);
 
78
        if (real_addr >= 0)
 
79
                return dsp_breakpoints.IsAddressBreakPoint(real_addr);
 
80
        else
 
81
                return false;
 
82
}
 
83
 
 
84
void DSPDebugInterface::setBreakpoint(unsigned int address)
 
85
{
 
86
        int real_addr = DSPSymbols::Line2Addr(address);
 
87
 
 
88
        if (real_addr >= 0)
 
89
        {
 
90
                if (dsp_breakpoints.Add(real_addr))
 
91
                {
 
92
 
 
93
                }
 
94
        }
 
95
}
 
96
 
 
97
void DSPDebugInterface::clearBreakpoint(unsigned int address)
 
98
{
 
99
        int real_addr = DSPSymbols::Line2Addr(address);
 
100
        
 
101
        if (real_addr >= 0)
 
102
        {
 
103
                if (dsp_breakpoints.Remove(real_addr))
 
104
                {
 
105
 
 
106
                }
 
107
        }
 
108
}
 
109
 
 
110
void DSPDebugInterface::clearAllBreakpoints()
 
111
{
 
112
        dsp_breakpoints.Clear();
 
113
}
 
114
 
 
115
void DSPDebugInterface::toggleBreakpoint(unsigned int address)
 
116
{
 
117
        int real_addr = DSPSymbols::Line2Addr(address);
 
118
        if (real_addr >= 0)
 
119
        {
 
120
                if (dsp_breakpoints.IsAddressBreakPoint(real_addr))
 
121
                        dsp_breakpoints.Remove(real_addr);
 
122
                else
 
123
                        dsp_breakpoints.Add(real_addr);
 
124
        }
 
125
}
 
126
 
 
127
bool DSPDebugInterface::isMemCheck(unsigned int address)
 
128
{
 
129
        return false;
 
130
}
 
131
 
 
132
void DSPDebugInterface::toggleMemCheck(unsigned int address)
 
133
{
 
134
        PanicAlert("MemCheck functionality not supported in DSP module.");
 
135
}
 
136
 
 
137
void DSPDebugInterface::insertBLR(unsigned int address, unsigned int value) 
 
138
{
 
139
        PanicAlert("insertBLR functionality not supported in DSP module.");
 
140
}
 
141
 
 
142
// =======================================================
 
143
// Separate the blocks with colors.
 
144
// -------------
 
145
int DSPDebugInterface::getColor(unsigned int address)
 
146
{
 
147
        static const int colors[6] =
 
148
        { 
 
149
                0xd0FFFF,  // light cyan
 
150
                0xFFd0d0,  // light red
 
151
                0xd8d8FF,  // light blue
 
152
                0xFFd0FF,  // light purple
 
153
                0xd0FFd0,  // light green
 
154
                0xFFFFd0,  // light yellow
 
155
        };
 
156
 
 
157
        // Scan backwards so we don't miss it. Hm, actually, let's not - it looks pretty good.
 
158
        int addr = -1;
 
159
        for (int i = 0; i < 1; i++)
 
160
        {
 
161
                addr = DSPSymbols::Line2Addr(address - i);
 
162
                if (addr >= 0)
 
163
                        break;
 
164
        }
 
165
        if (addr == -1)
 
166
                return 0xFFFFFF;
 
167
 
 
168
        Symbol *symbol = DSPSymbols::g_dsp_symbol_db.GetSymbolFromAddr(addr);
 
169
        if (!symbol)
 
170
                return 0xFFFFFF;
 
171
        if (symbol->type != Symbol::SYMBOL_FUNCTION)
 
172
                return 0xEEEEFF;
 
173
        return colors[symbol->index % 6];
 
174
}
 
175
// =============
 
176
 
 
177
 
 
178
std::string DSPDebugInterface::getDescription(unsigned int address) 
 
179
{
 
180
        return "";  // g_symbolDB.GetDescription(address);
 
181
}
 
182
 
 
183
unsigned int DSPDebugInterface::getPC() 
 
184
{
 
185
        return DSPSymbols::Addr2Line(g_dsp.pc);
 
186
}
 
187
 
 
188
void DSPDebugInterface::setPC(unsigned int address) 
 
189
{
 
190
        int new_pc = DSPSymbols::Line2Addr(address);
 
191
        if (new_pc > 0)
 
192
                g_dsp.pc = new_pc;
 
193
}
 
194
 
 
195
void DSPDebugInterface::runToBreakpoint() 
 
196
{
 
197
 
 
198
}