WinDBG/Exts/CodeAnalyzer/gdbplus/gdb-7.7/gdb/python/py-ref.c
/* Called when a new gdb.Object_ref object needs to be allocated.  Returns NULL on
 error, with a python exception set.  */
Called when a new gdb.Object_ref object needs to be allocated.  Returns NULL on
error, with a python exception set.
Called when a new gdb . Object_ref object needs to be allocated . Returns NULL on error with a python exception set .
static PyObject *
object_ref_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
{
	object_ref *self = NULL;
	PyObject *obj;
	address_t addr;
	if (PyTuple_Size (args) != 1)
	{
		PyErr_SetString (PyExc_TypeError, _("Object_ref object creation takes one argument"));
		return NULL;
	}
	obj = PyTuple_GetItem (args, 0);
	gdb_assert (obj != NULL);
	if (PyInt_Check (obj))
		addr = (address_t) PyInt_AsLong (obj);
	else if (PyLong_Check (obj))
		addr = (address_t) PyLong_AsLong (obj);
	else if (gdbpy_is_string (obj))
	{
		char *s;
		s = python_string_to_target_string (obj);
		if (s != NULL)
			addr = parse_and_eval_address (s);
	}
	if (!update_memory_segments_and_heaps())
	{
		PyErr_SetString (PyExc_MemoryError, _("Failed to read and initialize process's heap segments."));
		return NULL;
	}
	if (addr)
	{
		self = (object_ref *)type->tp_alloc(type, 1);
		if (self == NULL)
		{
			PyErr_SetString (PyExc_MemoryError, _("Could not allocate memory to create object_ref object."));
			return NULL;
		}
		self->ref.level        = 0;
		self->ref.target_index = -1;
		self->ref.storage_type = ENUM_UNKNOWN;
		self->ref.vaddr        = addr;
		self->ref.value        = 0;
		self->ref.where.target.size = 1;
		fill_ref_location(&self->ref);
	}
	else
	{
		PyErr_SetString (PyExc_ValueError, _("The input address is 0."));
		return NULL;
	}
	return (PyObject *) self;
}
static PyObject * object_ref_new ( PyTypeObject * type , PyObject * args , PyObject * keywords ) { object_ref * self = NULL ; PyObject * obj ; address_t addr ; if ( PyTuple_Size ( args ) != 1 ) { PyErr_SetString ( PyExc_TypeError , _ ( " " ) ) ; return NULL ; } obj = PyTuple_GetItem ( args , 0 ) ; gdb_assert ( obj != NULL ) ; if ( PyInt_Check ( obj ) ) addr = ( address_t ) PyInt_AsLong ( obj ) ; else if ( PyLong_Check ( obj ) ) addr = ( address_t ) PyLong_AsLong ( obj ) ; else if ( gdbpy_is_string ( obj ) ) { char * s ; s = python_string_to_target_string ( obj ) ; if ( s != NULL ) addr = parse_and_eval_address ( s ) ; } if ( ! update_memory_segments_and_heaps ( ) ) { PyErr_SetString ( PyExc_MemoryError , _ ( " " ) ) ; return NULL ; } if ( addr ) { self = ( object_ref * ) type -> tp_alloc ( type , 1 ) ; if ( self == NULL ) { PyErr_SetString ( PyExc_MemoryError , _ ( " " ) ) ; return NULL ; } self -> ref . level = 0 ; self -> ref . target_index = -1 ; self -> ref . storage_type = ENUM_UNKNOWN ; self -> ref . vaddr = addr ; self -> ref . value = 0 ; self -> ref . where . target . size = 1 ; fill_ref_location ( & self -> ref ) ; } else { PyErr_SetString ( PyExc_ValueError , _ ( " " ) ) ; return NULL ; } return ( PyObject * ) self ; }
Called when a new gdb.Object_ref object needs to be allocated.
Called when a new gdb . Object_ref object needs to be allocated .