aboutsummaryrefslogtreecommitdiff
path: root/gdb/valprint.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-04-01 14:09:52 -0600
committerTom Tromey <tromey@adacore.com>2020-04-01 14:09:52 -0600
commit4c99290df04ba757b74a21ac5a6d16fe300e49ed (patch)
treeccb4fc81ef873b8bb729af596360c54817a3e824 /gdb/valprint.c
parent5b930b4538f70a9f09280e36164840e48fb1c042 (diff)
downloadgdb-4c99290df04ba757b74a21ac5a6d16fe300e49ed.zip
gdb-4c99290df04ba757b74a21ac5a6d16fe300e49ed.tar.gz
gdb-4c99290df04ba757b74a21ac5a6d16fe300e49ed.tar.bz2
Add accessors for members of complex numbers
This introduces two new functions that make it simpler to access the components of a complex number. gdb/ChangeLog 2020-04-01 Tom Tromey <tom@tromey.com> * valprint.c (generic_value_print_complex): Use accessors. * value.h (value_real_part, value_imaginary_part): Declare. * valops.c (value_real_part, value_imaginary_part): New functions. * value.c (creal_internal_fn, cimag_internal_fn): Use accessors.
Diffstat (limited to 'gdb/valprint.c')
-rw-r--r--gdb/valprint.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 108a21b..80b7514 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -811,16 +811,11 @@ generic_value_print_complex (struct value *val, struct ui_file *stream,
{
fprintf_filtered (stream, "%s", decorations->complex_prefix);
- struct type *type = check_typedef (value_type (val));
- struct value *real_part
- = value_from_component (val, TYPE_TARGET_TYPE (type), 0);
+ struct value *real_part = value_real_part (val);
value_print_scalar_formatted (real_part, options, 0, stream);
fprintf_filtered (stream, "%s", decorations->complex_infix);
- struct value *imag_part
- = value_from_component (val, TYPE_TARGET_TYPE (type),
- TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
-
+ struct value *imag_part = value_imaginary_part (val);
value_print_scalar_formatted (imag_part, options, 0, stream);
fprintf_filtered (stream, "%s", decorations->complex_suffix);
}