aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-valprint.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-03-13 17:39:52 -0600
committerTom Tromey <tom@tromey.com>2020-03-13 18:03:42 -0600
commit42331a1ea2a13ce15ec202c5f0fbef3e5171253c (patch)
tree69cd05a4b2d8de096c8ee3f0b5a87c219f855ee1 /gdb/cp-valprint.c
parent3a916a975745f386cabbaba64531ed9b5f8be509 (diff)
downloadgdb-42331a1ea2a13ce15ec202c5f0fbef3e5171253c.zip
gdb-42331a1ea2a13ce15ec202c5f0fbef3e5171253c.tar.gz
gdb-42331a1ea2a13ce15ec202c5f0fbef3e5171253c.tar.bz2
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.
Diffstat (limited to 'gdb/cp-valprint.c')
-rw-r--r--gdb/cp-valprint.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 77725b7..5e4cb3c 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -848,13 +848,15 @@ cp_print_value (struct type *type, struct type *real_type,
/* Attempt to run an extension language pretty-printer on the
baseclass if possible. */
if (!options->raw)
- result
- = apply_ext_lang_val_pretty_printer (baseclass,
- thisoffset + boffset,
- value_address (base_val),
- stream, recurse,
- base_val, options,
- current_language);
+ {
+ struct value *v
+ = value_from_component (base_val, baseclass,
+ thisoffset + boffset);
+ result
+ = apply_ext_lang_val_pretty_printer (v, stream, recurse,
+ options,
+ current_language);
+ }
if (!result)
cp_print_value_fields (baseclass, thistype,
@@ -1006,19 +1008,19 @@ cp_print_value (struct value *val, struct ui_file *stream,
}
else
{
+ struct value *baseclass_val = value_primitive_field (val, 0,
+ i, type);
+
/* Attempt to run an extension language pretty-printer on the
baseclass if possible. */
if (!options->raw)
result
- = apply_ext_lang_val_pretty_printer (baseclass, boffset,
- value_address (base_val),
- stream, recurse,
- base_val, options,
+ = apply_ext_lang_val_pretty_printer (baseclass_val, stream,
+ recurse, options,
current_language);
if (!result)
- cp_print_value_fields (value_primitive_field (val, 0, i, type),
- stream, recurse, options,
+ cp_print_value_fields (baseclass_val, stream, recurse, options,
((struct type **)
obstack_base (&dont_print_vb_obstack)),
0);