GDB (xrefs)

Classes | Macros | Typedefs | Functions | Variables
py-symtab.c File Reference
`#include "defs.h"`
`#include "charset.h"`
`#include "symtab.h"`
`#include "source.h"`
`#include "python-internal.h"`
`#include "objfiles.h"`
`#include "block.h"`
`#include "py-ref.h"`

Go to the source code of this file.

## Classes
struct | stpy_symtab_object
struct | salpy_sal_object

## Macros
#define | STPY_REQUIRE_VALID(symtab_obj, symtab)
#define | SALPY_REQUIRE_VALID(sal_obj, sal)

## Typedefs
typedef struct stpy_symtab_object | symtab_object
typedef struct salpy_sal_object | sal_object

## Functions
PyTypeObject symtab_object_type | CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("symtab_object")
PyTypeObject sal_object_type | CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("sal_object")
static PyObject * | stpy_str (PyObject *self)
static PyObject * | stpy_get_filename (PyObject *self, void *closure)
static PyObject * | stpy_get_objfile (PyObject *self, void *closure)
static PyObject * | stpy_get_producer (PyObject *self, void *closure)
static PyObject * | stpy_fullname (PyObject *self, PyObject *args)
static PyObject * | stpy_is_valid (PyObject *self, PyObject *args)
static PyObject * | stpy_global_block (PyObject *self, PyObject *args)
static PyObject * | stpy_static_block (PyObject *self, PyObject *args)
static PyObject * | stpy_get_linetable (PyObject *self, PyObject *args)
static PyObject * | salpy_str (PyObject *self)
static void | stpy_dealloc (PyObject *obj)
static PyObject * | salpy_get_pc (PyObject *self, void *closure)
static PyObject * | salpy_get_last (PyObject *self, void *closure)
static PyObject * | salpy_get_line (PyObject *self, void *closure)
static PyObject * | salpy_get_symtab (PyObject *self, void *closure)
static PyObject * | salpy_is_valid (PyObject *self, PyObject *args)
static void | salpy_dealloc (PyObject *self)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION | set_sal (sal_object *sal_obj, struct symtab_and_line sal)
static void | set_symtab (symtab_object *obj, struct symtab *symtab)
PyObject * | symtab_to_symtab_object (struct symtab *symtab)
PyObject * | symtab_and_line_to_sal_object (struct symtab_and_line sal)
struct symtab_and_line * | sal_object_to_symtab_and_line (PyObject *obj)
struct symtab * | symtab_object_to_symtab (PyObject *obj)
static void | del_objfile_symtab (struct objfile *objfile, void *datum)
static void | del_objfile_sal (struct objfile *objfile, void *datum)
int | gdbpy_initialize_symtabs (void)

## Variables
static const struct objfile_data * | stpy_objfile_data_key
static const struct objfile_data * | salpy_objfile_data_key
static gdb_PyGetSetDef | symtab_object_getset []
static PyMethodDef | symtab_object_methods []
PyTypeObject | symtab_object_type
static gdb_PyGetSetDef | sal_object_getset []
static PyMethodDef | sal_object_methods []
PyTypeObject | sal_object_type

## Macro Definition Documentation

## ◆ SALPY_REQUIRE_VALID

#define SALPY_REQUIRE_VALID | ( |  | sal_obj,
|  |  | sal
| ) |  |

Value:
do { \
sal = sal_object_to_symtab_and_line (sal_obj); \
if (sal == NULL) \
{ \
PyErr_SetString (PyExc_RuntimeError, \
_("Symbol Table and Line is invalid.")); \
return NULL; \
} \
} while (0)
_
#define _(String)
Definition: gdb_locale.h:35
sal_object_to_symtab_and_line
struct symtab_and_line * sal_object_to_symtab_and_line(PyObject *obj)
Definition: py-symtab.c:453

Definition at line 78 of file py-symtab.c.

Referenced by salpy_get_last(), salpy_get_line(), salpy_get_pc(), salpy_get_symtab(), and salpy_str().

## ◆ STPY_REQUIRE_VALID

#define STPY_REQUIRE_VALID | ( |  | symtab_obj,
|  |  | symtab
| ) |  |

Value:
do { \
symtab = symtab_object_to_symtab (symtab_obj); \
if (symtab == NULL) \
{ \
PyErr_SetString (PyExc_RuntimeError, \
_("Symbol Table is invalid.")); \
return NULL; \
} \
} while (0)
_
#define _(String)
Definition: gdb_locale.h:35
symtab_object_to_symtab
struct symtab * symtab_object_to_symtab(PyObject *obj)
Definition: py-symtab.c:462
symtab
Definition: symtab.h:1291

Definition at line 47 of file py-symtab.c.

Referenced by stpy_fullname(), stpy_get_filename(), stpy_get_linetable(), stpy_get_objfile(), stpy_get_producer(), stpy_global_block(), stpy_static_block(), and stpy_str().

