Debug output cleanup.

svn path=/trunk/; revision=2579
This commit is contained in:
Eugene Ingerman 2002-01-30 20:42:04 +00:00
parent 23b672891b
commit 8d8acf54de
7 changed files with 75 additions and 70 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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));
}
//*************************************************************************

View file

@ -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,6 +271,7 @@ void InstallPrintkHook(void)
void DeInstallPrintkHook(void)
{
ENTER_FUNC();
DPRINT((0,"enter DeInstallPrintkHook()\n"));
if(bIsPrintkPatched && ulPrintk)
{

View file

@ -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,6 +507,7 @@ proceed_as_normal:
}
else
{
DPRINT((0,"no call at breakpoint\n"));
// modify trace flag
CurrentEFL|=0x100; // set trace flag (TF)
@ -2481,7 +2484,7 @@ COMMAND_PROTOTYPE(SwitchTables)
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 )

View file

@ -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();
}

View file

@ -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