WinDBG/Exts/CodeAnalyzer/gdbplus/gdb-7.7/gdb/gdb_dep.c
/*
 * Display known symbol/type of an instruction's operand value
 */
Display known symbol/type of an instruction's operand value
Display known symbol / type of an instruction ' s operand value
void print_op_value_context(size_t op_value, int op_size, address_t loc, int offset, int lea)
{
	size_t ptr_sz = g_ptr_bit >> 3;
	struct type* type = NULL;
	struct ca_addr_type_pair* addr_type;
	struct object_reference aref;
	if (op_size == ptr_sz && op_value)
	{
		memset(&aref, 0, sizeof(aref));
		aref.vaddr = op_value;
		aref.value = 0;
		aref.target_index = -1;
		fill_ref_location(&aref);
		if ( (aref.storage_type == ENUM_MODULE_TEXT || aref.storage_type == ENUM_MODULE_DATA)
			&& known_global_sym(&aref, NULL, NULL) )
		{
			printf_filtered (" ");
			print_ref(&aref, 0, CA_FALSE, CA_TRUE);
			return;
		}
		else if (aref.storage_type == ENUM_STACK && known_stack_sym(&aref, NULL, NULL))
		{
			printf_filtered (" ");
			print_ref(&aref, 0, CA_FALSE, CA_TRUE);
			return;
		}
		else if (aref.storage_type == ENUM_HEAP && known_heap_block(&aref))
		{
			printf_filtered (" ");
			print_ref(&aref, 0, CA_FALSE, CA_TRUE);
			return;
		}
	}
	if (loc && (addr_type = lookup_type_by_addr(loc)) )
	{
		aref.vaddr = loc + offset;
		aref.value = op_value;
		aref.target_index = 0;
		printf_filtered (" src=[");
		offset += loc - addr_type->addr;
		type = addr_type->type;
		if (addr_type->sym)
		{
			printf_filtered ("%s%s", lea?"&":"", SYMBOL_PRINT_NAME (addr_type->sym));
			if (offset > 0)
			{
				if (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_CODE (type) == TYPE_CODE_REF)
					type = TYPE_TARGET_TYPE(type);
				print_struct_field(&aref, type, offset);
			}
		}
		else if (type)
		{
			if (offset > 0)
			{
				print_type_name(type, NULL, "\"", "\"");
				print_struct_field(&aref, type, offset);
			}
			else
				print_type_name(type, NULL, "(type=\"", "\")");
		}
		printf_filtered ("]\n");
		return;
	}
	if (op_size == ptr_sz && op_value)
	{
		aref.vaddr = op_value;
		aref.value = 0;
		aref.target_index = -1;
		if (aref.storage_type != ENUM_UNKNOWN)
		{
			printf_filtered (" ");
			print_ref(&aref, 0, CA_FALSE, CA_TRUE);
			return;
		}
	}
	printf_filtered ("\n");
}
void print_op_value_context ( size_t op_value , int op_size , address_t loc , int offset , int lea ) { size_t ptr_sz = g_ptr_bit >> 3 ; struct type * type = NULL ; struct ca_addr_type_pair * addr_type ; struct object_reference aref ; if ( op_size == ptr_sz && op_value ) { memset ( & aref , 0 , sizeof ( aref ) ) ; aref . vaddr = op_value ; aref . value = 0 ; aref . target_index = -1 ; fill_ref_location ( & aref ) ; if ( ( aref . storage_type == ENUM_MODULE_TEXT || aref . storage_type == ENUM_MODULE_DATA ) && known_global_sym ( & aref , NULL , NULL ) ) { printf_filtered ( " " ) ; print_ref ( & aref , 0 , CA_FALSE , CA_TRUE ) ; return ; } else if ( aref . storage_type == ENUM_STACK && known_stack_sym ( & aref , NULL , NULL ) ) { printf_filtered ( " " ) ; print_ref ( & aref , 0 , CA_FALSE , CA_TRUE ) ; return ; } else if ( aref . storage_type == ENUM_HEAP && known_heap_block ( & aref ) ) { printf_filtered ( " " ) ; print_ref ( & aref , 0 , CA_FALSE , CA_TRUE ) ; return ; } } if ( loc && ( addr_type = lookup_type_by_addr ( loc ) ) ) { aref . vaddr = loc + offset ; aref . value = op_value ; aref . target_index = 0 ; printf_filtered ( " " ) ; offset += loc - addr_type -> addr ; type = addr_type -> type ; if ( addr_type -> sym ) { printf_filtered ( " " , lea ? " " : " " , SYMBOL_PRINT_NAME ( addr_type -> sym ) ) ; if ( offset > 0 ) { if ( TYPE_CODE ( type ) == TYPE_CODE_PTR || TYPE_CODE ( type ) == TYPE_CODE_REF ) type = TYPE_TARGET_TYPE ( type ) ; print_struct_field ( & aref , type , offset ) ; } } else if ( type ) { if ( offset > 0 ) { print_type_name ( type , NULL , " \" " , " \" " ) ; print_struct_field ( & aref , type , offset ) ; } else print_type_name ( type , NULL , " \" " , " \" " ) ; } printf_filtered ( " \n " ) ; return ; } if ( op_size == ptr_sz && op_value ) { aref . vaddr = op_value ; aref . value = 0 ; aref . target_index = -1 ; if ( aref . storage_type != ENUM_UNKNOWN ) { printf_filtered ( " " ) ; print_ref ( & aref , 0 , CA_FALSE , CA_TRUE ) ; return ; } } printf_filtered ( " \n " ) ; }
Display known symbol/type of an instruction's operand value
Display known symbol / type of an instruction ' s operand value
// if op_value is known stack or global symbol // global symbol // stack symbol // heap block with known type // we are here because we don't know anything about the op_value // try if we know anything of its source if any // lastly, we can still provide something useful, like heap/stack info