* gdb.texinfo (Remote configuration): Document "set/show
[deliverable/binutils-gdb.git] / gdb / osabi.c
index 239d508309fcd771a9d2e4275b7969ba9a605e74..7b4698a52d2409df571c142f1d3f72df52d94b9c 100644 (file)
@@ -1,5 +1,6 @@
 /* OS ABI variant handling for GDB.
-   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+
+   Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -70,9 +71,6 @@ static const char * const gdb_osabi_names[] =
   "HP/UX ELF",
   "HP/UX SOM",
 
-  "ARM EABI v1",
-  "ARM EABI v2",
-  "ARM APCS",
   "QNX Neutrino",
 
   "Cygwin",
@@ -116,9 +114,9 @@ gdbarch_register_osabi (enum bfd_architecture arch, unsigned long machine,
     {
       internal_error
        (__FILE__, __LINE__,
-        "gdbarch_register_osabi: An attempt to register a handler for "
+        _("gdbarch_register_osabi: An attempt to register a handler for "
          "OS ABI \"%s\" for architecture %s was made.  The handler will "
-        "not be registered",
+        "not be registered"),
         gdbarch_osabi_name (osabi),
         bfd_printable_arch_mach (arch, machine));
       return;
@@ -134,8 +132,8 @@ gdbarch_register_osabi (enum bfd_architecture arch, unsigned long machine,
        {
          internal_error
            (__FILE__, __LINE__,
-            "gdbarch_register_osabi: A handler for OS ABI \"%s\" "
-            "has already been registered for architecture %s",
+            _("gdbarch_register_osabi: A handler for OS ABI \"%s\" "
+            "has already been registered for architecture %s"),
             gdbarch_osabi_name (osabi),
             arch_info->printable_name);
          /* If user wants to continue, override previous definition.  */
@@ -232,8 +230,8 @@ gdbarch_lookup_osabi (bfd *abfd)
            {
              internal_error
                (__FILE__, __LINE__,
-                "gdbarch_lookup_osabi: invalid OS ABI (%d) from sniffer "
-                "for architecture %s flavour %d",
+                _("gdbarch_lookup_osabi: invalid OS ABI (%d) from sniffer "
+                "for architecture %s flavour %d"),
                 (int) osabi,
                 bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
                 (int) bfd_get_flavour (abfd));
@@ -251,9 +249,9 @@ gdbarch_lookup_osabi (bfd *abfd)
                    {
                      internal_error
                        (__FILE__, __LINE__,
-                        "gdbarch_lookup_osabi: multiple %sspecific OS ABI "
+                        _("gdbarch_lookup_osabi: multiple %sspecific OS ABI "
                         "match for architecture %s flavour %d: first "
-                        "match \"%s\", second match \"%s\"",
+                        "match \"%s\", second match \"%s\""),
                         match_specific ? "" : "non-",
                         bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
                         (int) bfd_get_flavour (abfd),
@@ -446,8 +444,8 @@ generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect, void *obj)
              break;
 
            default:
-             internal_error (__FILE__, __LINE__, "\
-generic_elf_osabi_sniff_abi_tag_sections: unknown OS number %d",
+             internal_error (__FILE__, __LINE__, _("\
+generic_elf_osabi_sniff_abi_tag_sections: unknown OS number %d"),
                              abi_tag);
            }
          return;
@@ -473,6 +471,15 @@ generic_elf_osabi_sniff_abi_tag_sections: unknown OS number %d",
       return;
     }
 
+  /* .note.openbsd.ident notes, used by OpenBSD.  */
+  if (strcmp (name, ".note.openbsd.ident") == 0
+      && check_note (abfd, sect, note, "OpenBSD", 4, NT_OPENBSD_IDENT))
+    {
+      /* There is no need to check the version yet.  */
+      *osabi = GDB_OSABI_OPENBSD_ELF;
+      return;
+    }
+
   /* .note.netbsdcore.procinfo notes, used by NetBSD.  */
   if (strcmp (name, ".note.netbsdcore.procinfo") == 0)
     {
@@ -492,10 +499,11 @@ generic_elf_osabi_sniffer (bfd *abfd)
   switch (elfosabi)
     {
     case ELFOSABI_NONE:
-      /* When elfosabi is ELFOSABI_NONE (0), then the ELF structures in the
-         file are conforming to the base specification for that machine
-        (there are no OS-specific extensions).  In order to determine the
-        real OS in use we must look for OS notes that have been added.  */
+      /* When the EI_OSABI field in the ELF header is ELFOSABI_NONE
+         (0), then the ELF structures in the file are conforming to
+         the base specification for that machine (there are no
+         OS-specific extensions).  In order to determine the real OS
+         in use we must look for OS-specific notes.  */
       bfd_map_over_sections (abfd,
                             generic_elf_osabi_sniff_abi_tag_sections,
                             &osabi);
@@ -522,7 +530,14 @@ generic_elf_osabi_sniffer (bfd *abfd)
       break;
 
     case ELFOSABI_HPUX:
+      /* For some reason the default value for the EI_OSABI field is
+         ELFOSABI_HPUX for all PA-RISC targets (with the exception of
+         GNU/Linux).  We use HP-UX ELF as the default, but let any
+         OS-specific notes override this.  */
       osabi = GDB_OSABI_HPUX_ELF;
+      bfd_map_over_sections (abfd,
+                            generic_elf_osabi_sniff_abi_tag_sections,
+                            &osabi);
       break;
     }
 
@@ -567,7 +582,7 @@ set_osabi (char *args, int from_tty, struct cmd_list_element *c)
          }
       if (i == GDB_OSABI_INVALID)
        internal_error (__FILE__, __LINE__,
-                       "Invalid OS ABI \"%s\" passed to command handler.",
+                       _("Invalid OS ABI \"%s\" passed to command handler."),
                        set_osabi_string);
     }
 
