Making the CPU debugger's bus read silent

This commit is contained in:
Anonymus Raccoon
2020-03-24 19:25:33 +01:00
parent a3c406db9d
commit 256fea8955
5 changed files with 31 additions and 30 deletions
+16 -18
View File
@@ -45,6 +45,8 @@ namespace ComSquare::Debugger
try { try {
if (this->_isPaused) if (this->_isPaused)
return 0xFF; return 0xFF;
if (this->_isStepping)
return this->_executeInstruction(this->_bus->read(this->_registers.pac++));
return CPU::update(); return CPU::update();
} catch (InvalidOpcode &e) { } catch (InvalidOpcode &e) {
if (!this->_isPaused) if (!this->_isPaused)
@@ -55,10 +57,6 @@ namespace ComSquare::Debugger
unsigned CPUDebug::_executeInstruction(uint8_t opcode) unsigned CPUDebug::_executeInstruction(uint8_t opcode)
{ {
if (this->_isPaused) {
this->_registers.pac--;
return 0;
}
if (this->_isStepping) { if (this->_isStepping) {
this->_isStepping = false; this->_isStepping = false;
this->_isPaused = true; this->_isPaused = true;
@@ -130,10 +128,10 @@ namespace ComSquare::Debugger
std::string CPUDebug::_getImmediateValueForA(uint24_t pc) std::string CPUDebug::_getImmediateValueForA(uint24_t pc)
{ {
unsigned value = this->_bus->read(pc); unsigned value = this->_bus->read(pc, true);
if (!this->_registers.p.m) if (!this->_registers.p.m)
value += this->_bus->read(pc + 1) << 8u; value += this->_bus->read(pc + 1, true) << 8u;
std::stringstream ss; std::stringstream ss;
ss << "#$" << std::hex << value; ss << "#$" << std::hex << value;
return ss.str(); return ss.str();
@@ -141,10 +139,10 @@ namespace ComSquare::Debugger
std::string CPUDebug::_getImmediateValueForX(uint24_t pc) std::string CPUDebug::_getImmediateValueForX(uint24_t pc)
{ {
unsigned value = this->_bus->read(pc); unsigned value = this->_bus->read(pc, true);
if (!this->_registers.p.x_b) if (!this->_registers.p.x_b)
value += this->_bus->read(pc + 1) << 8u; value += this->_bus->read(pc + 1, true) << 8u;
std::stringstream ss; std::stringstream ss;
ss << "#$" << std::hex << value; ss << "#$" << std::hex << value;
return ss.str(); return ss.str();
@@ -153,14 +151,14 @@ namespace ComSquare::Debugger
std::string CPUDebug::_getImmediateValue8Bits(uint24_t pc) std::string CPUDebug::_getImmediateValue8Bits(uint24_t pc)
{ {
std::stringstream ss; std::stringstream ss;
ss << "#$" << std::hex << static_cast<int>(this->_bus->read(pc)); ss << "#$" << std::hex << static_cast<int>(this->_bus->read(pc), true);
return ss.str(); return ss.str();
} }
std::string CPUDebug::_getImmediateValue16Bits(uint24_t pc) std::string CPUDebug::_getImmediateValue16Bits(uint24_t pc)
{ {
unsigned value = this->_bus->read(pc); unsigned value = this->_bus->read(pc, true);
value += this->_bus->read(pc + 1) << 8u; value += this->_bus->read(pc + 1, true) << 8u;
std::stringstream ss; std::stringstream ss;
ss << "#$" << std::hex << value; ss << "#$" << std::hex << value;
@@ -170,22 +168,22 @@ namespace ComSquare::Debugger
std::string CPUDebug::_getDirectValue(uint24_t pc) std::string CPUDebug::_getDirectValue(uint24_t pc)
{ {
std::stringstream ss; std::stringstream ss;
ss << "$" << std::hex << static_cast<int>(this->_bus->read(pc)); ss << "$" << std::hex << static_cast<int>(this->_bus->read(pc), true);
return ss.str(); return ss.str();
} }
std::string CPUDebug::_getAbsoluteValue(uint24_t pc) std::string CPUDebug::_getAbsoluteValue(uint24_t pc)
{ {
std::stringstream ss; std::stringstream ss;
ss << "$" << std::hex << (this->_bus->read(pc) + (this->_bus->read(pc + 1) << 8u)); ss << "$" << std::hex << (this->_bus->read(pc) + (this->_bus->read(pc + 1) << 8u), true);
return ss.str(); return ss.str();
} }
std::string CPUDebug::_getAbsoluteLongValue(uint24_t pc) std::string CPUDebug::_getAbsoluteLongValue(uint24_t pc)
{ {
unsigned value = this->_bus->read(pc++); unsigned value = this->_bus->read(pc++, true);
value += this->_bus->read(pc++) << 8u; value += this->_bus->read(pc++, true) << 8u;
value += this->_bus->read(pc) << 16u; value += this->_bus->read(pc, true) << 16u;
std::stringstream ss; std::stringstream ss;
ss << "$" << std::hex << value; ss << "$" << std::hex << value;
@@ -194,7 +192,7 @@ namespace ComSquare::Debugger
std::string CPUDebug::_getDirectIndexedByXValue(uint24_t pc) std::string CPUDebug::_getDirectIndexedByXValue(uint24_t pc)
{ {
unsigned value = this->_bus->read(pc); unsigned value = this->_bus->read(pc, true);
std::stringstream ss; std::stringstream ss;
ss << "$" << std::hex << value << ", x"; ss << "$" << std::hex << value << ", x";
@@ -203,7 +201,7 @@ namespace ComSquare::Debugger
std::string CPUDebug::_getInstructionString(uint24_t pc) std::string CPUDebug::_getInstructionString(uint24_t pc)
{ {
uint8_t opcode = this->_bus->read(pc++); uint8_t opcode = this->_bus->read(pc++, true);
switch (opcode) { switch (opcode) {
case Instructions::BRK: return "BRK"; case Instructions::BRK: return "BRK";
+11 -9
View File
@@ -48,12 +48,13 @@ namespace ComSquare::Debugger
return true; return true;
} }
uint8_t MemoryBusDebug::read(uint24_t addr) uint8_t MemoryBusDebug::read(uint24_t addr, bool silence)
{ {
auto accessor = this->getAccessor(addr); if (!silence) {
uint8_t value = accessor->read(addr - accessor->getStart()); auto accessor = this->getAccessor(addr);
this->_model.log(BusLog(false, addr, accessor, value, value)); uint8_t value = accessor->read(addr - accessor->getStart());
this->_model.log(BusLog(false, addr, accessor, value, value));
}
return MemoryBus::read(addr); return MemoryBus::read(addr);
} }
@@ -134,10 +135,11 @@ QVariant BusLogModel::headerData(int section, Qt::Orientation orientation, int r
void BusLogModel::log(ComSquare::Debugger::BusLog log) void BusLogModel::log(ComSquare::Debugger::BusLog log)
{ {
this->_logs.push_back(log);
int row = this->_logs.size(); int row = this->_logs.size();
this->beginInsertRows(QModelIndex(), row, row);
this->_logs.push_back(log);
this->insertRow(row); this->insertRow(row);
emit this->layoutChanged(); this->endInsertRows();
} }
ComSquare::Debugger::BusLog BusLogModel::getLogAt(int index) ComSquare::Debugger::BusLog BusLogModel::getLogAt(int index)
@@ -151,7 +153,7 @@ bool BusLoggerProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePa
{ {
ComSquare::Debugger::BusLog log = this->_parent.getLogAt(sourceRow); ComSquare::Debugger::BusLog log = this->_parent.getLogAt(sourceRow);
if (log.accessor && log.accessor->getName() == "Cartridge") // if (log.accessor && log.accessor->getName() == "Cartridge")
return false; // return false;
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
} }
+1 -1
View File
@@ -120,7 +120,7 @@ namespace ComSquare::Debugger
//! @brief Read data at a global address and log it to the debugger. //! @brief Read data at a global address and log it to the debugger.
//! @param addr The address to read from. //! @param addr The address to read from.
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register. //! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
uint8_t read(uint24_t addr) override; uint8_t read(uint24_t addr, bool silence = false) override;
//! @brief Write a data to a global address and log it to the debugger. //! @brief Write a data to a global address and log it to the debugger.
//! @param addr The address to write to. //! @param addr The address to write to.
+1 -1
View File
@@ -22,7 +22,7 @@ namespace ComSquare::Memory
return *it; return *it;
} }
uint8_t MemoryBus::read(uint24_t addr) uint8_t MemoryBus::read(uint24_t addr, bool)
{ {
std::shared_ptr<AMemory> handler = this->getAccessor(addr); std::shared_ptr<AMemory> handler = this->getAccessor(addr);
+2 -1
View File
@@ -38,8 +38,9 @@ namespace ComSquare
//! @brief Read data at a global address. //! @brief Read data at a global address.
//! @param addr The address to read from. //! @param addr The address to read from.
//! @param silence Disable login to the memory bus's debugger (if enabled). Should only be used by other debuggers.
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register. //! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
virtual uint8_t read(uint24_t addr); virtual uint8_t read(uint24_t addr, bool silence = false);
//! @brief Write a data to a global address. //! @brief Write a data to a global address.
//! @param addr The address to write to. //! @param addr The address to write to.