Update.
authorUlrich Drepper <drepper@redhat.com>
Fri, 12 Nov 1999 21:27:41 +0000 (21:27 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 12 Nov 1999 21:27:41 +0000 (21:27 +0000)
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.

Closes PR libc/1438.

ChangeLog
linuxthreads_db/Banner [new file with mode: 0644]
linuxthreads_db/ChangeLog
linuxthreads_db/Makefile
linuxthreads_db/td_ta_thr_iter.c
nis/nss_nisplus/nisplus-publickey.c
sysdeps/unix/sysv/linux/alpha/sys/procfs.h
sysdeps/unix/sysv/linux/arm/sys/procfs.h
sysdeps/unix/sysv/linux/mips/sys/procfs.h
sysdeps/unix/sysv/linux/powerpc/sys/procfs.h
sysdeps/unix/sysv/linux/sys/procfs.h

index 0d0d3e5dcf94e96cebf99c2653a8001f8905871e..54a5646ee6b62ce98fc98ca81d564077ed43413e 100644 (file)
--- 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 (file)
index 0000000..6f4f3f8
--- /dev/null
@@ -0,0 +1 @@
+libthread_db work sponsored by Alpha Processor Inc
index e62d56c02b7667dca06c7b634e5fd40c8bf99dab..5721a0190532fa90daf1605f9209abbc9f4c3c2a 100644 (file)
@@ -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>
index fa6b3bca5f558ff26bfb448b0c6c03fd6b7f5600..abeacf993d202e44920aedf64b53515b23cfb4d3 100644 (file)
@@ -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)
index ecc86c78711fb6a2b968f1a8e00cd11f1308d36e..8cb8c6342794984a7cb5fc40f70a1219d5c84ef1 100644 (file)
 #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;
 }
index 1620611fbc7004d517c34fac32a3c510d600aca3..2aa494f07808ce777aeedc30bb48983d1eaa2fd9 100644 (file)
@@ -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++] = '.';
index 428563b39a97a90abffc5d71e5bf2698d424c5dd..f47adeebfe51dbd18a7aa93c384c3cdd812c0319 100644 (file)
    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;
index 497c8e9b0b9133339cd6d2ed066c43976fc80dad..a2281797965546a9c99a09cd5b2ba84e619ad538 100644 (file)
    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;
index 5a94de0de54a76526c75c377b1b7256e9ed43c56..9c6bac9dc6029d4db2fd5021b00424cc6373dbe3 100644 (file)
    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;
index 83387783839b99df64e1c706ff2f57ee34acf419..371a59eda42ae6f0d41a3787c69106e624a89ee2 100644 (file)
    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;
index a2a30503c2379c823243178587377013ab95c5ae..56a14f3666be8558c19ad6a6abc2bf8efd3e6ecd 100644 (file)
    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;