67 object->objfile =
nullptr;
75#define OBJFPY_REQUIRE_VALID(obj) \
77 if (!(obj)->objfile) \
79 PyErr_SetString (PyExc_RuntimeError, \
80 _("Objfile no longer exists.")); \
155 const struct bfd_build_id *build_id = NULL;
163 catch (
const gdb_exception &except)
168 if (build_id != NULL)
170 std::string hex_form = bin2hex (build_id->data, build_id->size);
196 Py_XDECREF (self->
dict);
202 Py_TYPE (self)->tp_free (self);
213 self->
dict = PyDict_New ();
214 if (self->
dict == NULL)
251 return (
PyObject *) self.release ();
270 PyErr_SetString (PyExc_TypeError,
271 _(
"Cannot delete the pretty_printers attribute."));
275 if (! PyList_Check (
value))
277 PyErr_SetString (PyExc_TypeError,
278 _(
"The pretty_printers attribute must be a list."));
309 PyErr_SetString (PyExc_TypeError,
310 _(
"Cannot delete the frame filters attribute."));
314 if (! PyDict_Check (filters))
316 PyErr_SetString (PyExc_TypeError,
317 _(
"The frame_filters attribute must be a dictionary."));
349 PyErr_SetString (PyExc_TypeError,
350 _(
"Cannot delete the frame unwinders attribute."));
354 if (!PyList_Check (unwinders))
356 PyErr_SetString (PyExc_TypeError,
357 _(
"The frame_unwinders attribute must be a list."));
363 Py_INCREF (unwinders);
400 PyErr_SetString (PyExc_TypeError,
401 _(
"Cannot delete the type_printers attribute."));
405 if (! PyList_Check (
value))
407 PyErr_SetString (PyExc_TypeError,
408 _(
"The type_printers attribute must be a list."));
439 static const char *keywords[] = {
"file_name", NULL };
441 const char *file_name;
454 catch (
const gdb_exception &except)
468 static const char *keywords[] = {
"name",
"domain", NULL };
470 const char *symbol_name;
488 catch (
const gdb_exception &except)
502 static const char *keywords[] = {
"name",
"domain", NULL };
504 const char *symbol_name;
522 catch (
const gdb_exception &except)
539 return PyUnicode_FromString (
"<gdb.Objfile (invalid)>");
541 return PyUnicode_FromFormat (
"<gdb.Objfile filename=%s>",
551 size_t i, n = strlen (
string);
555 for (i = 0; i < n; ++i)
557 if (!isxdigit (
string[i]))
573 if (strlen (
string) != 2 * build_id->size)
576 for (i = 0; i < build_id->size; ++i)
578 char c1 =
string[i * 2],
c2 =
string[i * 2 + 1];
579 int byte = (fromhex (
c1) << 4) | fromhex (
c2);
581 if (
byte != build_id->data[i])
593 static const char *keywords[] = {
"name",
"by_build_id", NULL };
599 &
name, &PyBool_Type, &by_build_id_obj))
603 if (by_build_id_obj != NULL)
605 int cmp = PyObject_IsTrue (by_build_id_obj);
614 PyErr_SetString (PyExc_TypeError, _(
"Not a valid build id."));
633 if (obfd_build_id ==
nullptr)
674 PyErr_SetString (PyExc_ValueError, _(
"Objfile not found."));
701 result = (
PyObject *)
object.release ();
724 "is_valid () -> Boolean.\n\
725Return true if this object file is valid, false if not." },
728 METH_VARARGS | METH_KEYWORDS,
729 "add_separate_debug_file (file_name).\n\
730Add FILE_NAME to the list of files containing debug info for the objfile." },
733 METH_VARARGS | METH_KEYWORDS,
734 "lookup_global_symbol (name [, domain]).\n\
735Look up a global symbol in this objfile and return it." },
738 METH_VARARGS | METH_KEYWORDS,
739 "lookup_static_symbol (name [, domain]).\n\
740Look up a static-linkage global symbol in this objfile and return it." },
750 "The objfile's filename, or None.", NULL },
752 "The name of the objfile as provided by the user, or None.", NULL },
754 "The objfile owner of separate debug info objfiles, or None.",
757 "The objfile's build id, or None.", NULL },
759 "The objfile's progspace, or None.", NULL },
761 "Pretty printers.", NULL },
767 "Type printers.", NULL },
769 "Debug methods.", NULL },
771 "Whether this objfile came from a file.",
nullptr },
777 PyVarObject_HEAD_INIT (NULL, 0)
797 "GDB objfile object",
constexpr string_view get()
struct gdbarch * target_gdbarch(void)
const struct bfd_build_id * build_id_bfd_get(bfd *abfd)
void set(unsigned key, void *datum)
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
void gdbarch_iterate_over_objfiles_in_search_order(struct gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, struct objfile *current_objfile)
const char * objfile_name(const struct objfile *objfile)
const char * objfile_filename(const struct objfile *objfile)
static const registry< objfile >::key< objfile_object, objfpy_deleter > objfpy_objfile_data_key
static int objfpy_set_printers(PyObject *o, PyObject *value, void *ignore)
static int objfpy_set_frame_unwinders(PyObject *o, PyObject *unwinders, void *ignore)
static PyObject * objfpy_repr(PyObject *self_)
static PyObject * objfpy_get_owner(PyObject *self, void *closure)
PyTypeObject objfile_object_type
static PyObject * objfpy_get_build_id(PyObject *self, void *closure)
gdbpy_ref objfile_to_objfile_object(struct objfile *objfile)
#define OBJFPY_REQUIRE_VALID(obj)
static int objfpy_build_id_matches(const struct bfd_build_id *build_id, const char *string)
static gdb_PyGetSetDef objfile_getset[]
PyObject * gdbpy_lookup_objfile(PyObject *self, PyObject *args, PyObject *kw)
static int objfpy_build_id_ok(const char *string)
static PyObject * objfpy_lookup_global_symbol(PyObject *self, PyObject *args, PyObject *kw)
static int objfpy_set_type_printers(PyObject *o, PyObject *value, void *ignore)
PyObject * objfpy_get_frame_filters(PyObject *o, void *ignore)
static PyObject * objfpy_get_username(PyObject *self, void *closure)
PyObject * objfpy_get_xmethods(PyObject *o, void *ignore)
PyObject * objfpy_get_printers(PyObject *o, void *ignore)
static PyObject * objfpy_get_is_file(PyObject *o, void *ignore)
PyObject * objfpy_get_frame_unwinders(PyObject *o, void *ignore)
static PyObject * objfpy_lookup_static_symbol(PyObject *self, PyObject *args, PyObject *kw)
static PyMethodDef objfile_object_methods[]
static PyObject * objfpy_get_filename(PyObject *self, void *closure)
static PyObject * objfpy_add_separate_debug_file(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * objfpy_new(PyTypeObject *type, PyObject *args, PyObject *keywords)
static PyObject * objfpy_is_valid(PyObject *self, PyObject *args)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_objfile(void)
static PyObject * objfpy_get_type_printers(PyObject *o, void *ignore)
static int objfpy_initialize(objfile_object *self)
static void objfpy_dealloc(PyObject *o)
static PyObject * objfpy_get_progspace(PyObject *self, void *closure)
static int objfpy_set_frame_filters(PyObject *o, PyObject *filters, void *ignore)
gdbpy_ref pspace_to_pspace_object(struct program_space *pspace)
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
PyObject * symbol_to_symbol_object(struct symbol *sym)
gdbpy_ref host_string_to_python_string(const char *str)
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
PyObject * gdb_py_generic_dict(PyObject *self, void *closure)
#define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(ARG)
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
#define GDBPY_INITIALIZE_FILE(INIT,...)
#define GDB_PY_HANDLE_EXCEPTION(Exception)
static int gdb_PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, const char **keywords,...)
struct objfile * gdbpy_current_objfile
PyObject_HEAD struct objfile * objfile
PyObject * frame_unwinders
const char * original_name
struct objfile * separate_debug_objfile_backlink
struct program_space * pspace
objfile(gdb_bfd_ref_ptr, const char *, objfile_flags)
void operator()(objfile_object *obj)
domain_enum domain() const
gdb_bfd_ref_ptr symfile_bfd_open(const char *name)
void symbol_file_add_separate(const gdb_bfd_ref_ptr &bfd, const char *name, symfile_add_flags symfile_flags, struct objfile *objfile)
struct block_symbol lookup_global_symbol_from_objfile(struct objfile *main_objfile, enum block_enum block_index, const char *name, const domain_enum domain)
bool compare_filenames_for_search(const char *filename, const char *search_name)