diff --git a/src/debug/debug.cpp b/src/debug/debug.cpp index 5ffb2b4c..b11f2550 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.90 2007-11-24 17:26:48 c2woody Exp $ */ +/* $Id: debug.cpp,v 1.91 2007-12-15 16:28:32 c2woody Exp $ */ #include "dosbox.h" #if C_DEBUG @@ -448,7 +448,8 @@ bool CBreakpoint::CheckBreakpoint(Bitu seg, Bitu off) Bitu address; if (bp->GetType()==BKPNT_MEMORY_LINEAR) address = bp->GetOffset(); else address = GetAddress(bp->GetSegment(),bp->GetOffset()); - Bit8u value = mem_readb(address); + Bit8u value=0; + if (mem_readb_checked(address,&value)) return false; if (bp->GetValue() != value) { // Yup, memory value changed DEBUG_ShowMsg("DEBUG: Memory breakpoint %s: %04X:%04X - %02X -> %02X\n",(bp->GetType()==BKPNT_MEMORY_PROT)?"(Prot)":"",bp->GetSegment(),bp->GetOffset(),bp->GetValue(),value); @@ -674,9 +675,7 @@ static void DrawData(void) { else mvwprintw (dbg.win_data,1+y,0,"%04X:%08X ",dataSeg,add); for (int x=0; x<16; x++) { address = GetAddress(dataSeg,add); - if (!(get_tlb_readhandler(address)->flags & PFLAG_INIT)) { - ch = mem_readb(address); - } else ch = 0; + if (mem_readb_checked(address,&ch)) ch=0; mvwprintw (dbg.win_data,1+y,14+3*x,"%02X",ch); if (ch<32 || !isprint(*reinterpret_cast(&ch))) ch='.'; mvwprintw (dbg.win_data,1+y,63+x,"%c",ch); @@ -759,8 +758,7 @@ static void DrawRegisters(void) { wrefresh(dbg.win_reg); }; -static void DrawCode(void) -{ +static void DrawCode(void) { bool saveSel; Bit32u disEIP = codeViewData.useEIP; PhysPt start = GetAddress(codeViewData.useCS,codeViewData.useEIP); @@ -796,7 +794,11 @@ static void DrawCode(void) mvwprintw(dbg.win_code,i,0,"%04X:%04X ",codeViewData.useCS,disEIP); if (drawsize>10) { toolarge = true; drawsize = 9; }; - for (c=0;c %04Xxxx flags [uw] %x:%x::%x:%x",i,entry.block.base,entry.block.us,table.block.us,entry.block.wr,table.block.wr); + sprintf(out1,"page %05Xxxx -> %04Xxxx flags [uw] %x:%x::%x:%x [d=%x|a=%x]", + i,entry.block.base,entry.block.us,table.block.us, + entry.block.wr,table.block.wr,entry.block.d,entry.block.a); LOG(LOG_MISC,LOG_ERROR)(out1); } } @@ -1764,8 +1766,7 @@ void LogPages(char* selname) } }; -static void LogCPUInfo(void) -{ +static void LogCPUInfo(void) { char out1[512]; sprintf(out1,"cr0:%08X cr2:%08X cr3:%08X cpl=%x",cpu.cr0,paging.cr2,paging.cr3,cpu.cpl); LOG(LOG_MISC,LOG_ERROR)(out1); @@ -1778,13 +1779,15 @@ static void LogCPUInfo(void) Bitu sel=CPU_STR(); Descriptor desc; - cpu.gdt.GetDescriptor(sel,desc); - sprintf(out1,"TR selector=%04X, base=%08X limit=%08X*%X",sel,desc.GetBase(),desc.GetLimit(),desc.saved.seg.g?0x4000:1); - LOG(LOG_MISC,LOG_ERROR)(out1); + if (cpu.gdt.GetDescriptor(sel,desc)) { + sprintf(out1,"TR selector=%04X, base=%08X limit=%08X*%X",sel,desc.GetBase(),desc.GetLimit(),desc.saved.seg.g?0x4000:1); + LOG(LOG_MISC,LOG_ERROR)(out1); + } sel=CPU_SLDT(); - cpu.gdt.GetDescriptor(sel,desc); - sprintf(out1,"LDT selector=%04X, base=%08X limit=%08X*%X",sel,desc.GetBase(),desc.GetLimit(),desc.saved.seg.g?0x4000:1); - LOG(LOG_MISC,LOG_ERROR)(out1); + if (cpu.gdt.GetDescriptor(sel,desc)) { + sprintf(out1,"LDT selector=%04X, base=%08X limit=%08X*%X",sel,desc.GetBase(),desc.GetLimit(),desc.saved.seg.g?0x4000:1); + LOG(LOG_MISC,LOG_ERROR)(out1); + } }; #if C_HEAVY_DEBUG @@ -1813,7 +1816,9 @@ static void LogInstruction(Bit16u segValue, Bit32u eipValue, ofstream& out) { } else if (cpuLogType == 2) { char ibytes[200]=""; char tmpc[200]; for (Bitu i=0; i0) { - sprintf(buffer,"%04X:%04X ",seg,ofs1); for (Bit16u x=0; x<16; x++) { - sprintf (temp,"%02X ",mem_readb(GetAddress(seg,ofs1+x))); - strcat (buffer,temp); + Bit8u value; + if (mem_readb_checked(GetAddress(seg,ofs1+x),&value)) sprintf(temp,"?? ",value); + else sprintf(temp,"%02X ",value); + strcat(buffer,temp); }; ofs1+=16; num-=16; @@ -2080,7 +2085,8 @@ static void SaveMemoryBin(Bitu seg, Bitu ofs1, Bit32u num) { } for(Bitu x = 0; x < num;x++) { - Bit8u val = mem_readb(GetAddress(seg,ofs1+x)); + Bit8u val; + if (mem_readb_checked(GetAddress(seg,ofs1+x),&val)) val=0; fwrite(&val,1,1,f); }; @@ -2088,8 +2094,7 @@ static void SaveMemoryBin(Bitu seg, Bitu ofs1, Bit32u num) { DEBUG_ShowMsg("DEBUG: Memory dump binary success.\n"); }; -static void OutputVecTable(char* filename) -{ +static void OutputVecTable(char* filename) { FILE* f = fopen(filename, "wt"); if (!f) { @@ -2105,8 +2110,9 @@ static void OutputVecTable(char* filename) } #define DEBUG_VAR_BUF_LEN 16 -static void DrawVariables(void) -{ +static void DrawVariables(void) { + if (CDebugVar::varList.size()==0) return; + std::list::iterator i; CDebugVar *dv; char buffer[DEBUG_VAR_BUF_LEN]; @@ -2121,8 +2127,11 @@ static void DrawVariables(void) dv = static_cast(*i); - Bit16u value = mem_readw(dv->GetAdr()); - snprintf(buffer,DEBUG_VAR_BUF_LEN, "0x%04x", value); + Bit16u value; + if (mem_readw_checked(dv->GetAdr(),&value)) + snprintf(buffer,DEBUG_VAR_BUF_LEN, "??????", value); + else + snprintf(buffer,DEBUG_VAR_BUF_LEN, "0x%04x", value); int y = idx / 3; int x = (idx % 3) * 26; @@ -2276,8 +2285,14 @@ bool DEBUG_HeavyIsBreakpoint(void) { } // LogInstruction if (logHeavy) DEBUG_HeavyLogInstruction(); - if(zeroProtect && mem_readd(SegPhys(cs) + reg_eip) == 0) zero_count++; else zero_count = 0; - if(zeroProtect && GCC_UNLIKELY(zero_count == 10)) E_Exit("running zeroed code"); + if (zeroProtect) { + Bit32u value=0; + if (!mem_readd_checked(SegPhys(cs)+reg_eip,&value)) { + if (value == 0) zero_count++; + else zero_count = 0; + } + if (GCC_UNLIKELY(zero_count == 10)) E_Exit("running zeroed code"); + } if (skipFirstInstruction) { skipFirstInstruction = false; diff --git a/src/debug/debug_disasm.cpp b/src/debug/debug_disasm.cpp index 3ccbded5..c9cd7335 100644 --- a/src/debug/debug_disasm.cpp +++ b/src/debug/debug_disasm.cpp @@ -878,7 +878,7 @@ static void percent(char type, char subtype) vofs |= (UINT32)getbyte() << 8; vofs |= (UINT32)getbyte() << 16; vofs |= (UINT32)getbyte() << 24; - name = addr_to_hex(vofs+instruction_offset+INSTRUCTION_SIZE,1); + name = addr_to_hex(vofs+instruction_offset+INSTRUCTION_SIZE,(addrsize == 32)?0:1); break; } if (vofs<0)