From 39b528f97a342eabaaa4024e41d4f182de668ce4 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sat, 28 Aug 2004 12:51:35 +0000 Subject: [PATCH] Commit patch Gil Megidish. Modified it a bit to work in regular mode debug mode as well. (only updates on breakpoints though). Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1932 --- src/debug/debug.cpp | 68 +++++++++++++++++++++++++++++++++-------- src/debug/debug_gui.cpp | 17 +++++++---- src/debug/debug_inc.h | 4 +++ 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/src/debug/debug.cpp b/src/debug/debug.cpp index fc15273b..07eb4391 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.57 2004-08-04 09:12:53 qbix79 Exp $ */ +/* $Id: debug.cpp,v 1.58 2004-08-28 12:51:35 qbix79 Exp $ */ #include "programs.h" @@ -26,6 +26,7 @@ #include "dosbox.h" #if C_DEBUG #include "debug.h" +#include "cross.h" //snprintf #include "cpu.h" #include "video.h" #include "pic.h" @@ -53,13 +54,17 @@ int old_cursor_state; static void DrawCode(void); static bool DEBUG_Log_Loop(int count); static void DEBUG_RaiseTimerIrq(void); +static void SaveMemory(Bitu seg, Bitu ofs1, Bit32s num); +static void LogGDT(void); +static void LogLDT(void); +static void LogIDT(void); +static void OutputVecTable(char* filename); +static void DrawVariables(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); -void OutputVecTable(char* filename); + + class DEBUG; @@ -67,6 +72,7 @@ DEBUG* pDebugcom = 0; bool exitLoop = false; bool logHeavy = false; + // Heavy Debugging Vars for logging #if C_HEAVY_DEBUG static FILE* cpuLogFile = 0; @@ -74,6 +80,8 @@ static bool cpuLog = false; static int cpuLogCounter = 0; #endif + + static struct { Bit32u eax,ebx,ecx,edx,esi,edi,ebp,esp,eip; } oldregs; @@ -86,6 +94,8 @@ DBGBlock dbg; static Bitu input_count; Bitu cycle_count; static bool debugging; + + static void SetColor(Bitu test) { if (test) { if (has_colors()) { wattrset(dbg.win_reg,COLOR_PAIR(PAIR_BYELLOW_BLACK));} @@ -572,6 +582,10 @@ static bool StepOver() bool DEBUG_ExitLoop(void) { +#if C_HEAVY_DEBUG + DrawVariables(); +#endif + if (exitLoop) { exitLoop = false; return true; @@ -1446,13 +1460,14 @@ void DEBUG_DrawScreen(void) { DrawData(); DrawCode(); DrawRegisters(); + DrawVariables(); } static void DEBUG_RaiseTimerIrq(void) { PIC_ActivateIRQ(0); } -void LogGDT(void) +static void LogGDT(void) { char out1[512]; Descriptor desc; @@ -1471,7 +1486,7 @@ void LogGDT(void) }; }; -void LogLDT(void) +static void LogLDT(void) { char out1[512]; Descriptor desc; @@ -1492,7 +1507,7 @@ void LogLDT(void) }; }; -void LogIDT(void) +static void LogIDT(void) { char out1[512]; Descriptor desc; @@ -1759,7 +1774,7 @@ bool CDebugVar::LoadVars(char* name) return true; }; -void SaveMemory(Bitu seg, Bitu ofs1, Bit32s num) +static void SaveMemory(Bitu seg, Bitu ofs1, Bit32s num) { FILE* f = fopen("MEMDUMP.TXT","wt"); if (!f) { @@ -1786,7 +1801,7 @@ void SaveMemory(Bitu seg, Bitu ofs1, Bit32s num) DEBUG_ShowMsg("DEBUG: Memory dump success."); }; -void OutputVecTable(char* filename) +static void OutputVecTable(char* filename) { FILE* f = fopen(filename, "wt"); if (!f) @@ -1802,6 +1817,35 @@ void OutputVecTable(char* filename) DEBUG_ShowMsg("DEBUG: Interrupt vector table written to %s.", filename); } +#define DEBUG_VAR_BUF_LEN 16 +static void DrawVariables(void) +{ + std::list::iterator i; + CDebugVar *dv; + char buffer[DEBUG_VAR_BUF_LEN]; + + int idx = 0; + for(i=CDebugVar::varList.begin(); i != CDebugVar::varList.end(); i++, idx++) { + + if (idx == 4*3) { + /* too many variables */ + break; + } + + dv = static_cast(*i); + + Bit16u value = mem_readw(dv->GetAdr()); + snprintf(buffer,DEBUG_VAR_BUF_LEN, "0x%04x", value); + + int y = idx / 3; + int x = (idx % 3) * 26; + mvwprintw(dbg.win_var, y, x, dv->GetName()); + mvwprintw(dbg.win_var, y, (x + DEBUG_VAR_BUF_LEN + 1) , buffer); + } + + wrefresh(dbg.win_var); +} +#undef DEBUG_VAR_BUF_LEN // HEAVY DEBUGGING STUFF #if C_HEAVY_DEBUG @@ -1882,9 +1926,9 @@ bool DEBUG_HeavyIsBreakpoint(void) } return false; }; - #endif // HEAVY DEBUG + #endif // DEBUG diff --git a/src/debug/debug_gui.cpp b/src/debug/debug_gui.cpp index ab3998f0..268fecfa 100644 --- a/src/debug/debug_gui.cpp +++ b/src/debug/debug_gui.cpp @@ -53,7 +53,7 @@ void DEBUG_ShowMsg(char * format,...) { va_end(msg); wprintw(dbg.win_out,"%10d: %s\n",cycle_count,buf); wrefresh(dbg.win_out); - if(debuglog) fprintf(debuglog,"%10d: %s\n",cycle_count,buf); + if(debuglog) fprintf(debuglog,"%10d: %s\n",cycle_count,buf); } void LOG::operator() (char* format, ...){ @@ -99,13 +99,15 @@ static void DrawBars(void) { attrset(COLOR_PAIR(PAIR_BLACK_BLUE)); } /* Show the Register bar */ - mvaddstr(dbg.win_reg->_begy-1,0,"---[F1](Register Overview)---"); + mvaddstr(dbg.win_reg->_begy-1,0,"---(Register Overview)---"); /* Show the Data Overview bar perhaps with more special stuff in the end */ - mvaddstr(dbg.win_data->_begy-1,0,"---[F2](Data Overview)---"); + mvaddstr(dbg.win_data->_begy-1,0,"---(Data Overview)---"); /* Show the Code Overview perhaps with special stuff in bar too */ - mvaddstr(dbg.win_code->_begy-1,0,"---[F3](Code Overview)---"); + mvaddstr(dbg.win_code->_begy-1,0,"---(Code Overview)---"); + /* Show the Variable Overview bar */ + mvaddstr(dbg.win_var->_begy-1,0,"---(Variable Overview)---"); /* Show the Output OverView */ - mvaddstr(dbg.win_out->_begy-1,0,"---[F4](OutPut/Input)---"); + mvaddstr(dbg.win_out->_begy-1,0,"---(OutPut/Input)---"); attrset(0); } @@ -124,7 +126,10 @@ static void MakeSubWindows(void) { /* The Code Window */ dbg.win_code=subwin(dbg.win_main,11,dbg.win_main->_maxx,outy,0); outy+=12; - /* The output Window */ + /* The Variable Window */ + dbg.win_var=subwin(dbg.win_main,4,dbg.win_main->_maxx,outy,0); + outy+=5; + /* The Output Window */ dbg.win_out=subwin(dbg.win_main,dbg.win_main->_maxy-outy-1,dbg.win_main->_maxx,outy,0); dbg.input_y=dbg.win_main->_maxy-1; scrollok(dbg.win_out,TRUE); diff --git a/src/debug/debug_inc.h b/src/debug/debug_inc.h index 378b2df0..0435a515 100644 --- a/src/debug/debug_inc.h +++ b/src/debug/debug_inc.h @@ -17,6 +17,9 @@ */ /* Local Debug Function */ + +/* $Id: debug_inc.h,v 1.8 2004-08-28 12:51:35 qbix79 Exp $ */ + #include #include "mem.h" @@ -34,6 +37,7 @@ struct DBGBlock { WINDOW * win_reg; /* Register Window */ WINDOW * win_data; /* Data Output window */ WINDOW * win_code; /* Disassembly/Debug point Window */ + WINDOW * win_var; /* Variable Window */ WINDOW * win_out; /* Text Output Window */ Bit32u active_win; /* Current active window */ Bit32u input_y;