62 #define OBJFPY_REQUIRE_VALID(obj) \ 64 if (!(obj)->objfile) \ 66 PyErr_SetString (PyExc_RuntimeError, \ 67 _("Objfile no longer exists.")); \ 134 const struct bfd_build_id *build_id = NULL;
148 if (build_id != NULL)
184 Py_XDECREF (self->dict);
185 Py_XDECREF (self->printers);
186 Py_XDECREF (self->frame_filters);
187 Py_XDECREF (self->frame_unwinders);
188 Py_XDECREF (self->type_printers);
189 Py_XDECREF (self->xmethods);
190 Py_TYPE (
self)->tp_free (
self);
199 self->objfile = NULL;
201 self->dict = PyDict_New ();
202 if (self->dict == 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)
239 return (PyObject *)
self.
release ();
247 Py_INCREF (self->printers);
248 return self->printers;
259 PyErr_SetString (PyExc_TypeError,
260 _(
"Cannot delete the pretty_printers attribute."));
264 if (! PyList_Check (
value))
266 PyErr_SetString (PyExc_TypeError,
267 _(
"The pretty_printers attribute must be a list."));
272 tmp =
self->printers;
274 self->printers =
value;
287 Py_INCREF (self->frame_filters);
288 return self->frame_filters;
300 PyErr_SetString (PyExc_TypeError,
301 _(
"Cannot delete the frame filters attribute."));
305 if (! PyDict_Check (filters))
307 PyErr_SetString (PyExc_TypeError,
308 _(
"The frame_filters attribute must be a dictionary."));
313 tmp =
self->frame_filters;
315 self->frame_filters = filters;
328 Py_INCREF (self->frame_unwinders);
329 return self->frame_unwinders;
342 PyErr_SetString (PyExc_TypeError,
343 _(
"Cannot delete the frame unwinders attribute."));
347 if (!PyList_Check (unwinders))
349 PyErr_SetString (PyExc_TypeError,
350 _(
"The frame_unwinders attribute must be a list."));
355 tmp =
self->frame_unwinders;
356 Py_INCREF (unwinders);
357 self->frame_unwinders = unwinders;
370 Py_INCREF (self->type_printers);
371 return self->type_printers;
381 Py_INCREF (self->xmethods);
382 return self->xmethods;
395 PyErr_SetString (PyExc_TypeError,
396 _(
"Cannot delete the type_printers attribute."));
400 if (! PyList_Check (
value))
402 PyErr_SetString (PyExc_TypeError,
403 _(
"The type_printers attribute must be a list."));
408 tmp =
self->type_printers;
410 self->type_printers =
value;
435 static const char *keywords[] = {
"file_name", NULL };
437 const char *file_name;
465 size_t i, n = strlen (
string);
469 for (i = 0; i < n; ++i)
471 if (!isxdigit (
string[i]))
487 if (strlen (
string) != 2 * build_id->size)
490 for (i = 0; i < build_id->size; ++i)
492 char c1 =
string[i * 2], c2 =
string[i * 2 + 1];
495 if (byte != build_id->data[i])
512 const char *filename;
540 const struct bfd_build_id *obfd_build_id;
548 if (obfd_build_id == NULL)
562 static const char *keywords[] = {
"name",
"by_build_id", NULL };
564 PyObject *by_build_id_obj = NULL;
569 &
name, &PyBool_Type, &by_build_id_obj))
573 if (by_build_id_obj != NULL)
575 int cmp = PyObject_IsTrue (by_build_id_obj);
586 PyErr_SetString (PyExc_TypeError,
_(
"Not a valid build id."));
602 PyErr_SetString (PyExc_ValueError,
_(
"Objfile not found."));
615 object->objfile = NULL;
641 return (PyObject *)
object.release ();
662 "is_valid () -> Boolean.\n\ 663 Return true if this object file is valid, false if not." },
666 METH_VARARGS | METH_KEYWORDS,
667 "add_separate_debug_file (file_name).\n\ 668 Add FILE_NAME to the list of files containing debug info for the objfile." },
678 "The objfile's filename, or None.", NULL },
680 "The name of the objfile as provided by the user, or None.", NULL },
682 "The objfile owner of separate debug info objfiles, or None.",
685 "The objfile's build id, or None.", NULL },
687 "The objfile's progspace, or None.", NULL },
689 "Pretty printers.", NULL },
695 "Type printers.", NULL },
697 "Debug methods.", NULL },
723 "GDB objfile object",
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)
gdb_bfd_ref_ptr symfile_bfd_open(const char *name)
static int gdb_PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, const char **keywords,...)
char * make_hex_string(const gdb_byte *data, size_t length)
#define PyVarObject_HEAD_INIT(type, size)
static int objfpy_set_frame_unwinders(PyObject *o, PyObject *unwinders, void *ignore)
PyObject_HEAD struct objfile * objfile
static gdb_PyGetSetDef objfile_getset[]
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)
PyObject * host_string_to_python_string(const char *str)
#define CATCH(EXCEPTION, MASK)
objfile(bfd *, const char *, objfile_flags)
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)
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)
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)
PyTypeObject objfile_object_type
#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)
PyObject * frame_unwinders
#define ALL_OBJFILES(obj)
static int objfpy_set_frame_filters(PyObject *o, PyObject *filters, void *ignore)
PyObject * pspace_to_pspace_object(struct program_space *pspace)
void symbol_file_add_separate(bfd *bfd, const char *name, symfile_add_flags symfile_flags, struct objfile *objfile)