Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Bring QNX Neutrino support forward.
@ 2004-03-23 21:18 Kris Warkentin
  2004-03-23 23:21 ` Andrew Cagney
  2004-03-31 22:21 ` Daniel Jacobowitz
  0 siblings, 2 replies; 10+ messages in thread
From: Kris Warkentin @ 2004-03-23 21:18 UTC (permalink / raw)
  To: Gdb-Patches@Sources.Redhat.Com

[-- Attachment #1: Type: text/plain, Size: 2003 bytes --]

Some of this stuff is cosmetic/convenience.  I made the macros for my 
nto_target structure testable and moved the comments into the structure 
where they're more useful.

A few things had to do with initializers.  Some of the signal handling 
stuff didn't work because other _init functions hadn't been called so I 
moved them out to where they could be called when the osabi is initialized.

I added osabi and core sniffers.  Some is practical, some is 
future-proofing.  If we start supporting multiple targets, I'm going to 
want to be able to swap our various target processors support in and 
out.  The is_nto_target type stuff can be made more interesting later to 
do things like check to see if the remote host processor matches the 
binary abi and such.

cheers,

Kris

ChangeLog entry:
* nto-tdep.h: Include osabi.h.  Prototypes for generic Neutrino
osabi sniffer, signal handling initializer and
'in_dynsym_resolve_code' function.
(struct nto_target_ops): Put comments inline with struct.  Add osabi
sniffer hook.  Redefine macros to permit testing/assignment.
* nto-tdep.c (nto_find_and_open_solib): Allocate all buffers
dynamically to support arbitrary root paths.  Check for basename of
lib in search path and then check for absolute.
(nto_in_dynsym_resolve_code): New function.
(nto_core_sniffer): New function.
(regset_core_fns): Register core sniffer.
(nto_initialize_signals): New function.
(_initialize_nto_tdep): Move signal initialization code to above to
avoid initialization race conditions.
* nto-procfs.c: Minor formatting/indenting changes.
(procfs_is_nto_target): New function.
(procfs_open): Set nto_is_nto_target.
(_initialize_procfs): Ditto.  Remove notice_signals() call to avoid
initialization race conditions.
(procfs_create_inferior): Resume inferior after creation.
* i386-nto-tdep.c (init_i386nto_ops): Use new macros for assignment.
(i386nto_init_abi): Initialize signals.  Set
TARGET_SO_IN_DYNSYM_RESOLVE_CODE.
(_initialize_i386nto_tdep): Register osabi sniffer.


[-- Attachment #2: 2004-04-23.diff --]
[-- Type: text/plain, Size: 16880 bytes --]

Index: nto-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/nto-tdep.h,v
retrieving revision 1.2
diff -u -r1.2 nto-tdep.h
--- nto-tdep.h	6 May 2003 16:47:47 -0000	1.2
+++ nto-tdep.h	23 Mar 2004 21:07:41 -0000
@@ -26,6 +26,7 @@
 
 #include "defs.h"
 #include "solist.h"
+#include "osabi.h"
 
 /* Generic functions in nto-tdep.c.  */
 
@@ -36,39 +37,29 @@
 
 int proc_iterate_over_mappings (int (*func) (int, CORE_ADDR));
 
-void nto_relocate_section_addresses (struct so_list *, struct section_table *);
+void nto_relocate_section_addresses (struct so_list *,
+				     struct section_table *);
 
 int nto_map_arch_to_cputype (const char *);
 
 int nto_find_and_open_solib (char *, unsigned, char **);
 
+enum gdb_osabi nto_elf_osabi_sniffer (bfd *abfd);
+
+void nto_initialize_signals (void);
+
 /* Dummy function for initializing nto_target_ops on targets which do
    not define a particular regset.  */
 void nto_dummy_supply_regset (char *regs);
 
+int nto_in_dynsym_resolve_code (CORE_ADDR pc);
+
 /* Target operations defined for Neutrino targets (<target>-nto-tdep.c).  */
 
 struct nto_target_ops
 {
-  int nto_internal_debugging;
-  unsigned nto_cpuinfo_flags;
-  int nto_cpuinfo_valid;
-
-  int (*nto_regset_id) (int);
-  void (*nto_supply_gregset) (char *);
-  void (*nto_supply_fpregset) (char *);
-  void (*nto_supply_altregset) (char *);
-  void (*nto_supply_regset) (int, char *);
-  int (*nto_register_area) (int, int, unsigned *);
-  int (*nto_regset_fill) (int, char *);
-  struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
-};
-
-extern struct nto_target_ops current_nto_target;
-
 /* For 'maintenance debug nto-debug' command.  */
-#define nto_internal_debugging \
-	(current_nto_target.nto_internal_debugging)
+  int nto_internal_debugging;
 
 /* The CPUINFO flags from the remote.  Currently used by
    i386 for fxsave but future proofing other hosts.
@@ -76,47 +67,69 @@
    depending on our host/target.  It would only be invalid
    if we were talking to an older pdebug which didn't support
    the cpuinfo message.  */
-#define nto_cpuinfo_flags \
-	(current_nto_target.nto_cpuinfo_flags)
+  unsigned nto_cpuinfo_flags;
 
 /* True if successfully retrieved cpuinfo from remote.  */
-#define nto_cpuinfo_valid \
-	(current_nto_target.nto_cpuinfo_valid)
+  int nto_cpuinfo_valid;
 
 /* Given a register, return an id that represents the Neutrino
    regset it came from.  If reg == -1 update all regsets.  */
-#define nto_regset_id(reg) \
-	(*current_nto_target.nto_regset_id) (reg)
+  int (*nto_regset_id) (int);
 
-#define nto_supply_gregset(regs) \
-	(*current_nto_target.nto_supply_gregset) (regs)
+  void (*nto_supply_gregset) (char *);
 
-#define nto_supply_fpregset(regs) \
-	(*current_nto_target.nto_supply_fpregset) (regs)
+  void (*nto_supply_fpregset) (char *);
 
-#define nto_supply_altregset(regs) \
-	(*current_nto_target.nto_supply_altregset) (regs)
+  void (*nto_supply_altregset) (char *);
 
 /* Given a regset, tell gdb about registers stored in data.  */
-#define nto_supply_regset(regset, data) \
-	(*current_nto_target.nto_supply_regset) (regset, data)
+  void (*nto_supply_regset) (int, char *);
 
 /* Given a register and regset, calculate the offset into the regset
    and stuff it into the last argument.  If regno is -1, calculate the
    size of the entire regset.  Returns length of data, -1 if unknown
    regset, 0 if unknown register.  */
-#define nto_register_area(reg, regset, off) \
-	(*current_nto_target.nto_register_area) (reg, regset, off)
+  int (*nto_register_area) (int, int, unsigned *);
 
 /* Build the Neutrino register set info into the data buffer.  
    Return -1 if unknown regset, 0 otherwise.  */
-#define nto_regset_fill(regset, data) \
-	(*current_nto_target.nto_regset_fill) (regset, data)
+  int (*nto_regset_fill) (int, char *);
 
 /* Gives the fetch_link_map_offsets function exposure outside of
    solib-svr4.c so that we can override relocate_section_addresses().  */
-#define nto_fetch_link_map_offsets() \
-	(*current_nto_target.nto_fetch_link_map_offsets) ()
+  struct link_map_offsets *(*nto_fetch_link_map_offsets) (void);
+
+/* Used by nto_elf_osabi_sniffer to determine if we're connected to an
+   Neutrino target.  */
+  enum gdb_osabi (*nto_is_nto_target) (bfd *abfd);
+};
+
+extern struct nto_target_ops current_nto_target;
+
+#define nto_internal_debugging (current_nto_target.nto_internal_debugging)
+
+#define nto_cpuinfo_flags (current_nto_target.nto_cpuinfo_flags)
+
+#define nto_cpuinfo_valid (current_nto_target.nto_cpuinfo_valid)
+
+#define nto_regset_id (current_nto_target.nto_regset_id)
+
+#define nto_supply_gregset (current_nto_target.nto_supply_gregset)
+
+#define nto_supply_fpregset (current_nto_target.nto_supply_fpregset)
+
+#define nto_supply_altregset (current_nto_target.nto_supply_altregset)
+
+#define nto_supply_regset (current_nto_target.nto_supply_regset)
+
+#define nto_register_area (current_nto_target.nto_register_area)
+
+#define nto_regset_fill (current_nto_target.nto_regset_fill)
+
+#define nto_fetch_link_map_offsets \
+(current_nto_target.nto_fetch_link_map_offsets)
+
+#define nto_is_nto_target (current_nto_target.nto_is_nto_target)
 
 /* Keep this consistant with neutrino syspage.h.  */
 enum
Index: nto-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-tdep.c,v
retrieving revision 1.6
diff -u -r1.6 nto-tdep.c
--- nto-tdep.c	17 Jun 2003 18:30:48 -0000	1.6
+++ nto-tdep.c	23 Mar 2004 21:07:41 -0000
@@ -86,10 +86,10 @@
 int
 nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
 {
-  char *buf, arch_path[PATH_MAX], *nto_root, *endian;
+  char *buf, *arch_path, *nto_root, *endian, *base;
   const char *arch;
-  char *path_fmt = "%s/lib:%s/usr/lib:%s/usr/photon/lib\
-:%s/usr/photon/dll:%s/lib/dll";
+  int ret;
+#define PATH_FMT "%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
 
   nto_root = nto_target ();
   if (strcmp (TARGET_ARCHITECTURE->arch_name, "i386") == 0)
@@ -109,13 +109,38 @@
       endian = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? "be" : "le";
     }
 
+  /* In case nto_root is short, add strlen(solib)
+     so we can reuse arch_path below.  */
+  arch_path =
+    alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +
+	    strlen (solib));
   sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
 
