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
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.
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]
23 * Copyright (c) 1994, by Sun Microsytems, Inc.
26 #pragma ident "%Z%%M% %I% %E% SMI"
46 static queue_node_t g_fcnlist
= {
51 * Forward Declarations
54 static void fcn_destroy(fcn_t
* fcn_p
);
55 static void fcn_print(FILE * stream
, fcn_t
* fcn_p
);
59 * fcn() - builds a function block and inserts it on the global list.
65 fcn(char *name_p
, char *entry_name_p
)
70 /* does this setname exist already? */
71 old_p
= fcn_find(name_p
);
75 /* create a new set */
77 queue_init(&new_p
->qn
);
78 new_p
->name_p
= name_p
;
79 new_p
->entry_name_p
= entry_name_p
;
83 * allocate a target function block, and stuff the init and fini
86 prbstat
= prb_targmem_alloc(g_procfd
, sizeof (probe_funcs_t
),
89 semantic_err(gettext("problem allocating target memory"));
92 prbstat
= prb_proc_write(g_procfd
, new_p
->funcs_p
,
93 &new_p
->funcs
, sizeof (probe_funcs_t
));
96 "setup problem, initial/final "
97 "funcs in target memory"));
102 /* append the new set to the global list */
103 (void) queue_append(&g_fcnlist
, &new_p
->qn
);
116 * fcn_destroy() - destroys a fcn and related resources
120 fcn_destroy(fcn_t
* fcn_p
)
125 /* remove ourselves from any list */
126 if (!queue_isempty(&fcn_p
->qn
))
127 (void) queue_remove(&fcn_p
->qn
);
131 if (fcn_p
->entry_name_p
)
132 free(fcn_p
->entry_name_p
);
136 } /* end fcn_destroy */
140 * fcn_list() - pretty prints the global fcnlist
148 fcn_p
= (fcn_t
*) & g_fcnlist
;
149 while ((fcn_p
= (fcn_t
*) queue_next(&g_fcnlist
, &fcn_p
->qn
))) {
150 fcn_print(stdout
, fcn_p
);
157 * fcn_print() - pretty prints a fcn
161 fcn_print(FILE * stream
, fcn_t
* fcn_p
)
166 (void) fprintf(stream
, "&%-8s %-24s\n",
167 fcn_p
->name_p
, fcn_p
->entry_name_p
);
169 } /* end fcn_print */
173 * fcn_findname() - find the created name, given an entry name
177 fcn_findname(const char * const entry_p
)
184 fcn_p
= (fcn_t
*) & g_fcnlist
;
185 while ((fcn_p
= (fcn_t
*) queue_next(&g_fcnlist
, &fcn_p
->qn
)))
186 if (strcmp(entry_p
, fcn_p
->entry_name_p
) == 0)
187 return (fcn_p
->name_p
);
191 } /* end fcn_findname */
195 * fcn_find() - finds a fcn by name
199 fcn_find(char *fcnname_p
)
206 fcn_p
= (fcn_t
*) & g_fcnlist
;
207 while ((fcn_p
= (fcn_t
*) queue_next(&g_fcnlist
, &fcn_p
->qn
)))
208 if (strcmp(fcnname_p
, fcn_p
->name_p
) == 0)