## Typedef Documentation

## ◆ sal_object

typedef struct salpy_sal_object sal_object

## ◆ symtab_object

typedef struct stpy_symtab_object symtab_object

## Function Documentation

## ◆ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF() [1/2]

PyTypeObject symtab_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF | ( | "symtab_object" |  | ) |

## ◆ CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF() [2/2]

PyTypeObject sal_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF | ( | "sal_object" |  | ) |

## ◆ del_objfile_sal()

static void del_objfile_sal | ( | struct objfile * | objfile,
|  | void * | datum
| ) |  |
| static

Definition at line 496 of file py-symtab.c.

References salpy_sal_object::next, symtab::next, salpy_sal_object::prev, Py_DECREF, salpy_sal_object::sal, salpy_sal_object::symtab, and xfree().

Referenced by gdbpy_initialize_symtabs().

## ◆ del_objfile_symtab()

static void del_objfile_symtab | ( | struct objfile * | objfile,
|  | void * | datum
| ) |  |
| static

Definition at line 475 of file py-symtab.c.

References stpy_symtab_object::next, symtab::next, stpy_symtab_object::prev, and stpy_symtab_object::symtab.

Referenced by gdbpy_initialize_symtabs().

## ◆ gdbpy_initialize_symtabs()

int gdbpy_initialize_symtabs | ( | void |  | ) |

Definition at line 518 of file py-symtab.c.

References del_objfile_sal(), del_objfile_symtab(), gdb_module, gdb_pymodule_addobject(), sal_object_type, salpy_objfile_data_key, stpy_objfile_data_key, and symtab_object_type.

Referenced by do_start_initialization().

## ◆ sal_object_to_symtab_and_line()

struct symtab_and_line* sal_object_to_symtab_and_line | ( | PyObject * | obj | ) |

Definition at line 453 of file py-symtab.c.

References sal_object_type.

Referenced by salpy_is_valid().

## ◆ salpy_dealloc()

static void salpy_dealloc | ( | PyObject * | self | ) |
| static

Definition at line 330 of file py-symtab.c.

References salpy_sal_object::next, salpy_sal_object::prev, Py_DECREF, Py_TYPE, salpy_sal_object::sal, salpy_objfile_data_key, stpy_symtab_object::symtab, salpy_sal_object::symtab, SYMTAB_OBJFILE, and xfree().

## ◆ salpy_get_last()

static PyObject* salpy_get_last | ( | PyObject * | self,
|  | void * | closure
| ) |  |
| static

Definition at line 279 of file py-symtab.c.

References symtab_and_line::end, gdb_py_long_from_ulongest, and SALPY_REQUIRE_VALID.

## ◆ salpy_get_line()

static PyObject* salpy_get_line | ( | PyObject * | self,
|  | void * | closure
| ) |  |
| static

Definition at line 292 of file py-symtab.c.

References symtab_and_line::line, and SALPY_REQUIRE_VALID.

## ◆ salpy_get_pc()

static PyObject* salpy_get_pc | ( | PyObject * | self,
|  | void * | closure
| ) |  |
| static

Definition at line 266 of file py-symtab.c.

References gdb_py_long_from_ulongest, symtab_and_line::pc, and SALPY_REQUIRE_VALID.

## ◆ salpy_get_symtab()

static PyObject* salpy_get_symtab | ( | PyObject * | self,
|  | void * | closure
| ) |  |
| static

Definition at line 302 of file py-symtab.c.

References SALPY_REQUIRE_VALID, and salpy_sal_object::symtab.

## ◆ salpy_is_valid()

static PyObject* salpy_is_valid | ( | PyObject * | self,
|  | PyObject * | args
| ) |  |
| static

Definition at line 318 of file py-symtab.c.

References sal_object_to_symtab_and_line().

## ◆ salpy_str()

static PyObject* salpy_str | ( | PyObject * | self | ) |
| static

Definition at line 224 of file py-symtab.c.

References symtab::filename, symtab_and_line::line, SALPY_REQUIRE_VALID, stpy_symtab_object::symtab, salpy_sal_object::symtab, symtab_to_filename_for_display(), xfree(), and xstrprintf().

## ◆ set_sal()

static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION set_sal | ( | sal_object * | sal_obj,
|  | struct symtab_and_line | sal
| ) |  |
| static

Definition at line 354 of file py-symtab.c.

References salpy_sal_object::next, salpy_sal_object::prev, salpy_sal_object::sal, salpy_objfile_data_key, stpy_symtab_object::symtab, salpy_sal_object::symtab, symtab_and_line::symtab, SYMTAB_OBJFILE, and symtab_to_symtab_object().

Referenced by symtab_and_line_to_sal_object().

## ◆ set_symtab()

