Debugger: Fixed refresh/display issues after changing PRG ROM via the memory tools or assembler
This commit is contained in:
parent
a75294320b
commit
20fe8bd4c7
3 changed files with 27 additions and 18 deletions
|
@ -206,7 +206,7 @@ void Disassembler::GetInfo(AddressTypeInfo &info, uint8_t** source, uint32_t &si
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bool isSubEntryPoint, bool processJumps)
|
uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bool isSubEntryPoint, bool processJumps, bool forceDisassemble)
|
||||||
{
|
{
|
||||||
uint32_t mask = info.Type == AddressType::InternalRam ? 0x7FF : 0xFFFFFFFF;
|
uint32_t mask = info.Type == AddressType::InternalRam ? 0x7FF : 0xFFFFFFFF;
|
||||||
|
|
||||||
|
@ -218,13 +218,16 @@ uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bo
|
||||||
|
|
||||||
if(info.Address >= 0) {
|
if(info.Address >= 0) {
|
||||||
DisassemblyInfo *disInfo = (*cache)[absoluteAddr].get();
|
DisassemblyInfo *disInfo = (*cache)[absoluteAddr].get();
|
||||||
if(!disInfo) {
|
if(!disInfo || forceDisassemble) {
|
||||||
while(absoluteAddr < (int32_t)size && !(*cache)[absoluteAddr]) {
|
while(absoluteAddr < (int32_t)size && (forceDisassemble || !(*cache)[absoluteAddr])) {
|
||||||
bool isJump = IsUnconditionalJump(source[absoluteAddr]);
|
bool isJump = IsUnconditionalJump(source[absoluteAddr]);
|
||||||
disInfo = new DisassemblyInfo(source+absoluteAddr, isSubEntryPoint);
|
|
||||||
isSubEntryPoint = false;
|
if(!forceDisassemble) {
|
||||||
|
disInfo = new DisassemblyInfo(source+absoluteAddr, isSubEntryPoint);
|
||||||
(*cache)[absoluteAddr] = shared_ptr<DisassemblyInfo>(disInfo);
|
isSubEntryPoint = false;
|
||||||
|
(*cache)[absoluteAddr] = shared_ptr<DisassemblyInfo>(disInfo);
|
||||||
|
}
|
||||||
|
forceDisassemble = false;
|
||||||
|
|
||||||
absoluteAddr += disInfo->GetSize();
|
absoluteAddr += disInfo->GetSize();
|
||||||
if(isJump) {
|
if(isJump) {
|
||||||
|
@ -246,7 +249,7 @@ uint32_t Disassembler::BuildCache(AddressTypeInfo &info, uint16_t cpuAddress, bo
|
||||||
|
|
||||||
constexpr uint8_t jsrCode = 0x20;
|
constexpr uint8_t jsrCode = 0x20;
|
||||||
if(addressInfo.Address >= 0) {
|
if(addressInfo.Address >= 0) {
|
||||||
BuildCache(addressInfo, jumpDest, opCode == jsrCode, false);
|
BuildCache(addressInfo, jumpDest, opCode == jsrCode, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +304,7 @@ void Disassembler::InvalidateCache(AddressTypeInfo &info)
|
||||||
|
|
||||||
void Disassembler::RebuildPrgRomCache(uint32_t absoluteAddr, int32_t length)
|
void Disassembler::RebuildPrgRomCache(uint32_t absoluteAddr, int32_t length)
|
||||||
{
|
{
|
||||||
for(int i = 1; i <= 2; i++) {
|
for(int i = 0; i <= 2; i++) {
|
||||||
int offsetAddr = (int)absoluteAddr - i;
|
int offsetAddr = (int)absoluteAddr - i;
|
||||||
if(offsetAddr >= 0) {
|
if(offsetAddr >= 0) {
|
||||||
if(_disassembleCache[offsetAddr] != nullptr) {
|
if(_disassembleCache[offsetAddr] != nullptr) {
|
||||||
|
@ -313,18 +316,22 @@ void Disassembler::RebuildPrgRomCache(uint32_t absoluteAddr, int32_t length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isSubEntryPoint = false;
|
|
||||||
if(_disassembleCache[absoluteAddr]) {
|
|
||||||
isSubEntryPoint = _disassembleCache[absoluteAddr]->IsSubEntryPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i = absoluteAddr, end = absoluteAddr + length; i < end; i++) {
|
for(int i = absoluteAddr, end = absoluteAddr + length; i < end; i++) {
|
||||||
_disassembleCache[i] = nullptr;
|
_disassembleCache[i] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t memoryAddr = _debugger->GetRelativeAddress(absoluteAddr, AddressType::PrgRom);
|
//Re-disassemble based on the previous instruction (if one exists)
|
||||||
AddressTypeInfo info = { (int32_t)absoluteAddr, AddressType::PrgRom };
|
for(int i = 0; i < 6; i++) {
|
||||||
BuildCache(info, memoryAddr, isSubEntryPoint, false);
|
int offsetAddr = (int)absoluteAddr - i;
|
||||||
|
if(offsetAddr >= 0 && _disassembleCache[offsetAddr] != nullptr) {
|
||||||
|
int32_t memoryAddr = _debugger->GetRelativeAddress(offsetAddr, AddressType::PrgRom);
|
||||||
|
if(memoryAddr >= 0) {
|
||||||
|
AddressTypeInfo info = { offsetAddr, AddressType::PrgRom };
|
||||||
|
BuildCache(info, memoryAddr, false, false, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* hexTable[256] = {
|
static const char* hexTable[256] = {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
void BuildOpCodeTables(bool useLowerCase);
|
void BuildOpCodeTables(bool useLowerCase);
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
uint32_t BuildCache(AddressTypeInfo &info, uint16_t memoryAddr, bool isSubEntryPoint, bool processJumps);
|
uint32_t BuildCache(AddressTypeInfo &info, uint16_t memoryAddr, bool isSubEntryPoint, bool processJumps, bool forceDisassemble = false);
|
||||||
void InvalidateCache(AddressTypeInfo &info);
|
void InvalidateCache(AddressTypeInfo &info);
|
||||||
|
|
||||||
bool IsUnofficialOpCode(uint8_t opCode);
|
bool IsUnofficialOpCode(uint8_t opCode);
|
||||||
|
|
|
@ -165,6 +165,8 @@ void MemoryDumper::SetMemoryValues(DebugMemoryType memoryType, uint32_t address,
|
||||||
if(infoStart.Type == AddressType::PrgRom && infoEnd.Type == AddressType::PrgRom && infoEnd.Address - infoStart.Address == length) {
|
if(infoStart.Type == AddressType::PrgRom && infoEnd.Type == AddressType::PrgRom && infoEnd.Address - infoStart.Address == length) {
|
||||||
_disassembler->RebuildPrgRomCache(infoStart.Address, length);
|
_disassembler->RebuildPrgRomCache(infoStart.Address, length);
|
||||||
}
|
}
|
||||||
|
} else if(memoryType == DebugMemoryType::PrgRom) {
|
||||||
|
_disassembler->RebuildPrgRomCache(address, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddUndoHistory(originalRomData);
|
AddUndoHistory(originalRomData);
|
||||||
|
|
Loading…
Add table
Reference in a new issue