From 32664f39aebd325822ec7a9a4d04467665e3a190 Mon Sep 17 00:00:00 2001 From: Jonathan Campbell Date: Mon, 15 Apr 2024 00:15:46 -0700 Subject: [PATCH] Debugger: Fix DEBUG_Run() to manage CPU cycle count such that time advances only the amount, not any more than that. Show current PIC time and whether CPU is in HLT state in debugger UI --- CHANGELOG | 3 +++ src/cpu/cpu.cpp | 4 ++++ src/debug/debug.cpp | 13 +++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 56631d028df..7aa57db7ae6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ Next: + - Debugger UI now shows PIC_FullIndex() and whether or not the CPU is + in the HLT state. Single stepping does not do anything when the CPU is + in the HLT state, so at least let the user know (joncampbell123). - Keyboard controller (IBM PC): Cancel the IRQ signal upon reading I/O port 60h. The reason for the IRQ, the pending data, was just read, so now there is no point in keeping the IRQ signal up. This fixes Escape diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index 9f912807191..995defe85c5 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -3148,6 +3148,10 @@ Bits HLT_Decode(void) { return 0; } +bool CPU_IsHLTed(void) { + return (cpudecoder == &HLT_Decode); +} + void CPU_HLT(uint32_t oldeip) { /* Since cpu.hlt.old_decoder assigns the current decoder to old, and relies on restoring * it back when finished, setting cpudecoder to HLT_Decode while already HLT_Decode effectively diff --git a/src/debug/debug.cpp b/src/debug/debug.cpp index 5bebfc07666..39003990f28 100644 --- a/src/debug/debug.cpp +++ b/src/debug/debug.cpp @@ -1116,6 +1116,8 @@ void DrawRegistersUpdateOld(void) { oldcpucpl=cpu.cpl; } +bool CPU_IsHLTed(void); + static void DrawRegisters(void) { if (dbg.win_main == NULL || dbg.win_reg == NULL) return; @@ -1191,7 +1193,7 @@ static void DrawRegisters(void) { } else { mvwprintw(dbg.win_reg,0,76,"Real"); mvwprintw(dbg.win_reg,2,62,"NOPG"); - } + } // Selector info, if available if ((cpu.pmode) && curSelectorName[0]) { @@ -1202,7 +1204,13 @@ static void DrawRegisters(void) { } wattrset(dbg.win_reg,0); - mvwprintw(dbg.win_reg,3,60,"%u ",cycle_count); + + mvwprintw(dbg.win_reg,3,60,"cc=%-8u ",cycle_count); + if (CPU_IsHLTed()) mvwprintw(dbg.win_reg,3,73,"HLT "); + else mvwprintw(dbg.win_reg,3,73,"RUN "); + + mvwprintw(dbg.win_reg,4,60,"pfi=%-6.9f ",(double)PIC_FullIndex()); + wrefresh(dbg.win_reg); } @@ -3894,6 +3902,7 @@ extern "C" INPUT_RECORD * _pdcurses_hax_inputrecord(void); int32_t DEBUG_Run(int32_t amount,bool quickexit) { skipFirstInstruction = true; + CPU_CycleLeft += CPU_Cycles - amount; CPU_Cycles = amount; int32_t ret = (int32_t)(*cpudecoder)(); if (quickexit) SetCodeWinStart();