This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] set osabi command
- From: Simon Posnjak <simon dot posnjak at siol dot net>
- To: gdb-patches at sources dot redhat dot com
- Date: 15 Aug 2002 23:19:45 +0200
- Subject: [PATCH] set osabi command
Hi,
This patch adds a set osabi <which> 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 @@
"<invalid>"
};
+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], "<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