summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--linuxthreads_db/Banner1
-rw-r--r--linuxthreads_db/ChangeLog4
-rw-r--r--linuxthreads_db/Makefile2
-rw-r--r--linuxthreads_db/td_ta_thr_iter.c129
-rw-r--r--nis/nss_nisplus/nisplus-publickey.c24
-rw-r--r--sysdeps/unix/sysv/linux/alpha/sys/procfs.h14
-rw-r--r--sysdeps/unix/sysv/linux/arm/sys/procfs.h14
-rw-r--r--sysdeps/unix/sysv/linux/mips/sys/procfs.h15
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/sys/procfs.h14
-rw-r--r--sysdeps/unix/sysv/linux/sys/procfs.h15
11 files changed, 180 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d0d3e5dcf..54a5646ee6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+1999-11-12  Thorsten Kukuk  <kukuk@suse.de>
+
+	* nis/nss_nisplus/nisplus-publickey.c: Check for snprintf return value.
+
+	* sysdeps/unix/sysv/linux/alpha/sys/procfs.h: Follow changes from
+	i386 version.
+	* sysdeps/unix/sysv/linux/arm/sys/procfs.h: Likewise.
+	* sysdeps/unix/sysv/linux/mips/sys/procfs.h: Likewise.
+	* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h: Likewise.
+	* sysdeps/unix/sysv/linux/sys/procfs.h: Likewise.
+
 1999-11-12  Ulrich Drepper  <drepper@cygnus.com>
 
 	* intl/locale.alias: Add Estonian entries.
@@ -33,7 +44,7 @@
 	* sysdeps/unix/getlogin_r.c (getlogin_r): Sync with getlogin
 	implementation for ttyname_r call; fix inverted condition; return
 	ut_user.
-        Closes PR libc/1438.
+	Closes PR libc/1438.
 
 1999-11-10  Ulrich Drepper  <drepper@cygnus.com>
 
diff --git a/linuxthreads_db/Banner b/linuxthreads_db/Banner
new file mode 100644
index 0000000000..6f4f3f8189
--- /dev/null
+++ b/linuxthreads_db/Banner
@@ -0,0 +1 @@
+libthread_db work sponsored by Alpha Processor Inc
diff --git a/linuxthreads_db/ChangeLog b/linuxthreads_db/ChangeLog
index e62d56c02b..5721a01905 100644
--- a/linuxthreads_db/ChangeLog
+++ b/linuxthreads_db/ChangeLog
@@ -1,5 +1,9 @@
 1999-11-12  Ulrich Drepper  <drepper@cygnus.com>
 
+	* td_ta_thr_iter.c: Read descriptors for main and manager thread
+	special since after this we can assume that no new threads will be
+	created anymore (at least in the gdb implementation).
+
 	* Makefile: Define version correctly.
 
 1999-11-10  Ulrich Drepper  <drepper@cygnus.com>
diff --git a/linuxthreads_db/Makefile b/linuxthreads_db/Makefile
index fa6b3bca5f..abeacf993d 100644
--- a/linuxthreads_db/Makefile
+++ b/linuxthreads_db/Makefile
@@ -20,7 +20,7 @@
 
 subdir		:= linuxthreads_db
 
-libthread_db-version = 1
+linuxthreads_db-version = 1.0
 
 extra-libs = libthread_db
 extra-libs-others := $(extra-libs)
diff --git a/linuxthreads_db/td_ta_thr_iter.c b/linuxthreads_db/td_ta_thr_iter.c
index ecc86c7871..8cb8c63427 100644
--- a/linuxthreads_db/td_ta_thr_iter.c
+++ b/linuxthreads_db/td_ta_thr_iter.c
@@ -21,14 +21,69 @@
 #include "thread_dbP.h"
 
 