-  buf = alloca (strlen (path_fmt) + strlen (arch_path) * 5 + 1);
-  sprintf (buf, path_fmt, arch_path, arch_path, arch_path, arch_path,
+  buf = alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);
+  sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
 	   arch_path);
 
-  return openp (buf, 1, solib, o_flags, 0, temp_pathname);
+  /* Don't assume basename() isn't destructive.  */
+  base = strrchr (solib, '/');
+  if (!base)
+    base = solib;
+  else
+    base++;			/* Skip over '/'.  */
+
+  ret = openp (buf, 1, base, o_flags, 0, temp_pathname);
+  if (ret < 0 && base != solib)
+    {
+      sprintf (arch_path, "/%s", solib);
+      ret = open (arch_path, o_flags, 0);
+      if (temp_pathname)
+	{
+	  if (ret >= 0)
+	    *temp_pathname = gdb_realpath (arch_path);
+	  else
+	    **temp_pathname = '\0';
+	}
+    }
+  return ret;
 }
 
 void
@@ -287,32 +312,51 @@
     }
 }
 
+/* This is cheating a bit because our linker code is in libc.so.  If we
+   ever implement lazy linking, this may need to be re-examined.  */
+int
+nto_in_dynsym_resolve_code (CORE_ADDR pc)
+{
+  return 0;
+}
+
 void
 nto_dummy_supply_regset (char *regs)
 {
   /* Do nothing.  */
 }
 
