From 8d8acf54deaa41c0661bc480ea8f74c2bd4aef08 Mon Sep 17 00:00:00 2001 From: Eugene Ingerman Date: Wed, 30 Jan 2002 20:42:04 +0000 Subject: [PATCH] Debug output cleanup. svn path=/trunk/; revision=2579 --- reactos/apps/utils/pice/module/bp.c | 14 ++--- reactos/apps/utils/pice/module/debug.c | 4 +- reactos/apps/utils/pice/module/gpfault.c | 2 +- reactos/apps/utils/pice/module/output.c | 16 ++--- reactos/apps/utils/pice/module/parse.c | 21 ++++--- reactos/apps/utils/pice/module/pgflt.c | 10 +-- reactos/apps/utils/pice/module/shell.c | 78 ++++++++++++------------ 7 files changed, 75 insertions(+), 70 deletions(-) diff --git a/reactos/apps/utils/pice/module/bp.c b/reactos/apps/utils/pice/module/bp.c index 0eb12281e61..8116431cbf3 100644 --- a/reactos/apps/utils/pice/module/bp.c +++ b/reactos/apps/utils/pice/module/bp.c @@ -245,23 +245,23 @@ BOOLEAN InstallSWBreakpoint(ULONG ulAddress,BOOLEAN bPermanent,void (*SWBreakpoi // TODO: must also check if it's a writable page if(IsAddressValid(ulAddress) ) { - DPRINT((2,"InstallSWBreakpoint(): %.8X is valid, writable? %d\n",ulAddress,IsAddressWriteable(ulAddress))); - DPRINT((2,"pde: %x, pte: %x\n", *(ADDR_TO_PDE(ulAddress)), *(ADDR_TO_PTE(ulAddress)))); + DPRINT((0,"InstallSWBreakpoint(): %.8X is valid, writable? %d\n",ulAddress,IsAddressWriteable(ulAddress))); + DPRINT((0,"pde: %x, pte: %x\n", *(ADDR_TO_PDE(ulAddress)), *(ADDR_TO_PTE(ulAddress)))); if((p = FindSwBp(ulAddress))==NULL) { - DPRINT((2,"InstallSWBreakpoint(): %.8X is free\n",ulAddress)); + DPRINT((0,"InstallSWBreakpoint(): %.8X is free\n",ulAddress)); if( (p=FindEmptySwBpSlot()) ) { BOOLEAN isWriteable; - DPRINT((2,"InstallSWBreakpoint(): found empty slot\n")); - DPRINT((2,"InstallSWBreakpoint(): %x value: %x", ulAddress, *(PUCHAR)ulAddress)); + DPRINT((0,"InstallSWBreakpoint(): found empty slot\n")); + DPRINT((0,"InstallSWBreakpoint(): %x value: %x", ulAddress, *(PUCHAR)ulAddress)); p->ucOriginalOpcode = *(PUCHAR)ulAddress; //allow writing to page if( !( isWriteable = IsAddressWriteable(ulAddress) ) ) SetAddressWriteable(ulAddress,TRUE); - DPRINT((2,"writing breakpoint\n")); + DPRINT((0,"writing breakpoint\n")); *(PUCHAR)ulAddress = 0xCC; - DPRINT((2,"restoring page access\n")); + DPRINT((0,"restoring page access\n")); if( !isWriteable ) SetAddressWriteable(ulAddress,FALSE); p->bUsed = TRUE; diff --git a/reactos/apps/utils/pice/module/debug.c b/reactos/apps/utils/pice/module/debug.c index 68aa0201d0c..44529afd064 100644 --- a/reactos/apps/utils/pice/module/debug.c +++ b/reactos/apps/utils/pice/module/debug.c @@ -74,8 +74,8 @@ VOID Pice_dprintf(ULONG DebugLevel, PCHAR DebugMessage, ...) cli(); PICE_vsprintf(tempDebug, DebugMessage, ap); //ei DebugSendString(tempDebug); - //Print(OUTPUT_WINDOW, tempDebug); - DbgPrint("%s", tempDebug); + Print(OUTPUT_WINDOW, tempDebug); + //DbgPrint("%s", tempDebug); restore_flags(ulDebugFlags); } va_end(ap); diff --git a/reactos/apps/utils/pice/module/gpfault.c b/reactos/apps/utils/pice/module/gpfault.c index 4715b939b17..d0c3cf010c0 100644 --- a/reactos/apps/utils/pice/module/gpfault.c +++ b/reactos/apps/utils/pice/module/gpfault.c @@ -52,7 +52,7 @@ char tempGP[1024]; //************************************************************************* void HandleGPFault(FRAME* ptr) { - DPRINT((2,"HandleGPFault(): ptr = %x at eip: %x\n",ptr, ptr->eip)); + DPRINT((0,"HandleGPFault(): ptr = %x at eip: %x\n",ptr, ptr->eip)); } //************************************************************************* diff --git a/reactos/apps/utils/pice/module/output.c b/reactos/apps/utils/pice/module/output.c index d67eb93411b..836fa747c10 100644 --- a/reactos/apps/utils/pice/module/output.c +++ b/reactos/apps/utils/pice/module/output.c @@ -152,25 +152,25 @@ void PrintkCallback(void) ULONG countArgs,i,len; PANSI_STRING temp; - DPRINT((2,"In PrintkCallback:1\n")); + DPRINT((0,"In PrintkCallback:1\n")); bInPrintk = TRUE; - DPRINT((2,"In PrintkCallback:2\n")); + DPRINT((0,"In PrintkCallback:2\n")); // get the linear address of stack where string resides ulAddress = GetLinearAddress(CurrentSS,CurrentESP); if(ulAddress) { - DPRINT((2,"In PrintkCallback: ulAddress: %x\n", ulAddress)); + DPRINT((0,"In PrintkCallback: ulAddress: %x\n", ulAddress)); if(IsAddressValid(ulAddress+sizeof(char *)) ) { //KdpPrintString has PANSI_STRING as a parameter temp = (PANSI_STRING)*(PULONG)(ulAddress+sizeof(char *)); - DPRINT((2,"temp: %x\n", temp)); + DPRINT((0,"temp: %x\n", temp)); fmt = temp->Buffer; Print(OUTPUT_WINDOW,fmt); - DPRINT((2,"%s\n", fmt)); + DPRINT((0,"%s\n", fmt)); CurrentEIP = (ULONG)PICE_KdpPrintString; } } @@ -247,8 +247,7 @@ void InstallPrintkHook(void) { ENTER_FUNC(); - //ei disabled for now - return; + if( bIsPrintkPatched ) return; @@ -272,7 +271,8 @@ void InstallPrintkHook(void) void DeInstallPrintkHook(void) { ENTER_FUNC(); - DPRINT((0,"enter DeInstallPrintkHook()\n")); + + DPRINT((0,"enter DeInstallPrintkHook()\n")); if(bIsPrintkPatched && ulPrintk) { // will be done on exit debugger diff --git a/reactos/apps/utils/pice/module/parse.c b/reactos/apps/utils/pice/module/parse.c index e76d9551788..87ff57526a4 100644 --- a/reactos/apps/utils/pice/module/parse.c +++ b/reactos/apps/utils/pice/module/parse.c @@ -460,6 +460,8 @@ COMMAND_PROTOTYPE(StepOver) ENTER_FUNC(); + DPRINT((0,"StepOver():\n")); + // only no arguments supplied // when we have source and current disassembly mod is SOURCE // we have to analyse the code block for the source line @@ -505,7 +507,8 @@ proceed_as_normal: } else { - // modify trace flag + DPRINT((0,"no call at breakpoint\n")); + // modify trace flag CurrentEFL|=0x100; // set trace flag (TF) bSingleStep=TRUE; @@ -1944,7 +1947,7 @@ COMMAND_PROTOTYPE(ShowVirtualMemory) PMADDRESS_SPACE vma = NULL; MEMORY_AREA* current; char filename[64]; - + DPRINT((0,"ShowVirtualMemory()\n")); if( my_current ) vma = &(my_current->AddressSpace); @@ -1959,7 +1962,7 @@ COMMAND_PROTOTYPE(ShowVirtualMemory) while (current_entry != &vma->MAreaListHead) { *filename = 0; - + current = CONTAINING_RECORD(current_entry, MEMORY_AREA, Entry); @@ -1971,7 +1974,7 @@ COMMAND_PROTOTYPE(ShowVirtualMemory) if(IsAddressValid((ULONG)current->Data.SectionData.Section->FileObject->FileName.Buffer) ) PICE_sprintf(filename,"%.64S",current->Data.SectionData.Section->FileObject->FileName.Buffer); } - + PICE_sprintf(tempCmd,"%.8X %.8X %.8X %.8X %x %x %s\n", (ULONG)current->BaseAddress, (ULONG)current->BaseAddress+current->Length, @@ -1980,7 +1983,7 @@ COMMAND_PROTOTYPE(ShowVirtualMemory) current->Type, current->Attributes,//DecodeVmFlags(current->Type, current->Attributes), filename); Print(OUTPUT_WINDOW,tempCmd); - + if(WaitForKey()==FALSE) break; current_entry = current_entry->Flink; @@ -2477,12 +2480,12 @@ COMMAND_PROTOTYPE(SwitchTables) { PDEBUG_MODULE pTempMod; char temp[DEBUG_MODULE_NAME_LEN]; - + pCurrentSymbols = (PICE_SYMBOLFILE_HEADER*)pArgs->Value[0]; CopyWideToAnsi( temp, pCurrentSymbols->name ); - - DPRINT((2,"TableSwitchSym: pCurrentSymbols: %x, Name: %s\n", pCurrentSymbols, temp)); - + + DPRINT((0,"TableSwitchSym: pCurrentSymbols: %x, Name: %s\n", pCurrentSymbols, temp)); + pTempMod = IsModuleLoaded(temp); if( pTempMod ) pCurrentMod = pTempMod; diff --git a/reactos/apps/utils/pice/module/pgflt.c b/reactos/apps/utils/pice/module/pgflt.c index eb62bc289c9..7c9ec64a81c 100644 --- a/reactos/apps/utils/pice/module/pgflt.c +++ b/reactos/apps/utils/pice/module/pgflt.c @@ -220,7 +220,7 @@ ULONG HandlePageFault(FRAME* ptr) current->Type == MEMORY_AREA_PAGED_POOL || current->Type == MEMORY_AREA_SHARED_DATA ){ - Print(OUTPUT_WINDOW,"pICE: VMA Pageable Section.\n"); + //ei too much output Print(OUTPUT_WINDOW,"pICE: VMA Pageable Section.\n"); //ei DPRINT((2,"return 0 1\n")); return 0; //let the system handle this } @@ -271,7 +271,7 @@ ULONG HandlePageFault(FRAME* ptr) */ // let the system handle it - DPRINT((2,"return 0 5\n")); + //DPRINT((0,"return 0 5\n")); return 0; } } @@ -279,8 +279,8 @@ ULONG HandlePageFault(FRAME* ptr) } Print(OUTPUT_WINDOW,"pICE: no virtual memory arena at this address!\n"); - DPRINT((2,"return 0 6\n")); - return 0; + DPRINT((0,"return 0 6\n")); + return 1; // let the system handle it // return 0; @@ -378,7 +378,7 @@ void InstallIntEHook(void) OldIntEHandler=SetGlobalInt(0x0E,(ULONG)LocalIntEHandler); } UnmaskIrqs(); - DPRINT((2,"OldIntE @ %x\n", OldIntEHandler)); + DPRINT((0,"OldIntE @ %x\n", OldIntEHandler)); LEAVE_FUNC(); } diff --git a/reactos/apps/utils/pice/module/shell.c b/reactos/apps/utils/pice/module/shell.c index 4cc1a9f8ca5..e382d623a67 100644 --- a/reactos/apps/utils/pice/module/shell.c +++ b/reactos/apps/utils/pice/module/shell.c @@ -1017,7 +1017,7 @@ void DebuggerShell(void) //************************************************************************* void RealIsr(ULONG dwReasonForBreak) { - DPRINT((0,"#################################################################\n")); + DPRINT((0,"reason: %u#################################################################\n", dwReasonForBreak)); ENTER_FUNC(); // in handler @@ -1048,12 +1048,12 @@ void RealIsr(ULONG dwReasonForBreak) { ULONG ulAddress,ulAddressCurrent; - DPRINT((2,"REASON_SINGLESTEP\n")); + DPRINT((0,"REASON_SINGLESTEP: bSingleStep: %u\n", bSingleStep)); if(!bSingleStep) { - DPRINT((2,"no single step requested!\n")); dwCallOldInt1Handler = 1; + DPRINT((0,"no single step requested: %u!\n", dwCallOldInt1Handler)); goto common_return_point; } @@ -1065,7 +1065,7 @@ void RealIsr(ULONG dwReasonForBreak) // simply restart the system. if(NeedToReInstallSWBreakpoints(ulAddress,TRUE) ) { - DPRINT((2,"reinstalling INT3 @ %.4X:%.8X\n",OldCS,OldEIP)); + DPRINT((0,"reinstalling INT3 @ %.4X:%.8X\n",OldCS,OldEIP)); ReInstallSWBreakpoint(ulAddress); @@ -1084,7 +1084,7 @@ void RealIsr(ULONG dwReasonForBreak) } LEAVE_FUNC(); - DPRINT((2,"-----------------------------------------------------------------\n")); + DPRINT((0,"singlestep-----------------------------------------------------------------\n")); return; } bPreviousCommandWasGo = FALSE; @@ -1099,7 +1099,7 @@ void RealIsr(ULONG dwReasonForBreak) ULONG ulLineNumber; LPSTR pSrc,pFileName; - DPRINT((2,"RealIsr(): stepping through source!\n")); + DPRINT((0,"RealIsr(): stepping through source!\n")); // look up the corresponding source line // if there isn't any or the source line number has changed @@ -1108,12 +1108,12 @@ void RealIsr(ULONG dwReasonForBreak) pSrc = FindSourceLineForAddress(ulAddressCurrent,&ulLineNumber,NULL,NULL,&pFileName); else pSrc = NULL; - DPRINT((2,"RealIsr(): line #%u pSrc=%x (old line #%u)\n",ulLineNumber,(ULONG)pSrc,g_ulLineNumberStart)); + DPRINT((0,"RealIsr(): line #%u pSrc=%x (old line #%u)\n",ulLineNumber,(ULONG)pSrc,g_ulLineNumberStart)); // if we have found a source line there if(pSrc && ulLineNumber==g_ulLineNumberStart) { - DPRINT((2,"RealIsr(): stepping through line #%u in file = %s!\n",ulLineNumber,pFileName)); + DPRINT((0,"RealIsr(): stepping through line #%u in file = %s!\n",ulLineNumber,pFileName)); if(bStepInto) StepInto(NULL); @@ -1122,7 +1122,7 @@ void RealIsr(ULONG dwReasonForBreak) bInDebuggerShell = FALSE; LEAVE_FUNC(); - DPRINT((2,"-----------------------------------------------------------------\n")); + DPRINT((0,"singstep-----------------------------------------------------------------\n")); return; } bStepThroughSource = FALSE; @@ -1135,7 +1135,7 @@ void RealIsr(ULONG dwReasonForBreak) { ULONG ulReason; - DPRINT((2,"REASON_HARDWARE_BP\n")); + DPRINT((0,"REASON_HARDWARE_BP\n")); // disable HW breakpoints __asm__(" @@ -1149,7 +1149,7 @@ void RealIsr(ULONG dwReasonForBreak) :"eax" ); - DPRINT((2,"REASON_HARDWARE_BP: %x\n",(ulReason&0xF))); + DPRINT((0,"REASON_HARDWARE_BP: %x\n",(ulReason&0xF))); // HW breakpoint DR1 (skip: only used in init_module detection) if(ulReason&0x2) @@ -1183,12 +1183,12 @@ void RealIsr(ULONG dwReasonForBreak) else pSrc = NULL; - DPRINT((2,"RealIsr(): line #%u pSrc=%x (old line #%u) [2]\n",ulLineNumber,(ULONG)pSrc,g_ulLineNumberStart)); + DPRINT((0,"RealIsr(): line #%u pSrc=%x (old line #%u) [2]\n",ulLineNumber,(ULONG)pSrc,g_ulLineNumberStart)); // if we have found a source line there if(pSrc && ulLineNumber==g_ulLineNumberStart) { - DPRINT((2,"RealIsr(): stepping through line #%u in file = %s! [2]\n",ulLineNumber,pFileName)); + DPRINT((0,"RealIsr(): stepping through line #%u in file = %s! [2]\n",ulLineNumber,pFileName)); if(bStepInto) StepInto(NULL); @@ -1197,7 +1197,7 @@ void RealIsr(ULONG dwReasonForBreak) bInDebuggerShell = FALSE; LEAVE_FUNC(); - DPRINT((0,"-----------------------------------------------------------------\n")); + DPRINT((0,"rrr-----------------------------------------------------------------\n")); return; } bNotifyToExit = FALSE; @@ -1210,7 +1210,7 @@ void RealIsr(ULONG dwReasonForBreak) { ULONG ulAddress; - DPRINT((2,"REASON_INT3\n")); + DPRINT((0,"REASON_INT3\n")); // must subtract one cause INT3s are generated after instructions execution CurrentEIP--; @@ -1218,26 +1218,26 @@ void RealIsr(ULONG dwReasonForBreak) // make a flat address ulAddress = GetLinearAddress(CurrentCS,CurrentEIP); - DPRINT((2,"INT3 @ %.8X\n",ulAddress)); + DPRINT((0,"INT3 @ %.8X\n",ulAddress)); // if there's a breakpoint installed at current EIP remove it if(DeInstallSWBreakpoint(ulAddress) ) { PSW_BP p; - DPRINT((2,"INT3 @ %.8X removed\n",ulAddress)); + DPRINT((0,"INT3 @ %.8X removed\n",ulAddress)); // if it's permanent (must be Printk() ) skip the DebuggerShell() and // do a callback if( (p = IsPermanentSWBreakpoint(ulAddress)) ) { - DPRINT((2,"permanent breakpoint\n")); + DPRINT((0,"permanent breakpoint\n")); OldCS = CurrentCS; OldEIP = CurrentEIP; bSkipMainLoop = TRUE; - DPRINT((2,"callback at %x\n",p->Callback)); + DPRINT((0,"callback at %x\n",p->Callback)); if(p->Callback) p->Callback(); } @@ -1261,7 +1261,7 @@ void RealIsr(ULONG dwReasonForBreak) LPSTR pFind; PEPROCESS my_current = IoGetCurrentProcess(); - DPRINT((2,"can't deinstall, somebody else's breakpoint\n")); + DPRINT((0,"can't deinstall, somebody else's breakpoint\n")); // if no other debugger is running on this process and the address is @@ -1324,7 +1324,7 @@ void RealIsr(ULONG dwReasonForBreak) { LPSTR pSymbolName; - DPRINT((2,"REASON_PAGEFAULT\n")); + DPRINT((0,"REASON_PAGEFAULT\n")); if( ScanExportsByAddress(&pSymbolName,GetLinearAddress(CurrentCS,CurrentEIP)) ) { @@ -1343,7 +1343,7 @@ void RealIsr(ULONG dwReasonForBreak) { LPSTR pSymbolName; - DPRINT((2,"REASON_GPFAULT\n")); + DPRINT((0,"REASON_GPFAULT\n")); if( ScanExportsByAddress(&pSymbolName,GetLinearAddress(CurrentCS,CurrentEIP)) ) { @@ -1358,19 +1358,19 @@ void RealIsr(ULONG dwReasonForBreak) } else if(dwReasonForBreak == REASON_CTRLF) { - DPRINT((2,"REASON_CTRLF\n")); + DPRINT((0,"REASON_CTRLF\n")); // nothing to do } else if(dwReasonForBreak == REASON_DOUBLE_FAULT) { - DPRINT((2,"REASON_DOUBLE_FAULT\n")); + DPRINT((0,"REASON_DOUBLE_FAULT\n")); PICE_sprintf(tempShell,"pICE: Breakpoint due to double fault at %.4X:%.8X\n",CurrentCS,CurrentEIP); Print(OUTPUT_WINDOW,tempShell); } else if(dwReasonForBreak == REASON_INTERNAL_ERROR) { - DPRINT((2,"REASON_INTERNAL_ERROR\n")); + DPRINT((0,"REASON_INTERNAL_ERROR\n")); Print(OUTPUT_WINDOW,"pICE: Please report this error to klauspg@diamondmm.com!\n"); // Print(OUTPUT_WINDOW,"pICE: !!! SYSTEM HALTED !!!\n"); @@ -1378,7 +1378,7 @@ void RealIsr(ULONG dwReasonForBreak) } else { - DPRINT((2,"REASON_UNKNOWN\n")); + DPRINT((0,"REASON_UNKNOWN\n")); PICE_sprintf(tempShell,"pICE: Breakpoint due to unknown reason at %.4X:%.8X (code %x)\n",CurrentCS,CurrentEIP,dwReasonForBreak); Print(OUTPUT_WINDOW,tempShell); @@ -1388,21 +1388,21 @@ void RealIsr(ULONG dwReasonForBreak) } // we don't single-step yet - DPRINT((2,"RealIsr(): not stepping yet\n")); + DPRINT((0,"RealIsr(): not stepping yet\n")); bSingleStep=FALSE; // process commands if(bSkipMainLoop == FALSE) { - DPRINT((2,"RealIsr(): saving registers\n")); + DPRINT((0,"RealIsr(): saving registers\n")); // save the extended regs __asm__ __volatile__ (" pushl %eax movw %es,%ax movw %ax,_CurrentES - movw %fs,%ax - movw %ax,_CurrentFS + //movw %fs,%ax + //movw %ax,_CurrentFS movw %gs,%ax movw %ax,_CurrentGS movl %dr0,%eax @@ -1426,17 +1426,18 @@ void RealIsr(ULONG dwReasonForBreak) popl %eax" ); - DPRINT((2,"RealIsr(): adding colon to output()\n")); + CurrentFS = OLD_PCR; + DPRINT((0,"RealIsr(): adding colon to output()\n")); Print(OUTPUT_WINDOW,":"); - DPRINT((2,"RealIsr(): calling DebuggerShell()\n")); + DPRINT((0,"RealIsr(): calling DebuggerShell()\n")); DebuggerShell(); } // if there was a SW breakpoint at CS:EIP if(NeedToReInstallSWBreakpoints(GetLinearAddress(CurrentCS,CurrentEIP),TRUE)) { - DPRINT((2,"need to reinstall INT3\n")); + DPRINT((0,"need to reinstall INT3\n")); // remember how we restarted last time bPreviousCommandWasGo = !bSingleStep; // do a single step to reinstall breakpoint @@ -1457,9 +1458,10 @@ common_return_point: bInDebuggerShell = FALSE; LEAVE_FUNC(); - DPRINT((2,"common return-----------------------------------------------------------------\n")); + DPRINT((0,"common return-----------------------------------------------------------------\n")); } + __asm__(".global NewInt31Handler NewInt31Handler: cli @@ -1495,7 +1497,7 @@ notV86: cmpw $" STR(GLOBAL_CODE_SEGMENT) ",%ax je notswitched - // switched stack + // switched stack movl 6*4(%esp),%eax mov %eax,_CurrentESP mov 7*4(%esp),%eax @@ -1584,12 +1586,12 @@ afterswitch: // do we need to call old INT1 handler .byte 0x2e - cmp $0,_dwCallOldInt1Handler - je do_iret2 + cmp $0,_dwCallOldInt1Handler + je do_iret2 // call INT3 handler .byte 0x2e - jmp *_OldInt1Handler + jmp *_OldInt1Handler do_iret2: // do we need to call old INT3 handler