From c9b747adc43247f22ef398b5c4dec23200df366d Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sun, 4 May 2003 19:12:09 +0000 Subject: [PATCH] new logging system Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@987 --- src/cpu/callback.cpp | 2 +- src/cpu/core_16/main.h | 4 ++-- src/cpu/core_16/prefix_66.h | 2 +- src/cpu/core_16/prefix_of.h | 4 ++-- src/cpu/core_16/support.h | 2 +- src/cpu/core_full/load.h | 8 ++++---- src/cpu/core_full/loadwrite.h | 2 +- src/cpu/core_full/op.h | 6 +++--- src/cpu/core_full/save.h | 2 +- src/cpu/core_full/string.h | 4 ++-- src/cpu/cpu.cpp | 14 +++++++------- src/cpu/flags.cpp | 12 ++++++------ src/cpu/slow_16.cpp | 2 +- src/debug/debug.cpp | 2 ++ src/debug/debug_gui.cpp | 12 +++++++++++- 15 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/cpu/callback.cpp b/src/cpu/callback.cpp index fcdd049a..cf8b77cf 100644 --- a/src/cpu/callback.cpp +++ b/src/cpu/callback.cpp @@ -67,7 +67,7 @@ void CALLBACK_Idle(void) { } static Bitu default_handler(void) { - LOG(LOG_ERROR|LOG_CPU,"Illegal Unhandled Interrupt Called %X",lastint); + LOG(LOG_CPU,LOG_ERROR)("Illegal Unhandled Interrupt Called %X",lastint); return CBRET_NONE; }; diff --git a/src/cpu/core_16/main.h b/src/cpu/core_16/main.h index 381c0e81..44538829 100644 --- a/src/cpu/core_16/main.h +++ b/src/cpu/core_16/main.h @@ -880,7 +880,7 @@ restart: case 0xde: /* FPU ESC 6 */ case 0xdf: /* FPU ESC 7 */ { - LOG(LOG_CPU,"FPU used"); + LOG(LOG_CPU,LOG_NORMAL)("FPU used"); Bit8u rm=Fetchb(); if (rm<0xc0) GetEAa; } @@ -956,7 +956,7 @@ restart: IO_Write(reg_dx+1,reg_ah); break; case 0xf0: /* LOCK */ - LOG(LOG_CPU,"CPU:LOCK"); + LOG(LOG_CPU,LOG_NORMAL)("CPU:LOCK"); break; case 0xf1: /* Weird call undocumented */ // INTERRUPT(1); diff --git a/src/cpu/core_16/prefix_66.h b/src/cpu/core_16/prefix_66.h index b24339fa..0e30f431 100644 --- a/src/cpu/core_16/prefix_66.h +++ b/src/cpu/core_16/prefix_66.h @@ -258,7 +258,7 @@ switch(Fetchb()) { break; } case 0x8c: - LOG(LOG_CPU,"CPU:66:8c looped back"); + LOG(LOG_CPU,LOG_NORMAL)("CPU:66:8c looped back"); break; case 0x8d: /* LEA */ { diff --git a/src/cpu/core_16/prefix_of.h b/src/cpu/core_16/prefix_of.h index 61ad2a3c..750e0dc2 100644 --- a/src/cpu/core_16/prefix_of.h +++ b/src/cpu/core_16/prefix_of.h @@ -41,7 +41,7 @@ switch(Fetchb()) { break; default: GetEAa; - LOG(LOG_CPU|LOG_ERROR,"GRP7:Illegal call %2X",(rm>>3) &3); + LOG(LOG_CPU,LOG_ERROR)("GRP7:Illegal call %2X",(rm>>3) &3); } } break; @@ -63,7 +63,7 @@ switch(Fetchb()) { case 0x23: /* MOV DRx,Rd */ { GetRM; - LOG(LOG_CPU,"CPU:0F:23 does nothing"); + LOG(LOG_CPU,LOG_NORMAL)("CPU:0F:23 does nothing"); } break; /* 0x24 MOV Rd,TRx (386) */ diff --git a/src/cpu/core_16/support.h b/src/cpu/core_16/support.h index 2ec79b49..9bc6686d 100644 --- a/src/cpu/core_16/support.h +++ b/src/cpu/core_16/support.h @@ -395,7 +395,7 @@ rep_again: break; default: IPPoint--; - LOG(LOG_CPU|LOG_ERROR,"Unhandled REP Prefix %X",Fetchb()); + LOG(LOG_CPU,LOG_ERROR)("Unhandled REP Prefix %X",Fetchb()); goto normalexit; } /* If we end up here it's because the CPU_Cycles counter is 0, so restart instruction */ diff --git a/src/cpu/core_full/load.h b/src/cpu/core_full/load.h index b6ba9938..2dfbfbd2 100644 --- a/src/cpu/core_full/load.h +++ b/src/cpu/core_full/load.h @@ -114,7 +114,7 @@ l_M_Ed: break; case M_Efw: if (inst.rm>=0xC0) { - LOG(LOG_CPU|LOG_ERROR,"MODRM:Illegal M_Efw "); + LOG(LOG_CPU,LOG_ERROR)("MODRM:Illegal M_Efw "); goto nextopcode; } inst.op1.d=LoadMw(inst.rm_eaa); @@ -122,7 +122,7 @@ l_M_Ed: break; case M_Efd: if (inst.rm>=0xc0) { - LOG(LOG_CPU|LOG_ERROR,"MODRM:Illegal M_Efw "); + LOG(LOG_CPU,LOG_ERROR)("MODRM:Illegal M_Efw "); goto nextopcode; } inst.op1.d=LoadMd(inst.rm_eaa); @@ -157,7 +157,7 @@ l_M_Ed: case 0: break; default: - LOG(LOG_CPU|LOG_ERROR,"MODRM:Unhandled load %d entry %x",inst.code.extra,inst.entry); + LOG(LOG_CPU,LOG_ERROR)("MODRM:Unhandled load %d entry %x",inst.code.extra,inst.entry); break; } break; @@ -469,7 +469,7 @@ l_M_Ed: CPU_CPUID(); goto nextopcode; default: - LOG(LOG_CPU|LOG_ERROR,"LOAD:Unhandled code %d opcode %X",inst.code.load,inst.entry); + LOG(LOG_CPU,LOG_ERROR)("LOAD:Unhandled code %d opcode %X",inst.code.load,inst.entry); break; } diff --git a/src/cpu/core_full/loadwrite.h b/src/cpu/core_full/loadwrite.h index c1e192fb..77a9c61d 100644 --- a/src/cpu/core_full/loadwrite.h +++ b/src/cpu/core_full/loadwrite.h @@ -89,4 +89,4 @@ static INLINE Bit32u Pop_32(void) { } \ } -#endif \ No newline at end of file +#endif diff --git a/src/cpu/core_full/op.h b/src/cpu/core_full/op.h index 651c01ea..1d2c3241 100644 --- a/src/cpu/core_full/op.h +++ b/src/cpu/core_full/op.h @@ -417,7 +417,7 @@ switch (inst.code.op) { default: - LOG(LOG_ERROR|LOG_CPU,"Group 6 Illegal subfunction %X",inst.rm_index); + LOG(LOG_CPU,LOG_ERROR)("Group 6 Illegal subfunction %X",inst.rm_index); } break; case O_GRP7w: @@ -455,7 +455,7 @@ switch (inst.code.op) { CPU_LMSW(inst.op1.w); goto nextopcode; default: - LOG(LOG_ERROR|LOG_CPU,"Group 7 Illegal subfunction %X",inst.rm_index); + LOG(LOG_CPU,LOG_ERROR)("Group 7 Illegal subfunction %X",inst.rm_index); } break; case O_M_Cd_Rd: @@ -541,6 +541,6 @@ switch (inst.code.op) { case 0: break; default: - LOG(LOG_ERROR|LOG_CPU,"OP:Unhandled code %d entry %X",inst.code.op,inst.entry); + LOG(LOG_CPU,LOG_ERROR)("OP:Unhandled code %d entry %X",inst.code.op,inst.entry); } diff --git a/src/cpu/core_full/save.h b/src/cpu/core_full/save.h index df574350..0f7f4fe4 100644 --- a/src/cpu/core_full/save.h +++ b/src/cpu/core_full/save.h @@ -106,5 +106,5 @@ switch (inst.code.save) { case 0: break; default: - LOG(LOG_ERROR|LOG_CPU,"SAVE:Unhandled code %d entry %X",inst.code.save,inst.entry); + LOG(LOG_CPU,LOG_ERROR)("SAVE:Unhandled code %d entry %X",inst.code.save,inst.entry); } diff --git a/src/cpu/core_full/string.h b/src/cpu/core_full/string.h index 50e805da..bdc15b4e 100644 --- a/src/cpu/core_full/string.h +++ b/src/cpu/core_full/string.h @@ -2,7 +2,7 @@ EAPoint si_base,di_base; Bitu si_index,di_index; Bitu add_mask; - Bitu count,count_left; + Bits count,count_left; Bits add_index; bool restart=false; @@ -195,7 +195,7 @@ } break; default: - LOG(LOG_CPU|LOG_ERROR,"Unhandled string %d entry %X",inst.code.op,inst.entry); + LOG(LOG_CPU,LOG_ERROR)("Unhandled string %d entry %X",inst.code.op,inst.entry); } /* Clean up after certain amount of instructions */ reg_esi&=(~add_mask); diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index c60c7f40..6dce9085 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -121,12 +121,12 @@ bool Interrupt(Bitu num) { #if C_DEBUG switch (num) { case 0x00: - LOG(LOG_CPU,"Divide Error"); + LOG(LOG_CPU,LOG_NORMAL)("Divide Error"); break; case 0x06: break; case 0x07: - LOG(LOG_FPU,"Co Processor Exception"); + LOG(LOG_FPU,LOG_NORMAL)("Co Processor Exception"); break; case 0x08: case 0x09: @@ -148,7 +148,7 @@ bool Interrupt(Bitu num) { break; case 0xcd: #if C_HEAVY_DEBUG - LOG(LOG_CPU|LOG_ERROR,"Call to interrupt 0xCD this is BAD"); + LOG(LOG_CPU,LOG_ERROR)("Call to interrupt 0xCD this is BAD"); DEBUG_HeavyWriteLogInstruction(); #endif E_Exit("Call to interrupt 0xCD this is BAD"); @@ -156,7 +156,7 @@ bool Interrupt(Bitu num) { if (DEBUG_Breakpoint()) return true; break; case 0x05: - LOG(LOG_CPU,"CPU:Out Of Bounds interrupt"); + LOG(LOG_CPU,LOG_NORMAL)("CPU:Out Of Bounds interrupt"); break; default: // LOG_WARN("Call to unsupported INT %02X call %02X",num,reg_ah); @@ -539,7 +539,7 @@ bool CPU_SET_CRX(Bitu cr,Bitu value) { return CPU_CheckState(); } default: - LOG(LOG_CPU|LOG_ERROR,"Unhandled MOV CR%d,%X",cr,value); + LOG(LOG_CPU,LOG_ERROR)("Unhandled MOV CR%d,%X",cr,value); break; } return false; @@ -550,7 +550,7 @@ Bitu CPU_GET_CRX(Bitu cr) { case 0: return cpu.cr0; default: - LOG(LOG_CPU|LOG_ERROR,"Unhandled MOV XXX, CR%d",cr); + LOG(LOG_CPU,LOG_ERROR)("Unhandled MOV XXX, CR%d",cr); break; } return 0; @@ -762,7 +762,7 @@ void CPU_CPUID(void) { reg_edx=0; /* Nothing either */ break; default: - LOG(LOG_CPU|LOG_ERROR,"Unhandled CPUID Function %x",reg_eax); + LOG(LOG_CPU,LOG_ERROR)("Unhandled CPUID Function %x",reg_eax); break; } diff --git a/src/cpu/flags.cpp b/src/cpu/flags.cpp index c7adc6ed..44781cc5 100644 --- a/src/cpu/flags.cpp +++ b/src/cpu/flags.cpp @@ -134,7 +134,7 @@ Bitu get_CF(void) { case t_DIV: return false; /* Unkown */ default: - LOG(LOG_ERROR|LOG_CPU,"get_CF Unknown %d",flags.type); + LOG(LOG_CPU,LOG_ERROR)("get_CF Unknown %d",flags.type); } return 0; } @@ -229,7 +229,7 @@ again: case t_MUL: return false; /* Unkown */ default: - LOG(LOG_ERROR|LOG_CPU,"get_AF Unknown %d",flags.type); + LOG(LOG_CPU,LOG_ERROR)("get_AF Unknown %d",flags.type); } return 0; } @@ -314,7 +314,7 @@ again: case t_MUL: return false; /* Unkown */ default: - LOG(LOG_ERROR|LOG_CPU,"get_ZF Unknown %d",flags.type); + LOG(LOG_CPU,LOG_ERROR)("get_ZF Unknown %d",flags.type); } return false; } @@ -398,7 +398,7 @@ again: case t_MUL: return false; /* Unkown */ default: - LOG(LOG_ERROR|LOG_CPU,"get_SF Unkown %d",flags.type); + LOG(LOG_CPU,LOG_ERROR)("get_SF Unkown %d",flags.type); } return false; @@ -539,7 +539,7 @@ again: case t_DIV: return false; /* Unkown */ default: - LOG(LOG_ERROR|LOG_CPU,"get_OF Unkown %d",flags.type); + LOG(LOG_CPU,LOG_ERROR)("get_OF Unkown %d",flags.type); } return false; } @@ -800,7 +800,7 @@ Bitu get_Flags(void) { SET_FLAG(FLAG_CF,false); /* Unkown */ break; default: - LOG(LOG_ERROR|LOG_CPU,"Unhandled flag type %d",flags.type); + LOG(LOG_CPU,LOG_ERROR)("Unhandled flag type %d",flags.type); return 0; } flags.word=new_flags; diff --git a/src/cpu/slow_16.cpp b/src/cpu/slow_16.cpp index a8db93b1..428b6aa9 100644 --- a/src/cpu/slow_16.cpp +++ b/src/cpu/slow_16.cpp @@ -83,7 +83,7 @@ decode_start: if (prefix.count) { PrefixReset; //DEBUG_HeavyWriteLogInstruction(); - LOG(LOG_CPU,"Prefix for non prefixed instruction"); + LOG(LOG_CPU,LOG_NORMAL)("Prefix for non prefixed instruction"); } CPU_Cycles--; } diff --git a/src/debug/debug.cpp b/src/debug/debug.cpp index c3264d22..0f1d90ec 100644 --- a/src/debug/debug.cpp +++ b/src/debug/debug.cpp @@ -53,6 +53,8 @@ char* AnalyzeInstruction(char* inst, bool saveSelector); void SaveMemory(Bit16u seg, Bit16u ofs1, Bit32s num); class DEBUG; +extern void DEBUG_ShowMsg(Bit32u entry, char* format, ...); + DEBUG* pDebugcom = 0; bool exitLoop = false; bool logHeavy = false; diff --git a/src/debug/debug_gui.cpp b/src/debug/debug_gui.cpp index e5b06b1c..c44fb1ba 100644 --- a/src/debug/debug_gui.cpp +++ b/src/debug/debug_gui.cpp @@ -44,6 +44,9 @@ namespace { }; extern int old_cursor_state; + + + void DEBUG_ShowMsg(Bit32u entry, char * format,...) { if (!(entry & LOG_ERROR) && entry && !loggrp[entry].enabled) return; @@ -58,7 +61,14 @@ void DEBUG_ShowMsg(Bit32u entry, char * format,...) { wrefresh(dbg.win_out); if(debuglog) fprintf(debuglog,"%10d: %s\n",cycle_count,buf); } - +void LOG::operator() (char* format, ...){ + char buf[1024]; + va_list msg; + va_start(msg,format); + vsprintf(buf,format,msg); + va_end(msg); + DEBUG_ShowMsg(this->d_type|this->d_severity,buf); +} static void Draw_RegisterLayout(void) {