Some fixes for the expression evaluator:

Evaluate static symbols
Evaulate local symbols
Still has bugs locating type definitions, at least for pointer types
There also seems to be a bug matching up lines of source with the correct instruction addresses

svn path=/trunk/; revision=2690
This commit is contained in:
Phillip Susi 2002-03-09 20:51:43 +00:00
parent 48e308623c
commit 5126871fcf

View file

@ -817,8 +817,8 @@ 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_EXTERNAL) &&
//symbol is a function is it's type is 0x20, and section>0
if(( (pSym->Type == 0x20) &&
(pSym->SectionNumber > 0 )))
{
ULONG ulCurrAddr;
@ -1035,7 +1035,9 @@ ULONG ExtractTypeNumber(LPSTR p)
ULONG ulTypeNumber = 0;
DPRINT((0,"ExtractTypeNumber(%s)\n",p));
pTypeNumber = PICE_strchr(p,'(');
if(pTypeNumber)
{
pTypeNumber++;
@ -2356,6 +2358,8 @@ BOOLEAN FindGlobalStabSymbol(LPSTR pExpression,PULONG pValue,PULONG pulTypeNumbe
}
break;
case N_GSYM:
case N_LSYM:
case N_PSYM:
// symbol-name:type-identifier type-number =
nLen = StrLenUpToWhiteChar(pName,":");
PICE_strncpy(SymbolName,pName,nLen);
@ -2365,10 +2369,13 @@ BOOLEAN FindGlobalStabSymbol(LPSTR pExpression,PULONG pValue,PULONG pulTypeNumbe
DPRINT((0,"global symbol %s\n",pName));
// extract type-number from stab
ulTypeNumber = ExtractTypeNumber(pName);
DPRINT((0,"type number = %x\n",ulTypeNumber));
DPRINT((0,"type number = %x, from %s\n",ulTypeNumber, pName));
*pulTypeNumber = ulTypeNumber;
// look for symbols address in external symbols
*pValue = FindFunctionInModuleByName(SymbolName,pCurrentMod);
if( pStab->n_type == N_LSYM || pStab->n_type == N_PSYM )
*pValue = CurrentEBP + pStab->n_value;
else *pValue = FindFunctionInModuleByName(SymbolName,pCurrentMod);
DPRINT((0,"value = %x\n",*pValue));
*pulFileNumber = ulCurrentFileNumber;
DPRINT((0,"file = %x\n",ulCurrentFileNumber));
@ -2682,7 +2689,6 @@ BOOLEAN EvaluateSymbol(PVRET pvr,LPSTR pToken)
{
if(!(pTypeDef = FindTypeDefinition(pvr->pSymbols,pvr->type,pvr->file)))
break;
PICE_strcpy(type_def,pTypeDef);
pTypeDef = type_def;
@ -2851,7 +2857,23 @@ BOOLEAN EvaluateSymbol(PVRET pvr,LPSTR pToken)
bDone = TRUE; // meanwhile
break;
default:
DPRINT((0,"DEFAULT %x\n",pvr->type));
DPRINT((0,"DEFAULT %x, base: %c\n",pvr->type, *pTypeBase));
pvr->address = pvr->value;
if(IsRangeValid(pvr->value,ulBytes))
{
switch(ulBytes)
{
case 1:
pvr->value = *(PUCHAR)pvr->value;
break;
case 2:
pvr->value = *(PUSHORT)pvr->value;
break;
case 4:
pvr->value = *(PULONG)pvr->value;
break;
}
}
bDone = TRUE;
break;
}