Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] QNX Neutrino/i386 support
@ 2003-03-08 13:45 Mark Kettenis
  2003-03-08 15:02 ` Kris Warkentin
  2003-03-08 15:19 ` Kris Warkentin
  0 siblings, 2 replies; 11+ messages in thread
From: Mark Kettenis @ 2003-03-08 13:45 UTC (permalink / raw)
  To: Kris Warkentin; +Cc: gdb-patches

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);
+}
+\f
+
+/* 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);
+}


^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [RFC] QNX Neutrino/i386 support
@ 2003-03-09 14:54 Kris Warkentin
  0 siblings, 0 replies; 11+ messages in thread
From: Kris Warkentin @ 2003-03-09 14:54 UTC (permalink / raw)
  To: gdb-patches

> Sorry but the native procfs stuff is beyond my maintainership, and I
> don't feel confident enough to approve that stuff based on my global
> maintainership.

Okay.  I guess I'll have to wait for someone else to pipe up.

> The i386-nto-tdep.c (and the nto-tdep.c for that matter) should only
> contain ISA/ABI related code.  You'll probably need some register
> mapping functions in there (for interpreting core files), but I fail
> to see how the code that's in your proposed i386-nto-tdep.c file is
> related to the rest of the stuff.  There just seem to be too many
> interdependencies between all the different files.

Okay, I can see that.  One of the things I've been working on is untying all
our register stuff (in our own tree) because it bounces back and forth
between files so I can relate to how nasty that gets.  All there is in
i386-nto-tdep.c however is the link map stuff and the register fetch/store
functions which many tdep files have.  I just happen to do a little extra
calculating to report back regset numbers and sizes, etc. that are handy for
nto-procfs and remote-nto to know.

My plan was to have all the generic stuff in nto-tdep.c and then have hooks
for register store/fetch in the <arch>-nto-tdep.c files.  This way
nto-procfs.c and remote-nto.c get to take advantage of the same files.
Forgive my bad ascii art but we have:

nto-procfs.c__                  _i386-nto-tdep.c
              \_nto-tdep.[ch]__/_sh-nto-tdep.c
remote-nto.c__/                \_mips-nto-tdep.c, arm, ppc, ...

Where the nto-tdep.h is the interface to the arch specific back ends.

> That's the main reason why I
> (and Andrew before me) have asked you to seperate the target-dependent
> bits from the native and remote support and ask approval for those
> bits seperately.

Alright.  I had understood that you wanted me to separate the native from
the remote but perhaps I misunderstood.  If you would like to do it this
way, it's fine by me.

> We have seen in the past that such cleanups hardly ever happen.  Would
> it be acceptable for you to check the new files in on a branch and
> merge it in bit by bit from there?

I hope that I will eventually earn your trust but I can see your point.
Tell you what, how about you add the file as you presented it to me and then
I will start submitting additions to you.  Trust is a two way street so I
will trust you to do the right thing and help me get our support in and
working.

cheers,

Kris


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-03-19 18:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-08 13:45 [RFC] QNX Neutrino/i386 support Mark Kettenis
2003-03-08 15:02 ` Kris Warkentin
2003-03-08 23:49   ` Mark Kettenis
2003-03-09  0:14   ` Mark Kettenis
2003-03-09  4:34     ` Kris Warkentin
2003-03-09 17:51     ` Kris Warkentin
2003-03-19 18:19       ` Kris Warkentin
2003-03-19 18:27         ` Mark Kettenis
2003-03-08 15:19 ` Kris Warkentin
2003-03-08 15:22   ` Kris Warkentin
2003-03-09 14:54 Kris Warkentin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox