]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove unused ps_lgetLDT etc. on Solaris/x86 [PR25981]
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 19 May 2020 08:03:14 +0000 (10:03 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 19 May 2020 08:03:14 +0000 (10:03 +0200)
As reported in PR build/25981, a future Solaris 11.4 update will soon
remove the short i386 register names like SS etc. from <sys/regset.h>.
They could leak into user code (e.g. via <signal.h> -> <sys/signal.h> ->
<sys/ucontext.h>) and pollute the user namespace.  Affected code would
have a hard time avoiding the issue: LLVM is one of those.

While the short names are required to be present by the i386 psABI, that
document only demands that they exist in <ucontext.h>, which is what the
upcoming update assures.

With this change, in a 64-bit-default configuration, procfs.c fails to
compile on Solaris/x86:

/vol/src/gnu/gdb/hg/master/git/gdb/procfs.c: In function 'ssd* procfs_find_LDT_entry(ptid_t)':
/vol/src/gnu/gdb/hg/master/git/gdb/procfs.c:1643:18: error: 'GS' was not declared in this scope
 1643 |   key = (*gregs)[GS] & 0xffff;
      |                  ^~
make[2]: *** [Makefile:1607: procfs.o] Error 1

Initially I meant to provide a definition using the planned replacement
macro, but closer inspection revealed a better way.  procfs_find_LDT_entry
and its helper proc_get_LDT_entry are only used to implement ps_lgetLDT,
one of the callback functions required by libthread_db.so.1
(cf. <proc_service.h>).  While that function is still documented as being
required even in Solaris 11.4, I found that calls to it had been removed
long ago in Solaris 9, so just removing the three functions above is the
easiest fix.

The following patch does just that.  It compiled successfully on
amd64-pc-solaris2.11, however, as reported in PR gdb/25939, master is
completely broken on Solaris since the multi-target patch.  The patch
applies cleanly to the gdb-9 branch and there I could test it
successfully.

PR build/25981
* procfs.c [(__i386__ || __x86_64__) && sun] (proc_get_LDT_entry,
procfs_find_LDT_entry): Remove.
* procfs.h [(__i386__ || __x86_64__) && sun] (struct ssd,
procfs_find_LDT_entry): Remove.
* sol-thread.c [(__i386__ || __x86_64__) && sun] (ps_lgetLDT):
Remove.

gdb/ChangeLog
gdb/procfs.c
gdb/procfs.h
gdb/sol-thread.c

index 10b4f9c5345fa34f88a4690a911111bc604da69b..44c7fe86e5b9b59205a6fb367f4dd41886cadc9e 100644 (file)
@@ -1,3 +1,13 @@
+2020-05-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       PR build/25981
+       * procfs.c [(__i386__ || __x86_64__) && sun] (proc_get_LDT_entry,
+       procfs_find_LDT_entry): Remove.
+       * procfs.h [(__i386__ || __x86_64__) && sun] (struct ssd,
+       procfs_find_LDT_entry): Remove.
+       * sol-thread.c [(__i386__ || __x86_64__) && sun] (ps_lgetLDT):
+       Remove.
+
 2020-05-17  Tom Tromey  <tromey@adacore.com>
 
        Pushed by Joel Brobecker  <brobecker@adacore.com>
@@ -12,7 +22,7 @@
 
 2020-02-22  Eli Zaretskii  <eliz@gnu.org>
 
-       PRE gdb/25586:
+       PR gdb/25586
        * tui/tui-win.c (new_height_ok, tui_adjust_win_heights): Rename
        'locator' to 'status_line', to better match terminology in the
        manual.
index af9adfb4f899c156030077ab24ed4a62d52fc6a5..dcd2d7589bb383f55e233a61330759c9229efb3e 100644 (file)
@@ -1565,85 +1565,6 @@ proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags)
   return (write (pi->ctl_fd, &arg, sizeof (arg)) == sizeof (arg));
 }
 
