[pushed] update name of several Ada fixed-point type handling functions

Message ID 1589573315-71942-1-git-send-email-brobecker@adacore.com
State New
Headers show
Series
  • [pushed] update name of several Ada fixed-point type handling functions
Related show

Commit Message

Joel Brobecker May 15, 2020, 8:08 p.m.
Hello,

The purpose of this patch is to prepare for the future where
fixed point types become described using standard DWARF info,
rather than GNAT encodings. For that, we rename a number of
routines manipulating Ada fixed point types to make it explicit
from their new names that they rely on the GNAT encodings to work.
This will allow us, when we introduce support for fixed point types
from standard DWARF to use names that are not ambiguous with
the functions that do similar work, but only for GNAT encodings.

gdb/ChangeLog:

        * ada-lang.h: (ada_is_gnat_encoded_fixed_point_type): Renames
        ada_is_fixed_point_type.  Update all callers.
        (gnat_encoded_fixed_point_delta): Renames ada_delta.  Update
        all callers.
        * ada-lang.c (gnat_encoded_fixed_type_info): Renames fixed_type_info.
        Update all callers.
        * ada-typeprint.c (print_gnat_encoded_fixed_point_type): Renames
        print_fixed_point_type.  Update all callers.
        * ada-valprint.c (ada_value_print_num): Replace call to
        ada_is_fixed_point_type by ada_is_gnat_encoded_fixed_point_type.

Tested on x86_64-linux, no regression.
This is a fairly trivial patch, so I pushed it right away.

Thanks!
-- 
Joel

---
 gdb/ChangeLog       | 13 +++++++++++++
 gdb/ada-lang.c      | 42 +++++++++++++++++++++---------------------
 gdb/ada-lang.h      |  4 ++--
 gdb/ada-typeprint.c | 12 ++++++------
 gdb/ada-valprint.c  |  2 +-
 5 files changed, 43 insertions(+), 30 deletions(-)

-- 
2.1.4

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 44ccc18..f91827e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,16 @@ 
+2020-05-15  Joel Brobecker  <brobecker@adacore.com>
+
+	* ada-lang.h: (ada_is_gnat_encoded_fixed_point_type): Renames
+	ada_is_fixed_point_type.  Update all callers.
+	(gnat_encoded_fixed_point_delta): Renames ada_delta.  Update
+	all callers.
+	* ada-lang.c (gnat_encoded_fixed_type_info): Renames fixed_type_info.
+	Update all callers.
+	* ada-typeprint.c (print_gnat_encoded_fixed_point_type): Renames
+	print_fixed_point_type.  Update all callers.
+	* ada-valprint.c (ada_value_print_num): Replace call to
+	ada_is_fixed_point_type by ada_is_gnat_encoded_fixed_point_type.
+
 2020-05-14  Kevin Buettner  <kevinb@redhat.com>
 
 	* nat/linux-btrace.c (btrace_this_cpu): Add check for AMD
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 02e3404..e5288e2 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9460,7 +9460,7 @@  cast_to_fixed (struct type *type, struct value *arg)
     return arg;
 
   struct value *scale = ada_scaling_factor (type);
-  if (ada_is_fixed_point_type (value_type (arg)))
+  if (ada_is_gnat_encoded_fixed_point_type (value_type (arg)))
     arg = cast_from_fixed (value_type (scale), arg);
   else
     arg = value_cast (value_type (scale), arg);
@@ -10008,10 +10008,10 @@  ada_value_cast (struct type *type, struct value *arg2)
   if (type == ada_check_typedef (value_type (arg2)))
     return arg2;
 
-  if (ada_is_fixed_point_type (type))
+  if (ada_is_gnat_encoded_fixed_point_type (type))
     return cast_to_fixed (type, arg2);
 
-  if (ada_is_fixed_point_type (value_type (arg2)))
+  if (ada_is_gnat_encoded_fixed_point_type (value_type (arg2)))
     return cast_from_fixed (type, arg2);
 
   return value_cast (type, arg2);
