2 Copyright (C) 1999-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
22 #include "thread_dbP.h"
26 td_ta_event_getmsg (const td_thragent_t
*ta_arg
, td_event_msg_t
*msg
)
28 td_thragent_t
*const ta
= (td_thragent_t
*) ta_arg
;
30 psaddr_t eventbuf
, eventnum
, eventdata
;
34 /* XXX I cannot think of another way but using a static variable. */
35 /* XXX Use at least __thread once it is possible. */
36 static td_thrhandle_t th
;
38 LOG ("td_thr_event_getmsg");
40 /* Test whether the TA parameter is ok. */
44 /* Get the pointer to the thread descriptor with the last event. */
45 err
= DB_GET_VALUE (thp
, ta
, __nptl_last_event
, 0);
50 /* Nothing waiting. */
53 /* Copy the event message buffer in from the inferior. */
54 err
= DB_GET_FIELD_ADDRESS (eventbuf
, ta
, thp
, pthread
, eventbuf
, 0);
56 err
= DB_GET_STRUCT (copy
, ta
, eventbuf
, td_eventbuf_t
);
60 /* Read the event details from the target thread. */
61 err
= DB_GET_FIELD_LOCAL (eventnum
, ta
, copy
, td_eventbuf_t
, eventnum
, 0);
64 /* If the structure is on the list there better be an event recorded. */
65 if ((int) (uintptr_t) eventnum
== TD_EVENT_NONE
)
68 /* Fill the user's data structure. */
69 err
= DB_GET_FIELD_LOCAL (eventdata
, ta
, copy
, td_eventbuf_t
, eventdata
, 0);
73 /* Generate the thread descriptor. */
74 th
.th_ta_p
= (td_thragent_t
*) ta
;
77 /* Fill the user's data structure. */
78 msg
->msg
.data
= (uintptr_t) eventdata
;
79 msg
->event
= (uintptr_t) eventnum
;
82 /* And clear the event message in the target. */
83 memset (copy
, 0, ta
->ta_sizeof_td_eventbuf_t
);
84 err
= DB_PUT_STRUCT (ta
, eventbuf
, td_eventbuf_t
, copy
);
88 /* Get the pointer to the next descriptor with an event. */
89 err
= DB_GET_FIELD (next
, ta
, thp
, pthread
, nextevent
, 0);
93 /* Store the pointer in the list head variable. */
94 err
= DB_PUT_VALUE (ta
, __nptl_last_event
, 0, next
);
99 /* Clear the next pointer in the current descriptor. */
100 err
= DB_PUT_FIELD (ta
, thp
, pthread
, nextevent
, 0, 0);