Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Unified Diff: gdb/python/py-objfile.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/python/py-newobjfileevent.c ('k') | gdb/python/py-param.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/python/py-objfile.c
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 9fa6813f62e74aad1749f68663a907d8a2a63e98..9bbd4c22183f69dbe46849b7c927e90e65167b97 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -1,6 +1,6 @@
/* Python interface to objfiles.
- Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008-2013 Free Software Foundation, Inc.
This file is part of GDB.
@@ -32,9 +32,15 @@ typedef struct
/* The pretty-printer list of functions. */
PyObject *printers;
+
+ /* The frame filter list of functions. */
+ PyObject *frame_filters;
+ /* The type-printer list. */
+ PyObject *type_printers;
} objfile_object;
-static PyTypeObject objfile_object_type;
+static PyTypeObject objfile_object_type
+ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("objfile_object");
static const struct objfile_data *objfpy_objfile_data_key;
@@ -47,7 +53,8 @@ objfpy_get_filename (PyObject *self, void *closure)
objfile_object *obj = (objfile_object *) self;
if (obj->objfile)
- return PyString_Decode (obj->objfile->name, strlen (obj->objfile->name),
+ return PyString_Decode (objfile_name (obj->objfile),
+ strlen (objfile_name (obj->objfile)),
host_charset (), NULL);
Py_RETURN_NONE;
}
@@ -58,7 +65,9 @@ objfpy_dealloc (PyObject *o)
objfile_object *self = (objfile_object *) o;
Py_XDECREF (self->printers);
- self->ob_type->tp_free ((PyObject *) self);
+ Py_XDECREF (self->frame_filters);
+ Py_XDECREF (self->type_printers);
+ Py_TYPE (self)->tp_free (self);
}
static PyObject *
@@ -76,6 +85,20 @@ objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
Py_DECREF (self);
return NULL;
}
+
+ self->frame_filters = PyDict_New ();
+ if (!self->frame_filters)
+ {
+ Py_DECREF (self);
+ return NULL;
+ }
+
+ self->type_printers = PyList_New (0);
+ if (!self->type_printers)
+ {
+ Py_DECREF (self);
+ return NULL;
+ }
}
return (PyObject *) self;
}
@@ -118,6 +141,89 @@ objfpy_set_printers (PyObject *o, PyObject *value, void *ignore)
return 0;
}
+/* Return the Python dictionary attribute containing frame filters for
+ this object file. */
+PyObject *
+objfpy_get_frame_filters (PyObject *o, void *ignore)
+{
+ objfile_object *self = (objfile_object *) o;
+
+ Py_INCREF (self->frame_filters);
+ return self->frame_filters;
+}
+
+/* Set this object file's frame filters dictionary to FILTERS. */
+static int
+objfpy_set_frame_filters (PyObject *o, PyObject *filters, void *ignore)
+{
+ PyObject *tmp;
+ objfile_object *self = (objfile_object *) o;
+
+ if (! filters)
+ {
+ PyErr_SetString (PyExc_TypeError,
+ _("Cannot delete the frame filters attribute."));
+ return -1;
+ }
+
+ if (! PyDict_Check (filters))
+ {
+ PyErr_SetString (PyExc_TypeError,
+ _("The frame_filters attribute must be a dictionary."));
+ return -1;
+ }
+
+ /* Take care in case the LHS and RHS are related somehow. */
+ tmp = self->frame_filters;
+ Py_INCREF (filters);
+ self->frame_filters = filters;
+ Py_XDECREF (tmp);
+
+ return 0;
+}
+
+/* Get the 'type_printers' attribute. */
+
+static PyObject *
+objfpy_get_type_printers (PyObject *o, void *ignore)
+{
+ objfile_object *self = (objfile_object *) o;
+
+ Py_INCREF (self->type_printers);
+ return self->type_printers;
+}
+
+/* Set the 'type_printers' attribute. */
+
+static int
+objfpy_set_type_printers (PyObject *o, PyObject *value, void *ignore)
+{
+ PyObject *tmp;
+ objfile_object *self = (objfile_object *) o;
+
+ if (! value)
+ {
+ PyErr_SetString (PyExc_TypeError,
+ _("Cannot delete the type_printers attribute."));
+ return -1;
+ }
+
+ if (! PyList_Check (value))
+ {
+ PyErr_SetString (PyExc_TypeError,
+ _("The type_printers attribute must be a list."));
+ return -1;
+ }
+
+ /* Take care in case the LHS and RHS are related somehow. */
+ tmp = self->type_printers;
+ Py_INCREF (value);
+ self->type_printers = value;
+ Py_XDECREF (tmp);
+
+ return 0;
+}
+
/* Implementation of gdb.Objfile.is_valid (self) -> Boolean.
Returns True if this object file still exists in GDB. */
@@ -172,6 +278,20 @@ objfile_to_objfile_object (struct objfile *objfile)
return NULL;
}
+ object->frame_filters = PyDict_New ();
+ if (!object->frame_filters)
+ {
+ Py_DECREF (object);
+ return NULL;
+ }
+
+ object->type_printers = PyList_New (0);
+ if (!object->type_printers)
+ {
+ Py_DECREF (object);
+ return NULL;
+ }
+
set_objfile_data (objfile, objfpy_objfile_data_key, object);
}
}
@@ -179,18 +299,17 @@ objfile_to_objfile_object (struct objfile *objfile)
return (PyObject *) object;
}
-void
+int
gdbpy_initialize_objfile (void)
{
objfpy_objfile_data_key
= register_objfile_data_with_cleanup (NULL, py_free_objfile);
if (PyType_Ready (&objfile_object_type) < 0)
- return;
+ return -1;
- Py_INCREF (&objfile_object_type);
- PyModule_AddObject (gdb_module, "Objfile",
- (PyObject *) &objfile_object_type);
+ return gdb_pymodule_addobject (gdb_module, "Objfile",
+ (PyObject *) &objfile_object_type);
}
@@ -210,13 +329,16 @@ static PyGetSetDef objfile_getset[] =
"The objfile's filename, or None.", NULL },
{ "pretty_printers", objfpy_get_printers, objfpy_set_printers,
"Pretty printers.", NULL },
+ { "frame_filters", objfpy_get_frame_filters,
+ objfpy_set_frame_filters, "Frame Filters.", NULL },
+ { "type_printers", objfpy_get_type_printers, objfpy_set_type_printers,
+ "Type printers.", NULL },
{ NULL }
};
static PyTypeObject objfile_object_type =
{
- PyObject_HEAD_INIT (NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT (NULL, 0)
"gdb.Objfile", /*tp_name*/
sizeof (objfile_object), /*tp_basicsize*/
0, /*tp_itemsize*/
« no previous file with comments | « gdb/python/py-newobjfileevent.c ('k') | gdb/python/py-param.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698