static void set_symtab | ( | symtab_object * | obj,
|  | struct symtab * | symtab
| ) |  |
| static

Definition at line 404 of file py-symtab.c.

References stpy_symtab_object::next, stpy_symtab_object::prev, stpy_objfile_data_key, stpy_symtab_object::symtab, salpy_sal_object::symtab, and SYMTAB_OBJFILE.

Referenced by symtab_to_symtab_object().

## ◆ stpy_dealloc()

static void stpy_dealloc | ( | PyObject * | obj | ) |
| static

Definition at line 248 of file py-symtab.c.

References symtab::next, stpy_objfile_data_key, and SYMTAB_OBJFILE.

## ◆ stpy_fullname()

static PyObject* stpy_fullname | ( | PyObject * | self,
|  | PyObject * | args
| ) |  |
| static

Definition at line 150 of file py-symtab.c.

References symtab::fullname, host_string_to_python_string(), STPY_REQUIRE_VALID, and symtab_to_fullname().

## ◆ stpy_get_filename()

static PyObject* stpy_get_filename | ( | PyObject * | self,
|  | void * | closure
| ) |  |
| static

Definition at line 103 of file py-symtab.c.

References symtab::filename, host_string_to_python_string(), STPY_REQUIRE_VALID, and symtab_to_filename_for_display().

## ◆ stpy_get_linetable()

static PyObject* stpy_get_linetable | ( | PyObject * | self,
|  | PyObject * | args
| ) |  |
| static

Definition at line 214 of file py-symtab.c.

References STPY_REQUIRE_VALID, and symtab_to_linetable_object().

## ◆ stpy_get_objfile()

static PyObject* stpy_get_objfile | ( | PyObject * | self,
|  | void * | closure
| ) |  |
| static

Definition at line 117 of file py-symtab.c.

References objfile_to_objfile_object(), STPY_REQUIRE_VALID, and SYMTAB_OBJFILE.

## ◆ stpy_get_producer()

static PyObject* stpy_get_producer | ( | PyObject * | self,
|  | void * | closure
| ) |  |
| static

Definition at line 132 of file py-symtab.c.

References COMPUNIT_PRODUCER, host_string_to_python_string(), compunit_symtab::producer, STPY_REQUIRE_VALID, and SYMTAB_COMPUNIT.

## ◆ stpy_global_block()

static PyObject* stpy_global_block | ( | PyObject * | self,
|  | PyObject * | args
| ) |  |
| static

Definition at line 180 of file py-symtab.c.

References block_to_block_object(), BLOCKVECTOR_BLOCK, GLOBAL_BLOCK, STPY_REQUIRE_VALID, SYMTAB_BLOCKVECTOR, and SYMTAB_OBJFILE.

## ◆ stpy_is_valid()

static PyObject* stpy_is_valid | ( | PyObject * | self,
|  | PyObject * | args
| ) |  |
| static

Definition at line 166 of file py-symtab.c.

References symtab_object_to_symtab().

## ◆ stpy_static_block()

static PyObject* stpy_static_block | ( | PyObject * | self,
|  | PyObject * | args
| ) |  |
| static

Definition at line 196 of file py-symtab.c.

References block_to_block_object(), BLOCKVECTOR_BLOCK, STATIC_BLOCK, STPY_REQUIRE_VALID, SYMTAB_BLOCKVECTOR, and SYMTAB_OBJFILE.

## ◆ stpy_str()

static PyObject* stpy_str | ( | PyObject * | self | ) |
| static

Definition at line 90 of file py-symtab.c.

References STPY_REQUIRE_VALID, and symtab_to_filename_for_display().

## ◆ symtab_and_line_to_sal_object()

PyObject* symtab_and_line_to_sal_object | ( | struct symtab_and_line | sal | ) |

Definition at line 438 of file py-symtab.c.

References gdb::ref_ptr< T, Policy >::get(), gdb::ref_ptr< T, Policy >::release(), sal_object_type, and set_sal().

Referenced by frapy_find_sal(), gdbpy_decode_line(), gdbpy_find_pc_line(), and recpy_bt_insn_sal().

## ◆ symtab_object_to_symtab()

struct symtab* symtab_object_to_symtab | ( | PyObject * | obj | ) |

Definition at line 462 of file py-symtab.c.

References symtab_object_type.

Referenced by ltpy_is_valid(), ltpy_iter_is_valid(), and stpy_is_valid().

## ◆ symtab_to_symtab_object()

PyObject* symtab_to_symtab_object | ( | struct symtab * | symtab | ) |

Definition at line 424 of file py-symtab.c.

References set_symtab(), and symtab_object_type.

Referenced by set_sal(), and sympy_get_symtab().

## Variable Documentation

## ◆ sal_object_getset

gdb_PyGetSetDef sal_object_getset[]
| static

