2 .\" Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH TD_TA_EVENT_ADDR 3C_DB "Oct 19, 1998"
8 td_ta_event_addr, td_thr_event_enable, td_ta_set_event, td_thr_set_event,
9 td_ta_clear_event, td_thr_clear_event, td_ta_event_getmsg, td_thr_event_getmsg,
10 td_event_emptyset, td_event_fillset, td_event_addset, td_event_delset,
11 td_eventismember, td_eventisempty \- thread events in libc_db
15 cc [ \fIflag\fR... ] \fIfile\fR... -lc_db [ \fIlibrary\fR... ]
16 #include <proc_service.h>
17 #include <thread_db.h>
19 \fBtd_err_e\fR \fBtd_ta_event_addr\fR(\fBconst td_thragent_t *\fR\fIta_p\fR, \fBu_long event,td_notify_t *\fR\fInotify_p\fR);
24 \fBtd_err_e\fR \fBtd_thr_event_enable\fR(\fBconst td_thrhandle_t *\fR\fIth_p\fR, \fBint\fR \fIon_off\fR);
29 \fBtd_err_e\fR \fBtd_thr_set_event\fR(\fBconst td_thrhandle_t *\fR\fIth_p\fR, \fBtd_thr_events_t *\fR\fIevents\fR);
34 \fBtd_err_e\fR \fBtd_ta_set_event\fR(\fBconst td_thragent_t *\fR\fIta_p\fR, \fBtd_thr_events_t *\fR\fIevents\fR);
39 \fBtd_err_e\fR \fBtd_thr_clear_event\fR(\fBconst td_thrhandle_t *\fR\fIth_p\fR, \fBtd_thr_events_t *\fR\fIevents\fR);
44 \fBtd_err_e\fR \fBtd_ta_clear_event\fR(\fBconst td_thragent_t *\fR\fIta_p\fR, \fBtd_thr_events_t *\fR\fIevents\fR);
49 \fBtd_err_e\fR \fBtd_thr_event_getmsg\fR(\fBconst td_thrhandle_t *\fR\fIth_p\fR, \fBtd_event_msg_t *\fR\fImsg\fR);
54 \fBtd_err_e\fR \fBtd_ta_event_getmsg\fR(\fBconst td_thragent_t *\fR\fIta_p\fR, \fBtd_event_msg_t *\fR\fImsg\fR);
59 \fBvoid\fR \fBtd_event_emptyset\fR(\fBtd_thr_events_t\fR *);
64 \fBvoid\fR \fBtd_event_fillset\fR(\fBtd_thr_events_t\fR *);
69 \fBvoid\fR \fBtd_event_addset\fR(\fBtd_thr_events_t\fR \fI*\fR, \fBtd_thr_events_e\fR\fI n\fR);
74 \fBvoid\fR \fBtd_event_delset\fR(\fBtd_thr_events_t\fR \fI*\fR, \fBtd_thr_events_e\fR\fI n\fR);
79 \fBvoid\fR \fBtd_eventismember\fR(\fBtd_thr_events_t\fR \fI*\fR, \fBtd_thr_events_e\fR\fI n\fR);
84 \fBvoid\fR \fBtd_eventisempty\fR(\fBtd_thr_events_t\fR\fI*\fR);
90 These functions comprise the thread event facility for \fBlibc_db\fR(3LIB).
91 This facility allows the controlling process to be notified when certain
92 thread-related events occur in a target process and to retrieve information
93 associated with these events. An event consists of an event type, and
94 optionally, some associated event data, depending on the event type. See the
95 section titled "Event Set Manipulation Macros" that follows.
98 The event type and the associated event data, if any, constitute an "event
99 message." "Reporting an event" means delivering an event message to the
100 controlling process by way of \fBlibc_db\fR.
103 Several flags can control event reporting, both a per-thread and per event
104 basis. Event reporting may further be enabled or disabled for a thread. There
105 is not only a per-thread event mask that specifies which event types should be
106 reported for that thread, but there is also a global event mask that applies
110 An event is reported, if and only if, the executing thread has event reporting
111 enabled, and either the event type is enabled in the executing thread's event
112 mask, or the event type is enabled in the global event mask.
115 Each thread has associated with it an event buffer in which it stores the most
116 recent event message it has generated, the type of the most recent event that
117 it reported, and, depending on the event type, some additional information
118 related to that event. See the section titled "Event Set Manipulation Macros"
119 for a description of the \fBtd_thr_events_e\fR and \fBtd_event_msg_t\fR types
120 and a list of the event types and the values reported with them. The thread
121 handle, type \fBtd_thrhandle_t\fR, the event type, and the possible value,
122 together constitute an event message. Each thread's event buffer holds at most
126 Each event type has an event reporting address associated with it. A thread
127 reports an event by writing the event message into the thread's event buffer
128 and having control reach the event reporting address for that event type.
131 Typically, the controlling process sets a breakpoint at the event reporting
132 address for one or more event types. When the breakpoint is hit, the
133 controlling process knows that an event of the corresponding type has occurred.
136 The event types, and the additional information, if any, reported with each
144 The thread became ready to execute.
153 The thread has blocked on a synchronization object.
159 \fB\fBTD_SWITCHTO\fR\fR
162 A runnable thread is being assigned to \fBLWP.\fR
168 \fB\fBTD_SWITCHFROM\fR\fR
171 A running thread is being removed from its \fBLWP.\fR
177 \fB\fBTD_LOCK_TRY\fR\fR
180 A thread is trying to get an unavailable lock.
186 \fB\fBTD_CATCHSIG\fR\fR
189 A signal was posted to a thread.
198 An \fBLWP\fR is becoming idle.
204 \fB\fBTD_CREATE\fR\fR
207 A thread is being created.
216 A thread has terminated.
222 \fB\fBTD_PREEMPT\fR\fR
225 A thread is being preempted.
231 \fB\fBTD_PRI_INHERIT\fR\fR
234 A thread is inheriting an elevated priority from another thread.
243 A thread is being reaped.
249 \fB\fBTD_CONCURRENCY\fR\fR
252 The number of \fBLWPs\fR is changing.
258 \fB\fBTD_TIMEOUT\fR\fR
261 A condition-variable timed wait expired.
266 The \fBtd_ta_event_addr()\fR function returns in *\fInotify_p\fR the event
267 reporting address associated with event type \fBevent\fR. The controlling
268 process may then set a breakpoint at that address. If a thread hits that
269 breakpoint, it reports an event of type \fBevent\fR.
272 The \fBtd_thr_event_enable()\fR function enables or disables event reporting
273 for thread \fIth_p\fR. If a thread has event reporting disabled, it will not
274 report any events. Threads are started with event reporting disabled. Event
275 reporting is enabled if \fBon_off\fR is non-zero; otherwise, it is disabled.
276 To determine whether or not event reporting is enabled on a thread, call
277 \fBtd_thr_getinfo()\fR for the thread and examine the \fBti_traceme\fR member
278 of the \fBtd_thrinfo_t\fR structure it returns.
281 The \fBtd_thr_set_event()\fR and \fBtd_thr_clear_event()\fR functions set and
282 clear, respectively, a set of event types in the event mask associated with the
283 thread \fIth_p\fR. To inspect a thread's event mask, call
284 \fBtd_thr_getinfo()\fR for the thread and examine the \fBti_events\fR member of
285 the \fBtd_thrinfo_t\fR structure it returns.
288 The \fBtd_ta_set_event()\fR and \fBtd_ta_clear_event()\fR functions identical
289 to \fBtd_thr_set_event()\fR and \fBtd_thr_clear_event()\fR, respectively,
290 except that the target process's global event mask is modified. There is no
291 provision for inspecting the value of a target process's global event mask.
294 The \fBtd_thr_event_getmsg()\fR function returns in *\fImsg\fR the event
295 message associated with thread *\fIth_p\fR. Reading a thread's event message
296 consumes the message, emptying the thread's event buffer. As noted above, each
297 thread's event buffer holds at most one event message; if a thread reports a
298 second event before the first event message has been read, the second event
299 message overwrites the first.
302 The \fBtd_ta_event_getmsg()\fR function is identical to
303 \fBtd_thr_event_getmsg()\fR, except that it is passed a process handle rather
304 than a thread handle. It selects some thread that has an event message buffered
305 and returns that thread's message. The thread selected is undefined, except
306 that as long as at least one thread has an event message buffered, it returns
307 an event message from some such thread.
308 .SS "Event Set Manipulation Macros"
311 Several macros are provided for manipulating event sets of type
312 \fBtd_thr_events_t\fR:
316 \fB\fBtd_event_emptyset\fR \fR
319 Sets its argument to the \fINULL\fR event set.
325 \fB\fBtd_event_fillset\fR\fR
328 Sets its argument to the set of all events.
334 \fB\fBtd_event_addset\fR\fR
337 Adds a specific event type to an event set.
343 \fB\fBtd_event_delset\fR\fR
346 Deletes a specific event type from an event set.
352 \fB\fBtd_eventismember\fR\fR
355 Tests whether a specific event type is a member of an event set.
361 \fB\fBtd_eventisempty\fR\fR
364 Tests whether an event set is the \fINULL\fR set.
370 The following values may be returned for all thread event routines:
377 The call returned successfully.
386 An invalid thread handle was passed in.
395 An invalid internal process handle was passed.
404 There is a \fINULL\fR external process handle associated with this internal
414 A call to one of the imported interface routines failed.
423 No event message was available to return to \fBtd_thr_event_getmsg()\fR or
424 \fBtd_ta_event_getmsg()\fR.
433 Some other parameter error occurred, or a \fBlibc_db()\fR internal error
439 The following value can be returned for \fBtd_thr_event_enable()\fR,
440 \fBtd_thr_set_event()\fR, and \fBtd_thr_clear_event()\fR only:
444 \fB\fBTD_NOCAPAB\fR \fR
447 Because the agent thread in the target process has not completed
448 initialization, this operation cannot be performed. The operation can be
449 performed after the target process has been allowed to make some forward
450 progress. See \fBlibc_db\fR(3LIB).
456 See \fBattributes\fR(5) for description of the following attributes:
464 ATTRIBUTE TYPE ATTRIBUTE VALUE
472 \fBlibc_db\fR(3LIB), \fBattributes\fR(5)