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 2005 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 #include <stdlib.h>
28*7c478bd9Sstevel@tonic-gate #include <assert.h>
29*7c478bd9Sstevel@tonic-gate #include <errno.h>
30*7c478bd9Sstevel@tonic-gate #include <string.h>
31*7c478bd9Sstevel@tonic-gate #include <libgen.h>
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gate #include <dt_impl.h>
34*7c478bd9Sstevel@tonic-gate #include <dt_pid.h>
35*7c478bd9Sstevel@tonic-gate
36*7c478bd9Sstevel@tonic-gate #define OP(x) ((x) >> 30)
37*7c478bd9Sstevel@tonic-gate #define OP2(x) (((x) >> 22) & 0x07)
38*7c478bd9Sstevel@tonic-gate #define COND(x) (((x) >> 25) & 0x0f)
39*7c478bd9Sstevel@tonic-gate #define A(x) (((x) >> 29) & 0x01)
40*7c478bd9Sstevel@tonic-gate
41*7c478bd9Sstevel@tonic-gate #define OP_BRANCH 0
42*7c478bd9Sstevel@tonic-gate
43*7c478bd9Sstevel@tonic-gate #define OP2_BPcc 0x1
44*7c478bd9Sstevel@tonic-gate #define OP2_Bicc 0x2
45*7c478bd9Sstevel@tonic-gate #define OP2_BPr 0x3
46*7c478bd9Sstevel@tonic-gate #define OP2_FBPfcc 0x5
47*7c478bd9Sstevel@tonic-gate #define OP2_FBfcc 0x6
48*7c478bd9Sstevel@tonic-gate
49*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
50*7c478bd9Sstevel@tonic-gate int
dt_pid_create_entry_probe(struct ps_prochandle * P,dtrace_hdl_t * dtp,fasttrap_probe_spec_t * ftp,const GElf_Sym * symp)51*7c478bd9Sstevel@tonic-gate dt_pid_create_entry_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
52*7c478bd9Sstevel@tonic-gate fasttrap_probe_spec_t *ftp, const GElf_Sym *symp)
53*7c478bd9Sstevel@tonic-gate {
54*7c478bd9Sstevel@tonic-gate ftp->ftps_type = DTFTP_ENTRY;
55*7c478bd9Sstevel@tonic-gate ftp->ftps_pc = (uintptr_t)symp->st_value;
56*7c478bd9Sstevel@tonic-gate ftp->ftps_size = (size_t)symp->st_size;
57*7c478bd9Sstevel@tonic-gate ftp->ftps_noffs = 1;
58*7c478bd9Sstevel@tonic-gate ftp->ftps_offs[0] = 0;
59*7c478bd9Sstevel@tonic-gate
60*7c478bd9Sstevel@tonic-gate if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
61*7c478bd9Sstevel@tonic-gate dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
62*7c478bd9Sstevel@tonic-gate strerror(errno));
63*7c478bd9Sstevel@tonic-gate return (dt_set_errno(dtp, errno));
64*7c478bd9Sstevel@tonic-gate }
65*7c478bd9Sstevel@tonic-gate
66*7c478bd9Sstevel@tonic-gate return (1);
67*7c478bd9Sstevel@tonic-gate }
68*7c478bd9Sstevel@tonic-gate
69*7c478bd9Sstevel@tonic-gate int
dt_pid_create_return_probe(struct ps_prochandle * P,dtrace_hdl_t * dtp,fasttrap_probe_spec_t * ftp,const GElf_Sym * symp,uint64_t * stret)70*7c478bd9Sstevel@tonic-gate dt_pid_create_return_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
71*7c478bd9Sstevel@tonic-gate fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, uint64_t *stret)
72*7c478bd9Sstevel@tonic-gate {
73*7c478bd9Sstevel@tonic-gate
74*7c478bd9Sstevel@tonic-gate uint32_t *text;
75*7c478bd9Sstevel@tonic-gate int i;
76*7c478bd9Sstevel@tonic-gate int srdepth = 0;
77*7c478bd9Sstevel@tonic-gate
78*7c478bd9Sstevel@tonic-gate if ((text = malloc(symp->st_size + 4)) == NULL) {
79*7c478bd9Sstevel@tonic-gate dt_dprintf("mr sparkle: malloc() failed\n");
80*7c478bd9Sstevel@tonic-gate return (DT_PROC_ERR);
81*7c478bd9Sstevel@tonic-gate }
82*7c478bd9Sstevel@tonic-gate
83*7c478bd9Sstevel@tonic-gate if (Pread(P, text, symp->st_size, symp->st_value) != symp->st_size) {
84*7c478bd9Sstevel@tonic-gate dt_dprintf("mr sparkle: Pread() failed\n");
85*7c478bd9Sstevel@tonic-gate free(text);
86*7c478bd9Sstevel@tonic-gate return (DT_PROC_ERR);
87*7c478bd9Sstevel@tonic-gate }
88*7c478bd9Sstevel@tonic-gate
89*7c478bd9Sstevel@tonic-gate /*
90*7c478bd9Sstevel@tonic-gate * Leave a dummy instruction in the last slot to simplify edge
91*7c478bd9Sstevel@tonic-gate * conditions.
92*7c478bd9Sstevel@tonic-gate */
93*7c478bd9Sstevel@tonic-gate text[symp->st_size / 4] = 0;
94*7c478bd9Sstevel@tonic-gate
95*7c478bd9Sstevel@tonic-gate ftp->ftps_type = DTFTP_RETURN;
96*7c478bd9Sstevel@tonic-gate ftp->ftps_pc = symp->st_value;
97*7c478bd9Sstevel@tonic-gate ftp->ftps_size = symp->st_size;
98*7c478bd9Sstevel@tonic-gate ftp->ftps_noffs = 0;
99*7c478bd9Sstevel@tonic-gate
100*7c478bd9Sstevel@tonic-gate for (i = 0; i < symp->st_size / 4; i++) {
101*7c478bd9Sstevel@tonic-gate /*
102*7c478bd9Sstevel@tonic-gate * If we encounter an existing tracepoint, query the
103*7c478bd9Sstevel@tonic-gate * kernel to find out the instruction that was
104*7c478bd9Sstevel@tonic-gate * replaced at this spot.
105*7c478bd9Sstevel@tonic-gate */
106*7c478bd9Sstevel@tonic-gate while (text[i] == FASTTRAP_INSTR) {
107*7c478bd9Sstevel@tonic-gate fasttrap_instr_query_t instr;
108*7c478bd9Sstevel@tonic-gate
109*7c478bd9Sstevel@tonic-gate instr.ftiq_pid = Pstatus(P)->pr_pid;
110*7c478bd9Sstevel@tonic-gate instr.ftiq_pc = symp->st_value + i * 4;
111*7c478bd9Sstevel@tonic-gate
112*7c478bd9Sstevel@tonic-gate if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_GETINSTR,
113*7c478bd9Sstevel@tonic-gate &instr) != 0) {
114*7c478bd9Sstevel@tonic-gate
115*7c478bd9Sstevel@tonic-gate if (errno == ESRCH || errno == ENOENT) {
116*7c478bd9Sstevel@tonic-gate if (Pread(P, &text[i], 4,
117*7c478bd9Sstevel@tonic-gate instr.ftiq_pc) != 4) {
118*7c478bd9Sstevel@tonic-gate dt_dprintf("mr sparkle: "
119*7c478bd9Sstevel@tonic-gate "Pread() failed\n");
120*7c478bd9Sstevel@tonic-gate free(text);
121*7c478bd9Sstevel@tonic-gate return (DT_PROC_ERR);
122*7c478bd9Sstevel@tonic-gate }
123*7c478bd9Sstevel@tonic-gate continue;
124*7c478bd9Sstevel@tonic-gate }
125*7c478bd9Sstevel@tonic-gate
126*7c478bd9Sstevel@tonic-gate free(text);
127*7c478bd9Sstevel@tonic-gate dt_dprintf("mr sparkle: getinstr query "
128*7c478bd9Sstevel@tonic-gate "failed: %s\n", strerror(errno));
129*7c478bd9Sstevel@tonic-gate return (DT_PROC_ERR);
130*7c478bd9Sstevel@tonic-gate }
131*7c478bd9Sstevel@tonic-gate
132*7c478bd9Sstevel@tonic-gate text[i] = instr.ftiq_instr;
133*7c478bd9Sstevel@tonic-gate break;
134*7c478bd9Sstevel@tonic-gate }
135*7c478bd9Sstevel@tonic-gate
136*7c478bd9Sstevel@tonic-gate /* save */
137*7c478bd9Sstevel@tonic-gate if ((text[i] & 0xc1f80000) == 0x81e00000) {
138*7c478bd9Sstevel@tonic-gate srdepth++;
139*7c478bd9Sstevel@tonic-gate continue;
140*7c478bd9Sstevel@tonic-gate }
141*7c478bd9Sstevel@tonic-gate
142*7c478bd9Sstevel@tonic-gate /* restore */
143*7c478bd9Sstevel@tonic-gate if ((text[i] & 0xc1f80000) == 0x81e80000) {
144*7c478bd9Sstevel@tonic-gate srdepth--;
145*7c478bd9Sstevel@tonic-gate continue;
146*7c478bd9Sstevel@tonic-gate }
147*7c478bd9Sstevel@tonic-gate
148*7c478bd9Sstevel@tonic-gate if (srdepth > 0) {
149*7c478bd9Sstevel@tonic-gate /* ret */
150*7c478bd9Sstevel@tonic-gate if (text[i] == 0x81c7e008)
151*7c478bd9Sstevel@tonic-gate goto is_ret;
152*7c478bd9Sstevel@tonic-gate
153*7c478bd9Sstevel@tonic-gate /* return */
154*7c478bd9Sstevel@tonic-gate if (text[i] == 0x81cfe008)
155*7c478bd9Sstevel@tonic-gate goto is_ret;
156*7c478bd9Sstevel@tonic-gate
157*7c478bd9Sstevel@tonic-gate /* call or jmpl w/ restore in the slot */
158*7c478bd9Sstevel@tonic-gate if (((text[i] & 0xc0000000) == 0x40000000 ||
159*7c478bd9Sstevel@tonic-gate (text[i] & 0xc1f80000) == 0x81c00000) &&
160*7c478bd9Sstevel@tonic-gate (text[i + 1] & 0xc1f80000) == 0x81e80000)
161*7c478bd9Sstevel@tonic-gate goto is_ret;
162*7c478bd9Sstevel@tonic-gate
163*7c478bd9Sstevel@tonic-gate /* call to one of the stret routines */
164*7c478bd9Sstevel@tonic-gate if ((text[i] & 0xc0000000) == 0x40000000) {
165*7c478bd9Sstevel@tonic-gate int32_t disp = text[i] << 2;
166*7c478bd9Sstevel@tonic-gate uint64_t dest = ftp->ftps_pc + i * 4 + disp;
167*7c478bd9Sstevel@tonic-gate
168*7c478bd9Sstevel@tonic-gate dt_dprintf("dest = %llx\n", (u_longlong_t)dest);
169*7c478bd9Sstevel@tonic-gate
170*7c478bd9Sstevel@tonic-gate if (dest == stret[0] || dest == stret[1] ||
171*7c478bd9Sstevel@tonic-gate dest == stret[2] || dest == stret[3])
172*7c478bd9Sstevel@tonic-gate goto is_ret;
173*7c478bd9Sstevel@tonic-gate }
174*7c478bd9Sstevel@tonic-gate } else {
175*7c478bd9Sstevel@tonic-gate /* external call */
176*7c478bd9Sstevel@tonic-gate if ((text[i] & 0xc0000000) == 0x40000000) {
177*7c478bd9Sstevel@tonic-gate int32_t dst = text[i] << 2;
178*7c478bd9Sstevel@tonic-gate
179*7c478bd9Sstevel@tonic-gate dst += i * 4;
180*7c478bd9Sstevel@tonic-gate
181*7c478bd9Sstevel@tonic-gate if ((uintptr_t)dst >= (uintptr_t)symp->st_size)
182*7c478bd9Sstevel@tonic-gate goto is_ret;
183*7c478bd9Sstevel@tonic-gate }
184*7c478bd9Sstevel@tonic-gate
185*7c478bd9Sstevel@tonic-gate /* jmpl into %g0 -- this includes the retl pseudo op */
186*7c478bd9Sstevel@tonic-gate if ((text[i] & 0xfff80000) == 0x81c00000)
187*7c478bd9Sstevel@tonic-gate goto is_ret;
188*7c478bd9Sstevel@tonic-gate
189*7c478bd9Sstevel@tonic-gate /* external branch -- possible return site */
190*7c478bd9Sstevel@tonic-gate if (OP(text[i]) == OP_BRANCH) {
191*7c478bd9Sstevel@tonic-gate int32_t dst;
192*7c478bd9Sstevel@tonic-gate int baa;
193*7c478bd9Sstevel@tonic-gate
194*7c478bd9Sstevel@tonic-gate switch (OP2(text[i])) {
195*7c478bd9Sstevel@tonic-gate case OP2_BPcc:
196*7c478bd9Sstevel@tonic-gate dst = text[i] & 0x7ffff;
197*7c478bd9Sstevel@tonic-gate dst <<= 13;
198*7c478bd9Sstevel@tonic-gate dst >>= 11;
199*7c478bd9Sstevel@tonic-gate
200*7c478bd9Sstevel@tonic-gate baa = COND(text[i]) == 8 && A(text[i]);
201*7c478bd9Sstevel@tonic-gate break;
202*7c478bd9Sstevel@tonic-gate case OP2_Bicc:
203*7c478bd9Sstevel@tonic-gate dst = text[i] & 0x3fffff;
204*7c478bd9Sstevel@tonic-gate dst <<= 10;
205*7c478bd9Sstevel@tonic-gate dst >>= 8;
206*7c478bd9Sstevel@tonic-gate
207*7c478bd9Sstevel@tonic-gate baa = COND(text[i]) == 8 && A(text[i]);
208*7c478bd9Sstevel@tonic-gate break;
209*7c478bd9Sstevel@tonic-gate case OP2_BPr:
210*7c478bd9Sstevel@tonic-gate dst = (((text[i]) >> 6) & 0xc000) |
211*7c478bd9Sstevel@tonic-gate ((text[i]) & 0x3fff);
212*7c478bd9Sstevel@tonic-gate dst <<= 16;
213*7c478bd9Sstevel@tonic-gate dst >>= 14;
214*7c478bd9Sstevel@tonic-gate
215*7c478bd9Sstevel@tonic-gate baa = 0;
216*7c478bd9Sstevel@tonic-gate break;
217*7c478bd9Sstevel@tonic-gate case OP2_FBPfcc:
218*7c478bd9Sstevel@tonic-gate dst = text[i] & 0x7ffff;
219*7c478bd9Sstevel@tonic-gate dst <<= 13;
220*7c478bd9Sstevel@tonic-gate dst >>= 11;
221*7c478bd9Sstevel@tonic-gate
222*7c478bd9Sstevel@tonic-gate baa = COND(text[i]) == 8 && A(text[i]);
223*7c478bd9Sstevel@tonic-gate break;
224*7c478bd9Sstevel@tonic-gate case OP2_FBfcc:
225*7c478bd9Sstevel@tonic-gate dst = text[i] & 0x3fffff;
226*7c478bd9Sstevel@tonic-gate dst <<= 10;
227*7c478bd9Sstevel@tonic-gate dst >>= 8;
228*7c478bd9Sstevel@tonic-gate
229*7c478bd9Sstevel@tonic-gate baa = COND(text[i]) == 8 && A(text[i]);
230*7c478bd9Sstevel@tonic-gate break;
231*7c478bd9Sstevel@tonic-gate default:
232*7c478bd9Sstevel@tonic-gate continue;
233*7c478bd9Sstevel@tonic-gate }
234*7c478bd9Sstevel@tonic-gate
235*7c478bd9Sstevel@tonic-gate dst += i * 4;
236*7c478bd9Sstevel@tonic-gate
237*7c478bd9Sstevel@tonic-gate /*
238*7c478bd9Sstevel@tonic-gate * Interpret branches outside of the function's
239*7c478bd9Sstevel@tonic-gate * bounds as potential return sites. If the
240*7c478bd9Sstevel@tonic-gate * branch is a ba,a don't skip the instruction
241*7c478bd9Sstevel@tonic-gate * in the delay slot.
242*7c478bd9Sstevel@tonic-gate */
243*7c478bd9Sstevel@tonic-gate if ((uintptr_t)dst >=
244*7c478bd9Sstevel@tonic-gate (uintptr_t)symp->st_size) {
245*7c478bd9Sstevel@tonic-gate if (baa)
246*7c478bd9Sstevel@tonic-gate goto is_ret_baa;
247*7c478bd9Sstevel@tonic-gate else
248*7c478bd9Sstevel@tonic-gate goto is_ret;
249*7c478bd9Sstevel@tonic-gate }
250*7c478bd9Sstevel@tonic-gate }
251*7c478bd9Sstevel@tonic-gate }
252*7c478bd9Sstevel@tonic-gate
253*7c478bd9Sstevel@tonic-gate continue;
254*7c478bd9Sstevel@tonic-gate is_ret:
255*7c478bd9Sstevel@tonic-gate i++;
256*7c478bd9Sstevel@tonic-gate is_ret_baa:
257*7c478bd9Sstevel@tonic-gate dt_dprintf("return at offset %x\n", i * 4);
258*7c478bd9Sstevel@tonic-gate ftp->ftps_offs[ftp->ftps_noffs++] = i * 4;
259*7c478bd9Sstevel@tonic-gate }
260*7c478bd9Sstevel@tonic-gate
261*7c478bd9Sstevel@tonic-gate free(text);
262*7c478bd9Sstevel@tonic-gate if (ftp->ftps_noffs > 0) {
263*7c478bd9Sstevel@tonic-gate if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
264*7c478bd9Sstevel@tonic-gate dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
265*7c478bd9Sstevel@tonic-gate strerror(errno));
266*7c478bd9Sstevel@tonic-gate return (dt_set_errno(dtp, errno));
267*7c478bd9Sstevel@tonic-gate }
268*7c478bd9Sstevel@tonic-gate }
269*7c478bd9Sstevel@tonic-gate
270*7c478bd9Sstevel@tonic-gate
271*7c478bd9Sstevel@tonic-gate return (ftp->ftps_noffs);
272*7c478bd9Sstevel@tonic-gate }
273*7c478bd9Sstevel@tonic-gate
274*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
275*7c478bd9Sstevel@tonic-gate int
dt_pid_create_offset_probe(struct ps_prochandle * P,dtrace_hdl_t * dtp,fasttrap_probe_spec_t * ftp,const GElf_Sym * symp,ulong_t off)276*7c478bd9Sstevel@tonic-gate dt_pid_create_offset_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
277*7c478bd9Sstevel@tonic-gate fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, ulong_t off)
278*7c478bd9Sstevel@tonic-gate {
279*7c478bd9Sstevel@tonic-gate if (off & 0x3)
280*7c478bd9Sstevel@tonic-gate return (DT_PROC_ALIGN);
281*7c478bd9Sstevel@tonic-gate
282*7c478bd9Sstevel@tonic-gate ftp->ftps_type = DTFTP_OFFSETS;
283*7c478bd9Sstevel@tonic-gate ftp->ftps_pc = (uintptr_t)symp->st_value;
284*7c478bd9Sstevel@tonic-gate ftp->ftps_size = (size_t)symp->st_size;
285*7c478bd9Sstevel@tonic-gate ftp->ftps_noffs = 1;
286*7c478bd9Sstevel@tonic-gate ftp->ftps_offs[0] = off;
287*7c478bd9Sstevel@tonic-gate
288*7c478bd9Sstevel@tonic-gate if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
289*7c478bd9Sstevel@tonic-gate dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
290*7c478bd9Sstevel@tonic-gate strerror(errno));
291*7c478bd9Sstevel@tonic-gate return (dt_set_errno(dtp, errno));
292*7c478bd9Sstevel@tonic-gate }
293*7c478bd9Sstevel@tonic-gate
294*7c478bd9Sstevel@tonic-gate return (1);
295*7c478bd9Sstevel@tonic-gate }
296*7c478bd9Sstevel@tonic-gate
297*7c478bd9Sstevel@tonic-gate /*ARGSUSED*/
298*7c478bd9Sstevel@tonic-gate int
dt_pid_create_glob_offset_probes(struct ps_prochandle * P,dtrace_hdl_t * dtp,fasttrap_probe_spec_t * ftp,const GElf_Sym * symp,const char * pattern)299*7c478bd9Sstevel@tonic-gate dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp,
300*7c478bd9Sstevel@tonic-gate fasttrap_probe_spec_t *ftp, const GElf_Sym *symp, const char *pattern)
301*7c478bd9Sstevel@tonic-gate {
302*7c478bd9Sstevel@tonic-gate ulong_t i;
303*7c478bd9Sstevel@tonic-gate
304*7c478bd9Sstevel@tonic-gate ftp->ftps_type = DTFTP_OFFSETS;
305*7c478bd9Sstevel@tonic-gate ftp->ftps_pc = (uintptr_t)symp->st_value;
306*7c478bd9Sstevel@tonic-gate ftp->ftps_size = (size_t)symp->st_size;
307*7c478bd9Sstevel@tonic-gate ftp->ftps_noffs = 0;
308*7c478bd9Sstevel@tonic-gate
309*7c478bd9Sstevel@tonic-gate /*
310*7c478bd9Sstevel@tonic-gate * If we're matching against everything, just iterate through each
311*7c478bd9Sstevel@tonic-gate * instruction in the function, otherwise look for matching offset
312*7c478bd9Sstevel@tonic-gate * names by constructing the string and comparing it against the
313*7c478bd9Sstevel@tonic-gate * pattern.
314*7c478bd9Sstevel@tonic-gate */
315*7c478bd9Sstevel@tonic-gate if (strcmp("*", pattern) == 0) {
316*7c478bd9Sstevel@tonic-gate for (i = 0; i < symp->st_size; i += 4) {
317*7c478bd9Sstevel@tonic-gate ftp->ftps_offs[ftp->ftps_noffs++] = i;
318*7c478bd9Sstevel@tonic-gate }
319*7c478bd9Sstevel@tonic-gate } else {
320*7c478bd9Sstevel@tonic-gate char name[sizeof (i) * 2 + 1];
321*7c478bd9Sstevel@tonic-gate
322*7c478bd9Sstevel@tonic-gate for (i = 0; i < symp->st_size; i += 4) {
323*7c478bd9Sstevel@tonic-gate (void) sprintf(name, "%lx", i);
324*7c478bd9Sstevel@tonic-gate if (gmatch(name, pattern))
325*7c478bd9Sstevel@tonic-gate ftp->ftps_offs[ftp->ftps_noffs++] = i;
326*7c478bd9Sstevel@tonic-gate }
327*7c478bd9Sstevel@tonic-gate }
328*7c478bd9Sstevel@tonic-gate
329*7c478bd9Sstevel@tonic-gate if (ioctl(dtp->dt_ftfd, FASTTRAPIOC_MAKEPROBE, ftp) != 0) {
330*7c478bd9Sstevel@tonic-gate dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
331*7c478bd9Sstevel@tonic-gate strerror(errno));
332*7c478bd9Sstevel@tonic-gate return (dt_set_errno(dtp, errno));
333*7c478bd9Sstevel@tonic-gate }
334*7c478bd9Sstevel@tonic-gate
335*7c478bd9Sstevel@tonic-gate return (ftp->ftps_noffs);
336*7c478bd9Sstevel@tonic-gate }
337