diff options
author | Roland McGrath <roland@gnu.org> | 2003-03-18 21:13:51 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2003-03-18 21:13:51 +0000 |
commit | 8cfb7315ea11d715d6697b8aa07166eef1e220fc (patch) | |
tree | f2b00a8ef9aa22cb6e9d40b9dada882ff55f346c /nptl_db/td_ta_event_getmsg.c | |
parent | 90758db4341e2f19a1af05a09124ec7a5676304d (diff) | |
download | glibc-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/td_ta_event_getmsg.c')
-rw-r--r-- | nptl_db/td_ta_event_getmsg.c | 27 |
1 files changed, 20 insertions, 7 deletions
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; } |