mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
Porting pice. Intermediate checkin. Now compiles and runs a little bit.
svn path=/trunk/; revision=2516
This commit is contained in:
parent
793bbe0455
commit
3595be74a5
12 changed files with 170 additions and 63 deletions
|
@ -86,7 +86,7 @@ void process_stabs(
|
|||
SymbolFileHeader.magic = PICE_MAGIC;
|
||||
strcpy(temp,pExeName);
|
||||
pSlash = strrchr(temp,'\\');
|
||||
pDot = strrchr(temp,'.');
|
||||
pDot = strchr(temp,'.');
|
||||
if(pDot)
|
||||
{
|
||||
*pDot = 0;
|
||||
|
@ -371,7 +371,7 @@ int process_pe(char* filename,int file,void* p,int len)
|
|||
|
||||
strcpy(szSymName,filename);
|
||||
//printf("LOADER: file name = %s\n",szSymName);
|
||||
if((pDot = strrchr(szSymName,'.')))
|
||||
if((pDot = strchr(szSymName,'.')))
|
||||
{
|
||||
*pDot = 0;
|
||||
strcat(pDot,".dbg");
|
||||
|
|
|
@ -239,14 +239,14 @@ BOOLEAN InstallSWBreakpoint(ULONG ulAddress,BOOLEAN bPermanent,void (*SWBreakpoi
|
|||
// TODO: must also check if it's a writable page
|
||||
if(IsAddressValid(ulAddress) )
|
||||
{
|
||||
DPRINT((0,"InstallSWBreakpoint(): %.8X is valid\n",ulAddress));
|
||||
DPRINT((0,"InstallSWBreakpoint(): %.8X is valid, writable? %d\n",ulAddress,IsAddressWriteable(ulAddress)));
|
||||
if((p = FindSwBp(ulAddress))==NULL)
|
||||
{
|
||||
DPRINT((0,"InstallSWBreakpoint(): %.8X is free\n",ulAddress));
|
||||
if( (p=FindEmptySwBpSlot()) )
|
||||
{
|
||||
DPRINT((0,"InstallSWBreakpoint(): found empty slot\n"));
|
||||
|
||||
DPRINT((0,"InstallSWBreakpoint(): %x value: %x", ulAddress, *(PUCHAR)ulAddress));
|
||||
p->ucOriginalOpcode = *(PUCHAR)ulAddress;
|
||||
*(PUCHAR)ulAddress = 0xCC;
|
||||
p->bUsed = TRUE;
|
||||
|
|
|
@ -67,13 +67,13 @@ VOID Pice_dprintf(ULONG DebugLevel, PCHAR DebugMessage, ...)
|
|||
va_list ap;
|
||||
|
||||
va_start(ap, DebugMessage);
|
||||
if (DebugLevel <= lDebugLevel)
|
||||
if (/*DebugLevel <= lDebugLevel*/ DebugLevel == 2)
|
||||
{
|
||||
save_flags(ulDebugFlags);
|
||||
cli();
|
||||
PICE_vsprintf(tempDebug, DebugMessage, ap);
|
||||
//ei DebugSendString(tempDebug);
|
||||
DbgPrint("%s", tempDebug);
|
||||
Print(OUTPUT_WINDOW, tempDebug);
|
||||
restore_flags(ulDebugFlags);
|
||||
}
|
||||
va_end(ap);
|
||||
|
|
|
@ -798,7 +798,7 @@ void Print(USHORT Window,LPSTR p)
|
|||
{
|
||||
ULONG i;
|
||||
|
||||
DPRINT((5,"%s",p));
|
||||
DPRINT((11,"%s",p));
|
||||
|
||||
//ENTER_FUNC();
|
||||
if(!bConsoleIsInitialized)
|
||||
|
|
|
@ -262,7 +262,8 @@ void InstallPrintkHook(void)
|
|||
{
|
||||
ENTER_FUNC();
|
||||
DPRINT((0,"installing PrintString hook\n"));
|
||||
|
||||
DPRINT((0,"installing PrintString hook. DISABLED for now!!!!!!!!!!!\n"));
|
||||
/* ei fix later
|
||||
ScanExports("_KdpPrintString",(PULONG)&ulPrintk);
|
||||
|
||||
ASSERT( ulPrintk ); // temporary
|
||||
|
@ -271,6 +272,7 @@ void InstallPrintkHook(void)
|
|||
{
|
||||
InstallSWBreakpoint(ulPrintk,TRUE,PrintkCallback);
|
||||
}
|
||||
*/
|
||||
|
||||
LEAVE_FUNC();
|
||||
}
|
||||
|
|
|
@ -1313,7 +1313,7 @@ void DisplaySourceFile(LPSTR pSrcLine,LPSTR pSrcEnd,ULONG ulLineNumber,ULONG ulL
|
|||
LPSTR pTemp;
|
||||
ULONG j = ulLineNumber-1;
|
||||
|
||||
DPRINT((0,"DisplaySourceFile(%.8X,%u,%u)\n",pSrcLine,ulLineNumber,ulLineNumberToInvert));
|
||||
DPRINT((2,"DisplaySourceFile(%.8X,%u,%u)\n",pSrcLine,ulLineNumber,ulLineNumberToInvert));
|
||||
|
||||
// go to line
|
||||
while(j--)
|
||||
|
@ -1411,16 +1411,16 @@ void UnassembleOneLineDown(void)
|
|||
{
|
||||
ULONG addr,addrorg;
|
||||
|
||||
DPRINT((0,"UnassembleOneLineDown()\n"));
|
||||
DPRINT((2,"UnassembleOneLineDown()\n"));
|
||||
|
||||
addrorg = addr = GetLinearAddress(usOldDisasmSegment,ulOldDisasmOffset);
|
||||
|
||||
DPRINT((0,"UnassembleOneLineDown(): addr = %.8X\n",addr));
|
||||
DPRINT((2,"UnassembleOneLineDown(): addr = %.8X\n",addr));
|
||||
|
||||
tempCmd[0]=0;
|
||||
Disasm(&addr,tempCmd);
|
||||
|
||||
DPRINT((0,"UnassembleOneLineDown(): addr after = %.8X\n",addr));
|
||||
DPRINT((2,"UnassembleOneLineDown(): addr after = %.8X\n",addr));
|
||||
|
||||
ulOldDisasmOffset += (addr - addrorg);
|
||||
RepaintSource();
|
||||
|
@ -1434,17 +1434,17 @@ void UnassembleOnePageDown(ULONG page)
|
|||
{
|
||||
ULONG addr,addrorg,i;
|
||||
|
||||
DPRINT((0,"UnassembleOnePageDown()\n"));
|
||||
DPRINT((2,"UnassembleOnePageDown()\n"));
|
||||
|
||||
addrorg = addr = GetLinearAddress(usOldDisasmSegment,ulOldDisasmOffset);
|
||||
|
||||
DPRINT((0,"UnassembleOnePageDown(): addr = %.8X\n",addr));
|
||||
DPRINT((2,"UnassembleOnePageDown(): addr = %.8X\n",addr));
|
||||
|
||||
tempCmd[0]=0;
|
||||
for(i=0;i<page;i++)
|
||||
Disasm(&addr,tempCmd);
|
||||
|
||||
DPRINT((0,"UnassembleOnePageDown(): addr after = %.8X\n",addr));
|
||||
DPRINT((2,"UnassembleOnePageDown(): addr after = %.8X\n",addr));
|
||||
|
||||
ulOldDisasmOffset += (addr - addrorg);
|
||||
RepaintSource();
|
||||
|
@ -1460,18 +1460,18 @@ void UnassembleOneLineUp(void)
|
|||
LONG offset;
|
||||
LPSTR pSymbol;
|
||||
|
||||
DPRINT((0,"UnassembleOneLineUp()\n"));
|
||||
DPRINT((2,"UnassembleOneLineUp()\n"));
|
||||
|
||||
addrorg = addr = GetLinearAddress(usOldDisasmSegment,ulOldDisasmOffset);
|
||||
|
||||
DPRINT((0,"UnassembleOneLineUp(): addrorg = %.8X\n",addr));
|
||||
DPRINT((2,"UnassembleOneLineUp(): addrorg = %.8X\n",addr));
|
||||
|
||||
offset = 1;
|
||||
|
||||
if((pSymbol = FindFunctionByAddress(addrorg-offset,&start,&end)) )
|
||||
{
|
||||
offset = addrorg - start;
|
||||
DPRINT((0,"UnassembleOneLineUp(): %s @ offset = %u\n",pSymbol,offset));
|
||||
DPRINT((2,"UnassembleOneLineUp(): %s @ offset = %u\n",pSymbol,offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1485,12 +1485,12 @@ void UnassembleOneLineUp(void)
|
|||
addr = addrorg - offset;
|
||||
do
|
||||
{
|
||||
DPRINT((0,"UnassembleOneLineUp(): offset = %u addrorg %x addr %x\n",offset,addrorg,addr));
|
||||
DPRINT((2,"UnassembleOneLineUp(): offset = %u addrorg %x addr %x\n",offset,addrorg,addr));
|
||||
// disassemble while not reaching current instruction
|
||||
addrbefore = addr;
|
||||
tempCmd[0]=0;
|
||||
Disasm(&addr,tempCmd);
|
||||
DPRINT((0,"%.8X: %s\n",addrbefore,tempCmd));
|
||||
DPRINT((2,"%.8X: %s\n",addrbefore,tempCmd));
|
||||
}while((addr != addrorg) && (addrbefore < addrorg));
|
||||
|
||||
if((addrorg - addrstart)<=0)
|
||||
|
@ -1498,7 +1498,7 @@ void UnassembleOneLineUp(void)
|
|||
else
|
||||
ulOldDisasmOffset -= (addrorg - addrbefore);
|
||||
|
||||
DPRINT((0,"UnassembleOneLineUp(): new addr = %.4X:%.8X\n",usOldDisasmSegment,ulOldDisasmOffset));
|
||||
DPRINT((2,"UnassembleOneLineUp(): new addr = %.4X:%.8X\n",usOldDisasmSegment,ulOldDisasmOffset));
|
||||
|
||||
RepaintSource();
|
||||
}
|
||||
|
@ -1513,20 +1513,20 @@ void UnassembleOnePageUp(ULONG page)
|
|||
LONG offset;
|
||||
LPSTR pSymbol;
|
||||
|
||||
DPRINT((0,"UnassembleOnePageUp()\n"));
|
||||
DPRINT((2,"UnassembleOnePageUp()\n"));
|
||||
|
||||
for(i=0;i<page;i++)
|
||||
{
|
||||
addrorg = addr = GetLinearAddress(usOldDisasmSegment,ulOldDisasmOffset);
|
||||
|
||||
DPRINT((0,"UnassembleOnePageUp(): addrorg = %.8X\n",addr));
|
||||
DPRINT((2,"UnassembleOnePageUp(): addrorg = %.8X\n",addr));
|
||||
|
||||
offset = 1;
|
||||
|
||||
if((pSymbol = FindFunctionByAddress(addrorg-offset,&start,&end)) )
|
||||
{
|
||||
offset = addrorg - start;
|
||||
DPRINT((0,"UnassembleOnePageUp(): %s @ offset = %u\n",pSymbol,offset));
|
||||
DPRINT((2,"UnassembleOnePageUp(): %s @ offset = %u\n",pSymbol,offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1539,12 +1539,12 @@ void UnassembleOnePageUp(ULONG page)
|
|||
addrstart = addrorg;
|
||||
do
|
||||
{
|
||||
DPRINT((0,"UnassembleOnePageUp(): offset = %u addrorg %x addr %x\n",offset,addrorg,addr));
|
||||
DPRINT((2,"UnassembleOnePageUp(): offset = %u addrorg %x addr %x\n",offset,addrorg,addr));
|
||||
addrbefore = addr;
|
||||
// disassemble while not reaching current instruction
|
||||
tempCmd[0]=0;
|
||||
Disasm(&addr,tempCmd);
|
||||
DPRINT((0,"%.8X: %s\n",addrbefore,tempCmd));
|
||||
DPRINT((2,"%.8X: %s\n",addrbefore,tempCmd));
|
||||
}while((addr != addrorg) && (addrbefore < addrorg));
|
||||
|
||||
if((addrorg - addrstart)<=0)
|
||||
|
@ -1554,7 +1554,7 @@ void UnassembleOnePageUp(ULONG page)
|
|||
|
||||
}
|
||||
|
||||
DPRINT((0,"UnassembleOnePageUp(): new addr = %.4X:%.8X\n",usOldDisasmSegment,ulOldDisasmOffset));
|
||||
DPRINT((2,"UnassembleOnePageUp(): new addr = %.4X:%.8X\n",usOldDisasmSegment,ulOldDisasmOffset));
|
||||
|
||||
RepaintSource();
|
||||
}
|
||||
|
@ -1614,7 +1614,7 @@ COMMAND_PROTOTYPE(Unassemble)
|
|||
return TRUE;
|
||||
|
||||
|
||||
DPRINT((0,"Unassemble(%0.4X:%0.8X)\n",segment,addr));
|
||||
DPRINT((2,"Unassemble(%0.4X:%0.8X)\n",segment,addr));
|
||||
|
||||
//
|
||||
// unassemble
|
||||
|
@ -1652,18 +1652,19 @@ COMMAND_PROTOTYPE(Unassemble)
|
|||
if(pCurrentMod)
|
||||
{
|
||||
ULONG mod_addr;
|
||||
DPRINT((0,"Unassemble(): pCurrentMod->name = %S\n",pCurrentMod->name));
|
||||
DPRINT((2,"Unassemble(): pCurrentMod->name = %S\n",pCurrentMod->name));
|
||||
mod_addr = (ULONG)pCurrentMod->BaseAddress;
|
||||
|
||||
pCurrentSymbols = FindModuleSymbols(mod_addr);
|
||||
DPRINT((0,"Unassemble(): pCurrentSymbols = %x\n",(ULONG)pCurrentSymbols));
|
||||
DPRINT((2,"Unassemble(): pCurrentSymbols = %x\n",(ULONG)pCurrentSymbols));
|
||||
}
|
||||
DPRINT((0,"Unassemble(): pCurrentMod = %x\n",pCurrentMod));
|
||||
DPRINT((2,"Unassemble(): pCurrentMod = %x, showsrc: %d\n",pCurrentMod, bShowSrc));
|
||||
|
||||
ulCurrentlyDisplayedLineNumber = 0;
|
||||
|
||||
if(bShowSrc && bForceDisassembly == FALSE && (pSrc = FindSourceLineForAddress(addr,&ulLineNumber,&pSrcStart,&pSrcEnd,&pFilename)) )
|
||||
{
|
||||
DPRINT((2,"\n\n\nFoundSourceLineForAddress: file: %s line: %d\n", pFilename, ulLineNumber));
|
||||
PICE_strcpy(szCurrentFile,pFilename);
|
||||
|
||||
ulCurrentlyDisplayedLineNumber = ulLineNumber;
|
||||
|
@ -1710,7 +1711,7 @@ COMMAND_PROTOTYPE(Unassemble)
|
|||
else
|
||||
{
|
||||
*szCurrentFile = 0;
|
||||
|
||||
DPRINT((2,"Couldn't find source for file\n"));
|
||||
Home(SOURCE_WINDOW);
|
||||
// for each line in the disassembly window
|
||||
for(i=0;i<wWindow[SOURCE_WINDOW].cy;i++)
|
||||
|
@ -2006,7 +2007,8 @@ COMMAND_PROTOTYPE(Ver)
|
|||
system_utsname.release);
|
||||
*/
|
||||
Print(OUTPUT_WINDOW,tempCmd);
|
||||
Print(OUTPUT_WINDOW,"pICE: written by Klaus P. Gerlicher and Goran Devic. Ported to Reactos by Eugene Ingerman.\n");
|
||||
Print(OUTPUT_WINDOW,"pICE: written by Klaus P. Gerlicher and Goran Devic.\n");
|
||||
Print(OUTPUT_WINDOW,"pICE: ported to Reactos by Eugene Ingerman.\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -88,12 +88,13 @@ BOOLEAN PiceKbdIsr (
|
|||
|
||||
if(isDown)
|
||||
{
|
||||
// CTRL pressed
|
||||
DbgPrint("bControl: %x, ucKey: %x, breakkey: %x\n", bControl, ucKey, AsciiToScan(ucBreakKey));
|
||||
// CTRL pressed
|
||||
if(ucKey==0x1d)
|
||||
{
|
||||
bControl=TRUE;
|
||||
}
|
||||
else if(bControl==TRUE && ucKey==AsciiToScan(ucBreakKey)) // CTRL-D
|
||||
if(bControl==TRUE && ucKey==AsciiToScan(ucBreakKey)) // CTRL-D
|
||||
{
|
||||
// fake a CTRL-D release call
|
||||
bForward=FALSE;
|
||||
|
|
|
@ -216,7 +216,7 @@ ULONG HandlePageFault(FRAME* ptr)
|
|||
}
|
||||
|
||||
Print(OUTPUT_WINDOW,"pICE: no virtual memory arena at this address!\n");
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
// let the system handle it
|
||||
// return 0;
|
||||
|
|
|
@ -638,7 +638,7 @@ BOOLEAN ScanExportsByAddress(LPSTR *pFind,ULONG ulValue)
|
|||
(pSym->SectionNumber > 0 ))
|
||||
{
|
||||
ULONG ulCurrAddr;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + pSym->SectionNumber;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + (pSym->SectionNumber-1);
|
||||
|
||||
|
||||
DPRINT((0,"ScanExportsByAddress(): pShdr[%x] = %x\n",pSym->SectionNumber,(ULONG)pShdrThis));
|
||||
|
@ -665,11 +665,11 @@ BOOLEAN ScanExportsByAddress(LPSTR *pFind,ULONG ulValue)
|
|||
}
|
||||
*pFind = temp3;
|
||||
{
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + pFoundSym->SectionNumber;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + (pFoundSym->SectionNumber-1);
|
||||
//check that ulValue is below the limit for the section where best match is found
|
||||
ASSERT(ulValue < ((ULONG)pdTemp->BaseAddress+pShdrThis->SizeOfRawData));
|
||||
}
|
||||
if( !(pFoundSym->N.Name.Short) ){
|
||||
if( pFoundSym->N.Name.Short ){
|
||||
pName = pFoundSym->N.ShortName; //name is in the header
|
||||
PICE_sprintf(temp3,"%S!%.8s",pdTemp->name,pName); //if name is in the header it may be nonzero terminated
|
||||
}
|
||||
|
@ -715,14 +715,14 @@ BOOLEAN ScanExportsByAddress(LPSTR *pFind,ULONG ulValue)
|
|||
}
|
||||
// increment pointer to next line
|
||||
p = pStartOfLine;
|
||||
while(*p!=0 && *p!=0x0a)p++;
|
||||
while(*p!=0 && *p!=0x0a && *p!=0x0d)p++;
|
||||
p++;
|
||||
}
|
||||
if(bResult)
|
||||
{
|
||||
int i;
|
||||
// copy symbol name to temp string
|
||||
for(i=0;pSymbolName[i]!=0 && pSymbolName[i]!=0x0a;i++)
|
||||
for(i=0;pSymbolName[i]!=0 && pSymbolName[i]!=0x0a && pSymbolName[i]!=0x0d;i++)
|
||||
temp[i] = pSymbolName[i];
|
||||
temp[i] = 0;
|
||||
// decide if we need to append an offset
|
||||
|
@ -754,7 +754,7 @@ LPSTR FindFunctionByAddress(ULONG ulValue,PULONG pulstart,PULONG pulend)
|
|||
LPSTR pName;
|
||||
|
||||
pSymbols = FindModuleSymbols(ulValue);
|
||||
DPRINT((0,"FindFunctionByAddress(): symbols @ %x\n",(ULONG)pSymbols));
|
||||
DPRINT((0,"FindFunctionByAddress(): symbols for %S @ %x \n",pSymbols->name,(ULONG)pSymbols));
|
||||
if(pSymbols && pdebug_module_head)
|
||||
{
|
||||
DPRINT((0,"looking up symbol\n"));
|
||||
|
@ -768,7 +768,7 @@ LPSTR FindFunctionByAddress(ULONG ulValue,PULONG pulstart,PULONG pulend)
|
|||
start = (ULONG)pdTemp->BaseAddress;
|
||||
end = start+pdTemp->size;
|
||||
|
||||
DPRINT((0,"FindFunctionByAddress(): is it %S for %x\n",(ULONG)pdTemp->name,ulValue));
|
||||
DPRINT((0,"FindFunctionByAddress(): ulValue %x\n",ulValue));
|
||||
|
||||
if(ulValue>=start && ulValue<end)
|
||||
{
|
||||
|
@ -793,11 +793,11 @@ LPSTR FindFunctionByAddress(ULONG ulValue,PULONG pulstart,PULONG pulend)
|
|||
while( pSym < pSymEnd )
|
||||
{
|
||||
//symbol is a function is it's type is 0x20, storage class is external and section>0
|
||||
if(( (pSym->Type == 0x20) && (pSym->StorageClass==IMAGE_SYM_CLASS_STATIC) &&
|
||||
if(( (pSym->Type == 0x20) && (pSym->StorageClass==IMAGE_SYM_CLASS_EXTERNAL) &&
|
||||
(pSym->SectionNumber > 0 )))
|
||||
{
|
||||
ULONG ulCurrAddr;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + pSym->SectionNumber;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + (pSym->SectionNumber-1);
|
||||
|
||||
DPRINT((0,"FindFunctionByAddress(): pShdr[%x] = %x\n",pSym->SectionNumber,(ULONG)pShdrThis));
|
||||
|
||||
|
@ -811,17 +811,19 @@ LPSTR FindFunctionByAddress(ULONG ulValue,PULONG pulstart,PULONG pulend)
|
|||
//the begining of the section
|
||||
ulCurrAddr = ((ULONG)pdTemp->BaseAddress+pShdrThis->VirtualAddress+pSym->Value);
|
||||
DPRINT((0,"FindFunctionByAddress(): CurrAddr [1] = %x\n",ulCurrAddr));
|
||||
DPRINT((0,"%x ", ulCurrAddr));
|
||||
|
||||
if(ulCurrAddr<=ulValue && ulCurrAddr>start)
|
||||
{
|
||||
start = ulCurrAddr;
|
||||
pFoundSym = pSym;
|
||||
//DPRINT((0,"FindFunctionByAddress(): CANDIDATE for start %x\n",start));
|
||||
}
|
||||
else if(ulCurrAddr>=ulValue && ulCurrAddr<end)
|
||||
{
|
||||
end = ulCurrAddr;
|
||||
//DPRINT((0,"FindFunctionByAddress(): CANDIDATE for end %x\n",end));
|
||||
}
|
||||
|
||||
}
|
||||
//skip the auxiliary symbols and get the next symbol
|
||||
pSym += pSym->NumberOfAuxSymbols + 1;
|
||||
|
@ -834,7 +836,7 @@ LPSTR FindFunctionByAddress(ULONG ulValue,PULONG pulstart,PULONG pulend)
|
|||
|
||||
if(pulend){
|
||||
//just in case there is more than one code section
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + pFoundSym->SectionNumber;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + (pFoundSym->SectionNumber-1);
|
||||
if( end > (ULONG)pdTemp->BaseAddress+pShdrThis->SizeOfRawData ){
|
||||
DPRINT((0,"Hmm: end=%d, end of section: %d\n", end, (ULONG)pdTemp->BaseAddress+pShdrThis->SizeOfRawData));
|
||||
end = (ULONG)pdTemp->BaseAddress+pShdrThis->SizeOfRawData;
|
||||
|
@ -842,7 +844,7 @@ LPSTR FindFunctionByAddress(ULONG ulValue,PULONG pulstart,PULONG pulend)
|
|||
*pulend = end;
|
||||
}
|
||||
|
||||
if( !(pFoundSym->N.Name.Short) ){
|
||||
if(pFoundSym->N.Name.Short){
|
||||
//name is in the header. it's not zero terminated. have to copy.
|
||||
PICE_sprintf(temp4,"%.8s", pFoundSym->N.ShortName);
|
||||
pName = temp4;
|
||||
|
@ -954,17 +956,17 @@ ULONG FindFunctionInModuleByName(LPSTR szFunctionname, PDEBUG_MODULE pd)
|
|||
while( pSym < pSymEnd )
|
||||
{
|
||||
//symbol is a function is it's type is 0x20, storage class is external and section>0
|
||||
if(( (pSym->Type == 0x20) && (pSym->StorageClass==IMAGE_SYM_CLASS_STATIC) &&
|
||||
if(( (pSym->Type == 0x20) && (pSym->StorageClass==IMAGE_SYM_CLASS_EXTERNAL) &&
|
||||
(pSym->SectionNumber > 0 )))
|
||||
{
|
||||
ULONG start;
|
||||
LPSTR pName;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + pSym->SectionNumber;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + (pSym->SectionNumber-1);
|
||||
|
||||
DPRINT((0,"FindFunctionInModuleByName(): %s @ %x\n",pName,start));
|
||||
start = ((ULONG)pd->BaseAddress+pShdrThis->VirtualAddress+pSym->Value);
|
||||
|
||||
if( !(pSym->N.Name.Short) ){ //if name is stored in the structure
|
||||
if(pSym->N.Name.Short){ //if name is stored in the structure
|
||||
//name may be not zero terminated but 8 characters max
|
||||
if((PICE_strncmpi(pName,szFunctionname, 8) == 0) && start)
|
||||
{
|
||||
|
@ -1450,6 +1452,8 @@ LPSTR FindSourceLineForAddress(ULONG addr,PULONG pulLineNumber,LPSTR* ppSrcStart
|
|||
|
||||
// lookup the functions name and start-end (external symbols)
|
||||
pFunctionName = FindFunctionByAddress(addr,&start,&end);
|
||||
DPRINT((2,"FindSourceLineForAddress: %x\n", pFunctionName));
|
||||
|
||||
if(pFunctionName)
|
||||
{
|
||||
// lookup the modules symbol table (STABS)
|
||||
|
@ -1767,7 +1771,7 @@ ULONG ListSymbolStartingAt(PDEBUG_MODULE pMod,PICE_SYMBOLFILE_HEADER* pSymbols,U
|
|||
((pSym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL) || (pSym->StorageClass==IMAGE_SYM_CLASS_STATIC)) &&
|
||||
(pSym->SectionNumber > 0 ))
|
||||
{
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + pSym->SectionNumber;
|
||||
PIMAGE_SECTION_HEADER pShdrThis = (PIMAGE_SECTION_HEADER)pShdr + (pSym->SectionNumber-1);
|
||||
ULONG section_flags;
|
||||
ULONG start;
|
||||
|
||||
|
@ -1784,7 +1788,7 @@ ULONG ListSymbolStartingAt(PDEBUG_MODULE pMod,PICE_SYMBOLFILE_HEADER* pSymbols,U
|
|||
//the begining of the section
|
||||
|
||||
start = ((ULONG)pMod->BaseAddress+pShdrThis->VirtualAddress+pSym->Value);
|
||||
if( !(pSym->N.Name.Short) ){
|
||||
if(pSym->N.Name.Short){
|
||||
//name is in the header. it's not zero terminated. have to copy.
|
||||
PICE_sprintf(pOutput,"%.8X (%s) %.8s\n",start,(section_flags&IMAGE_SCN_CNT_CODE)?"TEXT":"DATA",pSym->N.ShortName);
|
||||
}
|
||||
|
@ -1946,19 +1950,21 @@ PICE_SYMBOLFILE_HEADER* LoadSymbols(LPSTR filename)
|
|||
{
|
||||
HANDLE hf;
|
||||
PICE_SYMBOLFILE_HEADER* pSymbols=NULL;
|
||||
WCHAR tempstr[DEBUG_MODULE_NAME_LEN];
|
||||
|
||||
WCHAR tempstr[256];
|
||||
int conv;
|
||||
ENTER_FUNC();
|
||||
|
||||
if( !PICE_MultiByteToWideChar(CP_ACP, NULL, filename, -1, tempstr, DEBUG_MODULE_NAME_LEN ) )
|
||||
if( !( conv = PICE_MultiByteToWideChar(CP_ACP, NULL, filename, -1, tempstr, 256 ) ) )
|
||||
{
|
||||
DPRINT((0,"Can't convert module name.\n"));
|
||||
return NULL;
|
||||
}
|
||||
DPRINT((0,"LoadSymbols: test %S, %s, tempstr %S, conv: %d\n",L"testing", filename, tempstr, conv));
|
||||
|
||||
if(ulNumSymbolsLoaded<DIM(apSymbols))
|
||||
{
|
||||
hf = PICE_open(tempstr,OF_READ);
|
||||
DPRINT((0,"LoadSymbols: hf: %x, file: %S\n",hf, tempstr));
|
||||
if(hf)
|
||||
{
|
||||
//mm_segment_t oldfs;
|
||||
|
@ -2172,6 +2178,7 @@ BOOLEAN LoadSymbolsFromConfig(BOOLEAN bIgnoreBootParams)
|
|||
{
|
||||
DPRINT((0,"Load symbols from file %s\n", temp));
|
||||
pSymbols = LoadSymbols(temp);
|
||||
DbgPrint("Load symbols from file %s, pSymbols: %x\n", temp, pSymbols);
|
||||
if(pSymbols)
|
||||
{
|
||||
PICE_SYMBOLFILE_SOURCE* pSrc;
|
||||
|
|
|
@ -1686,6 +1686,7 @@ int PICE_vsprintf(char *buf, const char *fmt, va_list args)
|
|||
int i, base;
|
||||
char * str;
|
||||
const char *s;
|
||||
const wchar_t *sw;
|
||||
|
||||
int flags; /* flags to PICE_number() */
|
||||
|
||||
|
@ -1777,6 +1778,44 @@ int PICE_vsprintf(char *buf, const char *fmt, va_list args)
|
|||
*str++ = ' ';
|
||||
continue;
|
||||
|
||||
case 'S':
|
||||
if (qualifier == 'h') {
|
||||
/* print ascii string */
|
||||
s = va_arg(args, char *);
|
||||
if (s == NULL)
|
||||
s = "<NULL>";
|
||||
|
||||
len = PICE_strlen (s);
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
|
||||
if (!(flags & NUM_LEFT))
|
||||
while (len < field_width--)
|
||||
*str++ = ' ';
|
||||
for (i = 0; i < len; ++i)
|
||||
*str++ = *s++;
|
||||
while (len < field_width--)
|
||||
*str++ = ' ';
|
||||
} else {
|
||||
/* print unicode string */
|
||||
sw = va_arg(args, wchar_t *);
|
||||
if (sw == NULL)
|
||||
sw = L"<NULL>";
|
||||
|
||||
len = wcslen (sw);
|
||||
if ((unsigned int)len > (unsigned int)precision)
|
||||
len = precision;
|
||||
|
||||
if (!(flags & NUM_LEFT))
|
||||
while (len < field_width--)
|
||||
*str++ = ' ';
|
||||
for (i = 0; i < len; ++i)
|
||||
*str++ = (unsigned char)(*sw++);
|
||||
while (len < field_width--)
|
||||
*str++ = ' ';
|
||||
}
|
||||
continue;
|
||||
|
||||
case 'p':
|
||||
if (field_width == -1) {
|
||||
field_width = 2*sizeof(void *);
|
||||
|
@ -2102,6 +2141,9 @@ HANDLE PICE_open (LPCWSTR lpPathName, int iReadWrite)
|
|||
HANDLE hfile;
|
||||
NTSTATUS status;
|
||||
|
||||
|
||||
DPRINT((0,"PICE_open: %S\n", lpPathName));
|
||||
|
||||
if ( (iReadWrite & OF_READWRITE ) == OF_READWRITE )
|
||||
dwAccessMask = GENERIC_READ | GENERIC_WRITE;
|
||||
else if ( (iReadWrite & OF_READ ) == OF_READ )
|
||||
|
@ -2127,13 +2169,11 @@ HANDLE PICE_open (LPCWSTR lpPathName, int iReadWrite)
|
|||
NULL,
|
||||
NULL);
|
||||
|
||||
|
||||
status = NtOpenFile( &hfile,
|
||||
dwAccessMask,
|
||||
&ObjectAttributes,
|
||||
NULL, dwShareMode, 0);
|
||||
//BUG BUG check status!!!
|
||||
DbgPrint("PICE_open: handle: %x, status: %x", hfile, status);
|
||||
if( !NT_SUCCESS( status ) ){
|
||||
DPRINT((0,"PICE_open: NtOpenFile error: %x\n", status));
|
||||
}
|
||||
|
@ -2157,6 +2197,9 @@ size_t PICE_len( HANDLE hFile )
|
|||
NTSTATUS status;
|
||||
|
||||
status = ZwQueryInformationFile( hFile, &iosb, &fs, sizeof fs, FileStandardInformation );
|
||||
if( !NT_SUCCESS( status ) ){
|
||||
DPRINT((0,"PICE_len: ZwQueryInformationFile error: %x\n", status));
|
||||
}
|
||||
ASSERT(fs.EndOfFile.u.HighPart == 0);
|
||||
return (size_t)fs.EndOfFile.u.LowPart;
|
||||
}
|
||||
|
@ -2194,12 +2237,12 @@ PICE_MultiByteToWideChar (
|
|||
&& (CP_MACCP != CodePage)
|
||||
&& (CP_OEMCP != CodePage))
|
||||
/* --- FLAGS --- */
|
||||
|| (dwFlags ^ ( MB_PRECOMPOSED
|
||||
/*|| (dwFlags ^ ( MB_PRECOMPOSED
|
||||
| MB_COMPOSITE
|
||||
| MB_ERR_INVALID_CHARS
|
||||
| MB_USEGLYPHCHARS
|
||||
)
|
||||
)
|
||||
)*/
|
||||
/* --- INPUT BUFFER --- */
|
||||
|| (NULL == lpMultiByteStr)
|
||||
)
|
||||
|
@ -2234,7 +2277,7 @@ PICE_MultiByteToWideChar (
|
|||
*/
|
||||
if (cchWideChar < InStringLength)
|
||||
{
|
||||
DPRINT((0,"ERROR_INSUFFICIENT_BUFFER\n"));
|
||||
DPRINT((0,"ERROR_INSUFFICIENT_BUFFER: cchWideChar: %d, InStringLength: %d\n", cchWideChar, InStringLength));
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
|
@ -2246,7 +2289,7 @@ PICE_MultiByteToWideChar (
|
|||
|
||||
((*r) && (cchConverted < cchWideChar));
|
||||
|
||||
r++,
|
||||
r++, w++,
|
||||
cchConverted++
|
||||
)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ Copyright notice:
|
|||
// GLOBALS
|
||||
////
|
||||
// used for HERCUELS text and VGA text mode
|
||||
/*
|
||||
WINDOW wWindowVga[4]=
|
||||
{
|
||||
{1,3,1,0,FALSE},
|
||||
|
@ -59,6 +60,15 @@ WINDOW wWindowVga[4]=
|
|||
{10,9,1,0,FALSE},
|
||||
{20,4,1,0,FALSE}
|
||||
};
|
||||
*/
|
||||
|
||||
WINDOW wWindowVga[4]=
|
||||
{
|
||||
{1,3,1,0,FALSE},
|
||||
{5,7,1,0,FALSE},
|
||||
{14,15,1,0,FALSE},
|
||||
{30,14,1,0,FALSE}
|
||||
};
|
||||
|
||||
// 25 line text mode
|
||||
UCHAR MGATable25[]={97,80,82,15,25, 6,25,25, 2,13,11,12, 0, 0, 0, 0};
|
||||
|
@ -389,7 +399,7 @@ BOOLEAN ConsoleInitVga(void)
|
|||
SetWindowGeometry(wWindowVga);
|
||||
|
||||
GLOBAL_SCREEN_WIDTH = 80;
|
||||
GLOBAL_SCREEN_HEIGHT = 25;
|
||||
GLOBAL_SCREEN_HEIGHT = 45;
|
||||
|
||||
attr.u.Asuchar = 0x07;
|
||||
|
||||
|
|
42
reactos/apps/utils/pice/readme.txt
Normal file
42
reactos/apps/utils/pice/readme.txt
Normal file
|
@ -0,0 +1,42 @@
|
|||
This is some preliminary information on using PICE. I am planning to write
|
||||
a detailed manual later.
|
||||
|
||||
BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA
|
||||
|
||||
PICE for Reactos is in early beta stage of development. It still has many bugs.
|
||||
|
||||
BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA-BETA
|
||||
|
||||
|
||||
PICE is a kernel debugger that was ported for Reactos (the original Linux
|
||||
project by Klaus P. Gerlicher and Goran Devic may be found here:
|
||||
http://pice.sourceforge.net).
|
||||
|
||||
Installation and use:
|
||||
|
||||
1. PICE is loaded like a regular device driver. The only limitation - it must
|
||||
be loaded before keyboard.sys driver. You should add:
|
||||
|
||||
LdrLoadAutoConfigDriver( L"pice.sys" );
|
||||
|
||||
in ntoskrnl/ldr/loader.c after the line loading keyboard driver.
|
||||
|
||||
2. You should copy pice.cfg and ntoskrnl.sym to \SystemRoot\symbols directory
|
||||
of Reactos.
|
||||
|
||||
3. If you want to add symbolic information you should use loader.exe to
|
||||
create .dbg file from the unstrippped version of exe or driver:
|
||||
For example:
|
||||
pice\loader\loader.exe -t ntoskrnl.nostrip.exe
|
||||
|
||||
After that copy .dbg file to \SystemRoot\symbols and add a line to pice.cfg:
|
||||
\\SystemRoot\symbols\ntoskrnl.dbg.
|
||||
|
||||
Pice will load the symbols during boot. For large .dbg files it may take a
|
||||
while (ntoskrnl.dbg is ~3Mb). You may find that loading time under bochs is
|
||||
quite slow, although otherwise performance should be fine.
|
||||
|
||||
Enjoy,
|
||||
Eugene
|
||||
|
||||
|
Loading…
Reference in a new issue