1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
// 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 "Debugger_BreakPoints.h"
#include "Debugger_SymbolMap.h"
#include "DebugInterface.h"
#include "PPCDebugInterface.h"
#include "PowerPCDisasm.h"
#include "../Core.h"
#include "../HW/Memmap.h"
#include "../PowerPC/PowerPC.h"
#include "../PowerPC/Jit64/Jit.h"
#include "../PowerPC/SymbolDB.h"
void PPCDebugInterface::disasm(unsigned int address, char *dest, int max_size)
{
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>");
}
}
void PPCDebugInterface::getRawMemoryString(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));
}
else
{
strcpy(dest, "--------");
}
}
else
{
strcpy(dest, "<unknwn>"); // bad spelling - 8 chars
}
}
unsigned int PPCDebugInterface::readMemory(unsigned int address)
{
return Memory::ReadUnchecked_U32(address);
}
unsigned int PPCDebugInterface::readInstruction(unsigned int address)
{
return Memory::Read_Instruction(address);
}
bool PPCDebugInterface::isAlive()
{
return Core::GetState() != Core::CORE_UNINITIALIZED;
}
bool PPCDebugInterface::isBreakpoint(unsigned int address)
{
return BreakPoints::IsAddressBreakPoint(address);
}
void PPCDebugInterface::setBreakpoint(unsigned int address)
{
if (BreakPoints::Add(address))
jit.NotifyBreakpoint(address, true);
}
void PPCDebugInterface::clearBreakpoint(unsigned int address)
{
if (BreakPoints::Remove(address))
jit.NotifyBreakpoint(address, false);
}
void PPCDebugInterface::clearAllBreakpoints() {}
void PPCDebugInterface::toggleBreakpoint(unsigned int address)
{
if (BreakPoints::IsAddressBreakPoint(address))
BreakPoints::Remove(address);
else
BreakPoints::Add(address);
}
void PPCDebugInterface::insertBLR(unsigned int address)
{
Memory::Write_U32(0x4e800020, address);
}
// =======================================================
// Separate the blocks with colors.
// -------------
int PPCDebugInterface::getColor(unsigned int address)
{
if (!Memory::IsRAMAddress(address, true))
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);
}
unsigned int PPCDebugInterface::getPC()
{
return PowerPC::ppcState.pc;
}
void PPCDebugInterface::setPC(unsigned int address)
{
PowerPC::ppcState.pc = address;
}
void PPCDebugInterface::runToBreakpoint()
{
}
|