mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-25 11:16:56 +08:00
Change extension language pretty-printers to use value API
This changes the extension language pretty-printers to use the value API. Note that new functions were needed, for both Guile and Python. Currently both languages always wrap values by removing the values from the value chain. This makes sense to avoid strange behavior with watchpoints, and to avoid excessive memory use. However, when printing, it's important to leave the passed-in value untouched, in case pretty-printing does nothing -- that way the caller can still access it. gdb/ChangeLog 2020-03-13 Tom Tromey <tom@tromey.com> * valprint.c (do_val_print): Update. * python/python-internal.h (gdbpy_apply_val_pretty_printer): Take a struct value. (value_to_value_object_no_release): Declare. * python/py-value.c (value_to_value_object_no_release): New function. * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Take a struct value. * guile/scm-value.c (vlscm_scm_from_value_no_release): New function. * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Take a struct value. * guile/guile-internal.h (vlscm_scm_from_value_no_release): Declare. (gdbscm_apply_val_pretty_printer): Take a struct value. * extension.h (apply_ext_lang_val_pretty_printer): Take a struct value. * extension.c (apply_ext_lang_val_pretty_printer): Take a struct value. * extension-priv.h (struct extension_language_ops) <apply_val_pretty_printer>: Take a struct value. * cp-valprint.c (cp_print_value): Create a struct value. (cp_print_value): Update.
This commit is contained in:
@ -1788,6 +1788,27 @@ value_to_value_object (struct value *val)
|
||||
return (PyObject *) val_obj;
|
||||
}
|
||||
|
||||
/* Returns an object for a value, but without releasing it from the
|
||||
all_values chain. */
|
||||
PyObject *
|
||||
value_to_value_object_no_release (struct value *val)
|
||||
{
|
||||
value_object *val_obj;
|
||||
|
||||
val_obj = PyObject_New (value_object, &value_object_type);
|
||||
if (val_obj != NULL)
|
||||
{
|
||||
value_incref (val);
|
||||
val_obj->value = val;
|
||||
val_obj->address = NULL;
|
||||
val_obj->type = NULL;
|
||||
val_obj->dynamic_type = NULL;
|
||||
note_value (val_obj);
|
||||
}
|
||||
|
||||
return (PyObject *) val_obj;
|
||||
}
|
||||
|
||||
/* Returns a borrowed reference to the struct value corresponding to
|
||||
the given value object. */
|
||||
struct value *
|
||||
|
Reference in New Issue
Block a user