Skip to content

Commit

Permalink
Merge pull request #276 from ogamespec/master
Browse files Browse the repository at this point in the history
Fixed step-over in Gekko debug (F10)
  • Loading branch information
ogamespec authored Aug 10, 2023
2 parents f960c61 + 6abe012 commit bced704
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 35 deletions.
22 changes: 18 additions & 4 deletions src/gekko.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ namespace Gekko

if (core->EnableTestBreakpoints)
{
core->TestBreakpoints();
if (core->TestBreakpoints()) {
return;
}
}

core->interp->ExecuteOpcode();
Expand Down Expand Up @@ -173,7 +175,15 @@ namespace Gekko

void GekkoCore::Exception(Gekko::Exception code)
{
//Halt("Gekko Exception: #%04X\n", (uint16_t)code);
if (break_on_exception)
{
Halt("Gekko Exception: #%04X\n", (uint16_t)code);
}

if (trace_exceptions)
{
Report(Channel::CPU, "Gekko Exception: #%04X\n", (uint16_t)code);
}

if (exception)
{
Expand Down Expand Up @@ -769,12 +779,13 @@ namespace Gekko
EnableTestWriteBreakpoints = false;
}

void GekkoCore::TestBreakpoints()
bool GekkoCore::TestBreakpoints()
{
if (oneShotBreakpoint != BadAddress && regs.pc == oneShotBreakpoint)
{
Halt("One shot breakpoint at addr: 0x%08X\n", oneShotBreakpoint);
oneShotBreakpoint = BadAddress;
Halt("One shot breakpoint\n");
return true;
}

uint32_t addr = BadAddress;
Expand All @@ -793,7 +804,10 @@ namespace Gekko
if (addr != BadAddress)
{
Halt("Gekko suspended at addr: 0x%08X\n", addr);
return true;
}

return false;
}

void GekkoCore::TestReadBreakpoints(uint32_t accessAddress)
Expand Down
5 changes: 4 additions & 1 deletion src/gekko.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,10 @@ namespace Gekko
SpinLock breakPointsLock;
uint32_t oneShotBreakpoint = BadAddress;

void TestBreakpoints();
bool break_on_exception = false;
bool trace_exceptions = false;

bool TestBreakpoints();
void TestReadBreakpoints(uint32_t accessAddress);
void TestWriteBreakpoints(uint32_t accessAddress);

Expand Down
60 changes: 30 additions & 30 deletions src/gekkoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3278,16 +3278,16 @@ namespace Gekko

switch (type)
{
case GEKKO_QUANT_TYPE::U8: flt = (float)(uint8_t)data; break;
case GEKKO_QUANT_TYPE::U16: flt = (float)(uint16_t)data; break;
case GEKKO_QUANT_TYPE::S8:
if (data & 0x80) data |= 0xffffff00;
flt = (float)(int8_t)data; break;
case GEKKO_QUANT_TYPE::S16:
if (data & 0x8000) data |= 0xffff0000;
flt = (float)(int16_t)data; break;
case GEKKO_QUANT_TYPE::SINGLE_FLOAT:
default: flt = *((float*)&data); break;
case GEKKO_QUANT_TYPE::U8: flt = (float)(uint8_t)data; break;
case GEKKO_QUANT_TYPE::U16: flt = (float)(uint16_t)data; break;
case GEKKO_QUANT_TYPE::S8:
if (data & 0x80) data |= 0xffffff00;
flt = (float)(int8_t)data; break;
case GEKKO_QUANT_TYPE::S16:
if (data & 0x8000) data |= 0xffff0000;
flt = (float)(int16_t)data; break;
case GEKKO_QUANT_TYPE::SINGLE_FLOAT:
default: flt = *((float*)&data); break;
}

return flt * core->interp->ldScale[scale];
Expand All @@ -3302,24 +3302,24 @@ namespace Gekko

switch (type)
{
case GEKKO_QUANT_TYPE::U8:
if (data < 0) data = 0;
if (data > 255) data = 255;
uval = (uint8_t)(uint32_t)data; break;
case GEKKO_QUANT_TYPE::U16:
if (data < 0) data = 0;
if (data > 65535) data = 65535;
uval = (uint16_t)(uint32_t)data; break;
case GEKKO_QUANT_TYPE::S8:
if (data < -128) data = -128;
if (data > 127) data = 127;
uval = (int8_t)(uint8_t)(int32_t)(uint32_t)data; break;
case GEKKO_QUANT_TYPE::S16:
if (data < -32768) data = -32768;
if (data > 32767) data = 32767;
uval = (int16_t)(uint16_t)(int32_t)(uint32_t)data; break;
case GEKKO_QUANT_TYPE::SINGLE_FLOAT:
default: *((float*)&uval) = data; break;
case GEKKO_QUANT_TYPE::U8:
if (data < 0) data = 0;
if (data > 255) data = 255;
uval = (uint8_t)(uint32_t)data; break;
case GEKKO_QUANT_TYPE::U16:
if (data < 0) data = 0;
if (data > 65535) data = 65535;
uval = (uint16_t)(uint32_t)data; break;
case GEKKO_QUANT_TYPE::S8:
if (data < -128) data = -128;
if (data > 127) data = 127;
uval = (int8_t)(uint8_t)(int32_t)(uint32_t)data; break;
case GEKKO_QUANT_TYPE::S16:
if (data < -32768) data = -32768;
if (data > 32767) data = 32767;
uval = (int16_t)(uint16_t)(int32_t)(uint32_t)data; break;
case GEKKO_QUANT_TYPE::SINGLE_FLOAT:
default: *((float*)&uval) = data; break;
}

return uval;
Expand Down Expand Up @@ -4282,12 +4282,12 @@ namespace Gekko
// Locked cache DMA

case SPR::DMAU:
//DBReport2(DbgChannel::CPU, "DMAU: 0x%08X\n", RRS);
Report(Channel::CPU, "DMAU: 0x%08X\n", core->regs.gpr[info.paramBits[1]]);
break;
case SPR::DMAL:
{
core->regs.spr[spr] = core->regs.gpr[info.paramBits[1]];
//DBReport2(DbgChannel::CPU, "DMAL: 0x%08X\n", RRS);
Report(Channel::CPU, "DMAL: 0x%08X\n", core->regs.spr[spr]);
if (core->regs.spr[SPR::DMAL] & GEKKO_DMAL_DMA_T)
{
uint32_t maddr = core->regs.spr[SPR::DMAU] & GEKKO_DMAU_MEM_ADDR;
Expand Down

0 comments on commit bced704

Please sign in to comment.