about summary refs log tree commit diff
path: root/linuxthreads_db
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads_db')
-rw-r--r--linuxthreads_db/ChangeLog12
-rw-r--r--linuxthreads_db/td_thr_clear_event.c7
-rw-r--r--linuxthreads_db/td_thr_event_enable.c15
-rw-r--r--linuxthreads_db/td_thr_event_getmsg.c7
-rw-r--r--linuxthreads_db/td_thr_set_event.c7
-rw-r--r--linuxthreads_db/td_thr_setfpregs.c7
-rw-r--r--linuxthreads_db/td_thr_setgregs.c7
-rw-r--r--linuxthreads_db/td_thr_tsd.c5
-rw-r--r--linuxthreads_db/td_thr_validate.c5
9 files changed, 56 insertions, 16 deletions
diff --git a/linuxthreads_db/ChangeLog b/linuxthreads_db/ChangeLog
index 1d1f8d7bc8..6cd9757643 100644
--- a/linuxthreads_db/ChangeLog
+++ b/linuxthreads_db/ChangeLog
@@ -1,3 +1,15 @@
+2002-07-16  Ulrich Drepper  <drepper@redhat.com>
+
+	* td_thr_clear_event.c: Yet more changes to help with TLS-enabled
+	libpthread.
+	* td_thr_event_enable.c: Likewise.
+	* td_thr_event_getmsg.c: Likewise.
+	* td_thr_set_event.c: Likewise.
+	* td_thr_setfpregs.c: Likewise.
+	* td_thr_setgregs.c: Likewise.
+	* td_thr_tsd.c: Likewise.
+	* td_thr_validate.c: Likewise.
+
 2002-07-15  Ulrich Drepper  <drepper@redhat.com>
 
 	* td_ta_thr_iter.c: Some more changes to enable using TLS-enabled
