// Public source: https://vccplus-git.brianholman.com/VCCPlus/VCCPlusOSS/src/branch/main/src/core/MachineSession.cpp
// Selected code lines: 30; selection, not the full current source.
// Original copyright/license notice and selected code follow unchanged.
// SPDX-License-Identifier: GPL-3.0-or-later
DebugSnapshot MachineSession::debuggerSnapshot(std::uint16_t address, unsigned count,
std::uint32_t physicalAddress, unsigned physicalCount) const {
if (count > 65536) throw std::invalid_argument("A debugger snapshot is limited to 64 KiB");
if (physicalCount > 256) throw std::invalid_argument("Physical memory inspection is limited to 256 bytes");
DebugSnapshot result;
result.generation = generation; result.memoryAddress = address;
result.physicalAddress = physicalAddress;
if (!impl) return result;
result.mmu = GetMMUState();
if (physicalCount) {
if (physicalAddress >= result.mmu.RAMBytes)
throw std::invalid_argument("Physical memory address is outside installed RAM");
const auto length = std::min(physicalCount, result.mmu.RAMBytes - physicalAddress);
result.physicalMemory.reserve(length);
for (unsigned i = 0; i < length; ++i)
result.physicalMemory.push_back(static_cast<std::uint8_t>(GetMem(physicalAddress + i)));
}
result.cpu = impl->CpuState(); result.state = impl->state; result.cycles = impl->cycles;
result.breakpoints = impl->breakpoints; result.disabledBreakpoints = impl->disabledBreakpoints; result.stopReason = impl->stopReason;
result.memory.resize(count); result.memoryAvailable.resize(count);
for (unsigned i = 0; i < count; ++i) {
const auto location = static_cast<std::uint16_t>(address + i);
// GIME has a non-destructive register view; interrupt vectors are ROM
// reads. Other I/O (including unclaimed cartridge ports) is unavailable.
const bool safe = location < 0xff00 || (location >= 0xff90 && location <= 0xffbf) || location >= 0xfff0;
result.memoryAvailable[i] = safe;
if (safe) result.memory[i] = SafeMemRead8(location);
}
return result;
}
Evidence record
snippets/debugger-snapshot.cpp.inc
From Windows Application to Portable Emulation Platform
2,189 bytes
SHA-256a1f296e3b7ae007fac89bef292bda983aabefe43af34b9176420f880b9f69765