aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-valprint.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-03-02 13:08:24 -0700
committerTom Tromey <tromey@adacore.com>2021-03-02 13:08:25 -0700
commitbbcdf9ab73018ff43855945fd72c642a67437d8b (patch)
tree2ee63dbc9109b91a86545693e6091d9e0e4de82d /gdb/ada-valprint.c
parent5f9febe0f6ef980d120f9fb5850c0fd3c8fddfa5 (diff)
downloadgdb-bbcdf9ab73018ff43855945fd72c642a67437d8b.zip
gdb-bbcdf9ab73018ff43855945fd72c642a67437d8b.tar.gz
gdb-bbcdf9ab73018ff43855945fd72c642a67437d8b.tar.bz2
Rewrite GNAT-encoded fixed point types in DWARF reader
gdb currently supports two different styles of fixed-point. The original style, where fixed point types are "GNAT encoded", is handled primarily in the Ada code. The newer style, encoded using DWARF, is handled by the core of gdb. This patch changes gdb to read the GNAT encodings in the DWARF reader as well. This removes some code and unifies the two paths. As a result, GNAT-encoded fixed-point now works a bit better. One possible drawback of this change is that, if someone uses stabs, then fixed-point might now stop working. I consider stabs to be fully obsolete, though, so I don't intend to address this. gdb/ChangeLog 2021-03-02 Tom Tromey <tromey@adacore.com> * ada-lang.c (cast_from_gnat_encoded_fixed_point_type) (cast_to_gnat_encoded_fixed_point_type): Remove. (ada_value_cast, ada_evaluate_subexp): Update. (gnat_encoded_fixed_point_type_info) (ada_is_gnat_encoded_fixed_point_type) (gnat_encoded_fixed_point_delta) (gnat_encoded_fixed_point_scaling_factor): Remove. * ada-lang.h (ada_is_gnat_encoded_fixed_point_type) (gnat_encoded_fixed_point_delta) (gnat_encoded_fixed_point_scaling_factor): Don't declare. * ada-typeprint.c (print_gnat_encoded_fixed_point_type): Remove. (ada_print_type): Update. * ada-valprint.c (ada_value_print_num): Update. * dwarf2/read.c (ada_get_gnat_encoded_number) (ada_get_gnat_encoded_ratio): New functions. (finish_fixed_point_type): Use them. Add parameters. (GNAT_FIXED_POINT_SUFFIX): New define. (gnat_encoded_fixed_point_type_info): New function. (read_base_type): Handle gnat encodings. gdb/testsuite/ChangeLog 2021-03-02 Tom Tromey <tromey@adacore.com> * gdb.ada/fixed_points.exp: Remove most special cases for minimal encodings.
Diffstat (limited to 'gdb/ada-valprint.c')
-rw-r--r--gdb/ada-valprint.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 8af9ef0..0d5b6d7 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -741,22 +741,10 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
struct type *type = ada_check_typedef (value_type (val));
const gdb_byte *valaddr = value_contents_for_printing (val);
- if (ada_is_gnat_encoded_fixed_point_type (type))
- {
- struct value *scale = gnat_encoded_fixed_point_scaling_factor (type);
- val = value_cast (value_type (scale), val);
- val = value_binop (val, scale, BINOP_MUL);
-
- const char *fmt = TYPE_LENGTH (type) < 4 ? "%.11g" : "%.17g";
- std::string str
- = target_float_to_string (value_contents (val), value_type (val), fmt);
- fputs_filtered (str.c_str (), stream);
- return;
- }
- else if (type->code () == TYPE_CODE_RANGE
- && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ENUM
- || TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_BOOL
- || TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR))
+ if (type->code () == TYPE_CODE_RANGE
+ && (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ENUM
+ || TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_BOOL
+ || TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR))
{
/* For enum-valued ranges, we want to recurse, because we'll end
up printing the constant's name rather than its numeric