+static int
+handle_descr (const td_thragent_t *ta, td_thr_iter_f *callback,
+	      void *cbdata_p, td_thr_state_e state, int ti_pri,
+	      size_t cnt, pthread_descr descr)
+{
+  struct _pthread_descr_struct pds;
+  size_t sizeof_descr = ta->sizeof_descr;
+  td_thrhandle_t th;
+
+#ifdef ALL_THREADS_STOPPED
+  /* First count this active thread.  */
+  --num;
+#endif
+
+  if (ps_pdread (ta->ph, descr, &pds, sizeof_descr) != PS_OK)
+    return TD_ERR;	/* XXX Other error value?  */
+
+  /* The manager thread must be handled special.  The descriptor
+     exists but the thread only gets created when the first
+     `pthread_create' call is issued.  A clear indication that this
+     happened is when the p_pid field is non-zero.  */
+  if (cnt == 1 && pds.p_pid == 0)
+    return TD_OK;
+
+  /* Now test whether this thread matches the specified
+     conditions.  */
+
+  /* Only if the priority level is as high or higher.  */
+  if (pds.p_priority < ti_pri)
+    return TD_OK;
+
+  /* Test the state.
+     XXX This is incomplete.  */
+  if (state != TD_THR_ANY_STATE)
+    return TD_OK;
+
+  /* XXX For now we ignore threads which are not running anymore.
+     The reason is that gdb tries to get the registers and fails.
+     In future we should have a special mode of the thread library
+     in which we keep the process around until the actual join
+     operation happened.  */
+  if (pds.p_exited != 0)
+    return TD_OK;
+
+  /* Yep, it matches.  Call the callback function.  */
+  th.th_ta_p = (td_thragent_t *) ta;
+  th.th_unique = descr;
+  if (callback (&th, cbdata_p) != 0)
+    return TD_DBERR;
+
+  /* All done successfully.  */
+  return TD_OK;
+}
+
+
 td_err_e
 td_ta_thr_iter (const td_thragent_t *ta, td_thr_iter_f *callback,
 		void *cbdata_p, td_thr_state_e state, int ti_pri,
 		sigset_t *ti_sigmask_p, unsigned int ti_user_flags)
 {
   int pthread_threads_max;
-  size_t sizeof_descr;
   struct pthread_handle_struct *phc;
+  td_err_e result = TD_OK;
   int cnt;
 #ifdef ALL_THREADS_STOPPED
   int num;
@@ -43,14 +98,28 @@ td_ta_thr_iter (const td_thragent_t *ta, td_thr_iter_f *callback,
     return TD_BADTA;
 
   pthread_threads_max = ta->pthread_threads_max;
-  sizeof_descr = ta->sizeof_descr;
   phc = (struct pthread_handle_struct *) alloca (sizeof (phc[0])
 						 * pthread_threads_max);
 
-  /* Read all the descriptors.  */
+  /* First read only the main thread and manager thread information.  */
   if (ps_pdread (ta->ph, ta->handles, phc,
-		 sizeof (struct pthread_handle_struct) * pthread_threads_max)
-      != PS_OK)
+		 sizeof (struct pthread_handle_struct) * 2) != PS_OK)
+    return TD_ERR;	/* XXX Other error value?  */
+
+  /* Now handle these descriptors.  */
+  result = handle_descr (ta, callback, cbdata_p, state, ti_pri, 0,
+			 phc[0].h_descr);
+  if (result != TD_OK)
+    return result;
+  result = handle_descr (ta, callback, cbdata_p, state, ti_pri, 1,
+			 phc[1].h_descr);
+  if (result != TD_OK)
+    return result;
+
+  /* Read all the descriptors.  */
+  if (ps_pdread (ta->ph, ta->handles, &phc[2],
+		 (sizeof (struct pthread_handle_struct)
+		  * (pthread_threads_max - 2))) != PS_OK)
     return TD_ERR;	/* XXX Other error value?  */
 
 #ifdef ALL_THREADS_STOPPED
