1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _PROC_SERVICE_H 28*7c478bd9Sstevel@tonic-gate #define _PROC_SERVICE_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Description: 34*7c478bd9Sstevel@tonic-gate * Types, global variables, and function definitions for provider 35*7c478bd9Sstevel@tonic-gate * of import functions for users of libc_db and librtld_db. 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 39*7c478bd9Sstevel@tonic-gate extern "C" { 40*7c478bd9Sstevel@tonic-gate #endif 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 43*7c478bd9Sstevel@tonic-gate #include <sys/procfs_isa.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/lwp.h> 45*7c478bd9Sstevel@tonic-gate #include <sys/auxv.h> 46*7c478bd9Sstevel@tonic-gate #include <elf.h> 47*7c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64) /* for struct ssd */ 48*7c478bd9Sstevel@tonic-gate #include <sys/segments.h> 49*7c478bd9Sstevel@tonic-gate #include <sys/sysi86.h> 50*7c478bd9Sstevel@tonic-gate #endif 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate typedef unsigned long psaddr_t; 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate typedef enum { 56*7c478bd9Sstevel@tonic-gate PS_OK, /* generic "call succeeded" */ 57*7c478bd9Sstevel@tonic-gate PS_ERR, /* generic error */ 58*7c478bd9Sstevel@tonic-gate PS_BADPID, /* bad process handle */ 59*7c478bd9Sstevel@tonic-gate PS_BADLID, /* bad lwp identifier */ 60*7c478bd9Sstevel@tonic-gate PS_BADADDR, /* bad address */ 61*7c478bd9Sstevel@tonic-gate PS_NOSYM, /* p_lookup() could not find given symbol */ 62*7c478bd9Sstevel@tonic-gate PS_NOFREGS /* FPU register set not available for given lwp */ 63*7c478bd9Sstevel@tonic-gate } ps_err_e; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate struct ps_prochandle; 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate /* 68*7c478bd9Sstevel@tonic-gate * See <sys/procfs_isa.h> for possible values of data_model. 69*7c478bd9Sstevel@tonic-gate */ 70*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pdmodel(struct ps_prochandle *, int *data_model); 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate /* 73*7c478bd9Sstevel@tonic-gate * Special values for 'object_name' to refer to certain well-known objects. 74*7c478bd9Sstevel@tonic-gate */ 75*7c478bd9Sstevel@tonic-gate #define PS_OBJ_EXEC ((const char *)0x0) /* the executable file */ 76*7c478bd9Sstevel@tonic-gate #define PS_OBJ_LDSO ((const char *)0x1) /* the dynamic linker */ 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pglobal_lookup(struct ps_prochandle *, 79*7c478bd9Sstevel@tonic-gate const char *object_name, const char *sym_name, psaddr_t *sym_addr); 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate #ifdef _LP64 82*7c478bd9Sstevel@tonic-gate typedef Elf64_Sym ps_sym_t; 83*7c478bd9Sstevel@tonic-gate #else 84*7c478bd9Sstevel@tonic-gate typedef Elf32_Sym ps_sym_t; 85*7c478bd9Sstevel@tonic-gate #endif 86*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pglobal_sym(struct ps_prochandle *, 87*7c478bd9Sstevel@tonic-gate const char *object_name, const char *sym_name, ps_sym_t *sym); 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate /* 90*7c478bd9Sstevel@tonic-gate * To read and write the process's address space. 91*7c478bd9Sstevel@tonic-gate */ 92*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pread(struct ps_prochandle *, 93*7c478bd9Sstevel@tonic-gate psaddr_t, void *, size_t); 94*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pwrite(struct ps_prochandle *, 95*7c478bd9Sstevel@tonic-gate psaddr_t, const void *, size_t); 96*7c478bd9Sstevel@tonic-gate /* 97*7c478bd9Sstevel@tonic-gate * The following four functions can be implemented as simple aliases for 98*7c478bd9Sstevel@tonic-gate * the corresponding primary two functions above (#pragma weak ...). 99*7c478bd9Sstevel@tonic-gate * They are artifacts of history that must be maintained. 100*7c478bd9Sstevel@tonic-gate */ 101*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pdread(struct ps_prochandle *, 102*7c478bd9Sstevel@tonic-gate psaddr_t, void *, size_t); 103*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pdwrite(struct ps_prochandle *, 104*7c478bd9Sstevel@tonic-gate psaddr_t, const void *, size_t); 105*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_ptread(struct ps_prochandle *, 106*7c478bd9Sstevel@tonic-gate psaddr_t, void *, size_t); 107*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_ptwrite(struct ps_prochandle *, 108*7c478bd9Sstevel@tonic-gate psaddr_t, const void *, size_t); 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pstop(struct ps_prochandle *); 111*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pcontinue(struct ps_prochandle *); 112*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lstop(struct ps_prochandle *, lwpid_t); 113*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lcontinue(struct ps_prochandle *, lwpid_t); 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetregs(struct ps_prochandle *, 116*7c478bd9Sstevel@tonic-gate lwpid_t, prgregset_t); 117*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lsetregs(struct ps_prochandle *, 118*7c478bd9Sstevel@tonic-gate lwpid_t, const prgregset_t); 119*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetfpregs(struct ps_prochandle *, 120*7c478bd9Sstevel@tonic-gate lwpid_t, prfpregset_t *); 121*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lsetfpregs(struct ps_prochandle *, 122*7c478bd9Sstevel@tonic-gate lwpid_t, const prfpregset_t *); 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate #if defined(__sparc) || defined(__sparcv9) 125*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetxregsize(struct ps_prochandle *, lwpid_t, int *); 126*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetxregs(struct ps_prochandle *, lwpid_t, caddr_t); 127*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lsetxregs(struct ps_prochandle *, lwpid_t, caddr_t); 128*7c478bd9Sstevel@tonic-gate #endif 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate #if defined(__i386) || defined(__amd64) 131*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lgetLDT(struct ps_prochandle *, lwpid_t, struct ssd *); 132*7c478bd9Sstevel@tonic-gate #endif 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_pauxv(struct ps_prochandle *, const auxv_t **); 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_kill(struct ps_prochandle *, int sig); 137*7c478bd9Sstevel@tonic-gate extern ps_err_e ps_lrolltoaddr(struct ps_prochandle *, 138*7c478bd9Sstevel@tonic-gate lwpid_t, psaddr_t go_addr, psaddr_t stop_addr); 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate extern void ps_plog(const char *fmt, ...); 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 143*7c478bd9Sstevel@tonic-gate } 144*7c478bd9Sstevel@tonic-gate #endif 145*7c478bd9Sstevel@tonic-gate 146*7c478bd9Sstevel@tonic-gate #endif /* _PROC_SERVICE_H */ 147