This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Add support for Dicos on x86-64.


Hi guys,

I'm checking in this change to add support for debugging DICOS
running on x86-64.  I'm moving the common non-architecture specific
code into a new dicos-tdep.c file in the process.

I'm applying the NEWS change under the obvious rule.

-- 
Pedro Alves
2009-02-17  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* Makefile.in (ALL_TARGET_OBS): Add dicos-tdep.o.
	(ALLDEPFILES): Add dicos-tdep.c.
	* configure.tgt (i[34567]86-*-dicos*): Add dicos-tdep.o to
	gdb_target_obs.
	(x86_64-*-dicos*): Add dicos-tdep.o and amd64-dicos-tdep.o to
	gdb_target_obs.
	* dicos-tdep.h, dicos-tdep.c: New.
	* amd64-dicos-tdep.c: New.
	* i386-dicos-tdep.c: Don't include solib.h, solib-target.h or
	inferior.h.  Include dicos-tdep.h.
	(i386_dicos_init_abi): Call dicos_init_abi.
	(i386_dicos_bfd_has_symbol_p): Delete.
	(i386_dicos_osabi_sniffer): Use dicos_load_module_p.

	* NEWS: Mention x86-64 DICOS target support.

---
 gdb/Makefile.in        |    9 ++-
 gdb/NEWS               |    1 
 gdb/amd64-dicos-tdep.c |   82 +++++++++++++++++++++++++++++++++++
 gdb/configure.tgt      |    4 -
 gdb/dicos-tdep.c       |  113 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/dicos-tdep.h       |   26 +++++++++++
 gdb/i386-dicos-tdep.c  |   83 ++---------------------------------
 7 files changed, 236 insertions(+), 82 deletions(-)

Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2009-02-06 23:43:10.000000000 +0000
+++ src/gdb/Makefile.in	2009-02-17 16:43:00.000000000 +0000
@@ -461,8 +461,8 @@ TARGET_OBS = @TARGET_OBS@
 ALL_64_TARGET_OBS = \
 	alphabsd-tdep.o alphafbsd-tdep.o alpha-linux-tdep.o alpha-mdebug-tdep.o \
 	alphanbsd-tdep.o alphaobsd-tdep.o alpha-osf1-tdep.o alpha-tdep.o \
-	amd64fbsd-tdep.o amd64-linux-tdep.o amd64nbsd-tdep.o amd64obsd-tdep.o \
-	amd64-sol2-tdep.o amd64-tdep.o \
+	amd64fbsd-tdep.o amd64-dicos-tdep.o amd64-linux-tdep.o amd64nbsd-tdep.o \
+	amd64obsd-tdep.o amd64-sol2-tdep.o amd64-tdep.o \
 	ia64-linux-tdep.o ia64-tdep.o \
 	mips64obsd-tdep.o \
 	sparc64fbsd-tdep.o sparc64-linux-tdep.o sparc64nbsd-tdep.o \
@@ -474,6 +474,7 @@ ALL_TARGET_OBS = \
 	arm-tdep.o arm-wince-tdep.o \
 	avr-tdep.o \
 	cris-tdep.o \
+	dicos-tdep.o \
 	frv-linux-tdep.o frv-tdep.o \
 	h8300-tdep.o \
 	hppabsd-tdep.o hppanbsd-tdep.o hppaobsd-tdep.o \
@@ -1271,6 +1272,7 @@ ALLDEPFILES = \
 	amd64bsd-nat.c amd64fbsd-nat.c amd64fbsd-tdep.c \
 	amd64nbsd-nat.c amd64nbsd-tdep.c \
 	amd64obsd-nat.c amd64obsd-tdep.c \
+	amd64-dicos-tdep.c \
 	amd64-linux-nat.c amd64-linux-tdep.c \
 	amd64-sol2-tdep.c \
 	arm-linux-nat.c arm-linux-tdep.c arm-tdep.c \
@@ -1278,7 +1280,8 @@ ALLDEPFILES = \
 	avr-tdep.c \
 	bsd-uthread.c bsd-kvm.c \
 	core-regset.c corelow.c \