+static int
+nto_core_sniffer (struct core_fns *our_fns, bfd *abfd)
+{
+  if (bfd_get_section_by_name (abfd, ".qnx_core_info"))
+    return 1;
+  return default_core_sniffer (our_fns, abfd);
+}
+
+enum gdb_osabi
+nto_elf_osabi_sniffer (bfd *abfd)
+{
+  if (nto_is_nto_target)
+    {
+      return nto_is_nto_target (abfd);
+    }
+  return GDB_OSABI_UNKNOWN;
+}
+
 /* Register that we are able to handle ELF file formats using standard
    procfs "regset" structures.  */
 static struct core_fns regset_core_fns = {
   bfd_target_elf_flavour,	/* core_flavour */
   default_check_format,		/* check_format */
-  default_core_sniffer,		/* core_sniffer */
+  nto_core_sniffer,		/* core_sniffer */
   fetch_core_registers,		/* core_read_registers */
   NULL				/* next */
 };
 
 void
-_initialize_nto_tdep (void)
+nto_initialize_signals (void)
 {
-  add_setshow_cmd ("nto-debug", class_maintenance, var_zinteger,
-		   &nto_internal_debugging, "Set QNX NTO internal debugging.\n\
-When non-zero, nto specific debug info is\n\
-displayed. Different information is displayed\n\
-for different positive values.", "Show QNX NTO internal debugging.\n",
-		   NULL, NULL, &setdebuglist, &showdebuglist);
-
   /* We use SIG45 for pulses, or something, so nostop, noprint
      and pass them.  */
   signal_stop_update (target_signal_from_name ("SIG45"), 0);
@@ -331,6 +375,17 @@
   signal_print_update (SIGPHOTON, 0);
   signal_pass_update (SIGPHOTON, 1);
 #endif
+}
+
+void
+_initialize_nto_tdep (void)
+{
+  add_setshow_cmd ("nto-debug", class_maintenance, var_zinteger,
+		   &nto_internal_debugging, "Set QNX NTO internal debugging.\n\
+When non-zero, nto specific debug info is\n\
+displayed. Different information is displayed\n\
+for different positive values.", "Show QNX NTO internal debugging.\n",
+		   NULL, NULL, &setdebuglist, &showdebuglist);
 
   /* Register core file support.  */
   add_core_fns (&regset_core_fns);
Index: i386-nto-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-nto-tdep.c,v
retrieving revision 1.10
diff -u -r1.10 i386-nto-tdep.c
--- i386-nto-tdep.c	23 Mar 2004 14:47:56 -0000	1.10
+++ i386-nto-tdep.c	23 Mar 2004 21:07:41 -0000
@@ -251,15 +251,14 @@
 static void
 init_i386nto_ops (void)
 {
-  current_nto_target.nto_regset_id = i386nto_regset_id;
-  current_nto_target.nto_supply_gregset = i386nto_supply_gregset;
-  current_nto_target.nto_supply_fpregset = i386nto_supply_fpregset;
-  current_nto_target.nto_supply_altregset = nto_dummy_supply_regset;
-  current_nto_target.nto_supply_regset = i386nto_supply_regset;
-  current_nto_target.nto_register_area = i386nto_register_area;
-  current_nto_target.nto_regset_fill = i386nto_regset_fill;
-  current_nto_target.nto_fetch_link_map_offsets =
-    i386nto_svr4_fetch_link_map_offsets;
+  nto_regset_id = i386nto_regset_id;
+  nto_supply_gregset = i386nto_supply_gregset;
+  nto_supply_fpregset = i386nto_supply_fpregset;
+  nto_supply_altregset = nto_dummy_supply_regset;
+  nto_supply_regset = i386nto_supply_regset;
+  nto_register_area = i386nto_register_area;
+  nto_regset_fill = i386nto_regset_fill;
+  nto_fetch_link_map_offsets = i386nto_svr4_fetch_link_map_offsets;
 }
 
 static void
@@ -267,6 +266,9 @@
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
+  /* Deal with our strange signals.  */
+  nto_initialize_signals ();
+
   /* NTO uses ELF.  */
   i386_elf_init_abi (info, gdbarch);
 
@@ -295,6 +297,9 @@
   /* Supply a nice function to find our solibs.  */
   TARGET_SO_FIND_AND_OPEN_SOLIB = nto_find_and_open_solib;
 
+  /* Our linker code is in libc.  */
+  TARGET_SO_IN_DYNSYM_RESOLVE_CODE = nto_in_dynsym_resolve_code;
+
   init_i386nto_ops ();
 }
 
