[RFC] [PATCH] Provide the ability to write the frame unwinder in Python
Andy Wingo
wingo@igalia.com
Wed Mar 18 08:54:00 GMT 2015
On Tue 17 Mar 2015 22:37, Alexander Smundak <asmundak@google.com> writes:
> +/* The implementation of
> + gdb.UnwindInfo.set_previous_frame_register (REG, VALUE) -> None. */
> +
> +static PyObject *
> +unwind_infopy_set_previous_frame_register (PyObject *self, PyObject *args)
> +{
> + unwind_info_object *unwind_info = (unwind_info_object *) self;
> + sniffer_info_object *sniffer_info
> + = (sniffer_info_object *) (unwind_info->sniffer_info);
> + PyObject *pyo_reg_id;
> + PyObject *pyo_reg_value;
> + int regnum;
> +
> + if (sniffer_info->frame_info == NULL)
> + {
> + PyErr_SetString (PyExc_ValueError,
> + "Attempting to read register from stale SnifferInfo");
> + return NULL;
> + }
Nit: we are setting the register here.
> +int
> +gdbpy_initialize_unwind (void)
> +{
> + int rc;
> + add_setshow_zuinteger_cmd
> + ("py-unwind", class_maintenance, &pyuw_debug,
> + _("Set Python unwinder debugging."),
> + _("Show Python unwinder debugging."),
> + _("When non-zero, Pythin unwinder debugging is enabled."),
"Python"
> +static PyMethodDef sniffer_info_object_methods[] =
> +{
> + { "read_register", sniffer_infopy_read_register, METH_VARARGS,
> + "read_register (REGNUM) -> gdb.Value\n"
> + "Return the value of the REGNUM in the frame." },
> + { "unwind_info_with_id",
> + sniffer_infopy_unwind_info_with_id, METH_VARARGS,
> + "unwind_info_with_id (SP, PC) -> gdb.UnwindInfo\n"
> + "Construct UnwindInfo for this FrameData, using given SP and PC registers \n"
> + "to identify the frame." },
> + { "unwind_info_with_id_special",
> + sniffer_infopy_unwind_info_with_id_special, METH_VARARGS,
> + "unwind_info_with_id_special (SP, PC, SPECIAL) -> gdb.UnwindInfo\n"
> + "Construct UnwindInfo for this FrameData, using given SP, PC, and SPECIAL "
> + "registers to identify the frame." },
> + { "unwind_info_with_id_wild",
> + sniffer_infopy_unwind_info_with_id_wild, METH_VARARGS,
> + "unwind_info_with_id_wild (SP) ->gdb.UnwindInfo\n"
> + "Construct UnwindInfo for this FrameData, using given SP register to \n"
> + "identify the frame." },
> + {NULL} /* Sentinel */
> +};
Still no support for register names.
> +import gdb
> +from gdb.sniffer import Sniffer
> +
> +class TestSniffer(Sniffer):
I still think it's much better to call these "unwinders". You say that
it's the terminology that GDB uses but that's not really the case --
"sniffer" names part of the unwinder interface, which Python and Guile
implement the whole of. You chose "unwinder" as the documentation
heading and the file name; why introduce a new term to the user?
Andy
More information about the Gdb-patches
mailing list