Refactor a few classes to not include so many headers.

Including many header files in other headers leads to a cascade of
compiles when changing one of them.

Note that this potentially makes some inline methods non-inline
(although current idea on this is that the compiler can make
much better choices for when to inline).  So we may need to check
performance after this work, to make sure no regressions happen.
This commit is contained in:
Stephen Anthony 2017-11-14 21:52:23 -03:30
parent 6970389ff5
commit 632fffcb49
5 changed files with 71 additions and 39 deletions

View File

@ -22,13 +22,17 @@
#include "FSNode.hxx"
#include "DiStella.hxx"
#include "Debugger.hxx"
#include "DebuggerParser.hxx"
#include "CpuDebug.hxx"
#include "OSystem.hxx"
#include "Settings.hxx"
#include "Version.hxx"
#include "Cart.hxx"
#include "CartDebug.hxx"
#include "CartDebugWidget.hxx"
#include "CartRamWidget.hxx"
#include "System.hxx"
#include "Base.hxx"
using Common::Base;
using std::hex;
using std::dec;
@ -179,6 +183,18 @@ int CartDebug::readFromWritePort()
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartDebug::lastReadBaseAddress()
{
return mySystem.m6502().lastReadBaseAddress();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartDebug::lastWriteBaseAddress()
{
return mySystem.m6502().lastWriteBaseAddress();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartDebug::toString()
{
@ -513,6 +529,18 @@ bool CartDebug::addDirective(CartDebug::DisasmType type,
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartDebug::getBank()
{
return myConsole.cartridge().getBank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int CartDebug::bankCount() const
{
return myConsole.cartridge().bankCount();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartDebug::addLabel(const string& label, uInt16 address)
{

View File

@ -26,11 +26,7 @@ class CartDebugWidget;
#include <list>
#include "bspf.hxx"
#include "Base.hxx"
#include "Cart.hxx"
#include "DebuggerSystem.hxx"
#include "System.hxx"
#include "M6502.hxx"
// Function type for CartDebug instance methods
class CartDebug;
@ -122,9 +118,9 @@ class CartDebug : public DebuggerSystem
int readFromWritePort();
// Return the base (= non-mirrored) address of the last CPU read
int lastReadBaseAddress() { return mySystem.m6502().lastReadBaseAddress(); }
int lastReadBaseAddress();
// Return the base (= non-mirrored) address of the last CPU write
int lastWriteBaseAddress() { return mySystem.m6502().lastWriteBaseAddress(); }
int lastWriteBaseAddress();
// The following two methods are meant to be used together
// First, a call is made to disassemble(), which updates the disassembly
@ -190,17 +186,12 @@ class CartDebug : public DebuggerSystem
Get the current bank in use by the cartridge
(non-const because of use in YaccParser)
*/
int getBank() { return myConsole.cartridge().getBank(); }
int getBank();
/**
Get the total number of banks supported by the cartridge.
*/
int bankCount() const { return myConsole.cartridge().bankCount(); }
/**
Get the name/type of the cartridge. // FIXME - dead code
*/
string getCartType() const { return myConsole.cartridge().name(); }
int bankCount() const;
/**
Add a label and associated address.
@ -293,19 +284,6 @@ class CartDebug : public DebuggerSystem
DirectiveList directiveList; // overrides for automatic code determination
BankInfo() : start(0), end(0), offset(0), size(0) { }
#if 0
friend ostream& operator<<(ostream& os, const BankInfo& b)
{
os << "start=$" << Common::Base::HEX4 << b.start
<< ", end=$" << Common::Base::HEX4 << b.end
<< ", offset=$" << Common::Base::HEX4 << b.offset
<< ", size=" << dec << b.size << endl
<< "addrlist: ";
for(const auto& i: b.addressList)
os << Common::Base::HEX4 << i << " ";
return os;
}
#endif
};
// Address type information determined by Distella

View File

@ -29,6 +29,7 @@
#include "Settings.hxx"
#include "DebuggerDialog.hxx"
#include "DebuggerParser.hxx"
#include "StateManager.hxx"
#include "Console.hxx"
#include "System.hxx"
@ -179,6 +180,24 @@ string Debugger::autoExec(StringList* history)
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PackedBitArray& Debugger::breakPoints() const
{
return mySystem.m6502().breakPoints();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrapArray& Debugger::readTraps() const
{
return mySystem.m6502().readTraps();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrapArray& Debugger::writeTraps() const
{
return mySystem.m6502().writeTraps();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::run(const string& command)
{
@ -512,6 +531,12 @@ string Debugger::showWatches()
return myParser->showWatches();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Debugger::stringToValue(const string& stringval)
{
return myParser->decipher_arg(stringval);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::patchROM(uInt16 addr, uInt8 value)
{

View File

@ -27,23 +27,23 @@ class EditTextWidget;
class RomWidget;
class Expression;
class PackedBitArray;
class TrapArray;
class PromptWidget;
class ButtonWidget;
class CartDebug;
class CpuDebug;
class RiotDebug;
class TIADebug;
class DebuggerParser;
class RewindManager;
#include <map>
#include "Base.hxx"
#include "DialogContainer.hxx"
#include "DebuggerDialog.hxx"
#include "DebuggerParser.hxx"
#include "StateManager.hxx"
#include "M6502.hxx"
#include "System.hxx"
#include "Stack.hxx"
#include "CartDebug.hxx"
#include "CpuDebug.hxx"
#include "RiotDebug.hxx"
#include "TIADebug.hxx"
#include "bspf.hxx"
using FunctionMap = std::map<string, unique_ptr<Expression>>;
@ -146,9 +146,9 @@ class Debugger : public DialogContainer
RomWidget& rom() const { return myDialog->rom(); }
TiaOutputWidget& tiaOutput() const { return myDialog->tiaOutput(); }
PackedBitArray& breakPoints() const { return mySystem.m6502().breakPoints(); }
TrapArray& readTraps() const { return mySystem.m6502().readTraps(); }
TrapArray& writeTraps() const { return mySystem.m6502().writeTraps(); }
PackedBitArray& breakPoints() const;
TrapArray& readTraps() const;
TrapArray& writeTraps() const;
/**
Run the debugger command and return the result.
@ -163,8 +163,7 @@ class Debugger : public DialogContainer
Convert between string->integer and integer->string, taking into
account the current base format.
*/
int stringToValue(const string& stringval)
{ return myParser->decipher_arg(stringval); }
int stringToValue(const string& stringval);
/* Convenience methods to get/set bit(s) in an 8-bit register */
static uInt8 set_bit(uInt8 input, uInt8 bit, bool on)

View File

@ -20,6 +20,8 @@
#include "OSystem.hxx"
#include "TIATypes.hxx"
#include "Debugger.hxx"
#include "CartDebug.hxx"
#include "TIADebug.hxx"
#include "Base.hxx"
#include "TIA.hxx"