xref: /titanic_41/usr/src/lib/libtnfctl/prb_proc_int.h (revision eb0cc229f19c437a6b538d3ac0d0443268290b7e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _PRB_PROC_INT_H
28 #define	_PRB_PROC_INT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Interfaces private to proc layer
38  */
39 
40 #include <sys/types.h>
41 #include <sys/syscall.h>
42 
43 #include <tnf/probe.h>
44 #include <note.h>
45 
46 #include "prb_proc.h"
47 
48 /*
49  * size of breakpoint instruction
50  */
51 #if defined(__sparc)
52 typedef unsigned int bptsave_t;
53 #elif defined(__i386) || defined(__amd64)
54 typedef unsigned char bptsave_t;
55 #endif
56 
57 /*
58  * memory shared between parent and child when exec'ing a child.
59  * child spins on "spin" member waiting for parent to set it free
60  */
61 typedef struct shmem_msg {
62 	boolean_t	spin;
63 } shmem_msg_t;
64 NOTE(SCHEME_PROTECTS_DATA("parent writes; child reads", shmem_msg))
65 
66 /*
67  * per /proc handle state
68  */
69 struct prb_proc_ctl {
70 	int 		procfd;
71 	int		pid;
72 	uintptr_t	bptaddr;
73 	bptsave_t	saveinstr;	/* instruction that bpt replaced */
74 	boolean_t	bpt_inserted;	/* is bpt inserted ? */
75 	uintptr_t	dbgaddr;
76 };
77 NOTE(SCHEME_PROTECTS_DATA("one thread per handle", prb_proc_ctl))
78 
79 /*
80  * Declarations
81  */
82 prb_status_t	prb_status_map(int);
83 prb_status_t	find_executable(const char *name, char *ret_path);
84 
85 /* shared memory lock interfaces */
86 prb_status_t	prb_shmem_init(volatile shmem_msg_t **);
87 prb_status_t	prb_shmem_wait(volatile shmem_msg_t *);
88 prb_status_t	prb_shmem_clear(volatile shmem_msg_t *);
89 prb_status_t	prb_shmem_free(volatile shmem_msg_t *smp);
90 
91 /* runs and stops the process to clear it out of system call */
92 prb_status_t	prb_proc_prstop(prb_proc_ctl_t *proc_p);
93 
94 /* break point interfaces */
95 prb_status_t	prb_proc_tracebpt(prb_proc_ctl_t *proc_p, boolean_t bpt);
96 prb_status_t	prb_proc_istepbpt(prb_proc_ctl_t *proc_p);
97 prb_status_t	prb_proc_clrbptflt(prb_proc_ctl_t *proc_p);
98 
99 /* read a string from target process */
100 prb_status_t	prb_proc_readstr(prb_proc_ctl_t *proc_p, uintptr_t addr,
101 			const char **outstr_pp);
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif	/* _PRB_PROC_INT_H */
108