[arm] Add support for FPU registers in prologue unwinder
[binutils-gdb.git] / gdb / arch-utils.c
index 4442ec9b82f4199abf80fd33988e43a5a5254241..ff946ee37671e4530ea6ff75b9957decf89ff326 100644 (file)
@@ -1,6 +1,6 @@
 /* Dynamic architecture support for GDB, the GNU debugger.
 
-   Copyright (C) 1998-2021 Free Software Foundation, Inc.
+   Copyright (C) 1998-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -359,7 +359,7 @@ static const char *const endian_enum[] =
   endian_auto,
   NULL,
 };
-static const char *set_endian_string;
+static const char *set_endian_string = endian_auto;
 
 enum bfd_endian
 selected_byte_order (void)
@@ -375,18 +375,18 @@ show_endian (struct ui_file *file, int from_tty, struct cmd_list_element *c,
 {
   if (target_byte_order_user == BFD_ENDIAN_UNKNOWN)
     if (gdbarch_byte_order (get_current_arch ()) == BFD_ENDIAN_BIG)
-      fprintf_unfiltered (file, _("The target endianness is set automatically "
-                                 "(currently big endian).\n"));
+      gdb_printf (file, _("The target endianness is set automatically "
+                         "(currently big endian).\n"));
     else
-      fprintf_unfiltered (file, _("The target endianness is set automatically "
-                                 "(currently little endian).\n"));
+      gdb_printf (file, _("The target endianness is set automatically "
+                         "(currently little endian).\n"));
   else
     if (target_byte_order_user == BFD_ENDIAN_BIG)
-      fprintf_unfiltered (file,
-                         _("The target is set to big endian.\n"));
+      gdb_printf (file,
+                 _("The target is set to big endian.\n"));
     else
-      fprintf_unfiltered (file,
-                         _("The target is set to little endian.\n"));
+      gdb_printf (file,
+                 _("The target is set to little endian.\n"));
 }
 
 static void
@@ -405,7 +405,8 @@ set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c)
     {
       info.byte_order = BFD_ENDIAN_LITTLE;
       if (! gdbarch_update_p (info))
-       printf_unfiltered (_("Little endian target not supported by GDB\n"));
+       gdb_printf (gdb_stderr,
+                   _("Little endian target not supported by GDB\n"));
       else
        target_byte_order_user = BFD_ENDIAN_LITTLE;
     }
@@ -413,7 +414,8 @@ set_endian (const char *ignore_args, int from_tty, struct cmd_list_element *c)
     {
       info.byte_order = BFD_ENDIAN_BIG;
       if (! gdbarch_update_p (info))
-       printf_unfiltered (_("Big endian target not supported by GDB\n"));
+       gdb_printf (gdb_stderr,
+                   _("Big endian target not supported by GDB\n"));
       else
        target_byte_order_user = BFD_ENDIAN_BIG;
     }
@@ -533,12 +535,12 @@ show_architecture (struct ui_file *file, int from_tty,
                   struct cmd_list_element *c, const char *value)
 {
   if (target_architecture_user == NULL)
-    fprintf_filtered (file, _("The target architecture is set to "
-                             "\"auto\" (currently \"%s\").\n"),
-                     gdbarch_bfd_arch_info (get_current_arch ())->printable_name);
+    gdb_printf (file, _("The target architecture is set to "
+                       "\"auto\" (currently \"%s\").\n"),
+               gdbarch_bfd_arch_info (get_current_arch ())->printable_name);
   else
-    fprintf_filtered (file, _("The target architecture is set to \"%s\".\n"),
-                     set_architecture_string);
+    gdb_printf (file, _("The target architecture is set to \"%s\".\n"),
+               set_architecture_string);
 }
 
 
@@ -567,8 +569,9 @@ set_architecture (const char *ignore_args,
       if (gdbarch_update_p (info))
        target_architecture_user = info.bfd_arch_info;
       else
-       printf_unfiltered (_("Architecture `%s' not recognized.\n"),
-                          set_architecture_string);
+       gdb_printf (gdb_stderr,
+                   _("Architecture `%s' not recognized.\n"),
+                   set_architecture_string);
     }
   show_architecture (gdb_stdout, from_tty, NULL, NULL);
 }
@@ -596,8 +599,8 @@ gdbarch_update_p (struct gdbarch_info info)
   if (new_gdbarch == NULL)
     {
       if (gdbarch_debug)
-       fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
-                           "Architecture not found\n");
+       gdb_printf (gdb_stdlog, "gdbarch_update_p: "
+                   "Architecture not found\n");
       return 0;
     }
 
@@ -606,19 +609,19 @@ gdbarch_update_p (struct gdbarch_info info)
   if (new_gdbarch == target_gdbarch ())
     {
       if (gdbarch_debug)
-       fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
-                           "Architecture %s (%s) unchanged\n",
-                           host_address_to_string (new_gdbarch),
-                           gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
+       gdb_printf (gdb_stdlog, "gdbarch_update_p: "
+                   "Architecture %s (%s) unchanged\n",
+                   host_address_to_string (new_gdbarch),
+                   gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
       return 1;
     }
 
   /* It's a new architecture, swap it in.  */
   if (gdbarch_debug)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: "
