From 1c84baf8a8698b6afd64874d70bbfe81010f16b0 Mon Sep 17 00:00:00 2001 From: Ulf Wohlers Date: Wed, 14 Jan 2004 19:54:14 +0000 Subject: [PATCH] improved logging; added logging for ldt, gdt, idt; fixed bug when displaying memory above 8mb Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1587 --- src/debug/debug.cpp | 125 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 116 insertions(+), 9 deletions(-) diff --git a/src/debug/debug.cpp b/src/debug/debug.cpp index b3d7325d..f21292b9 100644 --- a/src/debug/debug.cpp +++ b/src/debug/debug.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: debug.cpp,v 1.50 2004-01-10 14:03:34 qbix79 Exp $ */ +/* $Id: debug.cpp,v 1.51 2004-01-14 19:54:14 finsterr Exp $ */ #include "programs.h" @@ -56,6 +56,9 @@ static void DEBUG_RaiseTimerIrq(void); char* AnalyzeInstruction(char* inst, bool saveSelector); void SaveMemory(Bitu seg, Bitu ofs1, Bit32s num); Bit32u GetHexValue(char* str, char*& hex); +void LogGDT(void); +void LogLDT(void); +void LogIDT(void); class DEBUG; @@ -63,6 +66,13 @@ DEBUG* pDebugcom = 0; bool exitLoop = false; bool logHeavy = false; +// Heavy Debugging Vars for logging +#if C_HEAVY_DEBUG +static FILE* cpuLogFile = 0; +static bool cpuLog = false; +static int cpuLogCounter = 0; +#endif + static struct { Bit32u eax,ebx,ecx,edx,esi,edi,ebp,esp,eip; } oldregs; @@ -592,7 +602,9 @@ static void DrawData(void) { mvwprintw (dbg.win_data,1+y,0,"%04X:%04X ",dataSeg,add); for (int x=0; x<16; x++) { address = GetAddress(dataSeg,add); - if (address<8*1024*1024) ch = mem_readb(address); else ch = 0; + if (!(paging.tlb.handler[address >> 12]->flags & PFLAG_INIT)) { + ch = mem_readb(address); + } else ch = 0; mvwprintw (dbg.win_data,1+y,11+3*x,"%02X",ch); if (ch<32) ch='.'; mvwprintw (dbg.win_data,1+y,60+x,"%c",ch); @@ -991,14 +1003,27 @@ bool ParseCommand(char* str) DEBUG_ShowMsg("DEBUG: Set data overview to %04X:%04X",dataSeg,dataOfs); return true; } +#if C_HEAVY_DEBUG found = strstr(str,"LOG "); if (found) { // Create Cpu log file found+=4; DEBUG_ShowMsg("DEBUG: Starting log"); - DEBUG_Log_Loop(GetHexValue(found,found)); - DEBUG_ShowMsg("DEBUG: Logfile LOGCPU.TXT created."); +// DEBUG_Log_Loop(GetHexValue(found,found)); + cpuLogFile = fopen("LOGCPU.TXT","wt"); + if (!cpuLogFile) { + DEBUG_ShowMsg("DEBUG: Logfile couldnt be created."); + return false; + } + cpuLog = true; + cpuLogCounter = GetHexValue(found,found); + + debugging=false; + CBreakpoint::ActivateBreakpoints(SegPhys(cs)+reg_eip,true); + ignoreAddressOnce = SegPhys(cs)+reg_eip; + DOSBOX_SetNormalLoop(); return true; } +#endif found = strstr(str,"SR "); if (found) { // Set register value found+=2; @@ -1056,7 +1081,22 @@ bool ParseCommand(char* str) DEBUG_ShowMsg("%s",out2); }; -/* found = strstr(str,"EXCEPTION "); + found = strstr(str,"GDT"); + if (found) { + LogGDT(); + } + + found = strstr(str,"LDT"); + if (found) { + LogLDT(); + } + + found = strstr(str,"IDT"); + if (found) { + LogIDT(); + } + + /* found = strstr(str,"EXCEPTION "); if (found) { found += 9; Bit8u num = GetHexValue(found,found); @@ -1387,10 +1427,64 @@ void DEBUG_DrawScreen(void) { DrawCode(); DrawRegisters(); } + static void DEBUG_RaiseTimerIrq(void) { PIC_ActivateIRQ(0); } +void LogGDT(void) +{ + char out1[512]; + Descriptor desc; + Bitu length = cpu.gdt.GetLimit(); + PhysPt address = cpu.gdt.GetBase(); + PhysPt max = address + length; + Bitu i = 0; + LOG(LOG_MISC,LOG_ERROR)("GDT Base:%08X Limit:%08X",address,length); + while (address0) { + static char buffer[4096]; + LogInstruction(SegValue(cs),reg_eip,buffer); + fprintf(cpuLogFile,"%s",buffer); + cpuLogCounter--; + } + if (cpuLogCounter<=0) { + fclose(cpuLogFile); + DEBUG_ShowMsg("DEBUG: cpu log LOGCPU.TXT created"); + cpuLog = false; + DEBUG_EnableDebugger(); + return true; + } + } // LogInstruction if (logHeavy) DEBUG_HeavyLogInstruction(); @@ -1734,7 +1842,6 @@ bool DEBUG_HeavyIsBreakpoint(void) return false; } PhysPt where = SegPhys(cs)+reg_eip; - if (CBreakpoint::CheckBreakpoint(SegValue(cs),reg_eip)) { return true; }