@@ -303,4 +308,6 @@
 {
   gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_QNXNTO,
 			  i386nto_init_abi);
+  gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
+				  nto_elf_osabi_sniffer);
 }
Index: nto-procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-procfs.c,v
retrieving revision 1.3
diff -u -r1.3 nto-procfs.c
--- nto-procfs.c	18 Jul 2003 17:15:33 -0000	1.3
+++ nto-procfs.c	23 Mar 2004 21:07:42 -0000
@@ -97,20 +97,26 @@
    is required is because QNX node descriptors are transient so
    we have to re-acquire them every time.  */
 static unsigned
-nto_node(void)
+nto_node (void)
 {
   unsigned node;
 
-  if (ND_NODE_CMP(nto_procfs_node, ND_LOCAL_NODE) == 0)
+  if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) == 0)
     return ND_LOCAL_NODE;
 
-  node = netmgr_strtond(nto_procfs_path,0);
+  node = netmgr_strtond (nto_procfs_path, 0);
   if (node == -1)
-      error ("Lost the QNX node.  Debug session probably over.");
+    error ("Lost the QNX node.  Debug session probably over.");
 
   return (node);
 }
 
+static enum gdb_osabi
+procfs_is_nto_target (bfd *abfd)
+{
+  return GDB_OSABI_QNXNTO;
+}
+
 /* This is called when we call 'target procfs <arg>' from the (gdb) prompt.
    For QNX6 (nto), the only valid arg will be a QNX node string, 
    eg: "/net/some_node".  If arg is not a valid QNX node, we will
@@ -124,6 +130,8 @@
   int fd, total_size;
   procfs_sysinfo *sysinfo;
 
+  nto_is_nto_target = procfs_is_nto_target;
+
   /* Set the default node used for spawning to this one,
      and only override it if there is a valid arg.  */
 
@@ -153,7 +161,8 @@
 	    *endstr = 0;
 	}
     }
-  snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr : "", "/proc");
+  snprintf (nto_procfs_path, PATH_MAX - 1, "%s%s", nodestr ? nodestr : "",
+	    "/proc");
   if (nodestr)
     xfree (nodestr);
 
@@ -271,7 +280,7 @@
   if (dp == NULL)
     {
       fprintf_unfiltered (gdb_stderr, "failed to opendir \"%s\" - %d (%s)",
-	      nto_procfs_path, errno, safe_strerror (errno));
+			  nto_procfs_path, errno, safe_strerror (errno));
       return;
     }
 
@@ -299,7 +308,7 @@
       if (fd == -1)
 	{
 	  fprintf_unfiltered (gdb_stderr, "failed to open %s - %d (%s)\n",
-		  buf, errno, safe_strerror (errno));
+			      buf, errno, safe_strerror (errno));
 	  closedir (dp);
 	  return;
 	}
