55 extern PyTypeObject objfile_object_type
61 #define OBJFPY_REQUIRE_VALID(obj) \
63 if (!(obj)->objfile) \
65 PyErr_SetString (PyExc_RuntimeError, \
66 _("Objfile no longer exists.")); \
99 return PyString_Decode (username, strlen (username),
114 struct objfile *owner;
136 const struct bfd_build_id *build_id = NULL;
150 if (build_id != NULL)
155 result = PyString_Decode (hex_form, strlen (hex_form),
187 Py_XDECREF (self->dict);
188 Py_XDECREF (self->printers);
189 Py_XDECREF (self->frame_filters);
190 Py_XDECREF (self->frame_unwinders);
191 Py_XDECREF (self->type_printers);
192 Py_XDECREF (self->xmethods);
193 Py_TYPE (
self)->tp_free (
self);
202 self->objfile = NULL;
205 self->printers = PyList_New (0);
206 if (self->printers == NULL)
209 self->frame_filters = PyDict_New ();
210 if (self->frame_filters == NULL)
213 self->frame_unwinders = PyList_New (0);
214 if (self->frame_unwinders == NULL)
217 self->type_printers = PyList_New (0);
218 if (self->type_printers == NULL)
221 self->xmethods = PyList_New (0);
222 if (self->xmethods == NULL)
242 return (PyObject *)
self;
250 Py_INCREF (self->printers);
251 return self->printers;
262 PyErr_SetString (PyExc_TypeError,
263 _(
"Cannot delete the pretty_printers attribute."));
267 if (! PyList_Check (value))
269 PyErr_SetString (PyExc_TypeError,
270 _(
"The pretty_printers attribute must be a list."));
275 tmp =
self->printers;
277 self->printers = value;
290 Py_INCREF (self->frame_filters);
291 return self->frame_filters;
303 PyErr_SetString (PyExc_TypeError,
304 _(
"Cannot delete the frame filters attribute."));
308 if (! PyDict_Check (filters))
310 PyErr_SetString (PyExc_TypeError,
311 _(
"The frame_filters attribute must be a dictionary."));
316 tmp =
self->frame_filters;
318 self->frame_filters = filters;
331 Py_INCREF (self->frame_unwinders);
332 return self->frame_unwinders;
345 PyErr_SetString (PyExc_TypeError,
346 _(
"Cannot delete the frame unwinders attribute."));
350 if (!PyList_Check (unwinders))
352 PyErr_SetString (PyExc_TypeError,
353 _(
"The frame_unwinders attribute must be a list."));
358 tmp =
self->frame_unwinders;
359 Py_INCREF (unwinders);
360 self->frame_unwinders = unwinders;
373 Py_INCREF (self->type_printers);
374 return self->type_printers;
384 Py_INCREF (self->xmethods);
385 return self->xmethods;
398 PyErr_SetString (PyExc_TypeError,
399 _(
"Cannot delete the type_printers attribute."));
403 if (! PyList_Check (value))
405 PyErr_SetString (PyExc_TypeError,
406 _(
"The type_printers attribute must be a list."));
411 tmp =
self->type_printers;
413 self->type_printers = value;
438 static char *keywords[] = {
"file_name", NULL };
440 const char *file_name;
441 int symfile_flags = 0;
445 if (!PyArg_ParseTupleAndKeywords (args, kw,
"s", keywords, &file_name))
469 size_t i, n = strlen (
string);
473 for (i = 0; i < n; ++i)
475 if (!isxdigit (
string[i]))
491 if (strlen (
string) != 2 * build_id->size)
494 for (i = 0; i < build_id->size; ++i)
496 char c1 =
string[i * 2], c2 =
string[i * 2 + 1];
499 if (byte != build_id->data[i])
516 const char *filename;
544 const struct bfd_build_id *obfd_build_id;
546 if (objfile->
obfd == NULL)
552 if (obfd_build_id == NULL)
566 static char *keywords[] = {
"name",
"by_build_id", NULL };
568 PyObject *by_build_id_obj = NULL;
572 if (! PyArg_ParseTupleAndKeywords (args, kw,
"s|O!", keywords,
573 &name, &PyBool_Type, &by_build_id_obj))
577 if (by_build_id_obj != NULL)
579 int cmp = PyObject_IsTrue (by_build_id_obj);
590 PyErr_SetString (PyExc_TypeError,
_(
"Not a valid build id."));
606 PyErr_SetString (PyExc_ValueError,
_(
"Objfile not found."));
621 object->objfile = NULL;
636 object = objfile_data (objfile, objfpy_objfile_data_key);
648 object->objfile = objfile;
649 set_objfile_data (objfile, objfpy_objfile_data_key,
object);
653 return (PyObject *) object;
659 objfpy_objfile_data_key
662 if (PyType_Ready (&objfile_object_type) < 0)
666 (PyObject *) &objfile_object_type);
674 "is_valid () -> Boolean.\n\
675 Return true if this object file is valid, false if not." },
678 METH_VARARGS | METH_KEYWORDS,
679 "add_separate_debug_file (file_name).\n\
680 Add FILE_NAME to the list of files containing debug info for the objfile." },
685 static PyGetSetDef objfile_getset[] =
688 "The __dict__ for this objfile.", &objfile_object_type },
690 "The objfile's filename, or None.", NULL },
692 "The name of the objfile as provided by the user, or None.", NULL },
694 "The objfile owner of separate debug info objfiles, or None.",
697 "The objfile's build id, or None.", NULL },
699 "The objfile's progspace, or None.", NULL },
701 "Pretty printers.", NULL },
707 "Type printers.", NULL },
709 "Debug methods.", NULL },
713 PyTypeObject objfile_object_type =
735 "GDB objfile object",
742 objfile_object_methods,
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
PyObject * gdb_py_generic_dict(PyObject *self, void *closure)
struct objfile * separate_debug_objfile_backlink
static struct objfile * objfpy_lookup_objfile_by_name(const char *name)
struct program_space * pspace
static int objfpy_initialize(objfile_object *self)
PyTypeObject objfile_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("objfile_object")
int compare_filenames_for_search(const char *filename, const char *search_name)
const char * objfile_filename(const struct objfile *objfile)
#define OBJF_NOT_FILENAME
char * make_hex_string(const gdb_byte *data, size_t length)
static int objfpy_set_frame_unwinders(PyObject *o, PyObject *unwinders, void *ignore)
PyObject_HEAD struct objfile * objfile
static PyObject * objfpy_is_valid(PyObject *self, PyObject *args)
#define GDB_PY_HANDLE_EXCEPTION(Exception)
static int objfpy_set_type_printers(PyObject *o, PyObject *value, void *ignore)
#define ALL_OBJFILES(obj)
#define CATCH(EXCEPTION, MASK)
void symbol_file_add_separate(bfd *bfd, const char *name, int symfile_flags, struct objfile *objfile)
static struct objfile * objfpy_lookup_objfile_by_build_id(const char *build_id)
static int objfpy_build_id_ok(const char *string)
static int objfpy_build_id_matches(const struct bfd_build_id *build_id, const char *string)
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
PyObject * objfile_to_objfile_object(struct objfile *objfile)
int host_hex_value(char c)
PyObject * gdbpy_lookup_objfile(PyObject *self, PyObject *args, PyObject *kw)
struct cleanup * ensure_python_env(struct gdbarch *gdbarch, const struct language_defn *language)
int gdbpy_initialize_objfile(void)
PyObject * objfpy_get_xmethods(PyObject *o, void *ignore)
static PyObject * objfpy_get_username(PyObject *self, void *closure)
static const struct objfile_data * objfpy_objfile_data_key
const char * objfile_name(const struct objfile *objfile)
bfd * symfile_bfd_open(const char *name)
static PyObject * objfpy_new(PyTypeObject *type, PyObject *args, PyObject *keywords)
static PyObject * objfpy_get_owner(PyObject *self, void *closure)
const struct language_defn * current_language
static void py_free_objfile(struct objfile *objfile, void *datum)
static PyObject * objfpy_get_filename(PyObject *self, void *closure)
const struct bfd_build_id * build_id_bfd_get(bfd *abfd)
PyObject * objfpy_get_frame_unwinders(PyObject *o, void *ignore)
static PyObject * objfpy_get_type_printers(PyObject *o, void *ignore)
static int objfpy_set_printers(PyObject *o, PyObject *value, void *ignore)
PyObject * objfpy_get_printers(PyObject *o, void *ignore)
PyObject * objfpy_get_frame_filters(PyObject *o, void *ignore)
static PyObject * objfpy_add_separate_debug_file(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * objfpy_get_progspace(PyObject *self, void *closure)
static void objfpy_dealloc(PyObject *o)
#define OBJFPY_REQUIRE_VALID(obj)
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static PyMethodDef objfile_object_methods[]
static PyObject * objfpy_get_build_id(PyObject *self, void *closure)
const char * host_charset(void)
PyObject * frame_unwinders
static int objfpy_set_frame_filters(PyObject *o, PyObject *filters, void *ignore)
PyObject * pspace_to_pspace_object(struct program_space *pspace)
void do_cleanups(struct cleanup *old_chain)
#define PyVarObject_HEAD_INIT(type, size)