Skip to content

Commit

Permalink
Debugger: Fix DEBUG_Run() to manage CPU cycle count such that time ad…
Browse files Browse the repository at this point in the history
…vances only the amount, not any more than that. Show current PIC time and whether CPU is in HLT state in debugger UI
  • Loading branch information
joncampbell123 committed Apr 15, 2024
1 parent 21bec95 commit 32664f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/cpu/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions src/debug/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]) {
Expand All @@ -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);
}

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 32664f3

Please sign in to comment.