@@ -308,8 +317,8 @@
       if (devctl (fd, DCMD_PROC_INFO, pidinfo, sizeof (buf), 0) != EOK)
 	{
 	  fprintf_unfiltered (gdb_stderr,
-		  "devctl DCMD_PROC_INFO failed - %d (%s)\n", errno,
-		  safe_strerror (errno));
+			      "devctl DCMD_PROC_INFO failed - %d (%s)\n",
+			      errno, safe_strerror (errno));
 	  break;
 	}
       num_threads = pidinfo->num_threads;
@@ -375,7 +384,8 @@
   err = devctl (ctl_fd, DCMD_PROC_MAPINFO, NULL, 0, &num);
   if (err != EOK)
     {
-      printf ("failed devctl num mapinfos - %d (%s)\n", err, safe_strerror (err));
+      printf ("failed devctl num mapinfos - %d (%s)\n", err,
+	      safe_strerror (err));
       return;
     }
 
@@ -565,7 +575,7 @@
 
   if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK
       && status.flags & _DEBUG_FLAG_STOPPED)
-    SignalKill (nto_node(), PIDGET (ptid), 0, SIGCONT, 0, 0);
+    SignalKill (nto_node (), PIDGET (ptid), 0, SIGCONT, 0, 0);
   attach_flag = 1;
   nto_init_solib_absolute_prefix ();
   return ptid;
@@ -778,7 +788,7 @@
     siggnal = atoi (args);
 
   if (siggnal)
