summaryrefslogtreecommitdiff
path: root/Source/Core/DSPCore
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2009-06-28 17:18:52 +0000
committerhrydgard <hrydgard@gmail.com>2009-06-28 17:18:52 +0000
commitcc38e72dc3679e15248ffe1c0db6931ce87627c1 (patch)
treeca3d15a744d2eeae9f2d4c9045388604c23586cf /Source/Core/DSPCore
parente4af896638484da17dcdfe112dba1c9287b85193 (diff)
DSPLLE: Setting breakpoints and stepping through code now works in the (still rather basic) DSP debugger. Decided not to share the breakpoints code between PPC and DSP because it can be done much more efficiently for the DSP case due to the very limited memory space.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3575 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/DSPCore')
-rw-r--r--Source/Core/DSPCore/DSPCore.vcproj8
-rw-r--r--Source/Core/DSPCore/Src/DSPAnalyzer.h2
-rw-r--r--Source/Core/DSPCore/Src/DSPBreakpoints.cpp19
-rw-r--r--Source/Core/DSPCore/Src/DSPBreakpoints.h63
-rw-r--r--Source/Core/DSPCore/Src/DSPCore.cpp6
-rw-r--r--Source/Core/DSPCore/Src/DSPCore.h4
-rw-r--r--Source/Core/DSPCore/Src/DSPInterpreter.cpp40
-rw-r--r--Source/Core/DSPCore/Src/SConscript1
8 files changed, 128 insertions, 15 deletions
diff --git a/Source/Core/DSPCore/DSPCore.vcproj b/Source/Core/DSPCore/DSPCore.vcproj
index fffc872438..34f8e428f4 100644
--- a/Source/Core/DSPCore/DSPCore.vcproj
+++ b/Source/Core/DSPCore/DSPCore.vcproj
@@ -483,6 +483,14 @@
>
</File>
<File
+ RelativePath=".\Src\DSPBreakpoints.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Src\DSPBreakpoints.h"
+ >
+ </File>
+ <File
RelativePath=".\Src\DSPCodeUtil.cpp"
>
</File>
diff --git a/Source/Core/DSPCore/Src/DSPAnalyzer.h b/Source/Core/DSPCore/Src/DSPAnalyzer.h
index 89e1e6c980..1b29ede4af 100644
--- a/Source/Core/DSPCore/Src/DSPAnalyzer.h
+++ b/Source/Core/DSPCore/Src/DSPAnalyzer.h
@@ -23,8 +23,6 @@ namespace DSPAnalyzer {
#define ISPACE 65536
-
-
// Useful things to detect:
// * Loop endpoints - so that we can avoid checking for loops every cycle.
diff --git a/Source/Core/DSPCore/Src/DSPBreakpoints.cpp b/Source/Core/DSPCore/Src/DSPBreakpoints.cpp
new file mode 100644
index 0000000000..ec48a249fc
--- /dev/null
+++ b/Source/Core/DSPCore/Src/DSPBreakpoints.cpp
@@ -0,0 +1,19 @@
+// 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 "DSPBreakpoints.h"
+
diff --git a/Source/Core/DSPCore/Src/DSPBreakpoints.h b/Source/Core/DSPCore/Src/DSPBreakpoints.h
new file mode 100644
index 0000000000..98ff5f609d
--- /dev/null
+++ b/Source/Core/DSPCore/Src/DSPBreakpoints.h
@@ -0,0 +1,63 @@
+// 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 _DSP_BREAKPOINTS
+#define _DSP_BREAKPOINTS
+
+#include "Common.h"
+
+// super fast breakpoints for a limited range.
+// To be used interchangably with the BreakPoints class.
+class DSPBreakpoints
+{
+public:
+ DSPBreakpoints() {Clear();}
+ // is address breakpoint
+ bool IsAddressBreakPoint(u32 addr) {
+ return b[addr] != 0;
+ }
+
+ // AddBreakPoint
+ bool Add(u32 addr, bool temp=false) {
+ bool was_one = b[addr] != 0;
+ if (!was_one) {
+ b[addr] = temp ? 2 : 1;
+ return true;
+ } else {
+ return false;
+ }
+ }
+ // Remove Breakpoint
+ bool Remove(u32 addr) {
+ bool was_one = b[addr] != 0;
+ b[addr] = 0;
+ return was_one;
+ }
+ void Clear() {
+ for (int i = 0; i < 65536; i++)
+ b[i] = 0;
+ }
+
+ void DeleteByAddress(u32 addr) {
+ b[addr] = 0;
+ }
+
+private:
+ u8 b[65536];
+};
+
+#endif
diff --git a/Source/Core/DSPCore/Src/DSPCore.cpp b/Source/Core/DSPCore/Src/DSPCore.cpp
index 8824916db9..565e2e6b1a 100644
--- a/Source/Core/DSPCore/Src/DSPCore.cpp
+++ b/Source/Core/DSPCore/Src/DSPCore.cpp
@@ -34,7 +34,7 @@
#include "DSPIntUtil.h"
SDSP g_dsp;
-BreakPoints dsp_breakpoints;
+DSPBreakpoints dsp_breakpoints;
DSPCoreState core_state = DSPCORE_RUNNING;
Common::Event step_event;
@@ -200,11 +200,9 @@ int DSPCore_RunCycles(int cycles)
switch (core_state)
{
case DSPCORE_RUNNING:
-#if 0 // Set to 1 to enable stepping
- // Enable breakpoints
+#if 1 // Set to 0 to disable breakpoints, for a speed boost.
cycles = DSPInterpreter::RunCyclesDebug(cycles);
#else
- //1: enter a fast runloop
cycles = DSPInterpreter::RunCycles(cycles);
#endif
break;
diff --git a/Source/Core/DSPCore/Src/DSPCore.h b/Source/Core/DSPCore/Src/DSPCore.h
index a0c574ca1a..eab5773c03 100644
--- a/Source/Core/DSPCore/Src/DSPCore.h
+++ b/Source/Core/DSPCore/Src/DSPCore.h
@@ -26,7 +26,7 @@
#ifndef _DSPCORE_H
#define _DSPCORE_H
-#include "BreakPoints.h"
+#include "DSPBreakpoints.h"
#define DSP_IRAM_BYTE_SIZE 0x2000
#define DSP_IRAM_SIZE 0x1000
@@ -201,7 +201,7 @@ struct SDSP
};
extern SDSP g_dsp;
-extern BreakPoints dsp_breakpoints;
+extern DSPBreakpoints dsp_breakpoints;
bool DSPCore_Init(const char *irom_filename, const char *coef_filename);
void DSPCore_Reset();
diff --git a/Source/Core/DSPCore/Src/DSPInterpreter.cpp b/Source/Core/DSPCore/Src/DSPInterpreter.cpp
index d1f98995e9..e054c61237 100644
--- a/Source/Core/DSPCore/Src/DSPInterpreter.cpp
+++ b/Source/Core/DSPCore/Src/DSPInterpreter.cpp
@@ -157,33 +157,59 @@ int RunCyclesDebug(int cycles)
{
if (g_dsp.cr & CR_HALT)
return 0;
+ if (dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
+ {
+ DSPCore_SetState(DSPCORE_STEPPING);
+ return cycles;
+ }
Step();
cycles--;
+ if (cycles < 0)
+ return 0;
}
- while (cycles > 0)
+ DSPCore_CheckExternalInterrupt();
+
+ // Now, let's run a few cycles with idle skipping.
+ for (int i = 0; i < 8; i++)
{
- if (g_dsp.cr & CR_HALT) {
+ if (g_dsp.cr & CR_HALT)
return 0;
- }
if (dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
{
DSPCore_SetState(DSPCORE_STEPPING);
return cycles;
}
- DSPCore_CheckExternalInterrupt();
- Step();
- cycles--;
-
// Idle skipping.
if (DSPAnalyzer::code_flags[g_dsp.pc] & DSPAnalyzer::CODE_IDLE_SKIP)
return 0;
+
+ Step();
+ cycles--;
+ if (cycles < 0)
+ return 0;
}
+
+ // Finally, run the rest of the block without.
+ while (cycles > 0)
+ {
+ if (dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
+ {
+ DSPCore_SetState(DSPCORE_STEPPING);
+ return cycles;
+ }
+ Step();
+ cycles--;
+ }
+
+ return cycles;
}
// Used by non-thread mode. Meant to be efficient.
int RunCycles(int cycles)
{
+ DSPCore_CheckExternalInterrupt();
+
if (cycles < 18)
{
for (int i = 0; i < cycles; i++)
diff --git a/Source/Core/DSPCore/Src/SConscript b/Source/Core/DSPCore/Src/SConscript
index 3fcf93f3c2..f79d9e06f1 100644
--- a/Source/Core/DSPCore/Src/SConscript
+++ b/Source/Core/DSPCore/Src/SConscript
@@ -6,6 +6,7 @@ files = [
"assemble.cpp",
"disassemble.cpp",
"DSPAccelerator.cpp",
+ "DSPBreakpoints.cpp",
"DSPIntCCUtil.cpp",
"DSPIntExtOps.cpp",
"DSPHWInterface.cpp",