Initial value:
= {
{ "symtab", salpy_get_symtab, NULL, "Symtab object.", NULL },
{ "pc", salpy_get_pc, NULL, "Return the symtab_and_line's pc.", NULL },
{ "last", salpy_get_last, NULL,
"Return the symtab_and_line's last address.", NULL },
{ "line", salpy_get_line, NULL,
"Return the symtab_and_line's line.", NULL },
{NULL}
}
salpy_get_pc
static PyObject * salpy_get_pc(PyObject *self, void *closure)
Definition: py-symtab.c:266
salpy_get_last
static PyObject * salpy_get_last(PyObject *self, void *closure)
Definition: py-symtab.c:279
salpy_get_line
static PyObject * salpy_get_line(PyObject *self, void *closure)
Definition: py-symtab.c:292
salpy_get_symtab
static PyObject * salpy_get_symtab(PyObject *self, void *closure)
Definition: py-symtab.c:302

Definition at line 609 of file py-symtab.c.

## ◆ sal_object_methods

PyMethodDef sal_object_methods[]
| static

Initial value:
= {
{ "is_valid", salpy_is_valid, METH_NOARGS,
"is_valid () -> Boolean.\n\
Return true if this symbol table and line is valid, false if not." },
{NULL}
}
salpy_is_valid
static PyObject * salpy_is_valid(PyObject *self, PyObject *args)
Definition: py-symtab.c:318

Definition at line 619 of file py-symtab.c.

## ◆ sal_object_type

PyTypeObject sal_object_type

Definition at line 626 of file py-symtab.c.

Referenced by gdbpy_initialize_symtabs(), sal_object_to_symtab_and_line(), and symtab_and_line_to_sal_object().

## ◆ salpy_objfile_data_key

const struct objfile_data* salpy_objfile_data_key
| static

Definition at line 74 of file py-symtab.c.

Referenced by gdbpy_initialize_symtabs(), salpy_dealloc(), and set_sal().

## ◆ stpy_objfile_data_key

const struct objfile_data* stpy_objfile_data_key
| static

Definition at line 43 of file py-symtab.c.

Referenced by gdbpy_initialize_symtabs(), set_symtab(), and stpy_dealloc().

## ◆ symtab_object_getset

gdb_PyGetSetDef symtab_object_getset[]
| static

Initial value:
= {
{ "filename", stpy_get_filename, NULL,
"The symbol table's source filename.", NULL },
{ "objfile", stpy_get_objfile, NULL, "The symtab's objfile.",
NULL },
{ "producer", stpy_get_producer, NULL,
"The name/version of the program that compiled this symtab.", NULL },
{NULL}
}
stpy_get_filename
static PyObject * stpy_get_filename(PyObject *self, void *closure)
Definition: py-symtab.c:103
stpy_get_objfile
static PyObject * stpy_get_objfile(PyObject *self, void *closure)
Definition: py-symtab.c:117
stpy_get_producer
static PyObject * stpy_get_producer(PyObject *self, void *closure)
Definition: py-symtab.c:132

Definition at line 547 of file py-symtab.c.

## ◆ symtab_object_methods

PyMethodDef symtab_object_methods[]
| static

Initial value:
= {
{ "is_valid", stpy_is_valid, METH_NOARGS,
"is_valid () -> Boolean.\n\
Return true if this symbol table is valid, false if not." },
{ "fullname", stpy_fullname, METH_NOARGS,
"fullname () -> String.\n\
Return the symtab's full source filename." },
{ "global_block", stpy_global_block, METH_NOARGS,
"global_block () -> gdb.Block.\n\
Return the global block of the symbol table." },
{ "static_block", stpy_static_block, METH_NOARGS,
"static_block () -> gdb.Block.\n\
Return the static block of the symbol table." },
{ "linetable", stpy_get_linetable, METH_NOARGS,
"linetable () -> gdb.LineTable.\n\
Return the LineTable associated with this symbol table" },
{NULL}
}
stpy_fullname
static PyObject * stpy_fullname(PyObject *self, PyObject *args)
Definition: py-symtab.c:150
stpy_static_block
static PyObject * stpy_static_block(PyObject *self, PyObject *args)
Definition: py-symtab.c:196
stpy_get_linetable
static PyObject * stpy_get_linetable(PyObject *self, PyObject *args)
Definition: py-symtab.c:214
stpy_is_valid
static PyObject * stpy_is_valid(PyObject *self, PyObject *args)
Definition: py-symtab.c:166
stpy_global_block
static PyObject * stpy_global_block(PyObject *self, PyObject *args)
Definition: py-symtab.c:180

Definition at line 557 of file py-symtab.c.

## ◆ symtab_object_type

PyTypeObject symtab_object_type

Definition at line 576 of file py-symtab.c.

Referenced by gdbpy_initialize_symtabs(), symtab_object_to_symtab(), and symtab_to_symtab_object().