@@ -10411,9 +10411,9 @@  ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
 	{
 	  /* Nothing.  */
 	}
-      else if (ada_is_fixed_point_type (value_type (arg1)))
+      else if (ada_is_gnat_encoded_fixed_point_type (value_type (arg1)))
         arg2 = cast_to_fixed (value_type (arg1), arg2);
-      else if (ada_is_fixed_point_type (value_type (arg2)))
+      else if (ada_is_gnat_encoded_fixed_point_type (value_type (arg2)))
         error
           (_("Fixed-point values must be assigned to fixed-point variables"));
       else
@@ -10433,8 +10433,8 @@  ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
         return (value_from_longest
                  (value_type (arg2),
                   value_as_long (arg1) + value_as_long (arg2)));
-      if ((ada_is_fixed_point_type (value_type (arg1))
-           || ada_is_fixed_point_type (value_type (arg2)))
+      if ((ada_is_gnat_encoded_fixed_point_type (value_type (arg1))
+           || ada_is_gnat_encoded_fixed_point_type (value_type (arg2)))
           && value_type (arg1) != value_type (arg2))
         error (_("Operands of fixed-point addition must have the same type"));
       /* Do the addition, and cast the result to the type of the first
@@ -10459,8 +10459,8 @@  ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
         return (value_from_longest
                  (value_type (arg2),
                   value_as_long (arg1) - value_as_long (arg2)));
-      if ((ada_is_fixed_point_type (value_type (arg1))
-           || ada_is_fixed_point_type (value_type (arg2)))
+      if ((ada_is_gnat_encoded_fixed_point_type (value_type (arg1))
+           || ada_is_gnat_encoded_fixed_point_type (value_type (arg2)))
           && value_type (arg1) != value_type (arg2))
         error (_("Operands of fixed-point subtraction "
 		 "must have the same type"));
@@ -10489,9 +10489,9 @@  ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
       else
         {
           type = builtin_type (exp->gdbarch)->builtin_double;
-          if (ada_is_fixed_point_type (value_type (arg1)))
+          if (ada_is_gnat_encoded_fixed_point_type (value_type (arg1)))
             arg1 = cast_from_fixed (type, arg1);
-          if (ada_is_fixed_point_type (value_type (arg2)))
+          if (ada_is_gnat_encoded_fixed_point_type (value_type (arg2)))
             arg2 = cast_from_fixed (type, arg2);
           binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
           return ada_value_binop (arg1, arg2, op);
@@ -10519,7 +10519,7 @@  ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       if (noside == EVAL_SKIP)
         goto nosideret;
-      else if (ada_is_fixed_point_type (value_type (arg1)))
+      else if (ada_is_gnat_encoded_fixed_point_type (value_type (arg1)))
         return value_cast (value_type (arg1), value_neg (arg1));
       else
 	{
@@ -11391,7 +11391,7 @@  ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
    Otherwise, return NULL.  */
 
 static const char *
-fixed_type_info (struct type *type)
+gnat_encoded_fixed_type_info (struct type *type)
 {
   const char *name = ada_type_name (type);
   enum type_code code = (type == NULL) ? TYPE_CODE_UNDEF : type->code ();
@@ -11406,7 +11406,7 @@  fixed_type_info (struct type *type)
         return tail + 5;
     }
   else if (code == TYPE_CODE_RANGE && TYPE_TARGET_TYPE (type) != type)
-    return fixed_type_info (TYPE_TARGET_TYPE (type));
+    return gnat_encoded_fixed_type_info (TYPE_TARGET_TYPE (type));
   else
     return NULL;
 }
@@ -11414,9 +11414,9 @@  fixed_type_info (struct type *type)
 /* Returns non-zero iff TYPE represents an Ada fixed-point type.  */
 
 int