@@ -63,51 +132,11 @@ td_ta_thr_iter (const td_thragent_t *ta, td_thr_iter_f *callback,
   for (cnt = 0; cnt < pthread_threads_max && num > 0; ++cnt)
     if (phc[cnt].h_descr != NULL)
       {
-	struct _pthread_descr_struct pds;
-	td_thrhandle_t th;
-
-#ifdef ALL_THREADS_STOPPED
-	/* First count this active thread.  */
-	--num;
-#endif
-
-	if (ps_pdread (ta->ph, phc[cnt].h_descr, &pds, sizeof_descr)
-	    != PS_OK)
-	  return TD_ERR;	/* XXX Other error value?  */
-
-	/* The manager thread must be handled special.  The descriptor
-	   exists but the thread only gets created when the first
-	   `pthread_create' call is issued.  A clear indication that
-	   this happened is when the p_pid field is non-zero.  */
-	if (cnt == 1 && pds.p_pid == 0)
-	  continue;
-
-	/* Now test whether this thread matches the specified
-	   conditions.  */
-
-	/* Only if the priority level is as high or higher.  */
-	if (pds.p_priority < ti_pri)
-	  continue;
-
-	/* Test the state.
-	   XXX This is incomplete.  */
-	if (state != TD_THR_ANY_STATE)
-	  continue;
-
-	/* XXX For now we ignore threads which are not running anymore.
-	   The reason is that gdb tries to get the registers and fails.
-	   In future we should have a special mode of the thread library
-	   in which we keep the process around until the actual join
-	   operation happened.  */
-	if (pds.p_exited != 0)
-	  continue;
-
-	/* Yep, it matches.  Call the callback function.  */
-	th.th_ta_p = (td_thragent_t *) ta;
-	th.th_unique = phc[cnt].h_descr;
-	if (callback (&th, cbdata_p) != 0)
-	  return TD_DBERR;
+	result = handle_descr (ta, callback, cbdata_p, state, ti_pri, cnt,
+			       phc[cnt].h_descr);
+	if (result != TD_OK)
+	  break;
       }
 
-  return TD_OK;
+  return result;
 }
diff --git a/nis/nss_nisplus/nisplus-publickey.c b/nis/nss_nisplus/nisplus-publickey.c
index 1620611fbc..2aa494f078 100644
--- a/nis/nss_nisplus/nisplus-publickey.c
+++ b/nis/nss_nisplus/nisplus-publickey.c
@@ -1,6 +1,6 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
+   Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public License as
@@ -59,6 +59,12 @@ _nss_nisplus_getpublickey (const char *netname, char *pkey, int *errnop)
 		   "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
 		   netname, domain);
 
+  if (slen >= NIS_MAXNAMELEN)
+    {
+      *errnop = EINVAL;
+      return NSS_STATUS_UNAVAIL;
+    }
+
   if (buf[slen - 1] != '.')
     {
       buf[slen++] = '.';
@@ -131,6 +137,12 @@ _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd,
 		   "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
 		   netname, domain);
 
+  if (slen >= NIS_MAXNAMELEN)
+    {
+      *errnop = EINVAL;
+      return NSS_STATUS_UNAVAIL;
+    }
+
   if (buf[slen - 1] != '.')
     {
       buf[slen++] = '.';
@@ -216,7 +228,7 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
 {
   char *domain;
   nis_result *res;
-  char sname[NIS_MAXNAMELEN+1]; /*  search criteria + table name */
+  char sname[NIS_MAXNAMELEN+2]; /*  search criteria + table name */
   size_t slen;
   char principal[NIS_MAXNAMELEN+1];
   int len;
@@ -237,6 +249,12 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
 		   "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
 		   netname, domain);
 
+  if (slen >= NIS_MAXNAMELEN)
+    {
+      *errnop = EINVAL;
+      return NSS_STATUS_UNAVAIL;
+    }
+
   if (sname[slen - 1] != '.')
     {
       sname[slen++] = '.';
diff --git a/sysdeps/unix/sysv/linux/alpha/sys/procfs.h b/sysdeps/unix/sysv/linux/alpha/sys/procfs.h
index 428563b39a..f47adeebfe 100644
--- a/sysdeps/unix/sysv/linux/alpha/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/alpha/sys/procfs.h
@@ -17,17 +17,17 @@
    Boston, MA 02111-1307, USA.  */
 
 #ifndef _SYS_PROCFS_H
-
 #define _SYS_PROCFS_H	1
-#include <features.h>
 
 /* This is somehow modelled after the file of the same name on SysVr4
    systems.  It provides a definition of the core file format for ELF
    used on Linux.  */
 
+#include <features.h>
 #include <signal.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <sys/ucontext.h>
 #include <sys/user.h>
 #include <asm/elf.h>
 
@@ -100,6 +100,16 @@ struct elf_prpsinfo
     char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
   };
 
+/* Addresses.  */
+typedef void *psaddr_t;
+
+/* Register sets.  Linux has different names.  */
+typedef gregset_t prgregset_t;
+typedef fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+   therefore habe only ine PID type.  */
+typedef __pid_t lwpid_t;
 
 /* Addresses.  */
 typedef void *psaddr_t;
diff --git a/sysdeps/unix/sysv/linux/arm/sys/procfs.h b/sysdeps/unix/sysv/linux/arm/sys/procfs.h
index 497c8e9b0b..a228179796 100644
--- a/sysdeps/unix/sysv/linux/arm/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/arm/sys/procfs.h
@@ -17,17 +17,17 @@
    Boston, MA 02111-1307, USA.  */
 
 #ifndef _SYS_PROCFS_H
-
 #define _SYS_PROCFS_H	1
-#include <features.h>
 
 /* This is somehow modelled after the file of the same name on SysVr4
    systems.  It provides a definition of the core file format for ELF
    used on Linux.  */
 
+#include <features.h>
 #include <signal.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <sys/ucontext.h>
 #include <sys/user.h>
 #include <sys/elf.h>
 
@@ -90,6 +90,16 @@ struct elf_prpsinfo
     char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
   };
 