-	dcache.c exec.c \
+	dcache.c dicos-tdep.c \
+	exec.c \
 	fbsd-nat.c \
 	fork-child.c \
 	glibc-tdep.c \
Index: src/gdb/amd64-dicos-tdep.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/amd64-dicos-tdep.c	2009-02-17 16:48:22.000000000 +0000
@@ -0,0 +1,82 @@
+/* Target-dependent code for DICOS running on x86-64's, for GDB.
+
+   Copyright (C) 2009 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 "amd64-tdep.h"
+#include "dicos-tdep.h"
+
+static CORE_ADDR
+amd64_dicos_push_dummy_code (struct gdbarch *gdbarch,
+			     CORE_ADDR sp, CORE_ADDR funaddr,
+			     struct value **args, int nargs,
+			     struct type *value_type,
+			     CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+			     struct regcache *regcache)
+{
+  int bplen;
+  CORE_ADDR bppc = sp;
+
+  gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen);
+  *bp_addr = sp - bplen;
+  *real_pc = funaddr;
+
+  return *bp_addr;
+}
+
+static void
+amd64_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  amd64_init_abi (info, gdbarch);
+
+  dicos_init_abi (gdbarch);
+
+  set_gdbarch_push_dummy_code (gdbarch, amd64_dicos_push_dummy_code);
+}
+
+static enum gdb_osabi
+amd64_dicos_osabi_sniffer (bfd *abfd)
+{
+  char *target_name = bfd_get_target (abfd);
+
+  /* On amd64-DICOS, the Load Module's "header" section is 72
+     bytes.  */
+  if (strcmp (target_name, "elf64-x86-64") == 0
+      && dicos_load_module_p (abfd, 72))
+    return GDB_OSABI_DICOS;
+
+  return GDB_OSABI_UNKNOWN;
+}
+
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+void _initialize_amd64_dicos_tdep (void);
+
+void
+_initialize_amd64_dicos_tdep (void)
+{
+  gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
+				  amd64_dicos_osabi_sniffer);
+
+  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
+			  GDB_OSABI_DICOS,
+			  amd64_dicos_init_abi);
+}
Index: src/gdb/configure.tgt
===================================================================
--- src.orig/gdb/configure.tgt	2009-02-06 23:43:10.000000000 +0000
+++ src/gdb/configure.tgt	2009-02-17 16:40:31.000000000 +0000
@@ -153,7 +153,7 @@ i[34567]86-*-darwin*)
 i[34567]86-*-dicos*)
 	# Target: DICOS/i386
 	gdb_target_obs="i386-tdep.o i387-tdep.o \
-			i386-dicos-tdep.o \
+			dicos-tdep.o i386-dicos-tdep.o \
 			corelow.o solib.o solib-target.o"
 	;;
 i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
@@ -506,7 +506,7 @@ vax-*-*)
 x86_64-*-dicos*)
 	# Target: DICOS/x86-64
 	gdb_target_obs="amd64-tdep.o i386-tdep.o i387-tdep.o \
-			i386-dicos-tdep.o \
+			dicos-tdep.o i386-dicos-tdep.o amd64-dicos-tdep.o \
 			corelow.o solib.o solib-target.o"
 	;;
 x86_64-*-linux*)
