50#define FRAPY_REQUIRE_VALID(frame_obj, frame) \
52 frame = frame_object_to_frame_info (frame_obj); \
54 error (_("Frame is invalid.")); \
84 return PyUnicode_FromString (fid.
to_string ().c_str ());
100 catch (
const gdb_exception &except)
118 gdb::unique_xmalloc_ptr<char>
name;
128 catch (
const gdb_exception &except)
135 result = PyUnicode_Decode (
name.get (), strlen (
name.get ()),
162 catch (
const gdb_exception &except)
183 catch (
const gdb_exception &except)
204 catch (
const gdb_exception &except)
229 catch (
const gdb_exception &except)
246 static const char *keywords[] = {
"register",
nullptr };
266 PyErr_SetString (PyExc_ValueError, _(
"Can't read register."));
270 catch (
const gdb_exception &except)
292 catch (
const gdb_exception &except)
297 for (fn_block =
block;
298 fn_block != NULL && fn_block->
function () == NULL;
299 fn_block = fn_block->superblock ())
302 if (
block == NULL || fn_block == NULL || fn_block->
function () == NULL)
304 PyErr_SetString (PyExc_RuntimeError,
305 _(
"Cannot locate block for frame."));
319 struct symbol *sym = NULL;
328 gdb::unique_xmalloc_ptr<char> funname
331 catch (
const gdb_exception &except)
350 if (frame_obj == NULL)
364 frame_obj->frame_id_is_next = 1;
369 frame_obj->frame_id_is_next = 0;
373 catch (
const gdb_exception &except)
379 return (
PyObject *) frame_obj.release ();
398 catch (
const gdb_exception &except)
430 catch (
const gdb_exception &except)
462 catch (
const gdb_exception &except)
481 PyObject *sym_obj, *block_obj = NULL;
482 struct symbol *var = NULL;
485 static const char *keywords[] = {
"variable",
"block",
nullptr };
495 gdb::unique_xmalloc_ptr<char>
501 if (block_obj !=
nullptr)
507 gdb_assert (
block !=
nullptr);
521 catch (
const gdb_exception &except)
529 PyErr_Format (PyExc_ValueError,
530 _(
"Variable '%s' not found."), var_name.get ());
537 PyErr_Format (PyExc_TypeError,
538 _(
"argument 1 must be gdb.Symbol or str, not %s"),
539 Py_TYPE (sym_obj)->tp_name);
552 catch (
const gdb_exception &except)
573 catch (
const gdb_exception &except)
594 catch (
const gdb_exception &except)
617 catch (
const gdb_exception &except)
638 catch (
const gdb_exception &except)
661 catch (
const gdb_exception &except)
681 catch (
const gdb_exception &except)
698 if (!PyArg_ParseTuple (args,
"i", &reason))
701 if (reason < UNWIND_FIRST || reason > UNWIND_LAST)
703 PyErr_SetString (PyExc_ValueError,
704 _(
"Invalid frame stop reason."));
709 return PyUnicode_Decode (str, strlen (str),
host_charset (), NULL);
722 || (op != Py_EQ && op != Py_NE))
724 Py_INCREF (Py_NotImplemented);
725 return Py_NotImplemented;
757 || PyModule_AddIntConstant (
gdb_module,
"TAILCALL_FRAME",
759 || PyModule_AddIntConstant (
gdb_module,
"SIGTRAMP_FRAME",
762 || PyModule_AddIntConstant (
gdb_module,
"SENTINEL_FRAME",
766#define SET(name, description) \
767 if (PyModule_AddIntConstant (gdb_module, "FRAME_"#name, name) < 0) \
769#include "unwind_stop_reasons.def"
782 "is_valid () -> Boolean.\n\
783Return true if this frame is valid, false if not." },
785 "name () -> String.\n\
786Return the function name of the frame, or None if it can't be determined." },
788 "type () -> Integer.\n\
789Return the type of the frame." },
791 "architecture () -> gdb.Architecture.\n\
792Return the architecture of the frame." },
794 "unwind_stop_reason () -> Integer.\n\
795Return the reason why it's not possible to find frames older than this." },
798Return the frame's resume address." },
800 METH_VARARGS | METH_KEYWORDS,
801 "read_register (register_name) -> gdb.Value\n\
802Return the value of the register in the frame." },
804 "block () -> gdb.Block.\n\
805Return the frame's code block." },
807 "function () -> gdb.Symbol.\n\
808Returns the symbol for the function corresponding to this frame." },
810 "older () -> gdb.Frame.\n\
811Return the frame that called this frame." },
813 "newer () -> gdb.Frame.\n\
814Return the frame called by this frame." },
816 "find_sal () -> gdb.Symtab_and_line.\n\
817Return the frame's symtab and line." },
818 {
"read_var", (PyCFunction)
frapy_read_var, METH_VARARGS | METH_KEYWORDS,
819 "read_var (variable) -> gdb.Value.\n\
820Return the value of the variable in this frame." },
822 "Select this frame as the user's current frame." },
824 "The stack level of this frame." },
826 "The language of this frame." },
828 "The static link of this frame, or None." },
833 PyVarObject_HEAD_INIT (NULL, 0)
const struct block * get_frame_block(frame_info_ptr frame, CORE_ADDR *addr_in_block)
const char * host_charset(void)
struct value * value_of_register(int regnum, frame_info_ptr frame)
struct value * read_var_value(struct symbol *var, const struct block *var_block, frame_info_ptr frame)
frame_info_ptr get_next_frame(frame_info_ptr this_frame)
enum unwind_stop_reason get_frame_unwind_stop_reason(frame_info_ptr frame)
int frame_relative_level(frame_info_ptr fi)
frame_info_ptr frame_follow_static_link(frame_info_ptr frame)
void select_frame(frame_info_ptr fi)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
const char * unwind_stop_reason_to_string(enum unwind_stop_reason reason)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
enum frame_type get_frame_type(frame_info_ptr frame)
frame_info_ptr get_selected_frame(const char *message)
frame_info_ptr frame_find_by_id(struct frame_id id)
enum language get_frame_language(frame_info_ptr frame)
frame_info_ptr get_current_frame(void)
struct frame_id get_frame_id(frame_info_ptr fi)
frame_info_ptr get_prev_frame(frame_info_ptr this_frame)
symtab_and_line find_frame_sal(frame_info_ptr frame)
const struct language_defn * language_def(enum language lang)
PyObject * gdbarch_to_arch_object(struct gdbarch *gdbarch)
PyObject * block_to_block_object(const struct block *block, struct objfile *objfile)
PyTypeObject block_object_type
const struct block * block_object_to_block(PyObject *obj)
static PyObject * frapy_str(PyObject *self)
static PyObject * frapy_read_register(PyObject *self, PyObject *args, PyObject *kw)
PyObject * gdbpy_frame_stop_reason_string(PyObject *self, PyObject *args)
static PyObject * frapy_older(PyObject *self, PyObject *args)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION gdbpy_initialize_frames(void)
static PyObject * frapy_is_valid(PyObject *self, PyObject *args)
static PyObject * frapy_static_link(PyObject *self, PyObject *args)
static PyObject * frapy_arch(PyObject *self, PyObject *args)
static PyObject * frapy_language(PyObject *self, PyObject *args)
#define FRAPY_REQUIRE_VALID(frame_obj, frame)
PyObject * frame_info_to_frame_object(frame_info_ptr frame)
static PyObject * frapy_richcompare(PyObject *self, PyObject *other, int op)
static PyObject * frapy_pc(PyObject *self, PyObject *args)
static PyObject * frapy_block(PyObject *self, PyObject *args)
static PyObject * frapy_find_sal(PyObject *self, PyObject *args)
PyObject * gdbpy_selected_frame(PyObject *self, PyObject *args)
static PyObject * frapy_name(PyObject *self, PyObject *args)
static PyObject * frapy_level(PyObject *self, PyObject *args)
PyObject * gdbpy_newest_frame(PyObject *self, PyObject *args)
PyTypeObject frame_object_type
static PyObject * frapy_unwind_stop_reason(PyObject *self, PyObject *args)
static PyObject * frapy_type(PyObject *self, PyObject *args)
static PyObject * frapy_read_var(PyObject *self, PyObject *args, PyObject *kw)
static PyObject * frapy_function(PyObject *self, PyObject *args)
frame_info_ptr frame_object_to_frame_info(PyObject *obj)
static PyObject * frapy_newer(PyObject *self, PyObject *args)
static PyMethodDef frame_object_methods[]
static PyObject * frapy_select(PyObject *self, PyObject *args)
gdb::ref_ptr< T, gdbpy_ref_policy< T > > gdbpy_ref
bool gdbpy_parse_register_id(struct gdbarch *gdbarch, PyObject *pyo_reg_id, int *reg_num)
struct symbol * symbol_object_to_symbol(PyObject *obj)
PyObject * symbol_to_symbol_object(struct symbol *sym)
PyTypeObject symbol_object_type
PyObject * symtab_and_line_to_sal_object(struct symtab_and_line sal)
gdbpy_ref host_string_to_python_string(const char *str)
gdb::unique_xmalloc_ptr< char > python_string_to_target_string(PyObject *obj)
gdbpy_ref gdb_py_object_from_longest(LONGEST l)
void gdbpy_convert_exception(const struct gdb_exception &exception)
int gdb_pymodule_addobject(PyObject *module, const char *name, PyObject *object)
int gdbpy_is_string(PyObject *obj)
gdbpy_ref gdb_py_object_from_ulongest(ULONGEST l)
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,...)
gdb::unique_xmalloc_ptr< char > find_frame_funname(frame_info_ptr frame, enum language *funlang, struct symbol **funcp)
const struct block * block
symbol * function() const
std::string to_string() const
PyObject_HEAD struct frame_id frame_id
virtual const char * name() const =0
struct objfile * objfile() const
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)