[pushed] ada-lang.c: Renaming some fixed-point-related routines

Joel Brobecker brobecker@adacore.com
Sun Nov 1 07:31:02 GMT 2020


Hello,

This patch renames some of the fixed-point-related subprograms in ada-lang.c
so as to make it obvious that those routines only handle the case where
the types are encoded using the GNAT encoding.

No function change; this patch is preparation work for adding support
for fixed-point types purely based on standard DWARF debug info.

gdb/ChangeLog:

        * ada-lang.c (cast_from_gnat_encoded_fixed_point_type): Renames
        cast_from_fixed.  Update all callers.
        (cast_to_gnat_encoded_fixed_point_type): Renames cast_to_fixed.
        Update all callers.
        (gnat_encoded_fixed_point_scaling_factor): Renames ada_scaling_factor.
        Update all callers.
        * ada-lang.h (gnat_encoded_fixed_point_scaling_factor): Renames
        ada_scaling_factor.
        * ada-typeprint.c: Replace call to ada_scaling_factor by call
        to print_gnat_encoded_fixed_point_type.
        * ada-valprint.c: Likewise.

Tested on x86_64-linux.
Pushed to master.

Thanks,
-- 
Joel

---
 gdb/ChangeLog       | 14 ++++++++++++++
 gdb/ada-lang.c      | 22 +++++++++++-----------
 gdb/ada-lang.h      |  2 +-
 gdb/ada-typeprint.c |  2 +-
 gdb/ada-valprint.c  |  2 +-
 5 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4a160ec..8e46763 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,17 @@
+2020-11-01  Joel Brobecker  <brobecker@adacore.com>
+
+	* ada-lang.c (cast_from_gnat_encoded_fixed_point_type): Renames
+	cast_from_fixed.  Update all callers.
+	(cast_to_gnat_encoded_fixed_point_type): Renames cast_to_fixed.
+	Update all callers.
+	(gnat_encoded_fixed_point_scaling_factor): Renames ada_scaling_factor.
+	Update all callers.
+	* ada-lang.h (gnat_encoded_fixed_point_scaling_factor): Renames
+	ada_scaling_factor.
+	* ada-typeprint.c: Replace call to ada_scaling_factor by call
+	to print_gnat_encoded_fixed_point_type.
+	* ada-valprint.c: Likewise.
+
 2020-10-31  Andrew Burgess  <andrew.burgess@embecosm.com>
 
 	* infrun.h (infrun_debug_printf): Add check of debug_infrun flag.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 9aba814..c0c440d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9170,9 +9170,9 @@ unwrap_value (struct value *val)
 }
 
 static struct value *
-cast_from_fixed (struct type *type, struct value *arg)
+cast_from_gnat_encoded_fixed_point_type (struct type *type, struct value *arg)
 {
-  struct value *scale = ada_scaling_factor (value_type (arg));
+  struct value *scale = gnat_encoded_fixed_point_scaling_factor (value_type (arg));
   arg = value_cast (value_type (scale), arg);
 
   arg = value_binop (arg, scale, BINOP_MUL);
@@ -9180,14 +9180,14 @@ cast_from_fixed (struct type *type, struct value *arg)
 }
 
 static struct value *
-cast_to_fixed (struct type *type, struct value *arg)
+cast_to_gnat_encoded_fixed_point_type (struct type *type, struct value *arg)
 {
   if (type == value_type (arg))
     return arg;
 
-  struct value *scale = ada_scaling_factor (type);
+  struct value *scale = gnat_encoded_fixed_point_scaling_factor (type);
   if (ada_is_gnat_encoded_fixed_point_type (value_type (arg)))
-    arg = cast_from_fixed (value_type (scale), arg);
+    arg = cast_from_gnat_encoded_fixed_point_type (value_type (scale), arg);
   else
     arg = value_cast (value_type (scale), arg);
 
@@ -9735,10 +9735,10 @@ ada_value_cast (struct type *type, struct value *arg2)
     return arg2;
 
   if (ada_is_gnat_encoded_fixed_point_type (type))
-    return cast_to_fixed (type, arg2);
+    return cast_to_gnat_encoded_fixed_point_type (type, arg2);
 
   if (ada_is_gnat_encoded_fixed_point_type (value_type (arg2)))
-    return cast_from_fixed (type, arg2);
+    return cast_from_gnat_encoded_fixed_point_type (type, arg2);
 
   return value_cast (type, arg2);
 }
@@ -10138,7 +10138,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
 	  /* Nothing.  */
 	}
       else if (ada_is_gnat_encoded_fixed_point_type (value_type (arg1)))
-        arg2 = cast_to_fixed (value_type (arg1), arg2);
+        arg2 = cast_to_gnat_encoded_fixed_point_type (value_type (arg1), arg2);
       else if (ada_is_gnat_encoded_fixed_point_type (value_type (arg2)))
         error
           (_("Fixed-point values must be assigned to fixed-point variables"));
@@ -10216,9 +10216,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
         {
           type = builtin_type (exp->gdbarch)->builtin_double;
           if (ada_is_gnat_encoded_fixed_point_type (value_type (arg1)))
-            arg1 = cast_from_fixed (type, arg1);
+            arg1 = cast_from_gnat_encoded_fixed_point_type (type, arg1);
           if (ada_is_gnat_encoded_fixed_point_type (value_type (arg2)))
-            arg2 = cast_from_fixed (type, arg2);
+            arg2 = cast_from_gnat_encoded_fixed_point_type (type, arg2);
           binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
           return ada_value_binop (arg1, arg2, op);
         }
@@ -11188,7 +11188,7 @@ gnat_encoded_fixed_point_delta (struct type *type)
    the scaling factor ('SMALL value) associated with the type.  */
 
 struct value *
-ada_scaling_factor (struct type *type)
+gnat_encoded_fixed_point_scaling_factor (struct type *type)
 {
   const char *encoding = gnat_encoded_fixed_type_info (type);
   struct type *scale_type = ada_scaling_type (type);
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 9331926..e65be41 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -287,7 +287,7 @@ extern int ada_is_system_address_type (struct type *);
 
 extern struct value *gnat_encoded_fixed_point_delta (struct type *);
 
-extern struct value *ada_scaling_factor (struct type *);
+extern struct value *gnat_encoded_fixed_point_scaling_factor (struct type *);
 
 extern int ada_which_variant_applies (struct type *, struct value *);
 
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 13037c0..a58eaba 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -345,7 +345,7 @@ 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 = ada_scaling_factor (type);
+  struct value *small = gnat_encoded_fixed_point_scaling_factor (type);
 
   if (delta == nullptr)
     fprintf_filtered (stream, "delta ??");
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 3616711..67716f7 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -773,7 +773,7 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
 
   if (ada_is_gnat_encoded_fixed_point_type (type))
     {
-      struct value *scale = ada_scaling_factor (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);
 
-- 
2.1.4



More information about the Gdb-patches mailing list