@@ -575,22 +590,24 @@ set_osabi (char *args, int from_tty, struct cmd_list_element *c)
      graceful here.  */
   gdbarch_info_init (&info);
   if (! gdbarch_update_p (info))
-    internal_error (__FILE__, __LINE__, "Updating OS ABI failed.");
+    internal_error (__FILE__, __LINE__, _("Updating OS ABI failed."));
 }
 
 static void
-show_osabi (char *args, int from_tty)
+show_osabi (struct ui_file *file, int from_tty, struct cmd_list_element *c,
+           const char *value)
 {
   if (user_osabi_state == osabi_auto)
-    printf_filtered ("The current OS ABI is \"auto\" (currently \"%s\").\n",
-                    gdbarch_osabi_name (gdbarch_osabi (current_gdbarch)));
+    fprintf_filtered (file,
+                     _("The current OS ABI is \"auto\" (currently \"%s\").\n"),
+                     gdbarch_osabi_name (gdbarch_osabi (current_gdbarch)));
   else
-    printf_filtered ("The current OS ABI is \"%s\".\n",
-                    gdbarch_osabi_name (user_selected_osabi));
+    fprintf_filtered (file, _("The current OS ABI is \"%s\".\n"),
+                     gdbarch_osabi_name (user_selected_osabi));
 
   if (GDB_OSABI_DEFAULT != GDB_OSABI_UNKNOWN)
-    printf_filtered ("The default OS ABI is \"%s\".\n",
-                    gdbarch_osabi_name (GDB_OSABI_DEFAULT));
+    fprintf_filtered (file, _("The default OS ABI is \"%s\".\n"),
+                     gdbarch_osabi_name (GDB_OSABI_DEFAULT));
 }
 \f
 extern initialize_file_ftype _initialize_gdb_osabi; /* -Wmissing-prototype */
@@ -603,7 +620,7 @@ _initialize_gdb_osabi (void)
   if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID], "<invalid>") != 0)
     internal_error
       (__FILE__, __LINE__,
-       "_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent");
+       _("_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"));
 
   /* Register a generic sniffer for ELF flavoured files.  */
   gdbarch_register_osabi_sniffer (bfd_arch_unknown,
@@ -611,11 +628,12 @@ _initialize_gdb_osabi (void)
                                  generic_elf_osabi_sniffer);
 
   /* Register the "set osabi" command.  */
-  c = add_set_enum_cmd ("osabi", class_support, gdb_osabi_available_names,
-                       &set_osabi_string, "Set OS ABI of target.", &setlist);
-
-  set_cmd_sfunc (c, set_osabi);
-  add_cmd ("osabi", class_support, show_osabi, "Show OS/ABI of target.",
-          &showlist);
+  add_setshow_enum_cmd ("osabi", class_support, gdb_osabi_available_names,
+                       &set_osabi_string, _("\
+Set OS ABI of target."), _("\
+Show OS ABI of target."), NULL,
+                       set_osabi,
+                       show_osabi,
+                       &setlist, &showlist);
   user_osabi_state = osabi_auto;
 }
This page took 0.026149 seconds and 4 git commands to generate.