This is the mail archive of the gdb-patches@sources.redhat.com 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]

[RFC] QNX Neutrino/i386 support


Kris,

Here is a sort-of minimal patch to add the QNX Neutroni/i386 target
stuff into GDB.  I left out all the controversial bits for now, and
some bits I don't understand yet.  I also left out the bits dealing
with the special NTO remote protocol.  As I wrote to you before, I'd
rather not have those bits in i386-nto-tdep.c.

I'm still struggling with the shared library stuff.  There's something
fishy in there, but it seems that the comment in nto-tdep.c is wrong,
or at least outdated.

Anyway, this should be enough to do some basic debugging via the
standard GDB remote protocol if it were supported on NTO.  My proposal
is to check this in, and work from there.

Mark

Index: configure.tgt
===================================================================
RCS file: /cvs/src/src/gdb/configure.tgt,v
retrieving revision 1.98
diff -u -p -r1.98 configure.tgt
--- configure.tgt 5 Feb 2003 23:14:47 -0000 1.98
+++ configure.tgt 8 Mar 2003 13:25:19 -0000
@@ -90,6 +90,7 @@ i[3456]86-*-netbsd*)	gdb_target=nbsd ;;
 i[3456]86-*-openbsd*)	gdb_target=obsd ;;
 i[3456]86-*-go32*)	gdb_target=i386aout ;;
 i[3456]86-*-msdosdjgpp*) gdb_target=go32 ;;
+i[3456]86-*-nto* | x86-*-nto*)	gdb_target=nto ;;
 i[3456]86-*-lynxos*)	gdb_target=i386lynx ;;
 i[3456]86-*-solaris*)	gdb_target=i386sol2 ;;
 i[3456]86-*-sco*)	gdb_target=i386v ;;
@@ -280,5 +281,6 @@ esac
 case "${target}" in
 *-*-linux*)	gdb_osabi=GDB_OSABI_LINUX ;;
 *-*-gnu*)	gdb_osabi=GDB_OSABI_HURD ;;
+*-*-nto*)	gdb_osabi=GDB_OSABI_QNXNTO ;;
 *-*-solaris*)	gdb_osabi=GDB_OSABI_SOLARIS ;;
 esac
--- /dev/null	Sat Mar  8 14:22:37 2003
+++ config/i386/tm-nto.h	Sat Mar  1 20:33:57 2003
@@ -0,0 +1,27 @@
+/* Target-dependent definitions for QNX Neutrino/i386.
+   Copyright 2003 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 2 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, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef TM_NTO_H
+#define TM_NTO_H
+
+#include "i386/tm-i386.h"
+#include "solib.h"
+
+#endif /* TM_NTO_H */
--- /dev/null	Sat Mar  8 14:22:37 2003
+++ config/i386/nto.mt	Sat Mar  1 20:37:46 2003
@@ -0,0 +1,4 @@
+# Target: Intel 386 running QNX
+TDEPFILES= i386-tdep.o i387-tdep.o i386-nto-tdep.o \
+	solib.o solib-svr4.o
+TM_FILE= tm-nto.h
--- /dev/null	Sat Mar  8 14:22:37 2003
+++ i386-nto-tdep.c	Sat Mar  1 20:31:29 2003
@@ -0,0 +1,125 @@
+/* Target-dependent code for NTO.
+   Copyright 2003 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 2 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, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include "defs.h"
+#include "frame.h"
+#include "symtab.h"
+#include "objfiles.h"
+#include "osabi.h"
+#include "regcache.h"
+
+#include "i386-tdep.h"
+
+#include "solib-svr4.h"
+
+static int
+i386_nto_pc_in_sigtramp (CORE_ADDR pc, char *name)
+{
+  return (name && strcmp ("__signalstub", name) == 0);
+}
+
+#define I386_NTO_SIGCONTEXT_OFFSET	136
+
+static CORE_ADDR
+i386_nto_sigcontext_addr (struct frame_info *frame)
+{
+  struct frame_info *next = get_next_frame (frame);
+
+  if (next)
+    return get_frame_base (next) + I386_NTO_SIGCONTEXT_OFFSET;
+
+  return read_register (SP_REGNUM) + I386_NTO_SIGCONTEXT_OFFSET;
+}
+
+/* Fetch (and possibly build) an appropriate link_map_offsets
+   structure for native x86 targets using the struct offsets defined
+   in link.h (but without actual reference to that file).
+
+   This makes it possible to access x86 shared libraries from a GDB
+   that was not built on an x86 host (for cross debugging).  */
+
+static struct link_map_offsets *
+i386_nto_svr4_fetch_link_map_offsets (void)
+{
+  static struct link_map_offsets lmo;
+  static struct link_map_offsets *lmp = NULL;
+
+  if (lmp == NULL)
+    {
+      lmp = &lmo;
+
+      lmo.r_debug_size = 8;	/* The actual size is larger, but this
+                                   is all we need.  */
+      lmo.r_map_offset = 4;
+      lmo.r_map_size = 4;
+
+      lmo.link_map_size = 20;	/* The actual size is larger bytes,
+				   but this is all we need.  */
+      lmo.l_addr_offset = 0;
+      lmo.l_addr_size = 4;
+
+      lmo.l_name_offset = 4;
+      lmo.l_name_size = 4;
+
+      lmo.l_next_offset = 12;
+      lmo.l_next_size = 4;
+
+      lmo.l_prev_offset = 16;
+      lmo.l_prev_size = 4;
+    }
+
+  return lmp;
+}
+
+/* QNX Neutrino (NTO).  */
+
+static void
+i386_nto_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  /* NTO uses ELF.  */
+  i386_elf_init_abi (info, gdbarch);
+
+  /* NTO has shared libraries.  */
+  set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
+  set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
+
+  set_gdbarch_pc_in_sigtramp (gdbarch, i386_nto_pc_in_sigtramp);
+  tdep->sigcontext_addr = i386_nto_sigcontext_addr;
+  tdep->sc_pc_offset = 56;
+  tdep->sc_sp_offset = 68;
+
+  tdep->jb_pc_offset = 20;
+
+  set_solib_svr4_fetch_link_map_offsets (gdbarch,
+					 i386_nto_svr4_fetch_link_map_offsets);
+}
+
+
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+void _initialize_i386_nto_tdep (void);
+
+void
+_initialize_i386_nto_tdep (void)
+{
+  gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_QNXNTO,
+			  i386_nto_init_abi);
+}


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