Xmethod support in Python.

* python/py-xmethods.c: New file.
	* python/py-objfile.c (objfile_object): New field 'xmethods'.
	(objfpy_dealloc): XDECREF on the new xmethods field.
	(objfpy_new, objfile_to_objfile_object): Initialize xmethods
	field.
	(objfpy_get_xmethods): New function.
	(objfile_getset): New entry 'xmethods'.
	* python/py-progspace.c (pspace_object): New field 'xmethods'.
	(pspy_dealloc): XDECREF on the new xmethods field.
	(pspy_new, pspace_to_pspace_object): Initialize	xmethods
	field.
	(pspy_get_xmethods): New function.
	(pspace_getset): New entry 'xmethods'.
	* python/python-internal.h: Add declarations for new functions.
	* python/python.c (_initialize_python): Invoke
	gdbpy_initialize_xmethods.
	* python/lib/gdb/__init__.py (xmethods): New
	attribute.
	* python/lib/gdb/xmethod.py: New file.
	* python/lib/gdb/command/xmethods.py: New file.

	testuite/
	* gdb.python/py-xmethods.cc: New testcase to test xmethods.
	* gdb.python/py-xmethods.exp: New tests to test xmethods.
	* gdb.python/py-xmethods.py: Python script supporting the
	new testcase and tests.
This commit is contained in:
Siva Chandra 2014-05-20 06:53:04 -07:00
parent 58992dc550
commit 883964a75e
15 changed files with 1821 additions and 2 deletions

View file

@ -37,6 +37,9 @@ typedef struct
PyObject *frame_filters;
/* The type-printer list. */
PyObject *type_printers;
/* The debug method matcher list. */
PyObject *xmethods;
} objfile_object;
static PyTypeObject objfile_object_type
@ -67,6 +70,7 @@ objfpy_dealloc (PyObject *o)
Py_XDECREF (self->printers);
Py_XDECREF (self->frame_filters);
Py_XDECREF (self->type_printers);
Py_XDECREF (self->xmethods);
Py_TYPE (self)->tp_free (self);
}
@ -99,6 +103,13 @@ objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
Py_DECREF (self);
return NULL;
}
self->xmethods = PyList_New (0);
if (self->xmethods == NULL)
{
Py_DECREF (self);
return NULL;
}
}
return (PyObject *) self;
}
@ -193,6 +204,17 @@ objfpy_get_type_printers (PyObject *o, void *ignore)
return self->type_printers;
}
/* Get the 'xmethods' attribute. */
PyObject *
objfpy_get_xmethods (PyObject *o, void *ignore)
{
objfile_object *self = (objfile_object *) o;
Py_INCREF (self->xmethods);
return self->xmethods;
}
/* Set the 'type_printers' attribute. */
static int
@ -292,6 +314,13 @@ objfile_to_objfile_object (struct objfile *objfile)
return NULL;
}
object->xmethods = PyList_New (0);
if (object->xmethods == NULL)
{
Py_DECREF (object);
return NULL;
}
set_objfile_data (objfile, objfpy_objfile_data_key, object);
}
}
@ -333,6 +362,8 @@ static PyGetSetDef objfile_getset[] =
objfpy_set_frame_filters, "Frame Filters.", NULL },
{ "type_printers", objfpy_get_type_printers, objfpy_set_type_printers,
"Type printers.", NULL },
{ "xmethods", objfpy_get_xmethods, NULL,
"Debug methods.", NULL },
{ NULL }
};