Capture debug prints in PICE.

Break into PICE on control+d.

svn path=/trunk/; revision=2620
This commit is contained in:
Casper Hornstrup 2002-02-10 20:21:40 +00:00
parent 7a5ecf6515
commit f57567e347
4 changed files with 29 additions and 17 deletions

View file

@ -136,8 +136,17 @@ ULONG CountArgs(LPSTR fmt)
//***********************************************************************************
ULONG PICE_KdpPrintString(PANSI_STRING String)
{
//dummy function
ULONG ulRingBufferLock;
save_flags(ulRingBufferLock);
cli();
/* CH: What is bIsDebugPrint used for? */
bIsDebugPrint = FALSE;
DPRINT((0,"PICE_KdpPrintString\n\n\n"));
AddToRingBuffer(String->Buffer);
restore_flags(ulRingBufferLock);
}
//*************************************************************************
// PrintkCallback()
@ -151,11 +160,11 @@ void PrintkCallback(void)
ULONG ulAddress;
ULONG countArgs,i,len;
PANSI_STRING temp;
CHAR buf[128];
DPRINT((0,"In PrintkCallback:1\n"));
DPRINT((0,"In PrintkCallback\n"));
bInPrintk = TRUE;
DPRINT((0,"In PrintkCallback:2\n"));
// get the linear address of stack where string resides
ulAddress = GetLinearAddress(CurrentSS,CurrentESP);
@ -166,12 +175,9 @@ void PrintkCallback(void)
{
//KdpPrintString has PANSI_STRING as a parameter
temp = (PANSI_STRING)*(PULONG)(ulAddress+sizeof(char *));
DPRINT((0,"temp: %x\n", temp));
fmt = temp->Buffer;
Print(OUTPUT_WINDOW,fmt);
DPRINT((0,"%s\n", fmt));
CurrentEIP = (ULONG)PICE_KdpPrintString;
DPRINT((0,"PrintkCallback: %s\n", temp->Buffer));
/* Call our version of KdpPrintString() */
CurrentEIP = (ULONG_PTR)PICE_KdpPrintString;
}
}
bInPrintk = FALSE;
@ -251,16 +257,17 @@ void InstallPrintkHook(void)
if( bIsPrintkPatched )
return;
DPRINT((0,"installing PrintString hook\n"));
DPRINT((0,"installing PrintString hook\n"));
ScanExports("_KdpPrintString",(PULONG)&ulPrintk);
DPRINT((0,"_KdpPrintString @ %x\n", ulPrintk));
ASSERT( ulPrintk ); // temporary
if(ulPrintk)
{
bIsPrintkPatched = InstallSWBreakpoint(ulPrintk,TRUE,PrintkCallback);
DPRINT((0,"KdpPrintStringTest breakpoint installed? %d\n", bIsPrintkPatched));
bIsPrintkPatched = InstallSWBreakpoint(ulPrintk,TRUE,PrintkCallback);
DPRINT((0,"KdpPrintStringTest breakpoint installed? %d\n", bIsPrintkPatched));
}
LEAVE_FUNC();
}
@ -276,8 +283,8 @@ void DeInstallPrintkHook(void)
if(bIsPrintkPatched && ulPrintk)
{
// will be done on exit debugger
if( DeInstallSWBreakpoint(ulPrintk) )
bIsPrintkPatched = FALSE;
if (DeInstallSWBreakpoint(ulPrintk))
bIsPrintkPatched = FALSE;
}
LEAVE_FUNC();
}

View file

@ -52,7 +52,7 @@ static ULONG ulKeyPatchFlags;
void (*old_handle_scancode)(UCHAR,int);
char tempPatch[256];
UCHAR ucBreakKey = 'D'; // key that will break into debugger in combination with CTRL
UCHAR ucBreakKey = 'd'; // key that will break into debugger in combination with CTRL
////////////////////////////////////////////////////
// FUNCTIONS

View file

@ -1015,6 +1015,8 @@ void DebuggerShell(void)
//*************************************************************************
void RealIsr(ULONG dwReasonForBreak)
{
BOOLEAN ReinstallPermanentBp = FALSE;
DPRINT((0,"reason: %u#################################################################\n", dwReasonForBreak));
ENTER_FUNC();
@ -1231,6 +1233,8 @@ void RealIsr(ULONG dwReasonForBreak)
{
DPRINT((0,"permanent breakpoint\n"));
ReinstallPermanentBp = TRUE;
OldCS = CurrentCS;
OldEIP = CurrentEIP;
@ -1433,7 +1437,7 @@ void RealIsr(ULONG dwReasonForBreak)
}
// if there was a SW breakpoint at CS:EIP
if(NeedToReInstallSWBreakpoints(GetLinearAddress(CurrentCS,CurrentEIP),TRUE))
if(NeedToReInstallSWBreakpoints(GetLinearAddress(CurrentCS,CurrentEIP),TRUE) || ReinstallPermanentBp)
{
DPRINT((0,"need to reinstall INT3\n"));
// remember how we restarted last time

View file

@ -117,6 +117,7 @@ SCANTOASCII ucShiftScanToAscii_US[]=
{0,0}
};
SCANTOASCII ucScanToAscii_DK[]=
{
// Danish keyboard
@ -129,7 +130,7 @@ SCANTOASCII ucScanToAscii_DK[]=
{49,'n'},{50,'m'},{2,'1'},{3,'2'},
{4,'3'},{5,'4'},{6,'5'},{7,'6'},
{8,'7'},{9,'8'},{10,'9'},{11,'0'},{12,'+'},
{0x39,' '},{0x35,'_'},{0x34,'.'},{0x1b,''},
{0x39,' '},{0x35,'-'},{0x34,'.'},{0x1b,''},
{0x1a,'å'},{0x33,','},{0x27,'æ'},{0x0d,'´'},
{0x2b,'\''},{0x28,'ø'},{0x29,' '},
{0,0}