First pass at getting '--disable-developer' configure option to work.

It's still broken; just not as much as before.  So you should still
compile in debugger support for now.  This will probably involve
moving around some classes in the codebase, such as all GUI related
classes used by the debugger will go in 'debugger/gui'.

Sorry for any inconvenience this may cause, but the debugger
support has almost doubled the size of the executable, and there
are some platforms that can neither use it nor deal with its overhead.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@740 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-08-24 22:54:30 +00:00
parent 2370bb9764
commit ed135b1aa5
10 changed files with 175 additions and 122 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Console.cxx,v 1.65 2005-07-03 01:36:40 urchlay Exp $ // $Id: Console.cxx,v 1.66 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <assert.h>
@ -45,13 +45,16 @@
#include "FrameBuffer.hxx" #include "FrameBuffer.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "Menu.hxx" #include "Menu.hxx"
#include "Debugger.hxx"
#include "Version.hxx" #include "Version.hxx"
#ifdef SNAPSHOT_SUPPORT #ifdef SNAPSHOT_SUPPORT
#include "Snapshot.hxx" #include "Snapshot.hxx"
#endif #endif
#ifdef DEVELOPER_SUPPORT
#include "Debugger.hxx"
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Console::Console(const uInt8* image, uInt32 size, OSystem* osystem) Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
: myOSystem(osystem) : myOSystem(osystem)
@ -137,7 +140,9 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
M6502* m6502; M6502* m6502;
m6502 = new M6502High(1); m6502 = new M6502High(1);
#ifdef DEVELOPER_SUPPORT
m6502->attach(myOSystem->debugger()); m6502->attach(myOSystem->debugger());
#endif
M6532* m6532 = new M6532(*this); M6532* m6532 = new M6532(*this);
TIA *tia = new TIA(*this, myOSystem->settings()); TIA *tia = new TIA(*this, myOSystem->settings());
@ -185,9 +190,11 @@ Console::Console(const uInt8* image, uInt32 size, OSystem* osystem)
myOSystem->menu().initialize(); myOSystem->menu().initialize();
myOSystem->menu().setGameProfile(myProperties); myOSystem->menu().setGameProfile(myProperties);
#ifdef DEVELOPER_SUPPORT
// Finally, initialize the debugging system, since it depends on the current ROM // Finally, initialize the debugging system, since it depends on the current ROM
myOSystem->debugger().setConsole(this); myOSystem->debugger().setConsole(this);
myOSystem->debugger().initialize(); myOSystem->debugger().initialize();
#endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -374,7 +381,6 @@ void Console::fry()
mySystem->poke(ZPmem, mySystem->peek(ZPmem) & (uInt8)rand() % 256); mySystem->poke(ZPmem, mySystem->peek(ZPmem) & (uInt8)rand() % 256);
} }
#ifdef DEVELOPER_SUPPORT
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::changeXStart(const uInt32 direction) void Console::changeXStart(const uInt32 direction)
{ {
@ -612,5 +618,3 @@ void Console::setDeveloperProperties()
if(s != "") if(s != "")
myProperties.set("Emulation.HmoveBlanks", s); myProperties.set("Emulation.HmoveBlanks", s);
} }
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Console.hxx,v 1.37 2005-07-02 17:15:42 urchlay Exp $ // $Id: Console.hxx,v 1.38 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#ifndef CONSOLE_HXX #ifndef CONSOLE_HXX
@ -37,7 +37,7 @@ class System;
This class represents the entire game console. This class represents the entire game console.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Console.hxx,v 1.37 2005-07-02 17:15:42 urchlay Exp $ @version $Id: Console.hxx,v 1.38 2005-08-24 22:54:30 stephena Exp $
*/ */
class Console class Console
{ {
@ -172,7 +172,6 @@ class Console
*/ */
void fry(); void fry();
#ifdef DEVELOPER_SUPPORT
public: public:
/** /**
Change the "Display.XStart" variable. Currently, a system reset is issued Change the "Display.XStart" variable. Currently, a system reset is issued
@ -220,7 +219,6 @@ class Console
private: private:
void toggleTIABit(TIA::TIABit bit, const string& bitname, bool show = true); void toggleTIABit(TIA::TIABit bit, const string& bitname, bool show = true);
void setDeveloperProperties(); void setDeveloperProperties();
#endif
private: private:
// Pointer to the osystem object // Pointer to the osystem object

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.cxx,v 1.85 2005-08-11 19:12:38 stephena Exp $ // $Id: EventHandler.cxx,v 1.86 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#include <algorithm> #include <algorithm>
@ -30,10 +30,13 @@
#include "OSystem.hxx" #include "OSystem.hxx"
#include "Menu.hxx" #include "Menu.hxx"
#include "Launcher.hxx" #include "Launcher.hxx"
#include "Debugger.hxx"
#include "GuiUtils.hxx" #include "GuiUtils.hxx"
#include "bspf.hxx" #include "bspf.hxx"
#ifdef DEVELOPER_SUPPORT
#include "Debugger.hxx"
#endif
#ifdef SNAPSHOT_SUPPORT #ifdef SNAPSHOT_SUPPORT
#include "Snapshot.hxx" #include "Snapshot.hxx"
#endif #endif
@ -171,9 +174,11 @@ void EventHandler::refreshDisplay()
myOSystem->launcher().refresh(); myOSystem->launcher().refresh();
break; break;
#ifdef DEVELOPER_SUPPORT
case S_DEBUGGER: case S_DEBUGGER:
myOSystem->debugger().refresh(); myOSystem->debugger().refresh();
break; break;
#endif
default: default:
break; break;
@ -630,9 +635,11 @@ void EventHandler::poll(uInt32 time)
myOSystem->launcher().updateTime(time); myOSystem->launcher().updateTime(time);
break; break;
#ifdef DEVELOPER_SUPPORT
case S_DEBUGGER: case S_DEBUGGER:
myOSystem->debugger().updateTime(time); myOSystem->debugger().updateTime(time);
break; break;
#endif
default: default:
break; break;
@ -679,6 +686,7 @@ void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 sta
myOSystem->launcher().handleKeyEvent(unicode, key, mod, state); myOSystem->launcher().handleKeyEvent(unicode, key, mod, state);
break; break;
#ifdef DEVELOPER_SUPPORT
case S_DEBUGGER: case S_DEBUGGER:
if(myKeyTable[key] == Event::DebuggerMode && state == 1 && if(myKeyTable[key] == Event::DebuggerMode && state == 1 &&
!(kbdAlt(mod) || kbdControl(mod) || kbdShift(mod))) !(kbdAlt(mod) || kbdControl(mod) || kbdShift(mod)))
@ -688,8 +696,9 @@ void EventHandler::handleKeyEvent(int unicode, SDLKey key, SDLMod mod, uInt8 sta
} }
myOSystem->debugger().handleKeyEvent(unicode, key, mod, state); myOSystem->debugger().handleKeyEvent(unicode, key, mod, state);
break; break;
#endif
case S_NONE: default:
return; return;
break; break;
} }
@ -726,11 +735,13 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
myOSystem->launcher().handleMouseMotionEvent(x, y, 0); myOSystem->launcher().handleMouseMotionEvent(x, y, 0);
break; break;
#ifdef DEVELOPER_SUPPORT
case S_DEBUGGER: case S_DEBUGGER:
myOSystem->debugger().handleMouseMotionEvent(x, y, 0); myOSystem->debugger().handleMouseMotionEvent(x, y, 0);
break; break;
#endif
case S_NONE: default:
return; return;
break; break;
} }
@ -784,8 +795,10 @@ void EventHandler::handleMouseButtonEvent(SDL_Event& event, uInt8 state)
myOSystem->menu().handleMouseButtonEvent(button, x, y, state); myOSystem->menu().handleMouseButtonEvent(button, x, y, state);
else if(myState == S_LAUNCHER) else if(myState == S_LAUNCHER)
myOSystem->launcher().handleMouseButtonEvent(button, x, y, state); myOSystem->launcher().handleMouseButtonEvent(button, x, y, state);
#ifdef DEVELOPER_SUPPORT
else else
myOSystem->debugger().handleMouseButtonEvent(button, x, y, state); myOSystem->debugger().handleMouseButtonEvent(button, x, y, state);
#endif
break; break;
} }
@ -813,11 +826,13 @@ void EventHandler::handleJoyEvent(uInt8 stick, uInt32 code, uInt8 state)
myOSystem->launcher().handleJoyEvent(stick, code, state); myOSystem->launcher().handleJoyEvent(stick, code, state);
break; break;
#ifdef DEVELOPER_SUPPORT
case S_DEBUGGER: case S_DEBUGGER:
myOSystem->debugger().handleJoyEvent(stick, code, state); myOSystem->debugger().handleJoyEvent(stick, code, state);
break; break;
#endif
case S_NONE: default:
return; return;
break; break;
} }
@ -1366,6 +1381,7 @@ void EventHandler::leaveMenuMode()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EventHandler::enterDebugMode() bool EventHandler::enterDebugMode()
{ {
#ifdef DEVELOPER_SUPPORT
if(myState == S_DEBUGGER) if(myState == S_DEBUGGER)
return false; return false;
@ -1384,6 +1400,7 @@ bool EventHandler::enterDebugMode()
// Make sure screen is always refreshed when entering debug mode // Make sure screen is always refreshed when entering debug mode
// (sometimes entering on a breakpoint doesn't draw contents) // (sometimes entering on a breakpoint doesn't draw contents)
refreshDisplay(); refreshDisplay();
#endif
return true; return true;
} }
@ -1391,6 +1408,7 @@ bool EventHandler::enterDebugMode()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::leaveDebugMode() void EventHandler::leaveDebugMode()
{ {
#ifdef DEVELOPER_SUPPORT
// paranoia: this should never happen: // paranoia: this should never happen:
if(myState != S_DEBUGGER) if(myState != S_DEBUGGER)
return; return;
@ -1406,6 +1424,7 @@ void EventHandler::leaveDebugMode()
if(myPauseFlag) // Un-Pause when leaving debugger mode if(myPauseFlag) // Un-Pause when leaving debugger mode
handleEvent(Event::Pause, 1); handleEvent(Event::Pause, 1);
#endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.cxx,v 1.62 2005-08-24 05:29:59 markgrebe Exp $ // $Id: FrameBuffer.cxx,v 1.63 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -29,8 +29,12 @@
#include "GuiUtils.hxx" #include "GuiUtils.hxx"
#include "Menu.hxx" #include "Menu.hxx"
#include "Launcher.hxx" #include "Launcher.hxx"
#include "Debugger.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#ifdef DEVELOPER_SUPPORT
#include "Debugger.hxx"
#endif
#ifdef MAC_OSX #ifdef MAC_OSX
extern "C" { extern "C" {
uInt16 macOSXDisplayWidth(void); uInt16 macOSXDisplayWidth(void);
@ -213,13 +217,15 @@ void FrameBuffer::update()
break; // S_LAUNCHER break; // S_LAUNCHER
} }
#ifdef DEVELOPER_SUPPORT
case EventHandler::S_DEBUGGER: case EventHandler::S_DEBUGGER:
{ {
myOSystem->debugger().draw(); myOSystem->debugger().draw();
break; // S_DEBUGGER break; // S_DEBUGGER
} }
#endif
case EventHandler::S_NONE: default:
return; return;
break; break;
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.cxx,v 1.31 2005-08-24 01:07:36 stephena Exp $ // $Id: OSystem.cxx,v 1.32 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -34,13 +34,16 @@
#include "SoundSDL.hxx" #include "SoundSDL.hxx"
#endif #endif
#ifdef DEVELOPER_SUPPORT
#include "Debugger.hxx"
#endif
#include "FSNode.hxx" #include "FSNode.hxx"
#include "Settings.hxx" #include "Settings.hxx"
#include "PropsSet.hxx" #include "PropsSet.hxx"
#include "EventHandler.hxx" #include "EventHandler.hxx"
#include "Menu.hxx" #include "Menu.hxx"
#include "Launcher.hxx" #include "Launcher.hxx"
#include "Debugger.hxx"
#include "Font.hxx" #include "Font.hxx"
#include "StellaFont.hxx" #include "StellaFont.hxx"
#include "ConsoleFont.hxx" #include "ConsoleFont.hxx"
@ -66,7 +69,9 @@ OSystem::OSystem()
// Create menu and launcher GUI objects // Create menu and launcher GUI objects
myMenu = new Menu(this); myMenu = new Menu(this);
myLauncher = new Launcher(this); myLauncher = new Launcher(this);
#ifdef DEVELOPER_SUPPORT
myDebugger = new Debugger(this); myDebugger = new Debugger(this);
#endif
// Create fonts to draw text // Create fonts to draw text
myFont = new GUI::Font(GUI::stellaDesc); myFont = new GUI::Font(GUI::stellaDesc);
@ -97,10 +102,13 @@ OSystem::~OSystem()
delete myMenu; delete myMenu;
delete myLauncher; delete myLauncher;
delete myDebugger;
delete myFont; delete myFont;
delete myConsoleFont; delete myConsoleFont;
#ifdef DEVELOPER_SUPPORT
delete myDebugger;
#endif
// Remove any game console that is currently attached // Remove any game console that is currently attached
delete myConsole; delete myConsole;
@ -220,11 +228,13 @@ cout << " ==> video: " << video << endl;
myLauncher->initializeVideo(); myLauncher->initializeVideo();
break; // S_LAUNCHER break; // S_LAUNCHER
#ifdef DEVELOPER_SUPPORT
case EventHandler::S_DEBUGGER: case EventHandler::S_DEBUGGER:
myDebugger->initializeVideo(); myDebugger->initializeVideo();
break; // S_DEBUGGER break; // S_DEBUGGER
#endif
case EventHandler::S_NONE: default:
break; break;
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.hxx,v 1.26 2005-08-10 12:23:42 stephena Exp $ // $Id: OSystem.hxx,v 1.27 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#ifndef OSYSTEM_HXX #ifndef OSYSTEM_HXX
@ -42,7 +42,7 @@ class Debugger;
other objects belong. other objects belong.
@author Stephen Anthony @author Stephen Anthony
@version $Id: OSystem.hxx,v 1.26 2005-08-10 12:23:42 stephena Exp $ @version $Id: OSystem.hxx,v 1.27 2005-08-24 22:54:30 stephena Exp $
*/ */
class OSystem class OSystem
{ {
@ -135,20 +135,14 @@ class OSystem
*/ */
Launcher& launcher(void) const { return *myLauncher; } Launcher& launcher(void) const { return *myLauncher; }
#ifdef DEVELOPER_SUPPORT
/** /**
Get the ROM debugger of the system. Get the ROM debugger of the system.
@return The debugger object @return The debugger object
*/ */
Debugger& debugger(void) const { return *myDebugger; } Debugger& debugger(void) const { return *myDebugger; }
#endif
/**
Get the TIA debugger of the system.
@return The debugger object
I can't make this compile, weird header dependencies
*/
//TIADebug& tiaDebug(void) const { return *myDebugger->tiaDebug(); }
/** /**
Get the font object of the system Get the font object of the system

View File

@ -13,25 +13,30 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: M6502.cxx,v 1.13 2005-08-11 19:12:38 stephena Exp $ // $Id: M6502.cxx,v 1.14 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#include "M6502.hxx" #include "M6502.hxx"
#ifdef DEVELOPER_SUPPORT
#include "Expression.hxx" #include "Expression.hxx"
#endif
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
M6502::M6502(uInt32 systemCyclesPerProcessorCycle) M6502::M6502(uInt32 systemCyclesPerProcessorCycle)
: myExecutionStatus(0), : myExecutionStatus(0),
mySystem(0), mySystem(0),
myDebugger(0),
mySystemCyclesPerProcessorCycle(systemCyclesPerProcessorCycle) mySystemCyclesPerProcessorCycle(systemCyclesPerProcessorCycle)
{ {
uInt16 t; #ifdef DEVELOPER_SUPPORT
myDebugger = NULL;
breakPoints = NULL; breakPoints = NULL;
readTraps = NULL; readTraps = NULL;
writeTraps = NULL; writeTraps = NULL;
#endif
// Compute the BCD lookup table // Compute the BCD lookup table
uInt16 t;
for(t = 0; t < 256; ++t) for(t = 0; t < 256; ++t)
{ {
ourBCDTable[0][t] = ((t >> 4) * 10) + (t & 0x0f); ourBCDTable[0][t] = ((t >> 4) * 10) + (t & 0x0f);
@ -51,8 +56,10 @@ M6502::M6502(uInt32 systemCyclesPerProcessorCycle)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
M6502::~M6502() M6502::~M6502()
{ {
#ifdef DEVELOPER_SUPPORT
myBreakConds.clear(); myBreakConds.clear();
myBreakCondNames.clear(); myBreakCondNames.clear();
#endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -62,13 +69,6 @@ void M6502::install(System& system)
mySystem = &system; mySystem = &system;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::attach(Debugger& debugger)
{
// Remember the debugger for this microprocessor
myDebugger = &debugger;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::reset() void M6502::reset()
{ {
@ -102,54 +102,6 @@ void M6502::stop()
myExecutionStatus |= StopExecutionBit; myExecutionStatus |= StopExecutionBit;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
unsigned int M6502::addCondBreak(Expression *e, string name)
{
myBreakConds.push_back(e);
myBreakCondNames.push_back(name);
return myBreakConds.size() - 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::delCondBreak(unsigned int brk)
{
if(brk < myBreakConds.size()) {
delete myBreakConds[brk];
myBreakConds.remove_at(brk);
myBreakCondNames.remove_at(brk);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::clearCondBreaks()
{
for(unsigned int i=0; i<myBreakConds.size(); i++)
delete myBreakConds[i];
myBreakConds.clear();
myBreakCondNames.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const StringList& M6502::getCondBreakNames()
{
return myBreakCondNames;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int M6502::evalCondBreaks()
{
for(unsigned int i=0; i<myBreakConds.size(); i++) {
Expression *e = myBreakConds[i];
if(e->evaluate()) {
string name = myBreakCondNames[i]; // TODO: use this
cerr << "breakpoint due to condition: " << name << endl;
return i;
}
}
return -1; // no break hit
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
M6502::AddressingMode M6502::addressingMode(uInt8 opcode) const M6502::AddressingMode M6502::addressingMode(uInt8 opcode) const
{ {
@ -397,6 +349,63 @@ const char* M6502::ourInstructionMnemonicTable[256] = {
"SED", "SBC", "nop", "isb", "nop", "SBC", "INC", "isb" "SED", "SBC", "nop", "isb", "nop", "SBC", "INC", "isb"
}; };
#ifdef DEVELOPER_SUPPORT
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::attach(Debugger& debugger)
{
// Remember the debugger for this microprocessor
myDebugger = &debugger;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
unsigned int M6502::addCondBreak(Expression *e, string name)
{
myBreakConds.push_back(e);
myBreakCondNames.push_back(name);
return myBreakConds.size() - 1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::delCondBreak(unsigned int brk)
{
if(brk < myBreakConds.size()) {
delete myBreakConds[brk];
myBreakConds.remove_at(brk);
myBreakCondNames.remove_at(brk);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::clearCondBreaks()
{
for(unsigned int i=0; i<myBreakConds.size(); i++)
delete myBreakConds[i];
myBreakConds.clear();
myBreakCondNames.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const StringList& M6502::getCondBreakNames()
{
return myBreakCondNames;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int M6502::evalCondBreaks()
{
for(unsigned int i=0; i<myBreakConds.size(); i++) {
Expression *e = myBreakConds[i];
if(e->evaluate()) {
string name = myBreakCondNames[i]; // TODO: use this
cerr << "breakpoint due to condition: " << name << endl;
return i;
}
}
return -1; // no break hit
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::setBreakPoints(PackedBitArray *bp) { void M6502::setBreakPoints(PackedBitArray *bp) {
breakPoints = bp; breakPoints = bp;
} }
@ -406,4 +415,4 @@ void M6502::setTraps(PackedBitArray *read, PackedBitArray *write) {
readTraps = read; readTraps = read;
writeTraps = write; writeTraps = write;
} }
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: M6502.hxx,v 1.12 2005-08-11 19:12:38 stephena Exp $ // $Id: M6502.hxx,v 1.13 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#ifndef M6502_HXX #ifndef M6502_HXX
@ -26,10 +26,10 @@ class Deserializer;
class Debugger; class Debugger;
class CpuDebug; class CpuDebug;
class Expression; class Expression;
class PackedBitArray;
#include "bspf.hxx" #include "bspf.hxx"
#include "System.hxx" #include "System.hxx"
#include "PackedBitArray.hxx"
#include "Array.hxx" #include "Array.hxx"
#include "StringList.hxx" #include "StringList.hxx"
@ -41,7 +41,7 @@ typedef GUI::Array<Expression*> ExpressionList;
has a 64K addressing space. has a 64K addressing space.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: M6502.hxx,v 1.12 2005-08-11 19:12:38 stephena Exp $ @version $Id: M6502.hxx,v 1.13 2005-08-24 22:54:30 stephena Exp $
*/ */
class M6502 class M6502
{ {
@ -86,14 +86,6 @@ class M6502
*/ */
virtual void install(System& system); virtual void install(System& system);
/**
Attach the specified debugger.
@param debugger The debugger to attach to the microprocessor.
*/
void attach(Debugger& debugger);
public:
/** /**
Reset the processor to its power-on state. This method should not Reset the processor to its power-on state. This method should not
be invoked until the entire 6502 system is constructed and installed be invoked until the entire 6502 system is constructed and installed
@ -182,6 +174,15 @@ class M6502
friend ostream& operator<<(ostream& out, const AddressingMode& mode); friend ostream& operator<<(ostream& out, const AddressingMode& mode);
public: public:
#ifdef DEVELOPER_SUPPORT
/**
Attach the specified debugger.
@param debugger The debugger to attach to the microprocessor.
*/
void attach(Debugger& debugger);
// TODO - document these methods
void setBreakPoints(PackedBitArray *bp); void setBreakPoints(PackedBitArray *bp);
void setTraps(PackedBitArray *read, PackedBitArray *write); void setTraps(PackedBitArray *read, PackedBitArray *write);
int totalInstructionCount() { return myTotalInstructionCount; } int totalInstructionCount() { return myTotalInstructionCount; }
@ -191,6 +192,7 @@ class M6502
void clearCondBreaks(); void clearCondBreaks();
const StringList& getCondBreakNames(); const StringList& getCondBreakNames();
int evalCondBreaks(); int evalCondBreaks();
#endif
protected: protected:
/** /**
@ -223,10 +225,21 @@ class M6502
bool notZ; // Z flag complement for processor status register bool notZ; // Z flag complement for processor status register
bool C; // C flag for processor status register bool C; // C flag for processor status register
#ifdef DEVELOPER_SUPPORT
/// Pointer to the debugger for this processor or the null pointer
Debugger* myDebugger;
PackedBitArray *breakPoints; PackedBitArray *breakPoints;
PackedBitArray *readTraps; PackedBitArray *readTraps;
PackedBitArray *writeTraps; PackedBitArray *writeTraps;
// did we just now hit a trap?
bool justHitTrap;
StringList myBreakCondNames;
ExpressionList myBreakConds;
#endif
/** /**
Bit fields used to indicate that certain conditions need to be Bit fields used to indicate that certain conditions need to be
handled such as stopping execution, fatal errors, maskable interrupts handled such as stopping execution, fatal errors, maskable interrupts
@ -248,9 +261,6 @@ class M6502
/// Pointer to the system the processor is installed in or the null pointer /// Pointer to the system the processor is installed in or the null pointer
System* mySystem; System* mySystem;
/// Pointer to the debugger for this processor or the null pointer
Debugger* myDebugger;
/// Indicates the number of system cycles per processor cycle /// Indicates the number of system cycles per processor cycle
const uInt32 mySystemCyclesPerProcessorCycle; const uInt32 mySystemCyclesPerProcessorCycle;
@ -273,13 +283,7 @@ class M6502
/// Table of instruction mnemonics /// Table of instruction mnemonics
static const char* ourInstructionMnemonicTable[256]; static const char* ourInstructionMnemonicTable[256];
// did we just now hit a trap?
bool justHitTrap;
int myTotalInstructionCount; int myTotalInstructionCount;
StringList myBreakCondNames;
ExpressionList myBreakConds;
}; };
#endif #endif

View File

@ -13,13 +13,16 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: M6502Hi.cxx,v 1.11 2005-07-17 02:26:50 urchlay Exp $ // $Id: M6502Hi.cxx,v 1.12 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#include "M6502Hi.hxx" #include "M6502Hi.hxx"
#include "Serializer.hxx" #include "Serializer.hxx"
#include "Deserializer.hxx" #include "Deserializer.hxx"
#ifdef DEVELOPER_SUPPORT
#include "Debugger.hxx" #include "Debugger.hxx"
#endif
#define debugStream cout #define debugStream cout
@ -29,7 +32,10 @@ M6502High::M6502High(uInt32 systemCyclesPerProcessorCycle)
{ {
myNumberOfDistinctAccesses = 0; myNumberOfDistinctAccesses = 0;
myLastAddress = 0; myLastAddress = 0;
#ifdef DEVELOPER_SUPPORT
justHitTrap = false; justHitTrap = false;
#endif
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -47,10 +53,11 @@ inline uInt8 M6502High::peek(uInt16 address)
} }
mySystem->incrementCycles(mySystemCyclesPerProcessorCycle); mySystem->incrementCycles(mySystemCyclesPerProcessorCycle);
if(readTraps != NULL) { #ifdef DEVELOPER_SUPPORT
if(readTraps != NULL)
if(readTraps->isSet(address)) if(readTraps->isSet(address))
justHitTrap = true; justHitTrap = true;
} #endif
return mySystem->peek(address); return mySystem->peek(address);
} }
@ -65,10 +72,11 @@ inline void M6502High::poke(uInt16 address, uInt8 value)
} }
mySystem->incrementCycles(mySystemCyclesPerProcessorCycle); mySystem->incrementCycles(mySystemCyclesPerProcessorCycle);
if(writeTraps != NULL) { #ifdef DEVELOPER_SUPPORT
if(writeTraps != NULL)
if(writeTraps->isSet(address)) if(writeTraps->isSet(address))
justHitTrap = true; justHitTrap = true;
} #endif
mySystem->poke(address, value); mySystem->poke(address, value);
} }
@ -87,6 +95,7 @@ bool M6502High::execute(uInt32 number)
uInt16 operandAddress = 0; uInt16 operandAddress = 0;
uInt8 operand = 0; uInt8 operand = 0;
#ifdef DEVELOPER_SUPPORT
if(justHitTrap) if(justHitTrap)
{ {
if(myDebugger->start()) { if(myDebugger->start()) {
@ -110,6 +119,7 @@ bool M6502High::execute(uInt32 number)
return true; return true;
} }
} }
#endif
#ifdef DEBUG #ifdef DEBUG
debugStream << "PC=" << hex << setw(4) << PC << " "; debugStream << "PC=" << hex << setw(4) << PC << " ";

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: System.hxx,v 1.10 2005-07-09 23:44:08 urchlay Exp $ // $Id: System.hxx,v 1.11 2005-08-24 22:54:30 stephena Exp $
//============================================================================ //============================================================================
#ifndef SYSTEM_HXX #ifndef SYSTEM_HXX
@ -29,7 +29,6 @@ class Deserializer;
#include "bspf.hxx" #include "bspf.hxx"
#include "Device.hxx" #include "Device.hxx"
#include "NullDev.hxx" #include "NullDev.hxx"
#include "PackedBitArray.hxx"
/** /**
This class represents a system consisting of a 6502 microprocessor This class represents a system consisting of a 6502 microprocessor
@ -48,7 +47,7 @@ class Deserializer;
dynamic code for that page of memory. dynamic code for that page of memory.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: System.hxx,v 1.10 2005-07-09 23:44:08 urchlay Exp $ @version $Id: System.hxx,v 1.11 2005-08-24 22:54:30 stephena Exp $
*/ */
class System class System
{ {