-ada_is_fixed_point_type (struct type *type)
+ada_is_gnat_encoded_fixed_point_type (struct type *type)
 {
-  return fixed_type_info (type) != NULL;
+  return gnat_encoded_fixed_type_info (type) != NULL;
 }
 
 /* Return non-zero iff TYPE represents a System.Address type.  */
@@ -11443,9 +11443,9 @@  ada_scaling_type (struct type *type)
    delta cannot be determined.  */
 
 struct value *
-ada_delta (struct type *type)
+gnat_encoded_fixed_point_delta (struct type *type)
 {
-  const char *encoding = fixed_type_info (type);
+  const char *encoding = gnat_encoded_fixed_type_info (type);
   struct type *scale_type = ada_scaling_type (type);
 
   long long num, den;
@@ -11457,13 +11457,13 @@  ada_delta (struct type *type)
 			value_from_longest (scale_type, den), BINOP_DIV);
 }
 
-/* Assuming that ada_is_fixed_point_type (TYPE), return the scaling
-   factor ('SMALL value) associated with the type.  */
+/* Assuming that ada_is_gnat_encoded_fixed_point_type (TYPE), return
+   the scaling factor ('SMALL value) associated with the type.  */
 
 struct value *
 ada_scaling_factor (struct type *type)
 {
-  const char *encoding = fixed_type_info (type);
+  const char *encoding = gnat_encoded_fixed_type_info (type);
   struct type *scale_type = ada_scaling_type (type);
 
   long long num0, den0, num1, den1;
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index c0a7109..5ba0051 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -281,11 +281,11 @@  extern struct type *ada_aligned_type (struct type *);
 extern const gdb_byte *ada_aligned_value_addr (struct type *,
 					       const gdb_byte *);
 
-extern int ada_is_fixed_point_type (struct type *);
+extern int ada_is_gnat_encoded_fixed_point_type (struct type *);
 
 extern int ada_is_system_address_type (struct type *);
 
-extern struct value *ada_delta (struct type *);
+extern struct value *gnat_encoded_fixed_point_delta (struct type *);
 
 extern struct value *ada_scaling_factor (struct type *);
 
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 0ae8f93..1b976b1 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -342,9 +342,9 @@  print_enum_type (struct type *type, struct ui_file *stream)
 /* Print representation of Ada fixed-point type TYPE on STREAM.  */
 
 static void
-print_fixed_point_type (struct type *type, struct ui_file *stream)
+print_gnat_encoded_fixed_point_type (struct type *type, struct ui_file *stream)
 {
-  struct value *delta = ada_delta (type);
+  struct value *delta = gnat_encoded_fixed_point_delta (type);
   struct value *small = ada_scaling_factor (type);
 
   if (delta == nullptr)
@@ -1012,8 +1012,8 @@  ada_print_type (struct type *type0, const char *varstring,
 	fprintf_filtered (stream, "(false, true)");
 	break;
       case TYPE_CODE_INT:
-	if (ada_is_fixed_point_type (type))
-	  print_fixed_point_type (type, stream);
+	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);
@@ -1030,8 +1030,8 @@  ada_print_type (struct type *type0, const char *varstring,
 	  }
 	break;
       case TYPE_CODE_RANGE:
-	if (ada_is_fixed_point_type (type))
-	  print_fixed_point_type (type, stream);
+	if (ada_is_gnat_encoded_fixed_point_type (type))
+	  print_gnat_encoded_fixed_point_type (type, stream);
 	else if (ada_is_modular_type (type))
 	  fprintf_filtered (stream, "mod %s", 
 			    int_string (ada_modulus (type), 10, 0, 0, 1));
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 4ad4b54..e11e47e 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -793,7 +793,7 @@  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_fixed_point_type (type))
+  if (ada_is_gnat_encoded_fixed_point_type (type))
     {
       struct value *scale = ada_scaling_factor (type);
       val = value_cast (value_type (scale), val);