te
All Rights Reserved Copyright (c) 1998, Sun Microsystems, Inc. All Rights Reserved
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.
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.
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]
TD_THR_GET_INFO 3C_DB "Oct 20, 1998"
NAME
td_thr_get_info - get thread information in libc_db library of interfaces
SYNOPSIS

cc [ flag... ] file... -lc_db [ library... ]
#include <proc_service.h>
#include <thread_db.h>

td_err_e td_thr_get_info(const td_thrhandle_t *th_p, td_thrinfo_t *ti_p);
DESCRIPTION

The td_thr_get_info() function fills in the td_thrinfo_t structure *ti_p with values for the thread identified by th_p.

The td_thrinfo_t structure contains the following fields:

typedef struct td_thrinfo_t {
 td_thragen_tx *ti_ta_p /* internal process handle */
 unsigned ti_user_flags; /* value of flags parameter */
 thread_t ti_tid; /* thread identifier */
 char *ti_tls; /* pointer to thread-local storage*/
 paddr ti_startfunc; /* address of function at which thread
 execution began*/
 paddr ti_stkbase; /* base of thread's stack area*/
 int ti_stksize; /* size in bytes of thread's allocated
 stack region*/
 paddr ti_ro_area; /* address of ulwp_t structure*/
 int ti_ro_size /* size of the ulwp_t structure in
 bytes */
 td_thr_state_e ti_state /* state of the thread */
 uchar_t ti_db_suspended /* non-zero if thread suspended by
 td_thr_dbsuspend*/
 td_thr_type_e ti_type /* type of the thread*/
 int ti_pc /* value of thread's program counter*/
 int ti_sp /* value of thread's stack counter*/
 short ti_flags /* set of special flags used by
 libc*/
 int ti_pri /* priority of thread returned by
 thr_getprio(3T)*/
 lwpid_t ti_lid /* id of light weight process (LWP)
 executing this thread*/
 sigset_t ti_sigmask /* thread's signal mask. See
 thr_sigsetmask(3T)*/
 u_char ti_traceme /* non-zero if event tracing is on*/
 u_char_t ti_preemptflag /* non-zero if thread preempted when
 last active*/
 u_char_t ti_pirecflag /* non-zero if thread runs priority
 beside regular */
 sigset_t ti_pending /* set of signals pending for this
 thread*/
 td_thr_events_t ti_events /* bitmap of events enabled for this
 thread*/
} ;

The ti_ta_p member is the internal process handle identifying the process of which the thread is a member.

The ti_user_flags member is the value of the flags parameter passed to thr_create(3C) when the thread was created.

The ti_tid member is the thread identifier for the thread returned by thr_create(3C).

The ti_tls member is the thread's pointer to thread-local storage.

The ti_startfunc member is the address of the function at which thread execution began, as specified when the thread was created with thr_create(3C).

The ti_stkbase member is the base of the thread's stack area.

The ti_stksize member is the size in bytes of the thread's allocated stack region.

The ti_ro_area member is the address of the ulwp_t structure for this thread. Since accessing the ulwp_t structure directly violates the encapsulation provided by libc_db, this member should generally not be used. However, it might be useful as a prototype for extensions.

The ti_state member is the state of the thread. The td_thr_state_e enumeration type can contain the following values: TD_THR_ANY_STATE

This value is never returned by td_thr_get_info() but is used as a wildcard to select threads in td_ta_thr_iter().

TD_THR_UNKNOWN

The libc_db library cannot determine the state of the thread.

TD_THR_STOPPED

The thread has been stopped by a call to thr_suspend(3C).

TD_THR_RUN

The thread is runnable, but it is not currently assigned to an LWP.

TD_THR_ACTIVE

The thread is currently executing on an LWP.

TD_THR_ZOMBIE

The thread has exited, but it has not yet been deallocated by a call to thr_join(3C).

TD_THR_SLEEP

The thread is not currently runnable.

TD_THR_STOPPED_ASLEEP

The thread is both blocked by TD_THR_SLEEP and stopped by a call to td_thr_dbsuspend(3C_DB).

The ti_db_suspended member is non-zero if and only if this thread is currently suspended because the controlling process has called td_thr_dbsuspend on it.

The ti_type member is a type of thread. It is either TD_THR_USER for a user thread (one created by the application), or TD_THR_SYSTEM for one created by libc.

The ti_pc member is the value of the thread's program counter, provided that the thread's ti_state value is TD_THR_SLEEP, TD_THR_STOPPED, or TD_THR_STOPPED_ASLEEP. Otherwise, the value of this member is undefined.

The ti_sp member is the value of the thread's stack pointer, provided that the thread's ti_state value is TD_THR_SLEEP, TD_THR_STOPPED, or TD_THR_STOPPED_ASLEEP. Otherwise, the value of this member is undefined.

The ti_flags member is a set of special flags used by libc, currently of use only to those debugging libc.

The ti_pri member is the thread's priority as it would be returned by thr_getprio(3C).

The ti_lid member is the ID of the LWP executing this thread, or the ID of the LWP that last executed this thread, if this thread is not currently assigned to anLWP.

The ti_sigmask member is this thread's signal mask. See thr_sigsetmask(3C).

The ti_traceme member is non-zero if and only if event tracing for this thread is on.

The ti_preemptflag member is non-zero if and only if the thread was preempted the last time it was active.

The ti_pirecflag member is non-zero if and only if due to priority inheritance the thread is currently running at a priority other than its regular priority.

The ti_events member is the bitmap of events enabled for this thread.

RETURN VALUES
TD_OK

The call completed successfully.

TD_BADTH

An invalid thread handle was passed in.

TD_DBERR

A call to one of the imported interface routines failed.

TD_ERR

The call did not complete successfully.

ATTRIBUTES

See attributes(5) for description of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
MT-Level Safe
SEE ALSO

libc_db(3LIB), td_ta_thr_iter(3C_DB), td_thr_dbsuspend(3C_DB), thr_create(3C), thr_getprio(3C), thr_join(3C), thr_sigsetmask(3C), thr_suspend(3C), attributes(5), threads(5)