Index: src/gdb/dicos-tdep.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/dicos-tdep.c	2009-02-17 16:46:34.000000000 +0000
@@ -0,0 +1,113 @@
+/* Target-dependent, architecture-independent code for DICOS, for GDB.
+
+   Copyright (C) 2009 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"
+#include "inferior.h"
+#include "dicos-tdep.h"
+
+void
+dicos_init_abi (struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  set_solib_ops (gdbarch, &solib_target_so_ops);
+
+  /* Every process, although has its own address space, sees the same
+     list of shared libraries.  */
+  set_gdbarch_has_global_solist (gdbarch, 1);
+
+  /* There's no (standard definition of) entry point or a guaranteed
+     text location with a symbol where to place the call dummy, so we
+     put it on the stack.  */
+  set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
+
+  /* DICOS rewinds the PC itself.  */
+  set_gdbarch_decr_pc_after_break (gdbarch, 0);
+}
+
+/* Return true if ABFD is a dicos load module.  HEADER_SIZE is the
+   expected size of the "header" section in bytes.  */
+
+int
+dicos_load_module_p (bfd *abfd, int header_size)
+{
+  long storage_needed;
+  int ret = 0;
+  asymbol **symbol_table = NULL;
+  const char *symname = "Dicos_loadModuleInfo";
+  asection *section;
+
+  /* DICOS files don't have a .note.ABI-tag marker or something
+     similar.  We do know there's always a "header" section of
+     HEADER_SIZE bytes (size depends on architecture), and there's
+     always a "Dicos_loadModuleInfo" symbol defined.  Look for the
+     section first, as that should be cheaper.  */
+
+  section = bfd_get_section_by_name (abfd, "header");
+  if (!section)
+    return 0;
+
+  if (bfd_section_size (abfd, section) != header_size)
+    return 0;
+
+  /* Dicos LMs always have a "Dicos_loadModuleInfo" symbol
+     defined.  Look for it.  */
+
+  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
+		  && symname[0] == sym->name[0]
+		  && strcmp (symname + 1, sym->name + 1) == 0)
+		{
+		  ret = 1;
+		  break;
+		}
+	    }
+	}
+    }
+
+  xfree (symbol_table);
+  return ret;
+}
Index: src/gdb/dicos-tdep.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/dicos-tdep.h	2009-02-17 16:46:15.000000000 +0000
@@ -0,0 +1,26 @@
+/* Target-dependent, architecture-independent code for DICOS, for GDB.
+
+   Copyright (C) 2009 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/>.  */
+
+#ifndef DICOS_TDEP_H
+#define DICOS_TDEP_H
+
+extern void dicos_init_abi (struct gdbarch *gdbarch);
+extern int dicos_load_module_p (bfd *abfd, int header_size);
+
+#endif /* dicos-tdep.h */
Index: src/gdb/i386-dicos-tdep.c
===================================================================
--- src.orig/gdb/i386-dicos-tdep.c	2009-01-05 17:16:42.000000000 +0000
+++ src/gdb/i386-dicos-tdep.c	2009-02-17 16:48:03.000000000 +0000
@@ -20,9 +20,7 @@
 #include "defs.h"
 #include "osabi.h"
 #include "gdb_string.h"
-#include "solib.h"
-#include "solib-target.h"
-#include "inferior.h"
+#include "dicos-tdep.h"
 
 static CORE_ADDR
 i386_dicos_push_dummy_code (struct gdbarch *gdbarch,
@@ -47,69 +45,9 @@ i386_dicos_init_abi (struct gdbarch_info
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-  set_solib_ops (gdbarch, &solib_target_so_ops);
+  dicos_init_abi (gdbarch);
 
-  /* Every process, although has its own address space, sees the same
-     list of shared libraries.  */
-  set_gdbarch_has_global_solist (gdbarch, 1);
-
-  /* There's no (standard definition of) entry point or a guaranteed
-     text location we could find with a symbol where to place the call
-     dummy, so we put it on the stack.  */
-  set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
   set_gdbarch_push_dummy_code (gdbarch, i386_dicos_push_dummy_code);
-
-  /* DICOS rewinds itself.  Need to override the i386 default which is
-     to decrement the PC.  */
-  set_gdbarch_decr_pc_after_break (gdbarch, 0);
-}
-
-/* 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
@@ -117,19 +55,10 @@ 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;
-    }
+  /* On x86-DICOS, the Load Module's "header" section is 36 bytes.  */
+  if (strcmp (target_name, "elf32-i386") == 0
+      && dicos_load_module_p (abfd, 36))
+    return GDB_OSABI_DICOS;
 
   return GDB_OSABI_UNKNOWN;
 }
Index: src/gdb/NEWS
===================================================================
--- src.orig/gdb/NEWS	2009-02-17 16:50:28.000000000 +0000
+++ src/gdb/NEWS	2009-02-17 16:51:43.000000000 +0000
@@ -208,6 +208,7 @@ x86_64 MinGW			x86_64-*-mingw*
 * New targets
 
 x86 DICOS			i[34567]86-*-dicos*
+x86_64 DICOS		        x86_64-*-dicos*
 
 * Removed commands
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]