GDB (API)
/home/stan/gdb/src/gdb/osabi.c
Go to the documentation of this file.
00001 /* OS ABI variant handling for GDB.
00002 
00003    Copyright (C) 2001-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #include "defs.h"
00021 
00022 #include "gdb_assert.h"
00023 #include "gdb_string.h"
00024 
00025 #include "osabi.h"
00026 #include "arch-utils.h"
00027 #include "gdbcmd.h"
00028 #include "command.h"
00029 
00030 #include "elf-bfd.h"
00031 
00032 #ifndef GDB_OSABI_DEFAULT
00033 #define GDB_OSABI_DEFAULT GDB_OSABI_UNKNOWN
00034 #endif
00035 
00036 /* State for the "set osabi" command.  */
00037 static enum { osabi_auto, osabi_default, osabi_user } user_osabi_state;
00038 static enum gdb_osabi user_selected_osabi;
00039 static const char *gdb_osabi_available_names[GDB_OSABI_INVALID + 3] = {
00040   "auto",
00041   "default",
00042   "none",
00043   NULL
00044 };
00045 static const char *set_osabi_string;
00046 
00047 /* This table matches the indices assigned to enum gdb_osabi.  Keep
00048    them in sync.  */
00049 static const char * const gdb_osabi_names[] =
00050 {
00051   "none",
00052 
00053   "SVR4",
00054   "GNU/Hurd",
00055   "Solaris",
00056   "OSF/1",
00057   "GNU/Linux",
00058   "FreeBSD a.out",
00059   "FreeBSD ELF",
00060   "NetBSD a.out",
00061   "NetBSD ELF",
00062   "OpenBSD ELF",
00063   "Windows CE",
00064   "DJGPP",
00065   "Irix",
00066   "HP/UX ELF",
00067   "HP/UX SOM",
00068   "QNX Neutrino",
00069   "Cygwin",
00070   "AIX",
00071   "DICOS",
00072   "Darwin",
00073   "Symbian",
00074   "OpenVMS",
00075   "LynxOS178",
00076   "Newlib",
00077 
00078   "<invalid>"
00079 };
00080 
00081 const char *
00082 gdbarch_osabi_name (enum gdb_osabi osabi)
00083 {
00084   if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
00085     return gdb_osabi_names[osabi];
00086 
00087   return gdb_osabi_names[GDB_OSABI_INVALID];
00088 }
00089 
00090 /* Lookup the OS ABI corresponding to the specified target description
00091    string.  */
00092 
00093 enum gdb_osabi
00094 osabi_from_tdesc_string (const char *name)
00095 {
00096   int i;
00097 
00098   for (i = 0; i < ARRAY_SIZE (gdb_osabi_names); i++)
00099     if (strcmp (name, gdb_osabi_names[i]) == 0)
00100       {
00101         /* See note above: the name table matches the indices assigned
00102            to enum gdb_osabi.  */
00103         enum gdb_osabi osabi = (enum gdb_osabi) i;
00104 
00105         if (osabi == GDB_OSABI_INVALID)
00106           return GDB_OSABI_UNKNOWN;
00107         else
00108           return osabi;
00109       }
00110 
00111   return GDB_OSABI_UNKNOWN;
00112 }
00113 
00114 /* Handler for a given architecture/OS ABI pair.  There should be only
00115    one handler for a given OS ABI each architecture family.  */
00116 struct gdb_osabi_handler  
00117 {
00118   struct gdb_osabi_handler *next;
00119   const struct bfd_arch_info *arch_info;
00120   enum gdb_osabi osabi;
00121   void (*init_osabi)(struct gdbarch_info, struct gdbarch *);
00122 };
00123 
00124 static struct gdb_osabi_handler *gdb_osabi_handler_list;
00125 
00126 void
00127 gdbarch_register_osabi (enum bfd_architecture arch, unsigned long machine,
00128                         enum gdb_osabi osabi,
00129                         void (*init_osabi)(struct gdbarch_info,
00130                                            struct gdbarch *))
00131 {
00132   struct gdb_osabi_handler **handler_p;
00133   const struct bfd_arch_info *arch_info = bfd_lookup_arch (arch, machine);
00134   const char **name_ptr;
00135 
00136   /* Registering an OS ABI handler for "unknown" is not allowed.  */
00137   if (osabi == GDB_OSABI_UNKNOWN)
00138     {
00139       internal_error
00140         (__FILE__, __LINE__,
00141          _("gdbarch_register_osabi: An attempt to register a handler for "
00142          "OS ABI \"%s\" for architecture %s was made.  The handler will "
00143          "not be registered"),
00144          gdbarch_osabi_name (osabi),
00145          bfd_printable_arch_mach (arch, machine));
00146       return;
00147     }
00148 
00149   gdb_assert (arch_info);
00150 
00151   for (handler_p = &gdb_osabi_handler_list; *handler_p != NULL;
00152        handler_p = &(*handler_p)->next)
00153     {
00154       if ((*handler_p)->arch_info == arch_info
00155           && (*handler_p)->osabi == osabi)
00156         {
00157           internal_error
00158             (__FILE__, __LINE__,
00159              _("gdbarch_register_osabi: A handler for OS ABI \"%s\" "
00160              "has already been registered for architecture %s"),
00161              gdbarch_osabi_name (osabi),
00162              arch_info->printable_name);
00163           /* If user wants to continue, override previous definition.  */
00164           (*handler_p)->init_osabi = init_osabi;
00165           return;
00166         }
00167     }
00168 
00169   (*handler_p)
00170     = (struct gdb_osabi_handler *) xmalloc (sizeof (struct gdb_osabi_handler));
00171   (*handler_p)->next = NULL;
00172   (*handler_p)->arch_info = arch_info;
00173   (*handler_p)->osabi = osabi;
00174   (*handler_p)->init_osabi = init_osabi;
00175 
00176   /* Add this OS ABI to the list of enum values for "set osabi", if it isn't
00177      already there.  */
00178   for (name_ptr = gdb_osabi_available_names; *name_ptr; name_ptr ++)
00179     {
00180       if (*name_ptr == gdbarch_osabi_name (osabi))
00181         return;
00182     }
00183   *name_ptr++ = gdbarch_osabi_name (osabi);
00184   *name_ptr = NULL;
00185 }
00186 
00187 
00188 /* Sniffer to find the OS ABI for a given file's architecture and flavour.
00189    It is legal to have multiple sniffers for each arch/flavour pair, to
00190    disambiguate one OS's a.out from another, for example.  The first sniffer
00191    to return something other than GDB_OSABI_UNKNOWN wins, so a sniffer should
00192    be careful to claim a file only if it knows for sure what it is.  */
00193 struct gdb_osabi_sniffer
00194 {
00195   struct gdb_osabi_sniffer *next;
00196   enum bfd_architecture arch;   /* bfd_arch_unknown == wildcard */
00197   enum bfd_flavour flavour;
00198   enum gdb_osabi (*sniffer)(bfd *);
00199 };
00200 
00201 static struct gdb_osabi_sniffer *gdb_osabi_sniffer_list;
00202 
00203 void
00204 gdbarch_register_osabi_sniffer (enum bfd_architecture arch,
00205                                 enum bfd_flavour flavour,
00206                                 enum gdb_osabi (*sniffer_fn)(bfd *))
00207 {
00208   struct gdb_osabi_sniffer *sniffer;
00209 
00210   sniffer =
00211     (struct gdb_osabi_sniffer *) xmalloc (sizeof (struct gdb_osabi_sniffer));
00212   sniffer->arch = arch;
00213   sniffer->flavour = flavour;
00214   sniffer->sniffer = sniffer_fn;
00215 
00216   sniffer->next = gdb_osabi_sniffer_list;
00217   gdb_osabi_sniffer_list = sniffer;
00218 }
00219 
00220 
00221 enum gdb_osabi
00222 gdbarch_lookup_osabi (bfd *abfd)
00223 {
00224   struct gdb_osabi_sniffer *sniffer;
00225   enum gdb_osabi osabi, match;
00226   int match_specific;
00227 
00228   /* If we aren't in "auto" mode, return the specified OS ABI.  */
00229   if (user_osabi_state == osabi_user)
00230     return user_selected_osabi;
00231 
00232   /* If we don't have a binary, just return unknown.  The caller may
00233      have other sources the OSABI can be extracted from, e.g., the
00234      target description.  */
00235   if (abfd == NULL) 
00236     return GDB_OSABI_UNKNOWN;
00237 
00238   match = GDB_OSABI_UNKNOWN;
00239   match_specific = 0;
00240 
00241   for (sniffer = gdb_osabi_sniffer_list; sniffer != NULL;
00242        sniffer = sniffer->next)
00243     {
00244       if ((sniffer->arch == bfd_arch_unknown /* wildcard */
00245            || sniffer->arch == bfd_get_arch (abfd))
00246           && sniffer->flavour == bfd_get_flavour (abfd))
00247         {
00248           osabi = (*sniffer->sniffer) (abfd);
00249           if (osabi < GDB_OSABI_UNKNOWN || osabi >= GDB_OSABI_INVALID)
00250             {
00251               internal_error
00252                 (__FILE__, __LINE__,
00253                  _("gdbarch_lookup_osabi: invalid OS ABI (%d) from sniffer "
00254                  "for architecture %s flavour %d"),
00255                  (int) osabi,
00256                  bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
00257                  (int) bfd_get_flavour (abfd));
00258             }
00259           else if (osabi != GDB_OSABI_UNKNOWN)
00260             {
00261               /* A specific sniffer always overrides a generic sniffer.
00262                  Croak on multiple match if the two matches are of the
00263                  same class.  If the user wishes to continue, we'll use
00264                  the first match.  */
00265               if (match != GDB_OSABI_UNKNOWN)
00266                 {
00267                   if ((match_specific && sniffer->arch != bfd_arch_unknown)
00268                    || (!match_specific && sniffer->arch == bfd_arch_unknown))
00269                     {
00270                       internal_error
00271                         (__FILE__, __LINE__,
00272                          _("gdbarch_lookup_osabi: multiple %sspecific OS ABI "
00273                          "match for architecture %s flavour %d: first "
00274                          "match \"%s\", second match \"%s\""),
00275                          match_specific ? "" : "non-",
00276                          bfd_printable_arch_mach (bfd_get_arch (abfd), 0),
00277                          (int) bfd_get_flavour (abfd),
00278                          gdbarch_osabi_name (match),
00279                          gdbarch_osabi_name (osabi));
00280                     }
00281                   else if (sniffer->arch != bfd_arch_unknown)
00282                     {
00283                       match = osabi;
00284                       match_specific = 1;
00285                     }
00286                 }
00287               else
00288                 {
00289                   match = osabi;
00290                   if (sniffer->arch != bfd_arch_unknown)
00291                     match_specific = 1;
00292                 }
00293             }
00294         }
00295     }
00296 
00297   return match;
00298 }
00299 
00300 
00301 /* Return non-zero if architecture A can run code written for
00302    architecture B.  */
00303 static int
00304 can_run_code_for (const struct bfd_arch_info *a, const struct bfd_arch_info *b)
00305 {
00306   /* BFD's 'A->compatible (A, B)' functions return zero if A and B are
00307      incompatible.  But if they are compatible, it returns the 'more
00308      featureful' of the two arches.  That is, if A can run code
00309      written for B, but B can't run code written for A, then it'll
00310      return A.
00311 
00312      struct bfd_arch_info objects are singletons: that is, there's
00313      supposed to be exactly one instance for a given machine.  So you
00314      can tell whether two are equivalent by comparing pointers.  */
00315   return (a == b || a->compatible (a, b) == a);
00316 }
00317 
00318 
00319 void
00320 gdbarch_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
00321 {
00322   struct gdb_osabi_handler *handler;
00323 
00324   if (info.osabi == GDB_OSABI_UNKNOWN)
00325     {
00326       /* Don't complain about an unknown OSABI.  Assume the user knows
00327          what they are doing.  */
00328       return;
00329     }
00330 
00331   for (handler = gdb_osabi_handler_list; handler != NULL;
00332        handler = handler->next)
00333     {
00334       if (handler->osabi != info.osabi)
00335         continue;
00336 
00337       /* If the architecture described by ARCH_INFO can run code for
00338          the architcture we registered the handler for, then the
00339          handler is applicable.  Note, though, that if the handler is
00340          for an architecture that is a superset of ARCH_INFO, we can't
00341          use that --- it would be perfectly correct for it to install
00342          gdbarch methods that refer to registers / instructions /
00343          other facilities ARCH_INFO doesn't have.
00344 
00345          NOTE: kettenis/20021027: There may be more than one machine
00346          type that is compatible with the desired machine type.  Right
00347          now we simply return the first match, which is fine for now.
00348          However, we might want to do something smarter in the future.  */
00349       /* NOTE: cagney/2003-10-23: The code for "a can_run_code_for b"
00350          is implemented using BFD's compatible method (a->compatible
00351          (b) == a -- the lowest common denominator between a and b is
00352          a).  That method's definition of compatible may not be as you
00353          expect.  For instance the test "amd64 can run code for i386"
00354          (or more generally "64-bit ISA can run code for the 32-bit
00355          ISA").  BFD doesn't normally consider 32-bit and 64-bit
00356          "compatible" so it doesn't succeed.  */
00357       if (can_run_code_for (info.bfd_arch_info, handler->arch_info))
00358         {
00359           (*handler->init_osabi) (info, gdbarch);
00360           return;
00361         }
00362     }
00363 
00364   warning
00365     ("A handler for the OS ABI \"%s\" is not built into this configuration\n"
00366      "of GDB.  Attempting to continue with the default %s settings.\n",
00367      gdbarch_osabi_name (info.osabi),
00368      info.bfd_arch_info->printable_name);
00369 }
00370 
00371 /* Limit on the amount of data to be read.  */
00372 #define MAX_NOTESZ      128
00373 
00374 /* Return non-zero if NOTE matches NAME, DESCSZ and TYPE.  If
00375    *SECTSIZE is non-zero, then this reads that many bytes from
00376    the start of the section and clears *SECTSIZE.  */
00377 
00378 static int
00379 check_note (bfd *abfd, asection *sect, char *note, unsigned int *sectsize,
00380             const char *name, unsigned long descsz, unsigned long type)
00381 {
00382   unsigned long notesz;
00383 
00384   if (*sectsize)
00385     {
00386       if (!bfd_get_section_contents (abfd, sect, note, 0, *sectsize))
00387         return 0;
00388       *sectsize = 0;
00389     }
00390 
00391   /* Calculate the size of this note.  */
00392   notesz = strlen (name) + 1;
00393   notesz = ((notesz + 3) & ~3);
00394   notesz += descsz;
00395   notesz = ((notesz + 3) & ~3);
00396 
00397   /* If this assertion triggers, increase MAX_NOTESZ.  */
00398   gdb_assert (notesz <= MAX_NOTESZ);
00399 
00400   /* Check whether SECT is big enough to comtain the complete note.  */
00401   if (notesz > bfd_section_size (abfd, sect))
00402     return 0;
00403 
00404   /* Check the note name.  */
00405   if (bfd_h_get_32 (abfd, note) != (strlen (name) + 1)
00406       || strcmp (note + 12, name) != 0)
00407     return 0;
00408 
00409   /* Check the descriptor size.  */
00410   if (bfd_h_get_32 (abfd, note + 4) != descsz)
00411     return 0;
00412 
00413   /* Check the note type.  */
00414   if (bfd_h_get_32 (abfd, note + 8) != type)
00415     return 0;
00416 
00417   return 1;
00418 }
00419 
00420 /* Generic sniffer for ELF flavoured files.  */
00421 
00422 void
00423 generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect, void *obj)
00424 {
00425   enum gdb_osabi *osabi = obj;
00426   const char *name;
00427   unsigned int sectsize;
00428   char *note;
00429 
00430   name = bfd_get_section_name (abfd, sect);
00431   sectsize = bfd_section_size (abfd, sect);
00432 
00433   /* Limit the amount of data to read.  */
00434   if (sectsize > MAX_NOTESZ)
00435     sectsize = MAX_NOTESZ;
00436 
00437   /* We lazily read the section data here.  Since we use
00438      BFD_DECOMPRESS, we can't use bfd_get_section_contents on a
00439      compressed section.  But, since note sections are not compressed,
00440      deferring the reading until we recognize the section avoids any
00441      error.  */
00442   note = alloca (sectsize);
00443 
00444   /* .note.ABI-tag notes, used by GNU/Linux and FreeBSD.  */
00445   if (strcmp (name, ".note.ABI-tag") == 0)
00446     {
00447       /* GNU.  */
00448       if (check_note (abfd, sect, note, &sectsize, "GNU", 16, NT_GNU_ABI_TAG))
00449         {
00450           unsigned int abi_tag = bfd_h_get_32 (abfd, note + 16);
00451 
00452           switch (abi_tag)
00453             {
00454             case GNU_ABI_TAG_LINUX:
00455               *osabi = GDB_OSABI_LINUX;
00456               break;
00457 
00458             case GNU_ABI_TAG_HURD:
00459               *osabi = GDB_OSABI_HURD;
00460               break;
00461 
00462             case GNU_ABI_TAG_SOLARIS:
00463               *osabi = GDB_OSABI_SOLARIS;
00464               break;
00465 
00466             case GNU_ABI_TAG_FREEBSD:
00467               *osabi = GDB_OSABI_FREEBSD_ELF;
00468               break;
00469 
00470             case GNU_ABI_TAG_NETBSD:
00471               *osabi = GDB_OSABI_NETBSD_ELF;
00472               break;
00473 
00474             default:
00475               internal_error (__FILE__, __LINE__,
00476                               _("generic_elf_osabi_sniff_abi_tag_sections: "
00477                                 "unknown OS number %d"),
00478                               abi_tag);
00479             }
00480           return;
00481         }
00482 
00483       /* FreeBSD.  */
00484       if (check_note (abfd, sect, note, &sectsize, "FreeBSD", 4,
00485                       NT_FREEBSD_ABI_TAG))
00486         {
00487           /* There is no need to check the version yet.  */
00488           *osabi = GDB_OSABI_FREEBSD_ELF;
00489           return;
00490         }
00491 
00492       return;
00493     }
00494       
00495   /* .note.netbsd.ident notes, used by NetBSD.  */
00496   if (strcmp (name, ".note.netbsd.ident") == 0
00497       && check_note (abfd, sect, note, &sectsize, "NetBSD", 4, NT_NETBSD_IDENT))
00498     {
00499       /* There is no need to check the version yet.  */
00500       *osabi = GDB_OSABI_NETBSD_ELF;
00501       return;
00502     }
00503 
00504   /* .note.openbsd.ident notes, used by OpenBSD.  */
00505   if (strcmp (name, ".note.openbsd.ident") == 0
00506       && check_note (abfd, sect, note, &sectsize, "OpenBSD", 4,
00507                      NT_OPENBSD_IDENT))
00508     {
00509       /* There is no need to check the version yet.  */
00510       *osabi = GDB_OSABI_OPENBSD_ELF;
00511       return;
00512     }
00513 
00514   /* .note.netbsdcore.procinfo notes, used by NetBSD.  */
00515   if (strcmp (name, ".note.netbsdcore.procinfo") == 0)
00516     {
00517       *osabi = GDB_OSABI_NETBSD_ELF;
00518       return;
00519     }
00520 }
00521 
00522 static enum gdb_osabi
00523 generic_elf_osabi_sniffer (bfd *abfd)
00524 {
00525   unsigned int elfosabi;
00526   enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
00527 
00528   elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
00529 
00530   switch (elfosabi)
00531     {
00532     case ELFOSABI_NONE:
00533     case ELFOSABI_GNU:
00534       /* When the EI_OSABI field in the ELF header is ELFOSABI_NONE
00535          (0), then the ELF structures in the file are conforming to
00536          the base specification for that machine (there are no
00537          OS-specific extensions).  In order to determine the real OS
00538          in use, we must look for OS-specific notes.
00539 
00540          The same applies for ELFOSABI_GNU: this can mean GNU/Hurd,
00541          GNU/Linux, and possibly more.  */
00542       bfd_map_over_sections (abfd,
00543                              generic_elf_osabi_sniff_abi_tag_sections,
00544                              &osabi);
00545       break;
00546 
00547     case ELFOSABI_FREEBSD:
00548       osabi = GDB_OSABI_FREEBSD_ELF;
00549       break;
00550 
00551     case ELFOSABI_NETBSD:
00552       osabi = GDB_OSABI_NETBSD_ELF;
00553       break;
00554 
00555     case ELFOSABI_SOLARIS:
00556       osabi = GDB_OSABI_SOLARIS;
00557       break;
00558 
00559     case ELFOSABI_HPUX:
00560       /* For some reason the default value for the EI_OSABI field is
00561          ELFOSABI_HPUX for all PA-RISC targets (with the exception of
00562          GNU/Linux).  We use HP-UX ELF as the default, but let any
00563          OS-specific notes override this.  */
00564       osabi = GDB_OSABI_HPUX_ELF;
00565       bfd_map_over_sections (abfd,
00566                              generic_elf_osabi_sniff_abi_tag_sections,
00567                              &osabi);
00568       break;
00569 
00570     case ELFOSABI_OPENVMS:
00571       osabi = GDB_OSABI_OPENVMS;
00572       break;
00573     }
00574 
00575   if (osabi == GDB_OSABI_UNKNOWN)
00576     {
00577       /* The FreeBSD folks have been naughty; they stored the string
00578          "FreeBSD" in the padding of the e_ident field of the ELF
00579          header to "brand" their ELF binaries in FreeBSD 3.x.  */
00580       if (memcmp (&elf_elfheader (abfd)->e_ident[8],
00581                   "FreeBSD", sizeof ("FreeBSD")) == 0)
00582         osabi = GDB_OSABI_FREEBSD_ELF;
00583     }
00584 
00585   return osabi;
00586 }
00587 
00588 static void
00589 set_osabi (char *args, int from_tty, struct cmd_list_element *c)
00590 {
00591   struct gdbarch_info info;
00592 
00593   if (strcmp (set_osabi_string, "auto") == 0)
00594     user_osabi_state = osabi_auto;
00595   else if (strcmp (set_osabi_string, "default") == 0)
00596     {
00597       user_selected_osabi = GDB_OSABI_DEFAULT;
00598       user_osabi_state = osabi_user;
00599     }
00600   else if (strcmp (set_osabi_string, "none") == 0)
00601     {
00602       user_selected_osabi = GDB_OSABI_UNKNOWN;
00603       user_osabi_state = osabi_user;
00604     }
00605   else
00606     {
00607       int i;
00608 
00609       for (i = 1; i < GDB_OSABI_INVALID; i++)
00610         if (strcmp (set_osabi_string, gdbarch_osabi_name (i)) == 0)
00611           {
00612             user_selected_osabi = i;
00613             user_osabi_state = osabi_user;
00614             break;
00615           }
00616       if (i == GDB_OSABI_INVALID)
00617         internal_error (__FILE__, __LINE__,
00618                         _("Invalid OS ABI \"%s\" passed to command handler."),
00619                         set_osabi_string);
00620     }
00621 
00622   /* NOTE: At some point (true multiple architectures) we'll need to be more
00623      graceful here.  */
00624   gdbarch_info_init (&info);
00625   if (! gdbarch_update_p (info))
00626     internal_error (__FILE__, __LINE__, _("Updating OS ABI failed."));
00627 }
00628 
00629 static void
00630 show_osabi (struct ui_file *file, int from_tty, struct cmd_list_element *c,
00631             const char *value)
00632 {
00633   if (user_osabi_state == osabi_auto)
00634     fprintf_filtered (file,
00635                       _("The current OS ABI is \"auto\" "
00636                         "(currently \"%s\").\n"),
00637                       gdbarch_osabi_name (gdbarch_osabi (get_current_arch ())));
00638   else
00639     fprintf_filtered (file, _("The current OS ABI is \"%s\".\n"),
00640                       gdbarch_osabi_name (user_selected_osabi));
00641 
00642   if (GDB_OSABI_DEFAULT != GDB_OSABI_UNKNOWN)
00643     fprintf_filtered (file, _("The default OS ABI is \"%s\".\n"),
00644                       gdbarch_osabi_name (GDB_OSABI_DEFAULT));
00645 }
00646 
00647 extern initialize_file_ftype _initialize_gdb_osabi; /* -Wmissing-prototype */
00648 
00649 void
00650 _initialize_gdb_osabi (void)
00651 {
00652   if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID], "<invalid>") != 0)
00653     internal_error
00654       (__FILE__, __LINE__,
00655        _("_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"));
00656 
00657   /* Register a generic sniffer for ELF flavoured files.  */
00658   gdbarch_register_osabi_sniffer (bfd_arch_unknown,
00659                                   bfd_target_elf_flavour,
00660                                   generic_elf_osabi_sniffer);
00661 
00662   /* Register the "set osabi" command.  */
00663   add_setshow_enum_cmd ("osabi", class_support, gdb_osabi_available_names,
00664                         &set_osabi_string,
00665                         _("Set OS ABI of target."),
00666                         _("Show OS ABI of target."),
00667                         NULL, set_osabi, show_osabi,
00668                         &setlist, &showlist);
00669   user_osabi_state = osabi_auto;
00670 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines