| 260 | } |
| 261 | |
| 262 | void debug_record_ret(uint32_t retAddr, bool mode) { |
| 263 | uint32_t stack = cpu_address_mode(cpu.registers.stack[mode].hl, mode), |
| 264 | index = debug.stackIndex, size = debug.stackSize; |
| 265 | debug_stack_entry_t *entry; |
| 266 | bool found = false, stepOut = false, stepOutMatch; |
| 267 | while (size--) { |
| 268 | stepOutMatch = index == debug.stepOut; |
| 269 | entry = &debug.stack[index]; |
| 270 | index = (index - 1) & DBG_STACK_MASK; |
| 271 | if (mode == entry->mode && (stack == entry->stack || entry->popped) && |
| 272 | retAddr - entry->retAddr <= entry->range) { |
| 273 | debug.stackIndex = index; |
| 274 | debug.stackSize = size; |
| 275 | found = true; |
| 276 | } else if (found) { |
| 277 | break; |
| 278 | } |
| 279 | stepOut |= stepOutMatch; |
| 280 | } |
| 281 | if (found && stepOut) { |
| 282 | debug.step = true; |
| 283 | debug.stepOut = ~0u; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | void debug_set_pc(uint32_t addr) { |
| 288 | cpu_flush(addr, cpu.ADL); |
no test coverage detected