2 Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 #include "thread_dbP.h"
29 td_ta_event_getmsg (const td_thragent_t
*ta
, td_event_msg_t
*msg
)
31 /* XXX I cannot think of another way but using a static variable. */
32 /* XXX Use at least __thread once it is possible. */
33 static td_thrhandle_t th
;
35 LOG ("td_ta_event_getmsg");
37 /* Test whether the TA parameter is ok. */
41 /* Get the pointer to the thread descriptor with the last event. */
43 if (ps_pdread (ta
->ph
, ta
->pthread_last_event
,
44 &addr
, sizeof (struct pthread
*)) != PS_OK
)
45 return TD_ERR
; /* XXX Other error value? */
48 /* Nothing waiting. */
51 /* Read the event structure from the target. */
53 if (ps_pdread (ta
->ph
, (char *) addr
+ offsetof (struct pthread
, eventbuf
),
54 &event
, sizeof (td_eventbuf_t
)) != PS_OK
)
55 return TD_ERR
; /* XXX Other error value? */
57 /* If the structure is on the list there better be an event recorded. */
58 assert (event
.eventnum
!= TD_EVENT_NONE
);
60 /* Generate the thread descriptor. */
61 th
.th_ta_p
= (td_thragent_t
*) ta
;
64 /* Fill the user's data structure. */
65 msg
->event
= event
.eventnum
;
67 msg
->msg
.data
= (uintptr_t) event
.eventdata
;
69 /* Get the pointer to the next descriptor with an event. */
71 if (ps_pdread (ta
->ph
, (char *) addr
+ offsetof (struct pthread
, nextevent
),
72 &next
, sizeof (struct pthread
*)) != PS_OK
)
73 return TD_ERR
; /* XXX Other error value? */
75 /* Store the pointer in the list head variable. */
76 if (ps_pdwrite (ta
->ph
, ta
->pthread_last_event
,
77 &next
, sizeof (struct pthread
*)) != PS_OK
)
78 return TD_ERR
; /* XXX Other error value? */
80 /* Clear the next pointer in the current descriptor. */
82 if (ps_pdwrite (ta
->ph
, (char *) addr
+ offsetof (struct pthread
, nextevent
),
83 &next
, sizeof (struct pthread
*)) != PS_OK
)
84 return TD_ERR
; /* XXX Other error value? */