46 #define STPY_REQUIRE_VALID(symtab_obj, symtab) \
48 symtab = symtab_object_to_symtab (symtab_obj); \
51 PyErr_SetString (PyExc_RuntimeError, \
52 _("Symbol Table is invalid.")); \
71 extern PyTypeObject sal_object_type
77 #define SALPY_REQUIRE_VALID(sal_obj, sal) \
79 sal = sal_object_to_symtab_and_line (sal_obj); \
82 PyErr_SetString (PyExc_RuntimeError, \
83 _("Symbol Table and Line is invalid.")); \
111 str_obj = PyString_Decode (filename, strlen (filename),
143 return PyString_Decode (producer, strlen (producer),
153 const char *fullname;
160 return PyString_Decode (fullname, strlen (fullname),
host_charset (), NULL);
239 s =
xstrprintf (
"symbol and line for %s, line %d", filename,
242 result = PyString_FromString (s);
258 stpy_objfile_data_key, symtab->
next);
299 return PyInt_FromLong (sal->
line);
310 Py_INCREF (self_sal->
symtab);
312 return (PyObject *) self_sal->
symtab;
346 Py_TYPE (
self)->tp_free (
self);
364 if (symtab_obj == NULL)
375 sal_obj->
symtab = symtab_obj;
376 sal_obj->
prev = NULL;
383 salpy_objfile_data_key);
388 salpy_objfile_data_key, sal_obj);
391 sal_obj->
next = NULL;
409 stpy_objfile_data_key);
412 set_objfile_data (
SYMTAB_OBJFILE (symtab), stpy_objfile_data_key, obj);
429 return (PyObject *) symtab_obj;
440 sal_obj = PyObject_New (
sal_object, &sal_object_type);
443 if (
set_sal (sal_obj, sal) < 0)
450 return (PyObject *) sal_obj;
458 if (! PyObject_TypeCheck (obj, &sal_object_type))
527 sal_object_type.tp_new = PyType_GenericNew;
528 if (PyType_Ready (&sal_object_type) < 0)
535 stpy_objfile_data_key
537 salpy_objfile_data_key
545 (PyObject *) &sal_object_type);
552 "The symbol table's source filename.", NULL },
556 "The name/version of the program that compiled this symtab.", NULL },
562 "is_valid () -> Boolean.\n\
563 Return true if this symbol table is valid, false if not." },
565 "fullname () -> String.\n\
566 Return the symtab's full source filename." },
568 "global_block () -> gdb.Block.\n\
569 Return the global block of the symbol table." },
571 "static_block () -> gdb.Block.\n\
572 Return the static block of the symbol table." },
574 "linetable () -> gdb.Linetable.\n\
575 Return the Linetable associated with this symbol table" },
607 symtab_object_methods,
612 static PyGetSetDef sal_object_getset[] = {
614 {
"pc",
salpy_get_pc, NULL,
"Return the symtab_and_line's pc.", NULL },
616 "Return the symtab_and_line's last address.", NULL },
618 "Return the symtab_and_line's line.", NULL },
622 static PyMethodDef sal_object_methods[] = {
624 "is_valid () -> Boolean.\n\
625 Return true if this symbol table and line is valid, false if not." },
629 PyTypeObject sal_object_type = {
631 "gdb.Symtab_and_line",
650 "GDB symtab_and_line object",
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
static PyObject * salpy_get_pc(PyObject *self, void *closure)
struct symtab_and_line * sal
const char * symtab_to_filename_for_display(struct symtab *symtab)
#define SYMTAB_COMPUNIT(symtab)
PyObject * block_to_block_object(const struct block *block, struct objfile *objfile)
PyObject * symtab_and_line_to_sal_object(struct symtab_and_line sal)
static const struct objfile_data * salpy_objfile_data_key
static PyObject * stpy_fullname(PyObject *self, PyObject *args)
struct salpy_sal_object sal_object
#define SALPY_REQUIRE_VALID(sal_obj, sal)
static void salpy_dealloc(PyObject *self)
static PyObject * stpy_get_filename(PyObject *self, void *closure)
static PyObject * stpy_get_objfile(PyObject *self, void *closure)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION set_sal(sal_object *sal_obj, struct symtab_and_line sal)
#define gdb_py_long_from_ulongest
struct stpy_symtab_object * next
#define BLOCKVECTOR_BLOCK(blocklist, n)
PyObject * symtab_to_linetable_object(PyObject *symtab)
static void del_objfile_sal(struct objfile *objfile, void *datum)
static PyObject * stpy_static_block(PyObject *self, PyObject *args)
static void set_symtab(symtab_object *obj, struct symtab *symtab)
PyObject * symtab_to_symtab_object(struct symtab *symtab)
const char * symtab_to_fullname(struct symtab *s)
#define SYMTAB_BLOCKVECTOR(symtab)
PyObject_HEAD symtab_object * symtab
#define SYMTAB_OBJFILE(symtab)
struct symtab * symtab_object_to_symtab(PyObject *obj)
PyObject * objfile_to_objfile_object(struct objfile *objfile)
#define COMPUNIT_PRODUCER(cust)
PyTypeObject symtab_object_type
static PyObject * salpy_get_last(PyObject *self, void *closure)
static PyObject * salpy_str(PyObject *self)
char * xstrprintf(const char *format,...)
static PyObject * stpy_get_linetable(PyObject *self, PyObject *args)
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
struct stpy_symtab_object symtab_object
static PyObject * stpy_is_valid(PyObject *self, PyObject *args)
struct symtab_and_line * sal_object_to_symtab_and_line(PyObject *obj)
static PyObject * salpy_get_line(PyObject *self, void *closure)
struct salpy_sal_object * next
static PyMethodDef symtab_object_methods[]
static PyObject * salpy_is_valid(PyObject *self, PyObject *args)
int gdbpy_initialize_symtabs(void)
static const struct objfile_data * stpy_objfile_data_key
static void stpy_dealloc(PyObject *obj)
PyObject_HEAD struct symtab * symtab
static void del_objfile_symtab(struct objfile *objfile, void *datum)
static PyObject * stpy_global_block(PyObject *self, PyObject *args)
const char * host_charset(void)
struct salpy_sal_object * prev
static PyObject * stpy_str(PyObject *self)
PyTypeObject symtab_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF("symtab_object")
#define STPY_REQUIRE_VALID(symtab_obj, symtab)
static PyObject * salpy_get_symtab(PyObject *self, void *closure)
static PyGetSetDef symtab_object_getset[]
static PyObject * stpy_get_producer(PyObject *self, void *closure)
struct stpy_symtab_object * prev
#define PyVarObject_HEAD_INIT(type, size)