mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-23 18:26:47 +08:00
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:
@ -39,6 +39,9 @@ typedef struct
|
||||
PyObject *frame_filters;
|
||||
/* The type-printer list. */
|
||||
PyObject *type_printers;
|
||||
|
||||
/* The debug method list. */
|
||||
PyObject *xmethods;
|
||||
} pspace_object;
|
||||
|
||||
static PyTypeObject pspace_object_type
|
||||
@ -75,6 +78,7 @@ pspy_dealloc (PyObject *self)
|
||||
Py_XDECREF (ps_self->printers);
|
||||
Py_XDECREF (ps_self->frame_filters);
|
||||
Py_XDECREF (ps_self->type_printers);
|
||||
Py_XDECREF (ps_self->xmethods);
|
||||
Py_TYPE (self)->tp_free (self);
|
||||
}
|
||||
|
||||
@ -107,6 +111,13 @@ pspy_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;
|
||||
}
|
||||
@ -201,6 +212,17 @@ pspy_get_type_printers (PyObject *o, void *ignore)
|
||||
return self->type_printers;
|
||||
}
|
||||
|
||||
/* Get the 'xmethods' attribute. */
|
||||
|
||||
PyObject *
|
||||
pspy_get_xmethods (PyObject *o, void *ignore)
|
||||
{
|
||||
pspace_object *self = (pspace_object *) o;
|
||||
|
||||
Py_INCREF (self->xmethods);
|
||||
return self->xmethods;
|
||||
}
|
||||
|
||||
/* Set the 'type_printers' attribute. */
|
||||
|
||||
static int
|
||||
@ -297,6 +319,13 @@ pspace_to_pspace_object (struct program_space *pspace)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
object->xmethods = PyList_New (0);
|
||||
if (object->xmethods == NULL)
|
||||
{
|
||||
Py_DECREF (object);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
set_program_space_data (pspace, pspy_pspace_data_key, object);
|
||||
}
|
||||
}
|
||||
@ -329,6 +358,8 @@ static PyGetSetDef pspace_getset[] =
|
||||
"Frame filters.", NULL },
|
||||
{ "type_printers", pspy_get_type_printers, pspy_set_type_printers,
|
||||
"Type printers.", NULL },
|
||||
{ "xmethods", pspy_get_xmethods, NULL,
|
||||
"Debug methods.", NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user