-    SignalKill (nto_node(), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
+    SignalKill (nto_node (), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
 
   close (ctl_fd);
   ctl_fd = -1;
@@ -868,8 +878,8 @@
 	{
 	  if (signal_to_pass != status.info.si_signo)
 	    {
-	      SignalKill (nto_node(), PIDGET (inferior_ptid), 0, signal_to_pass,
-			  0, 0);
+	      SignalKill (nto_node (), PIDGET (inferior_ptid), 0,
+			  signal_to_pass, 0, 0);
 	      run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;
 	    }
 	  else			/* Let it kill the program without telling us.  */
@@ -892,7 +902,7 @@
 {
   if (!ptid_equal (inferior_ptid, null_ptid))
     {
-      SignalKill (nto_node(), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
+      SignalKill (nto_node (), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
       close (ctl_fd);
     }
   inferior_ptid = null_ptid;
@@ -1041,7 +1051,7 @@
 
   if (ND_NODE_CMP (nto_procfs_node, ND_LOCAL_NODE) != 0)
     {
-      inherit.nd = nto_node();
+      inherit.nd = nto_node ();
       inherit.flags |= SPAWN_SETND;
       inherit.flags &= ~SPAWN_EXEC;
     }
@@ -1054,7 +1064,8 @@
   sigprocmask (SIG_BLOCK, &set, NULL);
 
   if (pid == -1)
-    error ("Error spawning %s: %d (%s)", argv[0], errno, safe_strerror (errno));
+    error ("Error spawning %s: %d (%s)", argv[0], errno,
+	   safe_strerror (errno));
 
   if (fds[0] != STDIN_FILENO)
     close (fds[0]);
@@ -1082,6 +1093,8 @@
       || (symfile_objfile != NULL && symfile_objfile->obfd != NULL))
     SOLIB_CREATE_INFERIOR_HOOK (pid);
 #endif
+  stop_soon = 0;
+  proceed (-1, TARGET_SIGNAL_DEFAULT, 0);
 }
 
 static void
@@ -1323,7 +1336,6 @@
 
   /* Set up trace and fault sets, as gdb expects them.  */
   sigemptyset (&run.trace);
-  notice_signals ();
 
   /* Stuff some information.  */
   nto_cpuinfo_flags = SYSPAGE_ENTRY (cpuinfo)->flags;
@@ -1331,6 +1343,8 @@
 
   add_info ("pidlist", procfs_pidlist, "pidlist");
   add_info ("meminfo", procfs_meminfo, "memory information");
+
+  nto_is_nto_target = procfs_is_nto_target;
 }
 
 

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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-03-23 21:18 [patch] Bring QNX Neutrino support forward Kris Warkentin
@ 2004-03-23 23:21 ` Andrew Cagney
  2004-03-24 13:38   ` Kris Warkentin
  2004-03-31 22:21 ` Daniel Jacobowitz
  1 sibling, 1 reply; 10+ messages in thread
From: Andrew Cagney @ 2004-03-23 23:21 UTC (permalink / raw)
  To: Kris Warkentin; +Cc: Gdb-Patches@Sources.Redhat.Com

> Some of this stuff is cosmetic/convenience.  I made the macros for my nto_target structure testable and moved the comments into the structure where they're more useful.
> 
> A few things had to do with initializers.  Some of the signal handling stuff didn't work because other _init functions hadn't been called so I moved them out to where they could be called when the osabi is initialized.

BTW, what was the race condition?

> I added osabi and core sniffers.  Some is practical, some is future-proofing.  If we start supporting multiple targets, I'm going to want to be able to swap our various target processors support in and out.  The is_nto_target type stuff can be made more interesting later to do things like check to see if the remote host processor matches the binary abi and such.

You should also be able to kill off regset_core_fns, it's been 
superseeded by regsets (which reminds me ....).

Andrew



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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-03-23 23:21 ` Andrew Cagney
@ 2004-03-24 13:38   ` Kris Warkentin
  2004-03-24 14:35     ` Andrew Cagney
  0 siblings, 1 reply; 10+ messages in thread
From: Kris Warkentin @ 2004-03-24 13:38 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Gdb-Patches@Sources.Redhat.Com

Andrew Cagney wrote:

>> Some of this stuff is cosmetic/convenience.  I made the macros for my 
>> nto_target structure testable and moved the comments into the 
>> structure where they're more useful.
>>
>> A few things had to do with initializers.  Some of the signal 
>> handling stuff didn't work because other _init functions hadn't been 
>> called so I moved them out to where they could be called when the 
>> osabi is initialized.
>
>
> BTW, what was the race condition?

The _initialize_* functions were being called in a different order than 
previously so all my signal initialization stuff was breaking when I put 
it into my _init* funcs.  It was a while ago I changed it (haven't been 
working on FSF gdb recently) but I believe it was 
target_signal_from_name....

>
>> I added osabi and core sniffers.  Some is practical, some is 
>> future-proofing.  If we start supporting multiple targets, I'm going 
>> to want to be able to swap our various target processors support in 
>> and out.  The is_nto_target type stuff can be made more interesting 
>> later to do things like check to see if the remote host processor 
>> matches the binary abi and such.
>
>
> You should also be able to kill off regset_core_fns, it's been 
> superseeded by regsets (which reminds me ....).

Must have not seen that thread.  I'll look into it.

cheers,

Kris


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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-03-24 13:38   ` Kris Warkentin
@ 2004-03-24 14:35     ` Andrew Cagney
  2004-03-24 16:32       ` Kris Warkentin
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Cagney @ 2004-03-24 14:35 UTC (permalink / raw)
  To: Kris Warkentin; +Cc: Gdb-Patches@Sources.Redhat.Com

> Andrew Cagney wrote:
> 
>>> Some of this stuff is cosmetic/convenience.  I made the macros for my nto_target structure testable and moved the comments into the structure where they're more useful.
>>>
>>> A few things had to do with initializers.  Some of the signal handling stuff didn't work because other _init functions hadn't been called so I moved them out to where they could be called when the osabi is initialized.
>>
>>
>>
>> BTW, what was the race condition?
> 
> 
> The _initialize_* functions were being called in a different order than previously so all my signal initialization stuff was breaking when I put it into my _init* funcs.  It was a while ago I changed it (haven't been working on FSF gdb recently) but I believe it was target_signal_from_name....

Ulgh, one of those (if you remember any more details :-).  I'll need to 
investigate - these race conditions are a royal pain.

>>> I added osabi and core sniffers.  Some is practical, some is future-proofing.  If we start supporting multiple targets, I'm going to want to be able to swap our various target processors support in and out.  The is_nto_target type stuff can be made more interesting later to do things like check to see if the remote host processor matches the binary abi and such.
>>
>>
>>
>> You should also be able to kill off regset_core_fns, it's been superseeded by regsets (which reminds me ....).
> 
> 
> Must have not seen that thread.  I'll look into it.

There are no deprecated markers so there's no hint.  A grep of 
add_core_fns reveals that the i386/amd64 and GNU/Linux PPC do not make 
the call so I'm pretty sure that I'm not talking theory here (notably 
32x64 GNU/Linux debugging works on those systems -- that needs regsets).

Andrew



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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-03-24 14:35     ` Andrew Cagney
@ 2004-03-24 16:32       ` Kris Warkentin
  2004-03-25 17:22         ` Kris Warkentin
  0 siblings, 1 reply; 10+ messages in thread
From: Kris Warkentin @ 2004-03-24 16:32 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Gdb-Patches@Sources.Redhat.Com

Andrew Cagney wrote:

> Ulgh, one of those (if you remember any more details :-).  I'll need 
> to investigate - these race conditions are a royal pain.

I'll just temporarily move the signal setup stuff to my _init....okay.  
It's this line of code in my init function:

signal_stop_update (target_signal_from_name ("SIG45"), 0);

The array 'signal_stop' in signal_stop_update has not been initialized 
so we blow up.

> There are no deprecated markers so there's no hint.  A grep of 
> add_core_fns reveals that the i386/amd64 and GNU/Linux PPC do not make 
> the call so I'm pretty sure that I'm not talking theory here (notably 
> 32x64 GNU/Linux debugging works on those systems -- that needs regsets).


I think I'm failing to understand you here.  If I don't use the 
regset_core_functions, how do I sniff out a Neutrino core using

    if (bfd_get_section_by_name (abfd, ".qnx_core_info"))
       you_have_core();
?

Should I be adding that to the default_core_sniffer?

cheers,

Kris


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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-03-24 16:32       ` Kris Warkentin
@ 2004-03-25 17:22         ` Kris Warkentin
  2004-03-26  3:43           ` Andrew Cagney
  0 siblings, 1 reply; 10+ messages in thread
From: Kris Warkentin @ 2004-03-25 17:22 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Gdb-Patches@Sources.Redhat.Com

Andrew, given that the core_fns are not deprecated yet, is this patch 
otherwise okay?  It looks like I might be able to add some BFD support 
for our cores (perhaps a qnx_nto_core_flavour?) but I wouldn't mind 
getting this patch out of my sandbox for now.

cheers,

Kris

Kris Warkentin wrote:

> Andrew Cagney wrote:
>
>> Ulgh, one of those (if you remember any more details :-).  I'll need 
>> to investigate - these race conditions are a royal pain.
>
>
> I'll just temporarily move the signal setup stuff to my 
> _init....okay.  It's this line of code in my init function:
>
> signal_stop_update (target_signal_from_name ("SIG45"), 0);
>
> The array 'signal_stop' in signal_stop_update has not been initialized 
> so we blow up.
>
>> There are no deprecated markers so there's no hint.  A grep of 
>> add_core_fns reveals that the i386/amd64 and GNU/Linux PPC do not 
>> make the call so I'm pretty sure that I'm not talking theory here 
>> (notably 32x64 GNU/Linux debugging works on those systems -- that 
>> needs regsets).
>
>
>
> I think I'm failing to understand you here.  If I don't use the 
> regset_core_functions, how do I sniff out a Neutrino core using
>
>    if (bfd_get_section_by_name (abfd, ".qnx_core_info"))
>       you_have_core();
> ?
>
> Should I be adding that to the default_core_sniffer?
>
> cheers,
>
> Kris
>


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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-03-25 17:22         ` Kris Warkentin
@ 2004-03-26  3:43           ` Andrew Cagney
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Cagney @ 2004-03-26  3:43 UTC (permalink / raw)
  To: Kris Warkentin; +Cc: Gdb-Patches@Sources.Redhat.Com

> Andrew, given that the core_fns are not deprecated yet, is this patch otherwise okay?  It looks like I might be able to add some BFD support for our cores (perhaps a qnx_nto_core_flavour?) but I wouldn't mind getting this patch out of my sandbox for now.

They are not yet deprecated (that will take me at least a week) ... :-)

Andrew



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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-03-23 21:18 [patch] Bring QNX Neutrino support forward Kris Warkentin
  2004-03-23 23:21 ` Andrew Cagney
@ 2004-03-31 22:21 ` Daniel Jacobowitz
  2004-04-01 14:59   ` Kris Warkentin
  1 sibling, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2004-03-31 22:21 UTC (permalink / raw)
  To: Kris Warkentin; +Cc: Gdb-Patches@Sources.Redhat.Com

Some small comments.

On Tue, Mar 23, 2004 at 04:18:56PM -0500, Kris Warkentin wrote:
> ChangeLog entry:
> * nto-tdep.h: Include osabi.h.  Prototypes for generic Neutrino

Leading tabs in the ChangeLog entry, please :)  Post what you would
check in.

> +#define nto_fetch_link_map_offsets \
> +(current_nto_target.nto_fetch_link_map_offsets)

I believe this should be indented.  I'm not sure how far, I usually use
two spaces.

> -  return openp (buf, 1, solib, o_flags, 0, temp_pathname);
> +  /* Don't assume basename() isn't destructive.  */
> +  base = strrchr (solib, '/');
> +  if (!base)
> +    base = solib;
> +  else
> +    base++;			/* Skip over '/'.  */

There's an lbasename in libiberty, for this reason.  You should use
that instead.

> +  ret = openp (buf, 1, base, o_flags, 0, temp_pathname);
> +  if (ret < 0 && base != solib)
> +    {
> +      sprintf (arch_path, "/%s", solib);
> +      ret = open (arch_path, o_flags, 0);

Er... automatically falling back to the host library?  Why?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-03-31 22:21 ` Daniel Jacobowitz
@ 2004-04-01 14:59   ` Kris Warkentin
  2004-04-01 15:04     ` Daniel Jacobowitz
  0 siblings, 1 reply; 10+ messages in thread
From: Kris Warkentin @ 2004-04-01 14:59 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Gdb-Patches@Sources.Redhat.Com

I've been looking at the *nto-tdep files and it looks like I've got some 
refactoring to do in order to be current.  Particularily the 
supply_regset stuff and the whole core_fns deprecation thing.  Looks 
icky and I'm not really sure of the best way to do it.  I've got 4 other 
targets besides i386 so I'm looking for the most efficient way.  I'm 
thinking that I might be able to take advantage of more of the generic 
stuff in i386-tdep.c, at least for that target.

Daniel Jacobowitz wrote:

>Leading tabs in the ChangeLog entry, please :)  Post what you would
>check in.
>  
>

Lost in translation.  They're there in real life. ;-)

>>-  return openp (buf, 1, solib, o_flags, 0, temp_pathname);
>>+  /* Don't assume basename() isn't destructive.  */
>>+  base = strrchr (solib, '/');
>>+  if (!base)
>>+    base = solib;
>>+  else
>>+    base++;			/* Skip over '/'.  */
>>    
>>
>
>There's an lbasename in libiberty, for this reason.  You should use
>that instead.
>
>  
>
Cool.  I did not know that.

>>+  ret = openp (buf, 1, base, o_flags, 0, temp_pathname);
>>+  if (ret < 0 && base != solib)
>>+    {
>>+      sprintf (arch_path, "/%s", solib);
>>+      ret = open (arch_path, o_flags, 0);
>>    
>>
>
>Er... automatically falling back to the host library?  Why?
>  
>

I'm looking through solib_open() and trying to recreate my reasoning.  
It certainly seemed like a good idea at the time.  Let's say the linker 
has the library as /home/kewarken/libfoo.so.  Given the current 
solib_open, I don't believe that gdb will find it without having 
solib-search-path set.  I put that there as a 'just in case' thing 
because a) it works well on self hosted and b) even for remote 
debugging, we often match the host and target filesystems.  I figured 
that all common libs like libc.so, etc. would have been caught by the 
openp() above so the odds of accidentally getting a host library are 
slim.  This makes things a bit easier for the user: the linker fills in 
the full path and gdb uses it rather than requiring a solib-search-path.

cheers,

Kris


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

* Re: [patch] Bring QNX Neutrino support forward.
  2004-04-01 14:59   ` Kris Warkentin
@ 2004-04-01 15:04     ` Daniel Jacobowitz
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2004-04-01 15:04 UTC (permalink / raw)
  To: Kris Warkentin; +Cc: Gdb-Patches@Sources.Redhat.Com

On Thu, Apr 01, 2004 at 10:00:54AM -0500, Kris Warkentin wrote:
> I'm looking through solib_open() and trying to recreate my reasoning.  
> It certainly seemed like a good idea at the time.  Let's say the linker 
> has the library as /home/kewarken/libfoo.so.  Given the current 
> solib_open, I don't believe that gdb will find it without having 
> solib-search-path set.  I put that there as a 'just in case' thing 
> because a) it works well on self hosted and b) even for remote 
> debugging, we often match the host and target filesystems.  I figured 
> that all common libs like libc.so, etc. would have been caught by the 
> openp() above so the odds of accidentally getting a host library are 
> slim.  This makes things a bit easier for the user: the linker fills in 
> the full path and gdb uses it rather than requiring a solib-search-path.

We've resisted allowing this sort of fallback for other targets,
specifically refusing to ignore solib-absolute-prefix - which your code
does, by not using solib_open.  But since you add the paths by default
rather than the user specifying them I guess a fallback isn't so bad.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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

end of thread, other threads:[~2004-04-01 15:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-23 21:18 [patch] Bring QNX Neutrino support forward Kris Warkentin
2004-03-23 23:21 ` Andrew Cagney
2004-03-24 13:38   ` Kris Warkentin
2004-03-24 14:35     ` Andrew Cagney
2004-03-24 16:32       ` Kris Warkentin
2004-03-25 17:22         ` Kris Warkentin
2004-03-26  3:43           ` Andrew Cagney
2004-03-31 22:21 ` Daniel Jacobowitz
2004-04-01 14:59   ` Kris Warkentin
2004-04-01 15:04     ` Daniel Jacobowitz

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