diff --git a/linuxthreads_db/td_thr_clear_event.c b/linuxthreads_db/td_thr_clear_event.c
index 57cb821a3a..c027fc09fd 100644
--- a/linuxthreads_db/td_thr_clear_event.c
+++ b/linuxthreads_db/td_thr_clear_event.c
@@ -1,5 +1,5 @@
 /* Disable specific event for thread.
-   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -33,6 +33,11 @@ td_thr_clear_event (th, event)
 
   LOG ("td_thr_clear_event");
 
+  /* If the thread descriptor has not yet been constructed do not do
+     anything.  */
+  if (th->th_unique == NULL)
+    return TD_OK;
+
   /* Write the new value into the thread data structure.  */
   if (ps_pdread (th->th_ta_p->ph,
 		 ((char *) th->th_unique
diff --git a/linuxthreads_db/td_thr_event_enable.c b/linuxthreads_db/td_thr_event_enable.c
index d6ec2a99df..b6ec4d0c2f 100644
--- a/linuxthreads_db/td_thr_event_enable.c
+++ b/linuxthreads_db/td_thr_event_enable.c
@@ -1,5 +1,5 @@
 /* Enable event process-wide.
-   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -31,12 +31,13 @@ td_thr_event_enable (th, onoff)
   LOG ("td_thr_event_enable");
 
   /* Write the new value into the thread data structure.  */
-if (th->th_unique != NULL)
-  if (ps_pdwrite (th->th_ta_p->ph,
-		  ((char *) th->th_unique
-		   + offsetof (struct _pthread_descr_struct, p_report_events)),
-		  &onoff, sizeof (int)) != PS_OK)
-    return TD_ERR;	/* XXX Other error value?  */
+  if (th->th_unique != NULL)
+    if (ps_pdwrite (th->th_ta_p->ph,
+		    ((char *) th->th_unique
+		     + offsetof (struct _pthread_descr_struct,
+				 p_report_events)),
+		    &onoff, sizeof (int)) != PS_OK)
+      return TD_ERR;	/* XXX Other error value?  */
 
   return TD_OK;
 }
diff --git a/linuxthreads_db/td_thr_event_getmsg.c b/linuxthreads_db/td_thr_event_getmsg.c
index 6a10cdce34..bf4ddd4ade 100644
--- a/linuxthreads_db/td_thr_event_getmsg.c
+++ b/linuxthreads_db/td_thr_event_getmsg.c
@@ -1,5 +1,5 @@
 /* Retrieve event.
-   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -31,6 +31,11 @@ td_thr_event_getmsg (const td_thrhandle_t *th, td_event_msg_t *msg)
 
   LOG ("td_thr_event_getmsg");
 
+  /* If the thread descriptor has not yet been created there cannot be
+     any event.  */
+  if (th->th_unique == NULL)
+    return TD_NOMSG;
+
   /* Read the even structure from the target.  */
   if (ps_pdread (th->th_ta_p->ph,
 		 ((char *) th->th_unique
diff --git a/linuxthreads_db/td_thr_set_event.c b/linuxthreads_db/td_thr_set_event.c
index b90a6a6e82..205b445c79 100644
--- a/linuxthreads_db/td_thr_set_event.c
+++ b/linuxthreads_db/td_thr_set_event.c
@@ -1,5 +1,5 @@
 /* Enable specific event for thread.
-   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -33,6 +33,11 @@ td_thr_set_event (th, event)
 
   LOG ("td_thr_set_event");
 
+  /* What shall we do if no thread descriptor exists but the user
+     wants to set an event?  */
+  if (th->th_unique == NULL)
+    return TD_NOTALLOC;
+
   /* Write the new value into the thread data structure.  */
   if (ps_pdread (th->th_ta_p->ph,
 		 ((char *) th->th_unique
diff --git a/linuxthreads_db/td_thr_setfpregs.c b/linuxthreads_db/td_thr_setfpregs.c
index 0d4fce5402..e4d9ec65e7 100644
--- a/linuxthreads_db/td_thr_setfpregs.c
+++ b/linuxthreads_db/td_thr_setfpregs.c
@@ -1,5 +1,5 @@
 /* Set a thread's floating-point register set.
-   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -24,12 +24,13 @@
 td_err_e
 td_thr_setfpregs (const td_thrhandle_t *th, const prfpregset_t *fpregs)
 {
-  struct _pthread_descr_struct pds;
+  struct _pthread_descr_struct pds = { .p_terminated = 0, .p_pid = 0 };
 
   LOG ("td_thr_setfpregs");
 
   /* We have to get the state and the PID for this thread.  */
-  if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds,
+  if (th->th_unique != NULL
+      && ps_pdread (th->th_ta_p->ph, th->th_unique, &pds,
                  sizeof (struct _pthread_descr_struct)) != PS_OK)
     return TD_ERR;
 
diff --git a/linuxthreads_db/td_thr_setgregs.c b/linuxthreads_db/td_thr_setgregs.c
index 3cf653956f..8c021a4738 100644
--- a/linuxthreads_db/td_thr_setgregs.c
+++ b/linuxthreads_db/td_thr_setgregs.c
@@ -1,5 +1,5 @@
 /* Set a thread's general register set.
-   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -24,12 +24,13 @@
 td_err_e
 td_thr_setgregs (const td_thrhandle_t *th, prgregset_t gregs)
 {
-  struct _pthread_descr_struct pds;
+  struct _pthread_descr_struct pds = { .p_terminated = 0, .p_pid = 0 };
 
   LOG ("td_thr_setgregs");
 
   /* We have to get the state and the PID for this thread.  */
-  if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds,
+  if (th->th_unique != NULL
+      && ps_pdread (th->th_ta_p->ph, th->th_unique, &pds,
                  sizeof (struct _pthread_descr_struct)) != PS_OK)
     return TD_ERR;
 
diff --git a/linuxthreads_db/td_thr_tsd.c b/linuxthreads_db/td_thr_tsd.c
index aa362fe68a..95dec466c2 100644
--- a/linuxthreads_db/td_thr_tsd.c
+++ b/linuxthreads_db/td_thr_tsd.c
@@ -36,6 +36,11 @@ td_thr_tsd (const td_thrhandle_t *th, const thread_key_t tk, void **data)
 
   LOG ("td_thr_tsd");
 
+  /* If there is no thread descriptor there cannot be any thread
+     specific data.  */
+  if (th->th_unique == NULL)
+    return TD_BADKEY;
+
   /* Get the thread descriptor.  */
   if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds,
 		 sizeof (struct _pthread_descr_struct)) != PS_OK)
diff --git a/linuxthreads_db/td_thr_validate.c b/linuxthreads_db/td_thr_validate.c
index fcce270f29..8334ef74b7 100644
--- a/linuxthreads_db/td_thr_validate.c
+++ b/linuxthreads_db/td_thr_validate.c
@@ -31,6 +31,11 @@ td_thr_validate (const td_thrhandle_t *th)
 
   LOG ("td_thr_validate");
 
+  /* A special case: if the program just starts up the handle is
+     NULL.  */
+  if (th->th_unique == NULL)
+    return TD_OK;
+
   /* Now get all descriptors, one after the other.  */
   for (cnt = 0; cnt < pthread_threads_max; ++cnt, ++handles)
     {