-#if (defined(__i386__) || defined(__x86_64__)) && defined (sun)
-
-#include <sys/sysi86.h>
-
-/* The KEY is actually the value of the lower 16 bits of the GS
-   register for the LWP that we're interested in.  Returns the
-   matching ssh struct (LDT entry).  */
-
-static struct ssd *
-proc_get_LDT_entry (procinfo *pi, int key)     /* ARI: editCase function */
-{
-  static struct ssd *ldt_entry = NULL;
-  char pathname[MAX_PROC_NAME_SIZE];
-
-  /* Allocate space for one LDT entry.
-     This alloc must persist, because we return a pointer to it.  */
-  if (ldt_entry == NULL)
-    ldt_entry = XNEW (struct ssd);
-
-  /* Open the file descriptor for the LDT table.  */
-  xsnprintf (pathname, sizeof (pathname), "/proc/%d/ldt", pi->pid);
-  scoped_fd fd (open_with_retry (pathname, O_RDONLY));
-  if (fd.get () < 0)
-    {
-      proc_warn (pi, "proc_get_LDT_entry (open)", __LINE__);
-      return NULL;
-    }
-
-  /* Now 'read' thru the table, find a match and return it.  */
-  while (read (fd.get (), ldt_entry, sizeof (struct ssd))
-        == sizeof (struct ssd))
-    {
-      if (ldt_entry->sel == 0
-         && ldt_entry->bo  == 0
-         && ldt_entry->acc1 == 0
-         && ldt_entry->acc2 == 0)
-       break;  /* end of table */
-      /* If key matches, return this entry.  */
-      if (ldt_entry->sel == key)
-       return ldt_entry;
-    }
-  /* Loop ended, match not found.  */
-  return NULL;
-}
-
-/* Returns the pointer to the LDT entry of PTID.  */
-
-struct ssd *
-procfs_find_LDT_entry (ptid_t ptid)    /* ARI: editCase function */
-{
-  gdb_gregset_t *gregs;
-  int            key;
-  procinfo      *pi;
-
-  /* Find procinfo for the lwp.  */
-  pi = find_procinfo (ptid.pid (), ptid.lwp ());
-  if (pi == NULL)
-    {
-      warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%ld."),
-              ptid.pid (), ptid.lwp ());
-      return NULL;
-    }
-  /* get its general registers.  */
-  gregs = proc_get_gregs (pi);
-  if (gregs == NULL)
-    {
-      warning (_("procfs_find_LDT_entry: could not read gregs for %d:%ld."),
-              ptid.pid (), ptid.lwp ());
-      return NULL;
-    }
-  /* Now extract the GS register's lower 16 bits.  */
-  key = (*gregs)[GS] & 0xffff;
-
-  /* Find the matching entry and return it.  */
-  return proc_get_LDT_entry (pi, key);
-}
-
-#endif
-
 /* =============== END, non-thread part of /proc  "MODULE" =============== */
 
 /* =================== Thread "MODULE" =================== */
index 5bba4672b5750808d3852823d81bad96501084f6..46835fdf8207074155f7c8e78fad89f376e046f8 100644 (file)
 
 extern ptid_t procfs_first_available (void);
 
-#if (defined (__i386__) || defined (__x86_64__)) && defined (sun)
-struct ssd;
-
-extern struct ssd *procfs_find_LDT_entry (ptid_t);
-#endif
-
 #endif /* PROCFS_H */
index a1def95ee61246c872f7b376e3a381f8130ddf4b..383557b3194dfa83ce20c5bde1a0e85d5819d268 100644 (file)
@@ -961,38 +961,6 @@ ps_pdmodel (struct ps_prochandle *ph, int *data_model)
 
   return PS_OK;
 }
-
-#if (defined(__i386__) || defined(__x86_64__)) && defined (sun)
-
-/* Reads the local descriptor table of a LWP.
-
-   This function is necessary on x86-solaris only.  Without it, the loading
-   of libthread_db would fail because of ps_lgetLDT being undefined.  */
-
-ps_err_e
-ps_lgetLDT (struct ps_prochandle *ph, lwpid_t lwpid, struct ssd *pldt) /* ARI: editCase function */
-{
-  /* NOTE: only used on Solaris, therefore OK to refer to procfs.c.  */
-  struct ssd *ret;
-
-  /* FIXME: can't I get the process ID from the prochandle or
-     something?  */
-
-  if (inferior_ptid.pid () <= 0 || lwpid <= 0)
-    return PS_BADLID;
-
-  ret = procfs_find_LDT_entry (ptid_t (inferior_ptid.pid (),
-                              lwpid, 0));
-  if (ret)
-    {
-      memcpy (pldt, ret, sizeof (struct ssd));
-      return PS_OK;
-    }
-  else
-    /* LDT not found.  */
-    return PS_ERR;
-}
-#endif
 \f
 
 /* Convert PTID to printable form.  */