forked from Imagelibrary/binutils-gdb
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.
This commit is contained in:
@@ -339,31 +339,6 @@ print_enum_type (struct type *type, struct ui_file *stream)
|
||||
fprintf_filtered (stream, ")");
|
||||
}
|
||||
|
||||
/* Print representation of Ada fixed-point type TYPE on STREAM. */
|
||||
|
||||
static void
|
||||
print_gnat_encoded_fixed_point_type (struct type *type, struct ui_file *stream)
|
||||
{
|
||||
struct value *delta = gnat_encoded_fixed_point_delta (type);
|
||||
struct value *small = gnat_encoded_fixed_point_scaling_factor (type);
|
||||
|
||||
if (delta == nullptr)
|
||||
fprintf_filtered (stream, "delta ??");
|
||||
else
|
||||
{
|
||||
std::string str;
|
||||
str = target_float_to_string (value_contents (delta),
|
||||
value_type (delta), "%g");
|
||||
fprintf_filtered (stream, "delta %s", str.c_str());
|
||||
if (!value_equal (delta, small))
|
||||
{
|
||||
str = target_float_to_string (value_contents (small),
|
||||
value_type (small), "%g");
|
||||
fprintf_filtered (stream, " <'small = %s>", str.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Print simple (constrained) array type TYPE on STREAM. LEVEL is the
|
||||
recursion (indentation) level, in case the element type itself has
|
||||
nested structure, and SHOW is the number of levels of internal
|
||||
@@ -1026,27 +1001,22 @@ ada_print_type (struct type *type0, const char *varstring,
|
||||
fprintf_filtered (stream, "(false, true)");
|
||||
break;
|
||||
case TYPE_CODE_INT:
|
||||
if (ada_is_gnat_encoded_fixed_point_type (type))
|
||||
print_gnat_encoded_fixed_point_type (type, stream);
|
||||
else
|
||||
{
|
||||
const char *name = ada_type_name (type);
|
||||
{
|
||||
const char *name = ada_type_name (type);
|
||||
|
||||
if (!ada_is_range_type_name (name))
|
||||
fprintf_styled (stream, metadata_style.style (),
|
||||
_("<%s-byte integer>"),
|
||||
pulongest (TYPE_LENGTH (type)));
|
||||
else
|
||||
{
|
||||
fprintf_filtered (stream, "range ");
|
||||
print_range_type (type, stream, 1 /* bounds_prefered_p */);
|
||||
}
|
||||
}
|
||||
if (!ada_is_range_type_name (name))
|
||||
fprintf_styled (stream, metadata_style.style (),
|
||||
_("<%s-byte integer>"),
|
||||
pulongest (TYPE_LENGTH (type)));
|
||||
else
|
||||
{
|
||||
fprintf_filtered (stream, "range ");
|
||||
print_range_type (type, stream, 1 /* bounds_prefered_p */);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPE_CODE_RANGE:
|
||||
if (ada_is_gnat_encoded_fixed_point_type (type))
|
||||
print_gnat_encoded_fixed_point_type (type, stream);
|
||||
else if (is_fixed_point_type (type))
|
||||
if (is_fixed_point_type (type))
|
||||
{
|
||||
fprintf_filtered (stream, "<");
|
||||
print_type_fixed_point (type, stream);
|
||||
|
||||
Reference in New Issue
Block a user