summary refs log tree commit diff
path: root/nptl_db
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2003-03-18 21:13:51 +0000
committerRoland McGrath <roland@gnu.org>2003-03-18 21:13:51 +0000
commit8cfb7315ea11d715d6697b8aa07166eef1e220fc (patch)
treef2b00a8ef9aa22cb6e9d40b9dada882ff55f346c /nptl_db
parent90758db4341e2f19a1af05a09124ec7a5676304d (diff)
downloadglibc-8cfb7315ea11d715d6697b8aa07166eef1e220fc.tar.gz
glibc-8cfb7315ea11d715d6697b8aa07166eef1e220fc.tar.xz
glibc-8cfb7315ea11d715d6697b8aa07166eef1e220fc.zip
* td_thr_event_getmsg.c (td_thr_event_getmsg): Splice the thread out
	of the ->nextevent linkage.

	* td_ta_event_getmsg.c (td_ta_event_getmsg): Runtime error instead of
	assert for reading TD_EVENT_NONE.  Clear the event buffer after
	reading it.  Add a sanity check for foo->nextevent = foo.
Diffstat (limited to 'nptl_db')
-rw-r--r--nptl_db/ChangeLog9
-rw-r--r--nptl_db/td_ta_event_getmsg.c27
2 files changed, 29 insertions, 7 deletions
diff --git a/nptl_db/ChangeLog b/nptl_db/ChangeLog
index 86f1dc74b4..cb5b015510 100644
--- a/nptl_db/ChangeLog
+++ b/nptl_db/ChangeLog
@@ -1,3 +1,12 @@
+2003-03-18  Roland McGrath  <roland@redhat.com>
+
+	* td_thr_event_getmsg.c (td_thr_event_getmsg): Splice the thread out
+	of the ->nextevent linkage.
+
+	* td_ta_event_getmsg.c (td_ta_event_getmsg): Runtime error instead of
+	assert for reading TD_EVENT_NONE.  Clear the event buffer after
+	reading it.  Add a sanity check for foo->nextevent = foo.
+
 2003-03-15  Roland McGrath  <roland@redhat.com>
 
 	* thread_db.h (td_err_e): Add TD_NOTLS and TD_TLSDEFER.
diff --git a/nptl_db/td_ta_event_getmsg.c b/nptl_db/td_ta_event_getmsg.c
index ae3f8e7fa6..bab44cddda 100644
--- a/nptl_db/td_ta_event_getmsg.c
+++ b/nptl_db/td_ta_event_getmsg.c
@@ -18,7 +18,6 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <assert.h>
 #include <stddef.h>
 #include <string.h>
 
@@ -55,7 +54,8 @@ td_ta_event_getmsg (const td_thragent_t *ta, td_event_msg_t *msg)
     return TD_ERR;	/* XXX Other error value?  */
 
   /* If the structure is on the list there better be an event recorded.  */
-  assert (event.eventnum != TD_EVENT_NONE);
+  if (event.eventnum == TD_EVENT_NONE)
+    return TD_DBERR;
 
   /* Generate the thread descriptor.  */
   th.th_ta_p = (td_thragent_t *) ta;
@@ -66,22 +66,35 @@ td_ta_event_getmsg (const td_thragent_t *ta, td_event_msg_t *msg)
   msg->th_p = &th;
   msg->msg.data = (uintptr_t) event.eventdata;
 
+  /* And clear the event message in the target.  */
+  memset (&event, '\0', sizeof (td_eventbuf_t));
+  if (ps_pdwrite (ta->ph, (char *) addr + offsetof (struct pthread, eventbuf),
+		  &event, sizeof (td_eventbuf_t)) != PS_OK)
+    return TD_ERR;	/* XXX Other error value?  */
+
   /* Get the pointer to the next descriptor with an event.  */
   psaddr_t next;
   if (ps_pdread (ta->ph, (char *) addr + offsetof (struct pthread, nextevent),
 		 &next, sizeof (struct pthread *)) != PS_OK)
     return TD_ERR;	/* XXX Other error value?  */
 
+  if (next == addr)
+    return TD_DBERR;
+
   /* Store the pointer in the list head variable.  */
   if (ps_pdwrite (ta->ph, ta->pthread_last_event,
 		  &next, sizeof (struct pthread *)) != PS_OK)
     return TD_ERR;	/* XXX Other error value?  */
 
-  /* Clear the next pointer in the current descriptor.  */
-  next = NULL;
-  if (ps_pdwrite (ta->ph, (char *) addr + offsetof (struct pthread, nextevent),
-		  &next, sizeof (struct pthread *)) != PS_OK)
-    return TD_ERR;	/* XXX Other error value?  */
+  if (next != NULL)
+    {
+      /* Clear the next pointer in the current descriptor.  */
+      next = NULL;
+      if (ps_pdwrite (ta->ph,
+		      (char *) addr + offsetof (struct pthread, nextevent),
+		      &next, sizeof (struct pthread *)) != PS_OK)
+	return TD_ERR;	/* XXX Other error value?  */
+    }
 
   return TD_OK;
 }