Exemplo n.º 1
0
int ILDebugIterNext(ILDebugIter *iter)
{
	unsigned long offset;
	ILMetaDataRead reader;

	/* Find the next token information block that is formatted correctly */
	for(;iter->reserved1 < iter->reserved2; ++(iter->reserved1))
	{
		/* Fetch the data offset and validate it */
		offset = IL_READ_UINT32(iter->dbg->index + iter->reserved1 * 8 + 4);
		if(offset >= iter->dbg->sectionLen)
		{
			continue;
		}

		/* Read the token information block */
		reader.data = iter->dbg->section + offset;
		reader.len = iter->dbg->sectionLen - offset;
		reader.error = 0;
		iter->type = ILMetaUncompressData(&reader);
		iter->length = ILMetaUncompressData(&reader);
		iter->data = (const void *)(reader.data);
		if(reader.error || iter->length > reader.len)
		{
			continue;
		}

		/* Advance to the next block and return */
		++(iter->reserved1);
		return 1;
	}

	/* If we get here, then we don't have any more blocks for this token */
	return 0;
}
Exemplo n.º 2
0
unsigned long ILMetaUncompressToken(ILMetaDataRead *meta)
{
	unsigned long item = ILMetaUncompressData(meta);
	unsigned long type = (item & 0x03);
	if(!(meta->error))
	{
		if(type == 0x00)
		{
			return ((item >> 2) | IL_META_TOKEN_TYPE_DEF);
		}
		else if(type == 0x01)
		{
			return ((item >> 2) | IL_META_TOKEN_TYPE_REF);
		}
		else if(type == 0x02)
Exemplo n.º 3
0
const char *ILDebugGetVarName(ILDebugContext *dbg, ILToken token,
							  ILUInt32 offset, ILUInt32 varNum)
{
	ILDebugIter iter;
	ILMetaDataRead reader;
	const char *name = 0;
	ILUInt32 scopeStart = 0;
	ILUInt32 scopeEnd = IL_MAX_UINT32;
	ILUInt32 tempStart;
	ILUInt32 tempEnd;
	ILUInt32 tempName;
	ILUInt32 tempIndex;

	/* Find the innermost scope block that contains the variable */
	ILDebugIterInit(&iter, dbg, token);
	while(ILDebugIterNext(&iter))
	{
		/* Skip unknown debug types */
		if(iter.type != IL_DEBUGTYPE_VARS &&
		   iter.type != IL_DEBUGTYPE_VARS_OFFSETS)
		{
			continue;
		}

		/* Get the scope information for this block */
		reader.data = iter.data;
		reader.len = iter.length;
		reader.error = 0;
		if(iter.type == IL_DEBUGTYPE_VARS_OFFSETS)
		{
			tempStart = ILMetaUncompressData(&reader);
			tempEnd = ILMetaUncompressData(&reader);
			if(reader.error)
			{
				continue;
			}
			if(tempStart > tempEnd)
			{
				tempEnd = tempStart;
			}
		}
		else
		{
			tempStart = 0;
			tempEnd = IL_MAX_UINT32;
		}

		/* Read the name and variable index information */
		while(reader.len > 0)
		{
			tempName = ILMetaUncompressData(&reader);
			tempIndex = ILMetaUncompressData(&reader);
			if(reader.error)
			{
				break;
			}
			if(tempIndex != varNum)
			{
				continue;
			}
			if(tempStart >= scopeStart && tempEnd <= scopeEnd)
			{
				scopeStart = tempStart;
				scopeEnd = tempEnd;
				if(offset >= scopeStart && offset < scopeEnd)
				{
					name = ILDebugGetString(dbg, tempName);
				}
			}
		}
	}

	/* Return the innermost name that we found */
	return name;
}
Exemplo n.º 4
0
const char *ILDebugGetLineInfo(ILDebugContext *dbg, ILToken token,
						       ILUInt32 offset, ILUInt32 *line,
						       ILUInt32 *column)
{
	ILDebugIter iter;
	ILMetaDataRead reader;
	ILUInt32 lowOffset = 0;
	const char *lowFilename = 0;
	ILUInt32 lowLine = 0;
	ILUInt32 lowColumn = 0;
	ILUInt32 tempOffset;
	const char *tempFilename;
	ILUInt32 tempLine;
	ILUInt32 tempColumn;

	/* Find the highest block that is lower than the specified offset.
	   If there are multiple lines for the same offset then return
	   the highest line number.  Multiple lines can happen when nested
	   blocks in the original source all begin on the same offset */
	ILDebugIterInit(&iter, dbg, token);
	while(ILDebugIterNext(&iter))
	{
		/* Skip unknown debug types */
		if(iter.type != IL_DEBUGTYPE_LINE_COL &&
		   iter.type != IL_DEBUGTYPE_LINE_OFFSETS &&
		   iter.type != IL_DEBUGTYPE_LINE_COL_OFFSETS)
		{
			continue;
		}

		/* Read the filename string */
		reader.data = iter.data;
		reader.len = iter.length;
		reader.error = 0;
		tempFilename = ILDebugGetString(dbg, ILMetaUncompressData(&reader));
		if(!tempFilename || reader.error)
		{
			continue;
		}

		/* Determine how to decode the rest of the block */
		if(iter.type == IL_DEBUGTYPE_LINE_COL)
		{
			/* Line and column information */
			while(reader.len > 0)
			{
				tempLine = ILMetaUncompressData(&reader);
				tempColumn = ILMetaUncompressData(&reader);
				tempOffset = 0;
				if(reader.error)
				{
					break;
				}
				if(tempOffset <= offset && tempOffset >= lowOffset)
				{
					if(!lowFilename || tempLine > lowLine)
					{
						lowFilename = tempFilename;
						lowOffset = tempOffset;
						lowLine = tempLine;
						lowColumn = tempColumn;
					}
				}
			}
		}
		else if(iter.type == IL_DEBUGTYPE_LINE_OFFSETS)
		{
			/* Line and offset information */
			while(reader.len > 0)
			{
				tempLine = ILMetaUncompressData(&reader);
				tempColumn = 0;
				tempOffset = ILMetaUncompressData(&reader);
				if(reader.error)
				{
					break;
				}
				if(tempOffset <= offset && tempOffset >= lowOffset)
				{
					if(!lowFilename || tempLine > lowLine)
					{
						lowFilename = tempFilename;
						lowOffset = tempOffset;
						lowLine = tempLine;
						lowColumn = tempColumn;
					}
				}
			}
		}
		else
		{
			/* Line, column, and offset information */
			while(reader.len > 0)
			{
				tempLine = ILMetaUncompressData(&reader);
				tempColumn = ILMetaUncompressData(&reader);
				tempOffset = ILMetaUncompressData(&reader);
				if(reader.error)
				{
					break;
				}
				if(tempOffset <= offset && tempOffset >= lowOffset)
				{
					if(!lowFilename || tempLine > lowLine)
					{
						lowFilename = tempFilename;
						lowOffset = tempOffset;
						lowLine = tempLine;
						lowColumn = tempColumn;
					}
				}
			}
		}
	}

	/* Return the final information to the caller */
	*line = lowLine;
	*column = lowColumn;
	return lowFilename;
}