diff --git a/include/debug.h b/include/debug.h index de1d460e..28f02975 100644 --- a/include/debug.h +++ b/include/debug.h @@ -25,6 +25,7 @@ void DEBUG_CheckExecuteBreakpoint(Bit16u seg, Bit32u off); bool DEBUG_ExitLoop(void); extern Bitu cycle_count; +extern Bitu debugCallback; #ifdef C_HEAVY_DEBUG bool DEBUG_HeavyIsBreakpoint(void); diff --git a/src/cpu/core_16/main.h b/src/cpu/core_16/main.h index 97ff4080..2814fe54 100644 --- a/src/cpu/core_16/main.h +++ b/src/cpu/core_16/main.h @@ -798,8 +798,9 @@ restart: #if C_DEBUG SAVEIP; if (DEBUG_Breakpoint()) { + LOADIP; LEAVECORE; - return -1; + return debugCallback; } LOADIP; #endif @@ -811,8 +812,9 @@ restart: #if C_DEBUG SAVEIP; if (DEBUG_IntBreakpoint(num)) { + LOADIP; LEAVECORE; - return -1; + return debugCallback; } #endif EXCEPTION(num); diff --git a/src/cpu/core_full.cpp b/src/cpu/core_full.cpp index 5663a9b4..5dd03875 100644 --- a/src/cpu/core_full.cpp +++ b/src/cpu/core_full.cpp @@ -55,7 +55,6 @@ static EAPoint IPPoint; #include "core_full/ea_lookup.h" #include "instructions.h" - static INLINE void DecodeModRM(void) { inst.rm=Fetchb(); inst.rm_index=(inst.rm >> 3) & 7; @@ -89,7 +88,7 @@ Bits Full_DeCode(void) { SaveIP(); if (DEBUG_HeavyIsBreakpoint()) { LEAVECORE; - return 1; + return debugCallback; }; #endif #endif diff --git a/src/cpu/core_full/op.h b/src/cpu/core_full/op.h index 98596f49..8243fdaf 100644 --- a/src/cpu/core_full/op.h +++ b/src/cpu/core_full/op.h @@ -341,8 +341,8 @@ switch (inst.code.op) { case O_INT: LEAVECORE; #if C_DEBUG - if (((inst.entry & 0xFF)==0xcc) && DEBUG_Breakpoint()) return -1; - else if (DEBUG_IntBreakpoint(inst.op1.b)) return -1; + if (((inst.entry & 0xFF)==0xcc) && DEBUG_Breakpoint()) return debugCallback; + else if (DEBUG_IntBreakpoint(inst.op1.b)) return debugCallback; #endif Interrupt(inst.op1.b); LoadIP(); diff --git a/src/cpu/slow_16.cpp b/src/cpu/slow_16.cpp index 67b08d87..4ebe1ced 100644 --- a/src/cpu/slow_16.cpp +++ b/src/cpu/slow_16.cpp @@ -84,7 +84,7 @@ decode_start: cycle_count++; #if C_HEAVY_DEBUG LEAVECORE; - if (DEBUG_HeavyIsBreakpoint()) return 1; + if (DEBUG_HeavyIsBreakpoint()) return debugCallback; #endif #endif core_16.ip_start=core_16.ip_lookup; diff --git a/src/debug/debug.cpp b/src/debug/debug.cpp index caf7f1ff..351c8f17 100644 --- a/src/debug/debug.cpp +++ b/src/debug/debug.cpp @@ -512,8 +512,8 @@ bool DEBUG_Breakpoint(void) // Found. Breakpoint is valid reg_eip -= 1; CBreakpoint::ActivateBreakpoints(where,false); // Deactivate all breakpoints - exitLoop = true; - DEBUG_Enable(); +// exitLoop = true; +// DEBUG_Enable(); return true; }; @@ -526,8 +526,8 @@ bool DEBUG_IntBreakpoint(Bit8u intNum) // Found. Breakpoint is valid reg_eip -= 2; CBreakpoint::ActivateBreakpoints(where,false); // Deactivate all breakpoints - exitLoop = true; - DEBUG_Enable(); +// exitLoop = true; +// DEBUG_Enable(); return true; }; @@ -628,8 +628,8 @@ static void DrawRegisters(void) { oldflags=flags.word; - if (cpu.pmode) mvwprintw(dbg.win_reg,0,76,"Prot"); - else mvwprintw(dbg.win_reg,0,76,"Real"); + if (cpu.pmode) mvwprintw(dbg.win_reg,0,76,"Prot"); + else mvwprintw(dbg.win_reg,0,76,"Real"); // Selector info, if available if ((cpu.pmode) && curSelectorName[0]) { @@ -1272,6 +1272,7 @@ Bit32u DEBUG_CheckKeys(void) { skipFirstInstruction = true; // for heavy debugger CPU_Cycles = 1; Bitu ret=(*cpudecoder)(); + if (ret>0) ret=(*CallBack_Handlers[ret])(); SetCodeWinStart(); CBreakpoint::ignoreOnce = 0; } @@ -1280,15 +1281,11 @@ Bit32u DEBUG_CheckKeys(void) { skipFirstInstruction = true; // for heavy debugger CPU_Cycles = 1; ret = (*cpudecoder)(); + if (ret>0) ret=(*CallBack_Handlers[ret])(); SetCodeWinStart(); CBreakpoint::ignoreOnce = 0; break; - -// default: -// // FIXME : Is this correct ? -// if (key<0x200) ret=(*cpudecoder)(1); -// break; - }; + } DEBUG_DrawScreen(); } return ret; @@ -1308,7 +1305,6 @@ Bitu DEBUG_Loop(void) { DOSBOX_SetNormalLoop(); return 0; } - return DEBUG_CheckKeys(); } @@ -1371,7 +1367,8 @@ static bool DEBUG_Log_Loop(int count) { CPU_Cycles = 1; ret=(*cpudecoder)(); - + if (ret>0) ret=(*CallBack_Handlers[ret])(); + count--; if (count==0) break; @@ -1446,6 +1443,13 @@ void DEBUG_CheckExecuteBreakpoint(Bit16u seg, Bit32u off) }; }; +Bitu DEBUG_EnableDebugger(void) +{ + exitLoop = true; + DEBUG_Enable(); + return 0; +}; + static void DEBUG_ProgramStart(Program * * make) { *make=new DEBUG; } @@ -1481,6 +1485,8 @@ static void DEBUG_ShutDown(Section * sec) #endif }; +Bitu debugCallback; + void DEBUG_Init(Section* sec) { MSG_Add("DEBUG_CONFIGFILE_HELP","Nothing to setup yet!\n"); @@ -1492,6 +1498,9 @@ void DEBUG_Init(Section* sec) { memset((void*)&codeViewData,0,sizeof(codeViewData)); /* setup debug.com */ PROGRAMS_MakeFile("DEBUG.COM",DEBUG_ProgramStart); + /* Setup callback */ + debugCallback=CALLBACK_Allocate(); + CALLBACK_Setup(debugCallback,DEBUG_EnableDebugger,CB_RETF); /* shutdown function */ sec->AddDestroyFunction(&DEBUG_ShutDown); } @@ -1602,7 +1611,7 @@ void SaveMemory(Bit16u seg, Bit16u ofs1, Bit32s num) #if C_HEAVY_DEBUG -const Bit32u LOGCPUMAX = 200; +const Bit32u LOGCPUMAX = 20000; static Bit16u logCpuCS [LOGCPUMAX]; static Bit32u logCpuEIP[LOGCPUMAX]; @@ -1681,8 +1690,8 @@ bool DEBUG_HeavyIsBreakpoint(void) PhysPt where = SegPhys(cs)+reg_eip; if (CBreakpoint::CheckBreakpoint(SegValue(cs),reg_eip)) { - exitLoop = true; - DEBUG_Enable(); +// exitLoop = true; +// DEBUG_Enable(); return true; } return false; diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 0ca13ceb..fb9d96a6 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -111,6 +111,9 @@ static Bitu Normal_Loop(void) { if (ret>0) { Bitu blah=(*CallBack_Handlers[ret])(); if (blah) return blah; +#if C_DEBUG + if (DEBUG_ExitLoop()) return 0; +#endif } } else { if (RemainTicks>0) { @@ -260,6 +263,7 @@ void DOSBOX_Init(void) { secprop->Add_bool("ems",true); secprop->AddInitFunction(&DPMI_Init); secprop->Add_bool("dpmi",true); + #if C_MODEM secprop=control->AddSection_prop("modem",&MODEM_Init); secprop->Add_bool("enabled",true);