WinDBG/Exts/CodeAnalyzer/gdbplus/gdb-7.7/gdb/python/py-ref.c
/* Implementation of gdb.cpp_object()
 * Take one argument of an expression that may be evaluated to a C++ type
   Returns a list of gdb.Object_ref objects  */
Implementation of gdb.cpp_object()
Take one argument of an expression that may be evaluated to a C++ type
Returns a list of gdb.Object_ref objects
Implementation of gdb . cpp_object () Take one argument of an expression that may be evaluated to a C ++ type Returns a list of gdb . Object_ref objects
PyObject *gdbpy_cpp_object (PyObject *self, PyObject *args)
{
	PyObject *result = NULL;
	char *exp = NULL;
	struct CA_LIST* objects;
	if (PyTuple_Size (args) == 1)
	{
		PyObject *obj = PyTuple_GetItem (args, 0);
		if (gdbpy_is_string (obj))
			exp = python_string_to_target_string (obj);
		else
		{
			PyErr_SetString (PyExc_TypeError, _("Expect an integer of big heap blocks."));
			return NULL;
		}
	}
	else
	{
		PyErr_SetString (PyExc_TypeError, _("This function takes one argument."));
		return NULL;
	}
	if (!update_memory_segments_and_heaps())
	{
		PyErr_SetString (PyExc_MemoryError, _("Failed to read and initialize process's heap segments."));
		return NULL;
	}
	objects = search_cplusplus_objects_with_vptr (exp);
	if (objects)
	{
		struct object_reference* ref;
		unsigned int n = ca_list_size(objects);
		unsigned int i;
		result = PyList_New(n);
		i = 0;
		ca_list_traverse_start(objects);
		while ( (ref = (struct object_reference*) ca_list_traverse_next(objects)) )
		{
			object_ref* obj_ref = PyObject_New (object_ref, &object_ref_type);
			obj_ref->ref = *ref;
			PyList_SET_ITEM(result, i, (PyObject*)obj_ref);
			i++;
			free (ref);
		}
		ca_list_delete (objects);
	}
	else
	{
		Py_INCREF (Py_None);
		result = Py_None;
	}
	return result;
}
PyObject * gdbpy_cpp_object ( PyObject * self , PyObject * args ) { PyObject * result = NULL ; char * exp = NULL ; struct CA_LIST * objects ; if ( PyTuple_Size ( args ) == 1 ) { PyObject * obj = PyTuple_GetItem ( args , 0 ) ; if ( gdbpy_is_string ( obj ) ) exp = python_string_to_target_string ( obj ) ; else { PyErr_SetString ( PyExc_TypeError , _ ( " " ) ) ; return NULL ; } } else { PyErr_SetString ( PyExc_TypeError , _ ( " " ) ) ; return NULL ; } if ( ! update_memory_segments_and_heaps ( ) ) { PyErr_SetString ( PyExc_MemoryError , _ ( " " ) ) ; return NULL ; } objects = search_cplusplus_objects_with_vptr ( exp ) ; if ( objects ) { struct object_reference * ref ; unsigned int n = ca_list_size ( objects ) ; unsigned int i ; result = PyList_New ( n ) ; i = 0 ; ca_list_traverse_start ( objects ) ; while ( ( ref = ( struct object_reference * ) ca_list_traverse_next ( objects ) ) ) { object_ref * obj_ref = PyObject_New ( object_ref , & object_ref_type ) ; obj_ref -> ref = * ref ; PyList_SET_ITEM ( result , i , ( PyObject * ) obj_ref ) ; i ++ ; free ( ref ) ; } ca_list_delete ( objects ) ; } else { Py_INCREF ( Py_None ) ; result = Py_None ; } return result ; }
Implementation of gdb.cpp_object()
 Take one argument of an expression that may be evaluated to a C++ type
Returns a list of gdb.Object_ref objects
Implementation of gdb . cpp_object () Take one argument of an expression that may be evaluated to a C ++ type Returns a list of gdb . Object_ref objects
// Get the input parameters // Make sure we have built necessary data structures to do searching // Search for the objects