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
This commit is contained in:
hrydgard 2009-06-28 17:18:52 +00:00
parent e4af896638
commit cc38e72dc3
12 changed files with 137 additions and 24 deletions

View file

@ -482,6 +482,14 @@
RelativePath=".\Src\DSPAnalyzer.h"
>
</File>
<File
RelativePath=".\Src\DSPBreakpoints.cpp"
>
</File>
<File
RelativePath=".\Src\DSPBreakpoints.h"
>
</File>
<File
RelativePath=".\Src\DSPCodeUtil.cpp"
>

View file

@ -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.

View file

@ -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"

View file

@ -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

View file

@ -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;

View file

@ -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();

View file

@ -157,33 +157,59 @@ int RunCyclesDebug(int cycles)
{
if (g_dsp.cr & CR_HALT)
return 0;
Step();
cycles--;
}
while (cycles > 0)
{
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--;
if (cycles < 0)
return 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)
return 0;
if (dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
{
DSPCore_SetState(DSPCORE_STEPPING);
return 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++)

View file

@ -6,6 +6,7 @@ files = [
"assemble.cpp",
"disassemble.cpp",
"DSPAccelerator.cpp",
"DSPBreakpoints.cpp",
"DSPIntCCUtil.cpp",
"DSPIntExtOps.cpp",
"DSPHWInterface.cpp",

View file

@ -21,7 +21,7 @@
wxString CRegTable::GetValue(int row, int col)
{
if (row < 36) // 32 "normal" regs
if (row < 32) // 32 "normal" regs
{
switch (col)
{
@ -46,7 +46,7 @@ void CRegTable::UpdateCachedRegs()
m_CachedCounter = g_dsp.step_counter;
for (int i = 0; i < 36; ++i)
for (int i = 0; i < 32; ++i)
{
m_CachedRegHasChanged[i] = (m_CachedRegs[i] != g_dsp.r[i]);
m_CachedRegs[i] = g_dsp.r[i];

View file

@ -38,7 +38,7 @@ public:
}
int GetNumberCols(void) {return 2;}
int GetNumberRows(void) {return 36;}
int GetNumberRows(void) {return 32;}
bool IsEmptyCell(int row, int col) {return false;}
wxString GetValue(int row, int col);
void SetValue(int row, int col, const wxString &);

View file

@ -50,8 +50,8 @@ DSPDebuggerLLE::~DSPDebuggerLLE()
void DSPDebuggerLLE::CreateGUIControls()
{
// Basic settings
SetSize(700, 500);
this->SetSizeHints(700, 500);
SetSize(700, 800);
this->SetSizeHints(700, 800);
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
m_Toolbar = CreateToolBar(wxTB_NODIVIDER|wxTB_NOICONS|wxTB_HORZ_TEXT|wxTB_DOCKABLE, ID_TOOLBAR);

View file

@ -865,7 +865,7 @@ void 0233_Increase_32BitAddress_InMem(_MemAddr(AR0), _Bytes(AX0.L))
void 0239_WaitUntilLastFrameGotSynced()
{
// 0239 8100 clr $ACC0
// 23a 8900 clr $ACC1
// 023a 8900 clr $ACC1
// 023b 00df 0354 lr $AC1.M, @0x0354
// 023d 00de 034e lr $AC0.M, @0x034e
// 023f 8200 cmp