43#define SYMPY_REQUIRE_VALID(symbol_obj, symbol) \
45 symbol = symbol_object_to_symbol (symbol_obj); \
48 PyErr_SetString (PyExc_RuntimeError, \
49 _("Symbol is invalid.")); \
190 return PyBool_FromLong (theclass ==
LOC_BLOCK);
224 catch (
const gdb_exception &except)
272 if (!PyArg_ParseTuple (args,
"|O", &frame_obj))
277 PyErr_SetString (PyExc_TypeError,
"argument is not a frame");
284 PyErr_SetString (PyExc_TypeError,
"cannot get the value of a typedef");
291 if (frame_obj != NULL)
295 error (_(
"invalid frame"));
299 error (_(
"symbol requires a frame to compute its value"));
309 catch (
const gdb_exception &except)
371 else if (sym_obj->
symbol != NULL
378 Py_TYPE (obj)->tp_free (obj);
388 return PyUnicode_FromFormat (
"<%s (invalid)>", Py_TYPE (self)->tp_name);
390 return PyUnicode_FromFormat (
"<%s print_name=%s>", Py_TYPE (self)->tp_name,
406 static const char *keywords[] = {
"name",
"block",
"domain", NULL };
408 PyObject *block_obj = NULL, *sym_obj, *bool_obj;
427 catch (
const gdb_exception &except)
436 &is_a_field_of_this).
symbol;
438 catch (
const gdb_exception &except)
444 if (ret_tuple == NULL)
458 PyTuple_SET_ITEM (ret_tuple.get (), 0, sym_obj);
460 bool_obj = PyBool_FromLong (is_a_field_of_this.
type != NULL);
461 PyTuple_SET_ITEM (ret_tuple.get (), 1, bool_obj);
463 return ret_tuple.release ();
474 static const char *keywords[] = {
"name",
"domain", NULL };
486 catch (
const gdb_exception &except)
514 static const char *keywords[] = {
"name",
"domain", NULL };
534 catch (
const gdb_exception_forced_quit &e)
538 catch (
const gdb_exception &except)
545 if (
block !=
nullptr)
553 catch (
const gdb_exception &except)
583 static const char *keywords[] = {
"name",
"domain", NULL };
590 if (return_list == NULL)
607 if (cust->user !=
nullptr)
610 const struct blockvector *bv = cust->blockvector ();
613 if (
block !=
nullptr)
622 if (PyList_Append (return_list.get (), sym_obj) == -1)
629 catch (
const gdb_exception &except)
634 return return_list.release ();
644 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_CONST",
646 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_STATIC",
648 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_REGISTER",
650 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_ARG",
652 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_REF_ARG",
654 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_LOCAL",
656 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_TYPEDEF",
658 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_LABEL",
660 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_BLOCK",
662 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_CONST_BYTES",
664 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_UNRESOLVED",
666 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_OPTIMIZED_OUT",
668 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_COMPUTED",
670 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_COMMON_BLOCK",
672 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LOC_REGPARM_ADDR",
674 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_UNDEF_DOMAIN",
676 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_VAR_DOMAIN",
678 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_STRUCT_DOMAIN",
680 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_LABEL_DOMAIN",
682 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_MODULE_DOMAIN",
684 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_COMMON_BLOCK_DOMAIN",
694 if (PyModule_AddIntConstant (
gdb_module,
"SYMBOL_VARIABLES_DOMAIN",
696 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_FUNCTIONS_DOMAIN",
698 || PyModule_AddIntConstant (
gdb_module,
"SYMBOL_TYPES_DOMAIN",
712 "Type of the symbol.", NULL },
714 "Symbol table in which the symbol appears.", NULL },
716 "Name of the symbol, as it appears in the source code.", NULL },
718 "Name of the symbol, as used by the linker (i.e., may be mangled).",
721 "Name of the symbol in a form suitable for output.\n\
722This is either name or linkage_name, depending on whether the user asked GDB\n\
723to display demangled or mangled names.", NULL },
726 "True if the symbol is an argument of a function." },
728 "True if the symbol is a constant." },
730 "True if the symbol is a function or method." },
732 "True if the symbol is a variable." },
734 "True if the symbol requires a frame for evaluation." },
736 "The source line number at which the symbol was defined." },
742 "is_valid () -> Boolean.\n\
743Return true if this symbol is valid, false if not." },
745 "value ([frame]) -> gdb.Value\n\
746Return the value of the symbol." },
751 PyVarObject_HEAD_INIT (NULL, 0)
const struct block * get_frame_block(frame_info_ptr frame, CORE_ADDR *addr_in_block)
void set(unsigned key, void *datum)
int symbol_read_needs_frame(struct symbol *sym)
struct value * read_var_value(struct symbol *var, const struct block *var_block, frame_info_ptr frame)
static frame_info_ptr selected_frame
frame_info_ptr get_selected_frame(const char *message)
struct program_space * current_program_space
PyTypeObject block_object_type
const struct block * block_object_to_block(PyObject *obj)
PyTypeObject frame_object_type
frame_info_ptr frame_object_to_frame_info(PyObject *obj)
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_symbols(void)
struct symbol * symbol_object_to_symbol(PyObject *obj)
static PyObject * sympy_value(PyObject *self, PyObject *args)
static PyObject * sympy_get_print_name(PyObject *self, void *closure)
static void set_symbol(symbol_object *obj, struct symbol *symbol)
static PyObject * sympy_repr(PyObject *self)
static PyObject * sympy_is_function(PyObject *self, void *closure)
PyObject * symbol_to_symbol_object(struct symbol *sym)
PyObject * gdbpy_lookup_static_symbol(PyObject *self, PyObject *args, PyObject *kw)
#define SYMPY_REQUIRE_VALID(symbol_obj, symbol)
PyObject * gdbpy_lookup_global_symbol(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * sympy_get_type(PyObject *self, void *closure)
static PyObject * sympy_str(PyObject *self)
static PyObject * sympy_get_symtab(PyObject *self, void *closure)
static void sympy_dealloc(PyObject *obj)
PyTypeObject symbol_object_type
static PyObject * sympy_needs_frame(PyObject *self, void *closure)
static PyMethodDef symbol_object_methods[]
PyObject * gdbpy_lookup_symbol(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * sympy_is_constant(PyObject *self, void *closure)
static const registry< objfile >::key< symbol_object, symbol_object_deleter > sympy_objfile_data_key
static PyObject * sympy_get_addr_class(PyObject *self, void *closure)
PyObject * gdbpy_lookup_static_symbols(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * sympy_line(PyObject *self, void *closure)
static PyObject * sympy_is_argument(PyObject *self, void *closure)
static gdb_PyGetSetDef symbol_object_getset[]
static PyObject * sympy_get_linkage_name(PyObject *self, void *closure)
static PyObject * sympy_is_valid(PyObject *self, PyObject *args)
static PyObject * sympy_get_name(PyObject *self, void *closure)
static PyObject * sympy_is_variable(PyObject *self, void *closure)
PyObject * symtab_to_symtab_object(struct symtab *symtab)
PyObject * type_to_type_object(struct type *type)
gdbpy_ref gdb_py_object_from_longest(LONGEST l)
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
PyObject * value_to_value_object(struct value *val)
#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 block * static_block()
const char * natural_name() const
const char * print_name() const
const char * linkage_name() const
compunit_symtab_range compunits()
objfiles_range objfiles()
void operator()(symbol_object *obj)
PyObject_HEAD struct symbol * symbol
address_class aclass() const
struct type * type() const
domain_enum domain() const
bool is_objfile_owned() const
unsigned int line() const
struct objfile * objfile() const
bool expand_symtabs_matching(gdb::function_view< expand_symtabs_file_matcher_ftype > file_matcher, const lookup_name_info &lookup_name, gdb::function_view< expand_symtabs_symbol_matcher_ftype > symbol_matcher, gdb::function_view< expand_symtabs_exp_notify_ftype > expansion_notify, block_search_flags search_flags, enum search_domain kind)
struct block_symbol lookup_static_symbol(const char *name, const domain_enum domain)
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
struct block_symbol lookup_global_symbol(const char *name, const struct block *block, const domain_enum domain)
struct block_symbol lookup_symbol_in_static_block(const char *name, const struct block *block, const domain_enum domain)
void quit_force(int *exit_arg, int from_tty)