summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog15
-rw-r--r--gdb/Makefile.in4
-rw-r--r--gdb/configure.tgt13
-rw-r--r--gdb/defs.h1
-rw-r--r--gdb/i386-dicos-tdep.c115
-rw-r--r--gdb/osabi.c1
6 files changed, 149 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b45350a97de..5efa58ed6f2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,20 @@
2008-05-01 Pedro Alves <pedro@codesourcery.com>
+ * configure.tgt: Add i[34567]86-*-dicos* and x86_64-*-dicos*.
+ (i[34567]86-*-dicos*, x86_64-*-dicos*):
+ Set gdb_osabi to GDB_OSABI_DICOS.
+
+ * defs.h (enum gdb_osabi): Add GDB_OSABI_DICOS.
+ * osabi.c (gdb_osabi_name): Add "DICOS".
+
+ * i386-dicos-tdep.c: New file.
+
+ * Makefile.in (ALL_TARGET_OBS): Add i386-dicos-tdep.o.
+ (ALLDEPFILES): Add i386-dicos-tdep.c.
+ (i386-dicos-tdep.o): New rule.
+
+2008-05-01 Pedro Alves <pedro@codesourcery.com>
+
* linux-nat.c (linux_nat_switch_fork): Reinit GDB's thread list
and register the fork's PTID as a thread.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index a98351cd4cc..2000a0a8cb3 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -464,6 +464,7 @@ ALL_TARGET_OBS = \
i386bsd-tdep.o i386-cygwin-tdep.o i386fbsd-tdep.o i386gnu-tdep.o \
i386-linux-tdep.o i386nbsd-tdep.o i386-nto-tdep.o i386obsd-tdep.o \
i386-sol2-tdep.o i386-tdep.o i387-tdep.o \
+ i386-dicos-tdep.o \
iq2000-tdep.o \
m32c-tdep.o \
m32r-linux-tdep.o m32r-tdep.o \
@@ -1572,6 +1573,7 @@ ALLDEPFILES = \
i386bsd-nat.c i386bsd-tdep.c i386fbsd-nat.c i386fbsd-tdep.c \
i386nbsd-nat.c i386nbsd-tdep.c i386obsd-nat.c i386obsd-tdep.c \
i387-tdep.c \
+ i386-dicos-tdep.c \
i386-linux-tdep.c i386-nat.c \
i386-sol2-nat.c i386-sol2-tdep.c \
i386gnu-nat.c i386gnu-tdep.c \
@@ -2235,6 +2237,8 @@ i386bsd-tdep.o: i386bsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
i386-cygwin-tdep.o: i386-cygwin-tdep.c $(defs_h) $(osabi_h) $(gdb_string_h) \
$(i386_tdep_h) $(regset_h) $(gdb_obstack_h) $(xml_support_h) \
$(gdbcore_h) $(solib_h) $(solib_target_h) $(i386_cygwin_tdep_h)
+i386-dicos-tdep.o: i386-dicos-tdep.c $(defs_h) $(osabi_h) $(gdb_string_h) \
+ $(solib_h) $(solib_target_h)
i386fbsd-nat.o: i386fbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
$(target_h) $(fbsd_nat_h) $(i386_tdep_h) $(i386bsd_nat_h) \
$(bsd_kvm_h)
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 36ac71e4118..3b965fc79d4 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -145,6 +145,12 @@ hppa*-*-*)
gdb_target_obs="hppa-tdep.o"
;;
+i[34567]86-*-dicos*)
+ # Target: DICOS/i386
+ gdb_target_obs="i386-tdep.o i387-tdep.o \
+ i386-dicos-tdep.o \
+ corelow.o solib.o solib-target.o"
+ ;;
i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
# Target: FreeBSD/i386
gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
@@ -491,6 +497,12 @@ vax-*-*)
gdb_target_obs="vax-tdep.o"
;;
+x86_64-*-dicos*)
+ # Target: DICOS/x86-64
+ gdb_target_obs="amd64-tdep.o i386-tdep.o i387-tdep.o \
+ i386-dicos-tdep.o \
+ corelow.o solib.o solib-target.o"
+ ;;
x86_64-*-linux*)
# Target: GNU/Linux x86-64
gdb_target_obs="amd64-tdep.o amd64-linux-tdep.o i386-tdep.o \
@@ -542,4 +554,5 @@ m68*-*-openbsd* | m88*-*-openbsd* | vax-*-openbsd*) ;;
*-*-mingw32ce*) gdb_osabi=GDB_OSABI_WINCE ;;
*-*-mingw* | *-*-cygwin*)
gdb_osabi=GDB_OSABI_CYGWIN ;;
+*-*-dicos*) gdb_osabi=GDB_OSABI_DICOS ;;
esac
diff --git a/gdb/defs.h b/gdb/defs.h
index 2af40ab3dcd..0fa0e6c02c0 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -924,6 +924,7 @@ enum gdb_osabi
GDB_OSABI_CYGWIN,
GDB_OSABI_AIX,
+ GDB_OSABI_DICOS,
GDB_OSABI_INVALID /* keep this last */
};
diff --git a/gdb/i386-dicos-tdep.c b/gdb/i386-dicos-tdep.c
new file mode 100644
index 00000000000..e92313ad562
--- /dev/null
+++ b/gdb/i386-dicos-tdep.c
@@ -0,0 +1,115 @@
+/* Target-dependent code for DICOS running on i386's, for GDB.
+
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "defs.h"
+#include "osabi.h"
+#include "gdb_string.h"
+#include "solib.h"
+#include "solib-target.h"
+
+static void
+i386_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ set_solib_ops (gdbarch, &solib_target_so_ops);
+}
+
+/* Look in the elf symbol table of ABFD for a symbol named WANTED.
+ Return true if found. */
+static int
+i386_dicos_bfd_has_symbol_p (bfd *abfd, const char *wanted)
+{
+ long storage_needed;
+ int ret = 0;
+ asymbol **symbol_table = NULL;
+
+ storage_needed = bfd_get_symtab_upper_bound (abfd);
+ if (storage_needed < 0)
+ {
+ warning (_("Can't read elf symbols from %s: %s"), bfd_get_filename (abfd),
+ bfd_errmsg (bfd_get_error ()));
+ return 0;
+ }
+
+ if (storage_needed > 0)
+ {
+ long i, symcount;
+
+ symbol_table = xmalloc (storage_needed);
+ symcount = bfd_canonicalize_symtab (abfd, symbol_table);
+
+ if (symcount < 0)
+ warning (_("Can't read elf symbols from %s: %s"),
+ bfd_get_filename (abfd),
+ bfd_errmsg (bfd_get_error ()));
+ else
+ {
+ for (i = 0; i < symcount; i++)
+ {
+ asymbol *sym = symbol_table[i];
+ if (sym->name != NULL
+ && wanted[0] == sym->name[0]
+ && strcmp (wanted + 1, sym->name + 1) == 0)
+ {
+ ret = 1;
+ break;
+ }
+ }
+ }
+ }
+
+ xfree (symbol_table);
+ return ret;
+}
+
+static enum gdb_osabi
+i386_dicos_osabi_sniffer (bfd *abfd)
+{
+ char *target_name = bfd_get_target (abfd);
+
+ /* DICOS debug info files don't have a .note.ABI-tag marker or
+ something similar. We do know there's always a "header" section
+ of 36 bytes, and there's always a "Dicos_loadModuleInfo" symbol
+ defined. Look for the section first, as that should be
+ cheaper. */
+ if (strcmp (target_name, "elf32-i386") == 0)
+ {
+ asection *section = bfd_get_section_by_name (abfd, "header");
+ if (section
+ && bfd_section_size (abfd, section) == 36
+ && i386_dicos_bfd_has_symbol_p (abfd, "Dicos_loadModuleInfo"))
+ return GDB_OSABI_DICOS;
+ }
+
+ return GDB_OSABI_UNKNOWN;
+}
+
+/* Provide a prototype to silence -Wmissing-prototypes. */
+void _initialize_i386_dicos_tdep (void);
+
+void
+_initialize_i386_dicos_tdep (void)
+{
+ gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
+ i386_dicos_osabi_sniffer);
+
+ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_DICOS,
+ i386_dicos_init_abi);
+}
diff --git a/gdb/osabi.c b/gdb/osabi.c
index 04236fc2de4..64f091002f7 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -72,6 +72,7 @@ static const char * const gdb_osabi_names[] =
"Cygwin",
"AIX",
+ "DICOS",
"<invalid>"
};