From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15836 invoked by alias); 15 Aug 2002 21:19:55 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 15755 invoked from network); 15 Aug 2002 21:19:49 -0000 Received: from unknown (HELO zebra.siol.net) (193.189.160.16) by sources.redhat.com with SMTP; 15 Aug 2002 21:19:49 -0000 Received: from BSN-77-133-192.dsl.siol.net ([193.77.133.192]) by zebra.siol.net (InterMail vK.4.03.05.03 201-232-132-103 license 5ac1ec526f2360901e54ffce7671dc4c) with ESMTP id <20020815211752.GYVO28512.zebra@BSN-77-133-192.dsl.siol.net> for ; Thu, 15 Aug 2002 23:17:52 +0200 Subject: [PATCH] set osabi command From: Simon Posnjak To: gdb-patches@sources.redhat.com Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Thu, 15 Aug 2002 14:19:00 -0000 Message-Id: <1029446386.30623.13.camel@klada.dyndns.org> Mime-Version: 1.0 X-SW-Source: 2002-08/txt/msg00381.txt.bz2 Hi, This patch adds a set osabi command that it used to override the automatic osabi detection. This is needed for some libary that don't provide the .note.ABI-tag and the auto detection fails. Regards Simon --- /tmp/gdb+dejagnu-20020813/gdb/osabi.c Sat Jul 27 03:28:43 2002 +++ osabi.c Thu Aug 15 16:21:23 2002 @@ -20,6 +20,9 @@ #include "defs.h" #include "osabi.h" +#include "command.h" +#include "gdbcmd.h" +#include "completer.h" #include "elf-bfd.h" @@ -52,6 +55,48 @@ "" }; +static char *osabi_set_val = NULL; + +enum gdb_osabi +gdbarch_osabi_var_set () +{ + if (strcmp(osabi_set_val, "SVR4") == 0) + return GDB_OSABI_SVR4; + if (strcmp(osabi_set_val, "hurd") == 0) + return GDB_OSABI_HURD; + if (strcmp(osabi_set_val, "solaris") == 0) + return GDB_OSABI_SOLARIS; + if (strcmp(osabi_set_val, "OSF1") == 0) + return GDB_OSABI_OSF1; + if (strcmp(osabi_set_val, "linux") == 0) + return GDB_OSABI_LINUX; + if (strcmp(osabi_set_val, "freebsd_aout") == 0) + return GDB_OSABI_FREEBSD_AOUT; + if (strcmp(osabi_set_val, "freebsd_elf") == 0) + return GDB_OSABI_FREEBSD_ELF; + if (strcmp(osabi_set_val, "netbsd_aout") == 0) + return GDB_OSABI_NETBSD_AOUT; + if (strcmp(osabi_set_val, "netbsd_elf") == 0) + return GDB_OSABI_NETBSD_ELF; + if (strcmp(osabi_set_val, "wince") == 0) + return GDB_OSABI_WINCE; + if (strcmp(osabi_set_val, "go32") == 0) + return GDB_OSABI_GO32; + if (strcmp(osabi_set_val, "netware") == 0) + return GDB_OSABI_NETWARE; + if (strcmp(osabi_set_val, "irix") == 0) + return GDB_OSABI_IRIX; + if (strcmp(osabi_set_val, "lynxos") == 0) + return GDB_OSABI_LYNXOS; + if (strcmp(osabi_set_val, "arm_eabi_v1") == 0) + return GDB_OSABI_ARM_EABI_V1; + if (strcmp(osabi_set_val, "arm_eabi_v2") == 0) + return GDB_OSABI_ARM_EABI_V2; + if (strcmp(osabi_set_val, "arm_apcs") == 0) + return GDB_OSABI_ARM_APCS; + return GDB_OSABI_UNKNOWN; +} + const char * gdbarch_osabi_name (enum gdb_osabi osabi) { @@ -162,7 +207,13 @@ match = GDB_OSABI_UNKNOWN; match_specific = 0; - + + if (osabi_set_val != NULL) { + match = gdbarch_osabi_var_set(); + if (match != GDB_OSABI_UNKNOWN) + return match; + } + for (sniffer = gdb_osabi_sniffer_list; sniffer != NULL; sniffer = sniffer->next) { @@ -373,7 +424,13 @@ { unsigned int elfosabi; enum gdb_osabi osabi = GDB_OSABI_UNKNOWN; - + + if (osabi_set_val != NULL) { + osabi = gdbarch_osabi_var_set(); + if (osabi != GDB_OSABI_UNKNOWN) + return osabi; + } + elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI]; switch (elfosabi) @@ -425,13 +482,24 @@ void _initialize_gdb_osabi (void) { + struct cmd_list_element *c; + if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID], "") != 0) internal_error (__FILE__, __LINE__, "_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"); + c = add_set_cmd ("osabi", class_support, var_string, + (char *) &osabi_set_val, "Set the osabi. Posible targets are: linux, + hurd, irix, freebsd_aout, freebsd_elf, netbsd_aout, netbsd_aout, + netbsd_elf, OSF1, SVR4, solaris, wince, netware, go32, arm_apcs, + arm_eabi_v1, arm_eabi_v2, lynxos", &setlist); + add_show_from_set (c, &showlist); + set_cmd_completer (c, filename_completer); + /* Register a generic sniffer for ELF flavoured files. */ gdbarch_register_osabi_sniffer (bfd_arch_unknown, bfd_target_elf_flavour, generic_elf_osabi_sniffer); + } -- Simon Posnjak http://klada.dyndns.org