-                       "New architecture %s (%s) selected\n",
-                       host_address_to_string (new_gdbarch),
-                       gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
+    gdb_printf (gdb_stdlog, "gdbarch_update_p: "
+               "New architecture %s (%s) selected\n",
+               host_address_to_string (new_gdbarch),
+               gdbarch_bfd_arch_info (new_gdbarch)->printable_name);
   set_target_gdbarch (new_gdbarch);
 
   return 1;
@@ -754,7 +757,8 @@ initialize_current_architecture (void)
      list of architectures.  */
   {
     /* Append ``auto''.  */
-    arches.push_back ("auto");
+    set_architecture_string = "auto";
+    arches.push_back (set_architecture_string);
     arches.push_back (nullptr);
     set_show_commands architecture_cmds
       = add_setshow_enum_cmd ("architecture", class_support,
@@ -1102,7 +1106,7 @@ static void
 show_gdbarch_debug (struct ui_file *file, int from_tty,
                    struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("Architecture debugging is %s.\n"), value);
+  gdb_printf (file, _("Architecture debugging is %s.\n"), value);
 }
 
 static const char *
@@ -1198,7 +1202,7 @@ struct gdbarch_tdep *
 gdbarch_tdep (struct gdbarch *gdbarch)
 {
   if (gdbarch_debug >= 2)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_tdep called\n");
+    gdb_printf (gdb_stdlog, "gdbarch_tdep called\n");
   return gdbarch->tdep;
 }
 
@@ -1381,9 +1385,9 @@ gdbarch_register (enum bfd_architecture bfd_architecture,
     }
   /* log it */
   if (gdbarch_debug)
-    fprintf_unfiltered (gdb_stdlog, "register_gdbarch_init (%s, %s)\n",
-                       bfd_arch_info->printable_name,
-                       host_address_to_string (init));
+    gdb_printf (gdb_stdlog, "register_gdbarch_init (%s, %s)\n",
+               bfd_arch_info->printable_name,
+               host_address_to_string (init));
   /* Append it */
   (*curr) = XNEW (struct gdbarch_registration);
   (*curr)->bfd_architecture = bfd_architecture;
@@ -1442,23 +1446,23 @@ gdbarch_find_by_info (struct gdbarch_info info)
 
   if (gdbarch_debug)
     {
-      fprintf_unfiltered (gdb_stdlog,
-                         "gdbarch_find_by_info: info.bfd_arch_info %s\n",
-                         (info.bfd_arch_info != NULL
-                          ? info.bfd_arch_info->printable_name
-                          : "(null)"));
-      fprintf_unfiltered (gdb_stdlog,
-                         "gdbarch_find_by_info: info.byte_order %d (%s)\n",
-                         info.byte_order,
-                         (info.byte_order == BFD_ENDIAN_BIG ? "big"
-                          : info.byte_order == BFD_ENDIAN_LITTLE ? "little"
-                          : "default"));
-      fprintf_unfiltered (gdb_stdlog,
-                         "gdbarch_find_by_info: info.osabi %d (%s)\n",
-                         info.osabi, gdbarch_osabi_name (info.osabi));
-      fprintf_unfiltered (gdb_stdlog,
-                         "gdbarch_find_by_info: info.abfd %s\n",
-                         host_address_to_string (info.abfd));
+      gdb_printf (gdb_stdlog,
+                 "gdbarch_find_by_info: info.bfd_arch_info %s\n",
+                 (info.bfd_arch_info != NULL
+                  ? info.bfd_arch_info->printable_name
+                  : "(null)"));
+      gdb_printf (gdb_stdlog,
+                 "gdbarch_find_by_info: info.byte_order %d (%s)\n",
+                 info.byte_order,
+                 (info.byte_order == BFD_ENDIAN_BIG ? "big"
+                  : info.byte_order == BFD_ENDIAN_LITTLE ? "little"
+                  : "default"));
+      gdb_printf (gdb_stdlog,
+                 "gdbarch_find_by_info: info.osabi %d (%s)\n",
+                 info.osabi, gdbarch_osabi_name (info.osabi));
+      gdb_printf (gdb_stdlog,
+                 "gdbarch_find_by_info: info.abfd %s\n",
+                 host_address_to_string (info.abfd));
     }
 
   /* Find the tdep code that knows about this architecture.  */
@@ -1470,8 +1474,8 @@ gdbarch_find_by_info (struct gdbarch_info info)
   if (rego == NULL)
     {
       if (gdbarch_debug)
-       fprintf_unfiltered (gdb_stdlog, "gdbarch_find_by_info: "
-                           "No matching architecture\n");
+       gdb_printf (gdb_stdlog, "gdbarch_find_by_info: "
+                   "No matching architecture\n");
       return 0;
     }
 
@@ -1483,8 +1487,8 @@ gdbarch_find_by_info (struct gdbarch_info info)
   if (new_gdbarch == NULL)
     {
       if (gdbarch_debug)
-       fprintf_unfiltered (gdb_stdlog, "gdbarch_find_by_info: "
-                           "Target rejected architecture\n");
+       gdb_printf (gdb_stdlog, "gdbarch_find_by_info: "
+                   "Target rejected architecture\n");
       return NULL;
     }
 
@@ -1496,10 +1500,10 @@ gdbarch_find_by_info (struct gdbarch_info info)
       struct gdbarch_list **list;
       struct gdbarch_list *self;
       if (gdbarch_debug)
-       fprintf_unfiltered (gdb_stdlog, "gdbarch_find_by_info: "
-                           "Previous architecture %s (%s) selected\n",
-                           host_address_to_string (new_gdbarch),
-                           new_gdbarch->bfd_arch_info->printable_name);
+       gdb_printf (gdb_stdlog, "gdbarch_find_by_info: "
+                   "Previous architecture %s (%s) selected\n",
+                   host_address_to_string (new_gdbarch),
+                   new_gdbarch->bfd_arch_info->printable_name);
       /* Find the existing arch in the list.  */
       for (list = &rego->arches;
           (*list) != NULL && (*list)->gdbarch != new_gdbarch;
@@ -1518,10 +1522,10 @@ gdbarch_find_by_info (struct gdbarch_info info)
 
   /* It's a new architecture.  */
   if (gdbarch_debug)
-    fprintf_unfiltered (gdb_stdlog, "gdbarch_find_by_info: "
-                       "New architecture %s (%s) selected\n",
-                       host_address_to_string (new_gdbarch),
-                       new_gdbarch->bfd_arch_info->printable_name);
+    gdb_printf (gdb_stdlog, "gdbarch_find_by_info: "
+               "New architecture %s (%s) selected\n",
+               host_address_to_string (new_gdbarch),
+               new_gdbarch->bfd_arch_info->printable_name);
 
   /* Insert the new architecture into the front of the architecture
      list (keep the list sorted Most Recently Used).  */