Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/agent/src/os/linux/thread_db.h
38833 views
/*1* Copyright (C) 2013 The Android Open Source Project2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/1516#pragma once1718#include <pthread.h>19#include <signal.h>20#include <stdint.h>21// #include <sys/procfs.h>22#include "glibc_procfs.h"23#include <sys/types.h>2425#define TD_THR_ANY_USER_FLAGS 0xffffffff26#define TD_THR_LOWEST_PRIORITY -2027#define TD_SIGNO_MASK NULL2829/* td_err_e values */30enum {31TD_OK,32TD_ERR,33TD_NOTHR,34TD_NOSV,35TD_NOLWP,36TD_BADPH,37TD_BADTH,38TD_BADSH,39TD_BADTA,40TD_BADKEY,41TD_NOMSG,42TD_NOFPREGS,43TD_NOLIBTHREAD,44TD_NOEVENT,45TD_NOCAPAB,46TD_DBERR,47TD_NOAPLIC,48TD_NOTSD,49TD_MALLOC,50TD_PARTIALREG,51TD_NOXREGS,52TD_VERSION53};5455/*56* td_event_e values57* NOTE: There is a max of 32 events58*/59enum {60TD_CREATE,61TD_DEATH62};6364/* td_thr_state_e values */65enum {66TD_THR_ANY_STATE,67TD_THR_UNKNOWN,68TD_THR_SLEEP,69TD_THR_ZOMBIE70};7172typedef int32_t td_err_e;73typedef uint32_t td_event_e;74typedef uint32_t td_notify_e;75typedef uint32_t td_thr_state_e;76typedef pthread_t thread_t;7778typedef struct79{80pid_t pid;81struct ps_prochandle *ph;82} td_thragent_t;8384typedef struct85{86pid_t pid;87pid_t tid;88psaddr_t th_unique;89} td_thrhandle_t;9091typedef struct92{93td_event_e event;94td_thrhandle_t const * th_p;95union {96void * data;97} msg;98} td_event_msg_t;99100typedef struct101{102uint32_t events;103} td_thr_events_t;104105typedef struct106{107union {108void * bptaddr;109} u;110} td_notify_t;111112typedef struct113{114td_thr_state_e ti_state;115thread_t ti_tid; // pthread's id for the thread116int32_t ti_lid; // the kernel's id for the thread117} td_thrinfo_t;118119120#define td_event_emptyset(set) \121(set)->events = 0122123#define td_event_fillset(set) \124(set)->events = 0xffffffff125126#define td_event_addset(set, n) \127(set)->events |= (1 << n)128129130typedef int td_thr_iter_f(td_thrhandle_t const *, void *);131132133struct ps_prochandle;134135#ifdef __cplusplus136extern "C"{137#endif138139extern td_err_e td_ta_new(struct ps_prochandle * proc_handle, td_thragent_t ** thread_agent);140141extern td_err_e td_ta_delete(td_thragent_t * ta);142143extern td_err_e td_ta_set_event(td_thragent_t const * agent, td_thr_events_t * event);144145extern td_err_e td_ta_event_addr(td_thragent_t const * agent, td_event_e event, td_notify_t * notify);146147extern td_err_e td_ta_clear_event(const td_thragent_t * ta_arg,148td_thr_events_t * event);149150extern td_err_e td_ta_event_getmsg(td_thragent_t const * agent, td_event_msg_t * event);151152extern td_err_e td_ta_map_lwp2thr(td_thragent_t const * agent, lwpid_t lwpid,153td_thrhandle_t *th);154155extern td_err_e td_thr_get_info(td_thrhandle_t const * handle,156td_thrinfo_t * info);157158extern td_err_e td_thr_event_enable(const td_thrhandle_t * handle,159int event);160161extern td_err_e td_ta_thr_iter(td_thragent_t const * agent, td_thr_iter_f * func, void * cookie,162td_thr_state_e state, int32_t prio, sigset_t * sigmask, uint32_t user_flags);163164extern char const ** td_symbol_list(void);165166extern td_err_e td_thr_get_info(td_thrhandle_t const * handle, td_thrinfo_t * info);167168extern td_err_e td_thr_tlsbase(const td_thrhandle_t*, unsigned long int, psaddr_t*);169170extern td_err_e td_thr_tls_get_addr(const td_thrhandle_t*, psaddr_t, size_t, psaddr_t*);171172#ifdef __cplusplus173}174#endif175176177