Skip to content

Commit

Permalink
Debugger: NES - Fixed crash when importing DBG files containing symbo…
Browse files Browse the repository at this point in the history
…ls with an address > 2^31
  • Loading branch information
SourMesen committed Jun 21, 2023
1 parent 4580c66 commit fa49e40
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Core/NES/BaseMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ void BaseMapper::CopyChrTile(uint32_t address, uint8_t *dest)
}
}

AddressInfo BaseMapper::GetAbsoluteAddress(uint32_t relativeAddr)
AddressInfo BaseMapper::GetAbsoluteAddress(uint16_t relativeAddr)
{
AddressInfo info;
if(relativeAddr < 0x2000) {
Expand All @@ -951,7 +951,7 @@ AddressInfo BaseMapper::GetAbsoluteAddress(uint32_t relativeAddr)
return info;
}

void BaseMapper::GetPpuAbsoluteAddress(uint32_t relativeAddr, AddressInfo& info)
void BaseMapper::GetPpuAbsoluteAddress(uint16_t relativeAddr, AddressInfo& info)
{
if(relativeAddr >= 0x3F00) {
info.Address = relativeAddr & 0x1F;
Expand Down
4 changes: 2 additions & 2 deletions Core/NES/BaseMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ class BaseMapper : public INesMemoryHandler, public ISerializable

CartridgeState GetState();

AddressInfo GetAbsoluteAddress(uint32_t relativeAddr);
void GetPpuAbsoluteAddress(uint32_t relativeAddr, AddressInfo& info);
AddressInfo GetAbsoluteAddress(uint16_t relativeAddr);
void GetPpuAbsoluteAddress(uint16_t relativeAddr, AddressInfo& info);
AddressInfo GetPpuAbsoluteAddress(uint32_t relativeAddr);
AddressInfo GetRelativeAddress(AddressInfo& addr);
int32_t GetPpuRelativeAddress(AddressInfo& addr);
Expand Down
10 changes: 8 additions & 2 deletions UI/Debugger/Integration/DbgImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,11 @@ private bool LoadSymbols(string row)
});

if(id != null && symbolName != null) {
SymbolInfo symbol = new SymbolInfo(id.Value, symbolName, address, segmentId, exportSymbolId, size, definitions, references, type);
_symbols.Add(symbol.ID, symbol);
//Ignore negative addresses (e.g 0xFFFF8000)
if((address == null || address >= 0) && (size == null || size >= 0)) {
SymbolInfo symbol = new SymbolInfo(id.Value, symbolName, address, segmentId, exportSymbolId, size, definitions, references, type);
_symbols.Add(symbol.ID, symbol);
}
return true;
} else {
System.Diagnostics.Debug.Fail("Regex doesn't match sym");
Expand Down Expand Up @@ -546,6 +549,9 @@ private int GetSymbolSize(SymbolInfo symbol)

private void GetRamLabelAddressAndType(int address, out int absoluteAddress, out MemoryType? memoryType)
{
if(address < 0) {

}
AddressInfo absAddress = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = address, Type = _cpuMemType });
absoluteAddress = absAddress.Address;
if(absoluteAddress >= 0) {
Expand Down

0 comments on commit fa49e40

Please sign in to comment.