+/* Addresses.  */
+typedef void *psaddr_t;
+
+/* Register sets.  Linux has different names.  */
+typedef gregset_t prgregset_t;
+typedef fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+   therefore habe only ine PID type.  */
+typedef __pid_t lwpid_t;
 
 /* Addresses.  */
 typedef void *psaddr_t;
diff --git a/sysdeps/unix/sysv/linux/mips/sys/procfs.h b/sysdeps/unix/sysv/linux/mips/sys/procfs.h
index 5a94de0de5..9c6bac9dc6 100644
--- a/sysdeps/unix/sysv/linux/mips/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/mips/sys/procfs.h
@@ -17,17 +17,17 @@
    Boston, MA 02111-1307, USA.  */
 
 #ifndef _SYS_PROCFS_H
-
 #define _SYS_PROCFS_H	1
-#include <features.h>
 
 /* This is somehow modelled after the file of the same name on SysVr4
    systems.  It provides a definition of the core file format for ELF
    used on Linux.  */
 
+#include <features.h>
 #include <signal.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <sys/ucontext.h>
 #include <sys/user.h>
 #include <asm/elf.h>
 
@@ -100,6 +100,17 @@ struct elf_prpsinfo
     char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
   };
 
+/* Addresses.  */
+typedef void *psaddr_t;
+
+/* Register sets.  Linux has different names.  */
+typedef gregset_t prgregset_t;
+typedef fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+   therefore habe only ine PID type.  */
+typedef __pid_t lwpid_t;
+
 
 /* Addresses.  */
 typedef void *psaddr_t;
diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h b/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h
index 8338778383..371a59eda4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sys/procfs.h
@@ -17,14 +17,13 @@
    Boston, MA 02111-1307, USA.  */
 
 #ifndef _SYS_PROCFS_H
-
 #define _SYS_PROCFS_H	1
-#include <features.h>
 
 /* This is somehow modelled after the file of the same name on SysVr4
    systems.  It provides a definition of the core file format for ELF
    used on Linux.  */
 
+#include <features.h>
 #include <signal.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -100,6 +99,17 @@ struct elf_prpsinfo
     char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
   };
 
+/* Addresses.  */
+typedef void *psaddr_t;
+
+/* Register sets.  Linux has different names.  */
+typedef gregset_t prgregset_t;
+typedef fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+   therefore habe only ine PID type.  */
+typedef __pid_t lwpid_t;
+
 
 /* Addresses.  */
 typedef void *psaddr_t;
diff --git a/sysdeps/unix/sysv/linux/sys/procfs.h b/sysdeps/unix/sysv/linux/sys/procfs.h
index a2a30503c2..56a14f3666 100644
--- a/sysdeps/unix/sysv/linux/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/sys/procfs.h
@@ -17,17 +17,17 @@
    Boston, MA 02111-1307, USA.  */
 
 #ifndef _SYS_PROCFS_H
-
 #define _SYS_PROCFS_H	1
-#include <features.h>
 
 /* This is somehow modelled after the file of the same name on SysVr4
    systems.  It provides a definition of the core file format for ELF
    used on Linux.  */
 
+#include <features.h>
 #include <signal.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <sys/ucontext.h>
 #include <sys/user.h>
 #include <asm/elf.h>
 
@@ -95,6 +95,17 @@ struct elf_prpsinfo
     char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
   };
 
+/* Addresses.  */
+typedef void *psaddr_t;
+
+/* Register sets.  Linux has different names.  */
+typedef gregset_t prgregset_t;
+typedef fpregset_t prfpregset_t;
+
+/* We don't have any differences between processes and threads,
+   therefore habe only ine PID type.  */
+typedef __pid_t lwpid_t;
+
 
 /* Addresses.  */
 typedef void *psaddr_t;