xref: /titanic_41/usr/src/cmd/tnf/prex/help.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 (c) 1994, by Sun Microsytems, Inc.
24*7c478bd9Sstevel@tonic-gate  */
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate #include <stdio.h>
29*7c478bd9Sstevel@tonic-gate #include <strings.h>
30*7c478bd9Sstevel@tonic-gate #include "expr.h"
31*7c478bd9Sstevel@tonic-gate #include "y.tab.h"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #define	NUMHELPTOPICS	6
34*7c478bd9Sstevel@tonic-gate static char *helptopics[NUMHELPTOPICS] = {
35*7c478bd9Sstevel@tonic-gate 	"intro", "functions", "kernel_mode", "probe_spec", "processes",
36*7c478bd9Sstevel@tonic-gate 	"set_spec" };
37*7c478bd9Sstevel@tonic-gate static char *helptopicstrings[NUMHELPTOPICS] = {
38*7c478bd9Sstevel@tonic-gate /* help intro */
39*7c478bd9Sstevel@tonic-gate "Introduction to prex\n"
40*7c478bd9Sstevel@tonic-gate "\n"
41*7c478bd9Sstevel@tonic-gate "prex is used to control probes in a target process, or in the kernel.\n"
42*7c478bd9Sstevel@tonic-gate "If you are reading this help text, you have sucessfully invoked prex,\n"
43*7c478bd9Sstevel@tonic-gate "by either connecting to an existing process (prex -p), a new\n"
44*7c478bd9Sstevel@tonic-gate "process (prex myprogram), or to the kernel (prex -k).\n"
45*7c478bd9Sstevel@tonic-gate "\n"
46*7c478bd9Sstevel@tonic-gate "Most often, the user will want to enable some probes in the target,\n"
47*7c478bd9Sstevel@tonic-gate "continue the target - either to completion, or until the target is\n"
48*7c478bd9Sstevel@tonic-gate "interrupted - and then exit from prex to perform analysis on the resulting\n"
49*7c478bd9Sstevel@tonic-gate "tracefile.  An ascii dump of the tracefile can be obtained using the\n"
50*7c478bd9Sstevel@tonic-gate "tnfdump(1) command.\n"
51*7c478bd9Sstevel@tonic-gate "\n"
52*7c478bd9Sstevel@tonic-gate "The tracefile can be found in /tmp/trace-<pid> by default, or in a location\n"
53*7c478bd9Sstevel@tonic-gate "of your choice, if you specify the -o option when you invoke prex.\n"
54*7c478bd9Sstevel@tonic-gate "You can query the name of the current trace file by using the command.\n"
55*7c478bd9Sstevel@tonic-gate "list tracefile.\n"
56*7c478bd9Sstevel@tonic-gate "\n"
57*7c478bd9Sstevel@tonic-gate "Upon invocation, prex reads commands from the files ~/.prexrc and\n"
58*7c478bd9Sstevel@tonic-gate "./.prexrc (in that order).  The \"source\" command may be used to take\n"
59*7c478bd9Sstevel@tonic-gate "commands from an arbitrary file or set of files.\n"
60*7c478bd9Sstevel@tonic-gate "\n"
61*7c478bd9Sstevel@tonic-gate "Help is available for a variety of topics, and for each prex command.\n"
62*7c478bd9Sstevel@tonic-gate "Type help with no arguments for a list of available help topics.\n"
63*7c478bd9Sstevel@tonic-gate "\n"
64*7c478bd9Sstevel@tonic-gate "end of help for topic intro\n",
65*7c478bd9Sstevel@tonic-gate /* help functions */
66*7c478bd9Sstevel@tonic-gate "Probe Functions\n"
67*7c478bd9Sstevel@tonic-gate "\n"
68*7c478bd9Sstevel@tonic-gate "Note - probe functions are not available from kernel mode\n"
69*7c478bd9Sstevel@tonic-gate "\n"
70*7c478bd9Sstevel@tonic-gate "It is possible to use prex to connect functions to probe points, such that\n"
71*7c478bd9Sstevel@tonic-gate "the function is invoked each time a given probe point is hit.  Currently,\n"
72*7c478bd9Sstevel@tonic-gate "the only function available from prex is the &debug function, which prints\n"
73*7c478bd9Sstevel@tonic-gate "out the arguments sent in to the probe, as well as the value (if any)\n"
74*7c478bd9Sstevel@tonic-gate "associated with the sunw%debug attribute in the detail field.\n"
75*7c478bd9Sstevel@tonic-gate "\n"
76*7c478bd9Sstevel@tonic-gate "Relevant commands:\n"
77*7c478bd9Sstevel@tonic-gate "    list fcns                    # list the defined probe functions\n"
78*7c478bd9Sstevel@tonic-gate "    connect &debug name=myprobe  # attach probe &debug to probe myprobe\n"
79*7c478bd9Sstevel@tonic-gate "    connect &debug $myset        # attach probe &debug to probes in $myset\n"
80*7c478bd9Sstevel@tonic-gate "    clear name=myprobe           # disconnect probe functions from myprobe\n"
81*7c478bd9Sstevel@tonic-gate "    clear $myset                 # disconnect probe functions from $myset\n"
82*7c478bd9Sstevel@tonic-gate "\n"
83*7c478bd9Sstevel@tonic-gate "end of help for topic functions\n",
84*7c478bd9Sstevel@tonic-gate /* help kernel_mode */
85*7c478bd9Sstevel@tonic-gate "Controlling Kernel Probes\n"
86*7c478bd9Sstevel@tonic-gate "\n"
87*7c478bd9Sstevel@tonic-gate "The Solaris kernel is instrumented with a small number of strategically\n"
88*7c478bd9Sstevel@tonic-gate "placed probes, documented in tnf_kernel_probes(4).  The superuser can\n"
89*7c478bd9Sstevel@tonic-gate "control these probes by running prex with the \"-k\" option.\n"
90*7c478bd9Sstevel@tonic-gate "\n"
91*7c478bd9Sstevel@tonic-gate "In kernel mode, trace output is written to an in-core buffer, rather\n"
92*7c478bd9Sstevel@tonic-gate "than to a file on disk.  This buffer can be extracted with the tnfxtract(1)\n"
93*7c478bd9Sstevel@tonic-gate "commmand.  This buffer must be set up before tracing can begin, through the\n"
94*7c478bd9Sstevel@tonic-gate "use of the \"buffer alloc\" command.  After kernel tracing is complete (and\n"
95*7c478bd9Sstevel@tonic-gate "after the buffer has been extracted), the buffer can be deallocated from\n"
96*7c478bd9Sstevel@tonic-gate "prex using the \"buffer dealloc\" command.\n"
97*7c478bd9Sstevel@tonic-gate "\n"
98*7c478bd9Sstevel@tonic-gate "As in user mode, kernel probe control is accomplished using the commands\n"
99*7c478bd9Sstevel@tonic-gate "\"trace\", \"untrace\", \"enable\", and \"disable\".  Additionally, in\n"
100*7c478bd9Sstevel@tonic-gate "kernel mode, a \"master switch\" is provided to turn all tracing activity\n"
101*7c478bd9Sstevel@tonic-gate "on or off.  This switch is toggled using the commands \"ktrace on\" and\n"
102*7c478bd9Sstevel@tonic-gate "\"ktrace off\".  Unlike user mode, where the target is stopped while\n"
103*7c478bd9Sstevel@tonic-gate "tracing paramaters are manipulated from prex, the kernel does not stop\n"
104*7c478bd9Sstevel@tonic-gate "running during a tracing session.  Using the \"ktrace\" command, one can\n"
105*7c478bd9Sstevel@tonic-gate "set up all tracing parameters in advance of a session, without actually\n"
106*7c478bd9Sstevel@tonic-gate "writing trace records until a \"ktrace on\" command is given.\n"
107*7c478bd9Sstevel@tonic-gate "\n"
108*7c478bd9Sstevel@tonic-gate "Kernel mode also provides the ability to limit tracing to those kernel\n"
109*7c478bd9Sstevel@tonic-gate "probes hit on behalf of a specific user process.  The pfilter command\n"
110*7c478bd9Sstevel@tonic-gate "is provided to toggle process filtering on or off, and to specify the\n"
111*7c478bd9Sstevel@tonic-gate "set of processes that comprise the filter.  If pid 0 is a member of the\n"
112*7c478bd9Sstevel@tonic-gate "filter list, then any threads not associated with a process are included.\n"
113*7c478bd9Sstevel@tonic-gate "\n"
114*7c478bd9Sstevel@tonic-gate "Note that after a kernel tracing session, all tracing parameters are left\n"
115*7c478bd9Sstevel@tonic-gate "as-is.  One should re-enter prex to disable and untrace probes, turn off\n"
116*7c478bd9Sstevel@tonic-gate "process filtering, and deallocate the in-core trace buffer.\n"
117*7c478bd9Sstevel@tonic-gate "\n"
118*7c478bd9Sstevel@tonic-gate "Relevant Commands:\n"
119*7c478bd9Sstevel@tonic-gate "    buffer alloc 2m    # allocate a 2M in-core buffer\n"
120*7c478bd9Sstevel@tonic-gate "    enable $all        # enable all kernel probes\n"
121*7c478bd9Sstevel@tonic-gate "    trace $all         # trace all kernel probes\n"
122*7c478bd9Sstevel@tonic-gate "    ktrace on          # turn on kernel tracing\n"
123*7c478bd9Sstevel@tonic-gate "    pfilter add 1234   # add pid 1234 to the filter list\n"
124*7c478bd9Sstevel@tonic-gate "    pfilter on         # turn on process filtering\n"
125*7c478bd9Sstevel@tonic-gate "    ktrace off         # turn off kernel tracing\n"
126*7c478bd9Sstevel@tonic-gate "Also see tnfxtract(1), which is used to extract the in-core trace buffer\n"
127*7c478bd9Sstevel@tonic-gate "to an on-disk tracefile.\n"
128*7c478bd9Sstevel@tonic-gate "\n"
129*7c478bd9Sstevel@tonic-gate "end of help for topic kernel_mode\n",
130*7c478bd9Sstevel@tonic-gate /* help probe_spec */
131*7c478bd9Sstevel@tonic-gate "Probe Specification\n"
132*7c478bd9Sstevel@tonic-gate "\n"
133*7c478bd9Sstevel@tonic-gate "Many prex commands operate on probes or sets of probes.  Probes are\n"
134*7c478bd9Sstevel@tonic-gate "specified by a list of space-separated selectors of the form:\n"
135*7c478bd9Sstevel@tonic-gate "      <attribute>=<value>\n"
136*7c478bd9Sstevel@tonic-gate "If the \""
137*7c478bd9Sstevel@tonic-gate "<attribute>=\" is omitted, the attribute defaults to \"keys=\".\n"
138*7c478bd9Sstevel@tonic-gate "The \""
139*7c478bd9Sstevel@tonic-gate "<value>\" can be either a string or an ed(1) regular expression\n"
140*7c478bd9Sstevel@tonic-gate "enclosed in slashes.  Regular expressions in prex are unanchored, meaning\n"
141*7c478bd9Sstevel@tonic-gate "that any value that contains the given regex as a substring is a valid\n"
142*7c478bd9Sstevel@tonic-gate "match, regardless of position.  To anchor a regular expression, use \"^\"\n"
143*7c478bd9Sstevel@tonic-gate "to match the beginning of a line, or \"$\" to match the end of a line.\n"
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate "If a list of selectors is specified, an OR operation is applied - the\n"
146*7c478bd9Sstevel@tonic-gate "resulting probe_spec includes probes that match any of the selectors.\n"
147*7c478bd9Sstevel@tonic-gate "See the prex(1) man page for a complete specification of the accepted\n"
148*7c478bd9Sstevel@tonic-gate "grammar.\n"
149*7c478bd9Sstevel@tonic-gate "\n"
150*7c478bd9Sstevel@tonic-gate "The \"list\" command is used to view available probes in the target,\n"
151*7c478bd9Sstevel@tonic-gate "and to display their attributes. The \"trace\" and \"untrace\" commands\n"
152*7c478bd9Sstevel@tonic-gate "determine whether a probe will write a trace record when hit.  The\n"
153*7c478bd9Sstevel@tonic-gate "\"enable\" and \"disable\" commands indicate whether a probe will perform\n"
154*7c478bd9Sstevel@tonic-gate "any action (such as a calling a connected function or creating a trace\n"
155*7c478bd9Sstevel@tonic-gate "record) when hit.   Normally, a probe is enabled and traced for tracing,\n"
156*7c478bd9Sstevel@tonic-gate "and disabled and untraced otherwise.  It is possible to enable a probe\n"
157*7c478bd9Sstevel@tonic-gate "with tracing off to get debug output without writing trace records.\n"
158*7c478bd9Sstevel@tonic-gate "\n"
159*7c478bd9Sstevel@tonic-gate "Relevant Commands:\n"
160*7c478bd9Sstevel@tonic-gate "   list probes $all         # list probes in set $all (all probes)\n"
161*7c478bd9Sstevel@tonic-gate "   list probes file=test.c  # list probes with a specific attribute\n"
162*7c478bd9Sstevel@tonic-gate "   list 'file' probes $all  # list the file attribute in all probes\n"
163*7c478bd9Sstevel@tonic-gate "   list probes name=/^thr/  # list probes whose name attribute matches\n"
164*7c478bd9Sstevel@tonic-gate "                            # the given regular expression\n"
165*7c478bd9Sstevel@tonic-gate "   list probes name=/^thr/ keys=vm  # list probes matching either selector\n"
166*7c478bd9Sstevel@tonic-gate "   enable name=/^thr/       # enable probes whose name matches this regex\n"
167*7c478bd9Sstevel@tonic-gate "   trace $all               # trace all probes\n"
168*7c478bd9Sstevel@tonic-gate "   untrace $myset           # untrace probes in set $myset\n"
169*7c478bd9Sstevel@tonic-gate "\n"
170*7c478bd9Sstevel@tonic-gate "end of help for topic probe_spec\n",
171*7c478bd9Sstevel@tonic-gate /* help processes */
172*7c478bd9Sstevel@tonic-gate "Controlling Processes with prex\n"
173*7c478bd9Sstevel@tonic-gate "\n"
174*7c478bd9Sstevel@tonic-gate "Prex is used to control probes in a given process, or in the kernel.\n"
175*7c478bd9Sstevel@tonic-gate "The process which prex is to control is identified as an argument when\n"
176*7c478bd9Sstevel@tonic-gate "prex is invoked.  If the \"-p"
177*7c478bd9Sstevel@tonic-gate " <pid>\" switch is used, prex connects to the\n"
178*7c478bd9Sstevel@tonic-gate "specified process.  Otherwise prex exec's the command supplied at the\n"
179*7c478bd9Sstevel@tonic-gate "end of its argument list.  In either case, prex stops the target process\n"
180*7c478bd9Sstevel@tonic-gate "immediately so that the user may set up probe control.\n"
181*7c478bd9Sstevel@tonic-gate "\n"
182*7c478bd9Sstevel@tonic-gate "Once probe control is set up (typically using the \"enable\" and \"trace\"\n"
183*7c478bd9Sstevel@tonic-gate "commands), the process is continued using the \"continue\" command.  Prex\n"
184*7c478bd9Sstevel@tonic-gate "remains attached to the target, and the user can force the target to\n"
185*7c478bd9Sstevel@tonic-gate "stop again by typing control-C, at which time additional probe control\n"
186*7c478bd9Sstevel@tonic-gate "directives may be given.\n"
187*7c478bd9Sstevel@tonic-gate "\n"
188*7c478bd9Sstevel@tonic-gate "Upon quitting from prex, the target process is normally resumed if prex\n"
189*7c478bd9Sstevel@tonic-gate "attached to it, or killed if prex invoked it.  An optional argument may\n"
190*7c478bd9Sstevel@tonic-gate "be given with the \"quit\" command to explicitly specify whether to kill\n"
191*7c478bd9Sstevel@tonic-gate "the target, continue it, or leave it suspended.\n"
192*7c478bd9Sstevel@tonic-gate "\n"
193*7c478bd9Sstevel@tonic-gate "If the target forks, any probe that the child encounters will be logged to\n"
194*7c478bd9Sstevel@tonic-gate "the same trace file as the parent.  If the child calls exec, it will no\n"
195*7c478bd9Sstevel@tonic-gate "longer be traced.\n"
196*7c478bd9Sstevel@tonic-gate "\n"
197*7c478bd9Sstevel@tonic-gate "In kernel mode (prex -k), process filtering may be enabled, to limit\n"
198*7c478bd9Sstevel@tonic-gate "tracing to those kernel probes hit on behalf of a specific process or\n"
199*7c478bd9Sstevel@tonic-gate "set of processes.  Kernel-mode process filtering is controlled using\n"
200*7c478bd9Sstevel@tonic-gate "the \"pfilter\" command.\n"
201*7c478bd9Sstevel@tonic-gate "\n"
202*7c478bd9Sstevel@tonic-gate "\n"
203*7c478bd9Sstevel@tonic-gate "Relevant Commands:\n"
204*7c478bd9Sstevel@tonic-gate "    continue               # continue target (user mode only)\n"
205*7c478bd9Sstevel@tonic-gate "    Control-C              # stop target (user mode only)\n"
206*7c478bd9Sstevel@tonic-gate "    quit resume            # quit prex, continue target\n"
207*7c478bd9Sstevel@tonic-gate "    quit suspend           # quit prex, suspend target\n"
208*7c478bd9Sstevel@tonic-gate "    quit kill              # quit prex, kill target\n"
209*7c478bd9Sstevel@tonic-gate "    quit                   # quit prex, default action\n"
210*7c478bd9Sstevel@tonic-gate "# Note: pfilter commands apply only to kernel mode\n"
211*7c478bd9Sstevel@tonic-gate "    pfilter                # show pfilter status\n"
212*7c478bd9Sstevel@tonic-gate "    pfilter on             # turn on process filter mode\n"
213*7c478bd9Sstevel@tonic-gate "    pfilter off            # turn off process filter mode\n"
214*7c478bd9Sstevel@tonic-gate "    pfilter add 1234       # add to process filter pid list\n"
215*7c478bd9Sstevel@tonic-gate "    pfilter delete 1234    # delete from process filter pid list\n"
216*7c478bd9Sstevel@tonic-gate "\n"
217*7c478bd9Sstevel@tonic-gate "end of help for topic processes\n",
218*7c478bd9Sstevel@tonic-gate /* help set_spec */
219*7c478bd9Sstevel@tonic-gate "Specifying Probe Sets\n"
220*7c478bd9Sstevel@tonic-gate "\n"
221*7c478bd9Sstevel@tonic-gate "Prex provides the ability to define named sets of probes to simplify\n"
222*7c478bd9Sstevel@tonic-gate "commands operating on multiple probes.  The set \"$all\" is predefined,\n"
223*7c478bd9Sstevel@tonic-gate "as the set of all probes in the target.  A set is defined using the\n"
224*7c478bd9Sstevel@tonic-gate "\"create\" command, and can be used as an argument to the \"list\",\n"
225*7c478bd9Sstevel@tonic-gate "\"enable\", \"disable\", \"trace\", \"untrace\", \"connect\" and\n"
226*7c478bd9Sstevel@tonic-gate "\"clear\" commands.\n"
227*7c478bd9Sstevel@tonic-gate "\n"
228*7c478bd9Sstevel@tonic-gate "Relevant Commands:\n"
229*7c478bd9Sstevel@tonic-gate "    create $myset name=/^thr/        # create a set\n"
230*7c478bd9Sstevel@tonic-gate "    list probes $myset               # list probes in a set\n"
231*7c478bd9Sstevel@tonic-gate "    list sets                        # list defined sets\n"
232*7c478bd9Sstevel@tonic-gate "    enable $myset                    # enable a set of probes\n"
233*7c478bd9Sstevel@tonic-gate "    trace $myset                     # trace a set of probes\n"
234*7c478bd9Sstevel@tonic-gate "\n"
235*7c478bd9Sstevel@tonic-gate "end of help for topic set_spec\n"
236*7c478bd9Sstevel@tonic-gate };
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate static char *helpstr_continue =
239*7c478bd9Sstevel@tonic-gate "\n"
240*7c478bd9Sstevel@tonic-gate "Usage:  continue\n"
241*7c478bd9Sstevel@tonic-gate "\n"
242*7c478bd9Sstevel@tonic-gate "\"continue\" is used to resume execution of the target process.  This\n"
243*7c478bd9Sstevel@tonic-gate "command is not available in kernel mode, since the kernel is never stopped.\n"
244*7c478bd9Sstevel@tonic-gate "\n"
245*7c478bd9Sstevel@tonic-gate "end of help for cmd continue\n";
246*7c478bd9Sstevel@tonic-gate static char *helpstr_disable =
247*7c478bd9Sstevel@tonic-gate "\n"
248*7c478bd9Sstevel@tonic-gate "Usage: disable <probe_spec>|<set_spec>\n"
249*7c478bd9Sstevel@tonic-gate "\n"
250*7c478bd9Sstevel@tonic-gate "\"disable\" is used to to turn off all tracing activity associated with a\n"
251*7c478bd9Sstevel@tonic-gate "probe or a set of probes.\n"
252*7c478bd9Sstevel@tonic-gate "\n"
253*7c478bd9Sstevel@tonic-gate "End of help for cmd disable\n";
254*7c478bd9Sstevel@tonic-gate static char *helpstr_enable=
255*7c478bd9Sstevel@tonic-gate "\n"
256*7c478bd9Sstevel@tonic-gate "Usage: enable <probe_spec>|<set_spec>\n"
257*7c478bd9Sstevel@tonic-gate "\n"
258*7c478bd9Sstevel@tonic-gate "\"enable\" is used to specify that any activity associated with the probe\n"
259*7c478bd9Sstevel@tonic-gate "or probes will be performed when the probe is hit.  This includes connected\n"
260*7c478bd9Sstevel@tonic-gate "probe functions as well as the generation of trace records.  Note that in\n"
261*7c478bd9Sstevel@tonic-gate "order for a probe to generate a trace record, it must be \"traced\" as well\n"
262*7c478bd9Sstevel@tonic-gate "as enabled.\n"
263*7c478bd9Sstevel@tonic-gate "\n"
264*7c478bd9Sstevel@tonic-gate "End of help for cmd enable\n";
265*7c478bd9Sstevel@tonic-gate static char *helpstr_help =
266*7c478bd9Sstevel@tonic-gate "\n"
267*7c478bd9Sstevel@tonic-gate "Usage: help [<cmd>|<topic>]\n"
268*7c478bd9Sstevel@tonic-gate "\n"
269*7c478bd9Sstevel@tonic-gate "\"help\" lists all available help topics when run without any arguments.\n"
270*7c478bd9Sstevel@tonic-gate "If a valid topic or command-name is supplied as an argument, help text for\n"
271*7c478bd9Sstevel@tonic-gate "the topic or command is displayed.\n"
272*7c478bd9Sstevel@tonic-gate "\n"
273*7c478bd9Sstevel@tonic-gate "End of help for cmd help\n";
274*7c478bd9Sstevel@tonic-gate static char *helpstr_list =
275*7c478bd9Sstevel@tonic-gate "\n"
276*7c478bd9Sstevel@tonic-gate "Usage: list probes <probe_spec>|<set_spec> \n"
277*7c478bd9Sstevel@tonic-gate "       list <attrs> probes <probe_spec>|<set_spec>\n"
278*7c478bd9Sstevel@tonic-gate "       list sets\n"
279*7c478bd9Sstevel@tonic-gate "       list fcns\n"
280*7c478bd9Sstevel@tonic-gate "       list history\n"
281*7c478bd9Sstevel@tonic-gate "       list tracefile\n"
282*7c478bd9Sstevel@tonic-gate "\n"
283*7c478bd9Sstevel@tonic-gate "\"list\" displays information about currently defined probes, sets, and\n"
284*7c478bd9Sstevel@tonic-gate "probe functions.  When listing probes, one can limit the output to a\n"
285*7c478bd9Sstevel@tonic-gate "desired set of attributes by specifying an attribute list as a set of\n"
286*7c478bd9Sstevel@tonic-gate "strings.  If an attribute is also a reserved word (such as \"trace\", it\n"
287*7c478bd9Sstevel@tonic-gate "must be enclosed in single quotes.  For example:\n"
288*7c478bd9Sstevel@tonic-gate "\n"
289*7c478bd9Sstevel@tonic-gate "       list file 'trace' probes $all\n"
290*7c478bd9Sstevel@tonic-gate "\n"
291*7c478bd9Sstevel@tonic-gate "\"list\" history lists the probe control commands history, and\n"
292*7c478bd9Sstevel@tonic-gate "\"list\" tracefile displays the current trace file name.\n"
293*7c478bd9Sstevel@tonic-gate "\n"
294*7c478bd9Sstevel@tonic-gate "End of help for cmd list\n";
295*7c478bd9Sstevel@tonic-gate static char *helpstr_quit =
296*7c478bd9Sstevel@tonic-gate "\n"
297*7c478bd9Sstevel@tonic-gate "Usage: quit\n"
298*7c478bd9Sstevel@tonic-gate "       quit kill\n"
299*7c478bd9Sstevel@tonic-gate "       quit resume\n"
300*7c478bd9Sstevel@tonic-gate "       quit suspend\n"
301*7c478bd9Sstevel@tonic-gate "\n"
302*7c478bd9Sstevel@tonic-gate "The \"quit\" command exits prex, leaving the target in a state specified\n"
303*7c478bd9Sstevel@tonic-gate "by the user, or taking a default action if no instructions are specified.\n"
304*7c478bd9Sstevel@tonic-gate "An optional argument may be used to indicated that the target should be\n"
305*7c478bd9Sstevel@tonic-gate "killed, resumed, or left suspended.  If no argument is supplied, then\n"
306*7c478bd9Sstevel@tonic-gate "prex's default behavior is to resume a process to which it had attached,\n"
307*7c478bd9Sstevel@tonic-gate "and to kill a process which it had invoked.\n"
308*7c478bd9Sstevel@tonic-gate "\n"
309*7c478bd9Sstevel@tonic-gate "End of help for cmd quit\n";
310*7c478bd9Sstevel@tonic-gate static char *helpstr_source =
311*7c478bd9Sstevel@tonic-gate "\n"
312*7c478bd9Sstevel@tonic-gate "Usage: source <filename>\n"
313*7c478bd9Sstevel@tonic-gate "\n"
314*7c478bd9Sstevel@tonic-gate "The \"source\" command is used to invoke a set of prex commands stored in\n"
315*7c478bd9Sstevel@tonic-gate "a file.  A sourced file may in turn source other files.  The files\n"
316*7c478bd9Sstevel@tonic-gate "~/.prexrc and ./.prexrc are sourced automatically (in that order) when prex\n"
317*7c478bd9Sstevel@tonic-gate "is invoked, and may be used to store commonly used probe and set\n"
318*7c478bd9Sstevel@tonic-gate "specifications, or probe control directives.  Commands in sourced files\n"
319*7c478bd9Sstevel@tonic-gate "may override the effects of commands in previously sourced files.\n"
320*7c478bd9Sstevel@tonic-gate "\n"
321*7c478bd9Sstevel@tonic-gate "End of help for cmd source\n";
322*7c478bd9Sstevel@tonic-gate static char *helpstr_trace =
323*7c478bd9Sstevel@tonic-gate "\n"
324*7c478bd9Sstevel@tonic-gate "Usage: trace <probe_spec>|<set_spec>\n"
325*7c478bd9Sstevel@tonic-gate "\n"
326*7c478bd9Sstevel@tonic-gate "\"trace\" is used to turn on tracing for the specified probe or probes.\n"
327*7c478bd9Sstevel@tonic-gate "A \"traced\" probe that is also \"enabled\" will generate a trace record\n"
328*7c478bd9Sstevel@tonic-gate "when it is hit.\n"
329*7c478bd9Sstevel@tonic-gate "\n"
330*7c478bd9Sstevel@tonic-gate "End of help for cmd trace\n";
331*7c478bd9Sstevel@tonic-gate static char *helpstr_untrace =
332*7c478bd9Sstevel@tonic-gate "\n"
333*7c478bd9Sstevel@tonic-gate "Usage: untrace <probe_spec>|<set_spec>\n"
334*7c478bd9Sstevel@tonic-gate "\n"
335*7c478bd9Sstevel@tonic-gate "\"untrace\" turns tracing off for the specified probe or probes.  A probe\n"
336*7c478bd9Sstevel@tonic-gate "will not generate a trace record when it is not traced, although connected\n"
337*7c478bd9Sstevel@tonic-gate "probe functions will still be invoked as long as a probe is \"enabled\".\n"
338*7c478bd9Sstevel@tonic-gate "\n"
339*7c478bd9Sstevel@tonic-gate "End of help for cmd untrace\n";
340*7c478bd9Sstevel@tonic-gate static char *helpstr_buffer =
341*7c478bd9Sstevel@tonic-gate "\n"
342*7c478bd9Sstevel@tonic-gate "Usage: buffer alloc <size>\n"
343*7c478bd9Sstevel@tonic-gate "       buffer dealloc\n"
344*7c478bd9Sstevel@tonic-gate "\n"
345*7c478bd9Sstevel@tonic-gate "Note:  Kernel Mode Only\n"
346*7c478bd9Sstevel@tonic-gate "\n"
347*7c478bd9Sstevel@tonic-gate "\"buffer\" allocates or deallocates the in-core buffer used to hold\n"
348*7c478bd9Sstevel@tonic-gate "kernel trace records.  Size can be specified in kilobytes or megabytes,\n"
349*7c478bd9Sstevel@tonic-gate "by appending the character 'k' or 'm' to a numeric value (e.g. \"2m\").\n"
350*7c478bd9Sstevel@tonic-gate "A buffer must be allocated prior to a kernel tracing session.  Once\n"
351*7c478bd9Sstevel@tonic-gate "allocated, the buffer remains usable until deallocated, even through\n"
352*7c478bd9Sstevel@tonic-gate "multiple invocations of prex.\n"
353*7c478bd9Sstevel@tonic-gate "\n"
354*7c478bd9Sstevel@tonic-gate "Before the buffer is deallocated, data may be extracted to an on-disk\n"
355*7c478bd9Sstevel@tonic-gate "tracefile using tnfxtract(1).\n"
356*7c478bd9Sstevel@tonic-gate "\n"
357*7c478bd9Sstevel@tonic-gate "End of help for cmd buffer\n";
358*7c478bd9Sstevel@tonic-gate static char *helpstr_ktrace =
359*7c478bd9Sstevel@tonic-gate "\n"
360*7c478bd9Sstevel@tonic-gate "Usage: ktrace on\n"
361*7c478bd9Sstevel@tonic-gate "       ktrace off\n"
362*7c478bd9Sstevel@tonic-gate "\n"
363*7c478bd9Sstevel@tonic-gate "Note:  Kernel Mode Only\n"
364*7c478bd9Sstevel@tonic-gate "\n"
365*7c478bd9Sstevel@tonic-gate "\"ktrace\" toggles the master switch that indicates whether kernel\n"
366*7c478bd9Sstevel@tonic-gate "tracing is active or inactive.  Since the kernel cannot be stopped while\n"
367*7c478bd9Sstevel@tonic-gate "a tracing experiment is set up, \"ktrace\" is provided so that tracing\n"
368*7c478bd9Sstevel@tonic-gate "can be set up as desired before any trace records are generated\n"
369*7c478bd9Sstevel@tonic-gate "\n"
370*7c478bd9Sstevel@tonic-gate "End of help for cmd ktrace\n";
371*7c478bd9Sstevel@tonic-gate static char *helpstr_pfilter =
372*7c478bd9Sstevel@tonic-gate "\n"
373*7c478bd9Sstevel@tonic-gate "Usage: pfilter\n"
374*7c478bd9Sstevel@tonic-gate "       pfilter on\n"
375*7c478bd9Sstevel@tonic-gate "       pfilter off\n"
376*7c478bd9Sstevel@tonic-gate "       pfilter add <pidlist>\n"
377*7c478bd9Sstevel@tonic-gate "       pfilter delete <pidlist>\n"
378*7c478bd9Sstevel@tonic-gate "\n"
379*7c478bd9Sstevel@tonic-gate "Note:  Kernel Mode Only\n"
380*7c478bd9Sstevel@tonic-gate "\n"
381*7c478bd9Sstevel@tonic-gate "\"pfilter\" controls process filtering by toggling process-filter mode,\n"
382*7c478bd9Sstevel@tonic-gate "and maintaining a list of process id's on which to filter.  When process\n"
383*7c478bd9Sstevel@tonic-gate "filtering mode is on, tracing is limited to the kernel events hit on behalf\n"
384*7c478bd9Sstevel@tonic-gate "of the processes in the pid list.  Process id 0 is used to represent all\n"
385*7c478bd9Sstevel@tonic-gate "threads not associated with a process.\n"
386*7c478bd9Sstevel@tonic-gate 
387*7c478bd9Sstevel@tonic-gate "When run without arguments, \"pfilter\" displays the current process-filter\n"
388*7c478bd9Sstevel@tonic-gate "mode and pid list.  A process filter pid list can be maintained whether\n"
389*7c478bd9Sstevel@tonic-gate "or not process filter mode is currently active.\n"
390*7c478bd9Sstevel@tonic-gate "\n"
391*7c478bd9Sstevel@tonic-gate "A process must exist in order to be added to the pid list, and the pid list\n"
392*7c478bd9Sstevel@tonic-gate "is automatically updated to delete any processes that no longer exist.  If\n"
393*7c478bd9Sstevel@tonic-gate "the pid list becomes empty while process filtering is on, prex issues a\n"
394*7c478bd9Sstevel@tonic-gate "warning.  Process filtering mode is persistent between invocations of prex\n"
395*7c478bd9Sstevel@tonic-gate "so it should be turned off manually when a tracing experiment is complete.\n"
396*7c478bd9Sstevel@tonic-gate "\n"
397*7c478bd9Sstevel@tonic-gate "End of help for cmd pfilter\n";
398*7c478bd9Sstevel@tonic-gate static char *helpstr_clear =
399*7c478bd9Sstevel@tonic-gate "\n"
400*7c478bd9Sstevel@tonic-gate "Usage: clear <probe_spec>|<set_spec>\n"
401*7c478bd9Sstevel@tonic-gate "\n"
402*7c478bd9Sstevel@tonic-gate "Note:  Not available in Kernel Mode\n"
403*7c478bd9Sstevel@tonic-gate "\n"
404*7c478bd9Sstevel@tonic-gate "\"clear\" disconnects any probe functions that have previously been\n"
405*7c478bd9Sstevel@tonic-gate "connected to a probe or group of probes using the \"connect\" command.\n"
406*7c478bd9Sstevel@tonic-gate "The \"clear\" command cannot be used in kernel mode, since probe functions\n"
407*7c478bd9Sstevel@tonic-gate "are not available for kernel probes.\n"
408*7c478bd9Sstevel@tonic-gate "\n"
409*7c478bd9Sstevel@tonic-gate "End of help for cmd clear\n";
410*7c478bd9Sstevel@tonic-gate static char *helpstr_connect =
411*7c478bd9Sstevel@tonic-gate "\n"
412*7c478bd9Sstevel@tonic-gate "Usage: connect <function> <probe_spec>|<set_spec>\n"
413*7c478bd9Sstevel@tonic-gate "\n"
414*7c478bd9Sstevel@tonic-gate "Note:  Not available in Kernel Mode\n"
415*7c478bd9Sstevel@tonic-gate "\n"
416*7c478bd9Sstevel@tonic-gate "\"connect\" connects a probe function to a probe or group of probes.\n"
417*7c478bd9Sstevel@tonic-gate "Currently, the only probe function available from prex is \"&debug\", which\n"
418*7c478bd9Sstevel@tonic-gate "prints out the arguments sent in to the probe, as well as the value (if\n"
419*7c478bd9Sstevel@tonic-gate "any) associated with the sunw%debug attribute in the detail field.\n"
420*7c478bd9Sstevel@tonic-gate "In order for a probe function to be invoked, the probe to which the\n"
421*7c478bd9Sstevel@tonic-gate "function is attached must be \"enabled\", but need not be \"traced\".\n"
422*7c478bd9Sstevel@tonic-gate "\n"
423*7c478bd9Sstevel@tonic-gate "The \"clear\" command is available to disconnect a probe function from\n"
424*7c478bd9Sstevel@tonic-gate "a probe or group of probes.\n"
425*7c478bd9Sstevel@tonic-gate "\n"
426*7c478bd9Sstevel@tonic-gate "End of help for cmd connect\n";
427*7c478bd9Sstevel@tonic-gate 
428*7c478bd9Sstevel@tonic-gate static char *helpstr =
429*7c478bd9Sstevel@tonic-gate "\n"
430*7c478bd9Sstevel@tonic-gate "Usage: help [topic|command]\n"
431*7c478bd9Sstevel@tonic-gate "\n"
432*7c478bd9Sstevel@tonic-gate "Topics\n"
433*7c478bd9Sstevel@tonic-gate "\tintro         functions    kernel_mode\n"
434*7c478bd9Sstevel@tonic-gate "\tprobe_spec    processes    set_spec\n"
435*7c478bd9Sstevel@tonic-gate "\n"
436*7c478bd9Sstevel@tonic-gate "User and Kernel Mode Commands\n"
437*7c478bd9Sstevel@tonic-gate "\tdisable       enable       help       list\n"
438*7c478bd9Sstevel@tonic-gate "\tquit          source       trace      untrace\n"
439*7c478bd9Sstevel@tonic-gate "\n"
440*7c478bd9Sstevel@tonic-gate "Additional user-mode-only commands\n"
441*7c478bd9Sstevel@tonic-gate "\tclear         connect      continue\n"
442*7c478bd9Sstevel@tonic-gate "\n"
443*7c478bd9Sstevel@tonic-gate "Additional kernel-mode-only (prex -k) commands\n"
444*7c478bd9Sstevel@tonic-gate "\tbuffer        ktrace       pfilter\n"
445*7c478bd9Sstevel@tonic-gate ;
446*7c478bd9Sstevel@tonic-gate 
447*7c478bd9Sstevel@tonic-gate 
448*7c478bd9Sstevel@tonic-gate static char	*oldhelpstr =
449*7c478bd9Sstevel@tonic-gate "grammar for non-terminals:\n"
450*7c478bd9Sstevel@tonic-gate "__________________________\n"
451*7c478bd9Sstevel@tonic-gate "\n"
452*7c478bd9Sstevel@tonic-gate "filename ::=	QUOTED_STR\n"
453*7c478bd9Sstevel@tonic-gate "\n"
454*7c478bd9Sstevel@tonic-gate "selector_list ::= 	/* empty */ |\n"
455*7c478bd9Sstevel@tonic-gate "		<selector_list> <selector>\n"
456*7c478bd9Sstevel@tonic-gate "\n"
457*7c478bd9Sstevel@tonic-gate "spec_list ::=	/*empty */ |\n"
458*7c478bd9Sstevel@tonic-gate "		<spec_list> <spec>\n"
459*7c478bd9Sstevel@tonic-gate "\n"
460*7c478bd9Sstevel@tonic-gate "selector ::=	<spec>=<spec> |		/* whitespace around '=' optional */\n"
461*7c478bd9Sstevel@tonic-gate "		<spec>			/* keys attribute is default */\n"
462*7c478bd9Sstevel@tonic-gate "\n"
463*7c478bd9Sstevel@tonic-gate "spec ::= 	IDENT |\n"
464*7c478bd9Sstevel@tonic-gate "		QUOTED_STR |\n"
465*7c478bd9Sstevel@tonic-gate "		REGEXP\n"
466*7c478bd9Sstevel@tonic-gate "\n"
467*7c478bd9Sstevel@tonic-gate "pidlist ::=	<pid> |\n"
468*7c478bd9Sstevel@tonic-gate "		<pid> ',' <pidlist>\n"
469*7c478bd9Sstevel@tonic-gate "pid ::=		INT\n"
470*7c478bd9Sstevel@tonic-gate "\n"
471*7c478bd9Sstevel@tonic-gate "Reg-exps to match terminals:\n"
472*7c478bd9Sstevel@tonic-gate "____________________________\n"
473*7c478bd9Sstevel@tonic-gate "\n"
474*7c478bd9Sstevel@tonic-gate "IDENT 		= [a-zA-Z_\\.%]{[a-zA-Z0-9_\\.%]}+ \n"
475*7c478bd9Sstevel@tonic-gate "QUOTED_STR	= '[^\\n']*'		/* any string in single quotes	*/\n"
476*7c478bd9Sstevel@tonic-gate "REGEXP		= /[^\\n/]/		/* reg-exp's have to be in / /	*/\n"
477*7c478bd9Sstevel@tonic-gate "INT		= [0-9]+\n"
478*7c478bd9Sstevel@tonic-gate "\n"
479*7c478bd9Sstevel@tonic-gate "Commands:\n"
480*7c478bd9Sstevel@tonic-gate "_________\n"
481*7c478bd9Sstevel@tonic-gate "\n"
482*7c478bd9Sstevel@tonic-gate "# set creation and set listing\n"
483*7c478bd9Sstevel@tonic-gate "create $<set_name> <selector_list>\n"
484*7c478bd9Sstevel@tonic-gate "list sets				# list the defined sets\n"
485*7c478bd9Sstevel@tonic-gate "\n"
486*7c478bd9Sstevel@tonic-gate "# function listing\n"
487*7c478bd9Sstevel@tonic-gate "list fcns				# list the defined functions.\n"
488*7c478bd9Sstevel@tonic-gate "\n"
489*7c478bd9Sstevel@tonic-gate "# commands to connect and disconnect probe functions\n"
490*7c478bd9Sstevel@tonic-gate "# (not available in kernel mode)\n"
491*7c478bd9Sstevel@tonic-gate "connect &<fcn_handle> $<set_name>	# eg. connect &debug $all\n"
492*7c478bd9Sstevel@tonic-gate "connect &<fcn_handle> <selector_list>\n"
493*7c478bd9Sstevel@tonic-gate "\n"
494*7c478bd9Sstevel@tonic-gate "# command to disconnect all connected probe functions\n"
495*7c478bd9Sstevel@tonic-gate "# (not available in kernel mode)\n"
496*7c478bd9Sstevel@tonic-gate "clear $<set_name>\n"
497*7c478bd9Sstevel@tonic-gate "clear <selector_list>\n"
498*7c478bd9Sstevel@tonic-gate "\n"
499*7c478bd9Sstevel@tonic-gate "# commands to toggle the tracing mode\n"
500*7c478bd9Sstevel@tonic-gate "trace $<set_name>\n"
501*7c478bd9Sstevel@tonic-gate "trace <selector_list>\n"
502*7c478bd9Sstevel@tonic-gate "untrace $<set_name>\n"
503*7c478bd9Sstevel@tonic-gate "untrace <selector_list>\n"
504*7c478bd9Sstevel@tonic-gate "\n"
505*7c478bd9Sstevel@tonic-gate "# commands to enable and disable probes\n"
506*7c478bd9Sstevel@tonic-gate "enable $<set_name>\n"
507*7c478bd9Sstevel@tonic-gate "enable <selector_list>\n"
508*7c478bd9Sstevel@tonic-gate "disable $<set_name>\n"
509*7c478bd9Sstevel@tonic-gate "disable <selector_list>\n"
510*7c478bd9Sstevel@tonic-gate "list history		# lists probe control commands issued\n"
511*7c478bd9Sstevel@tonic-gate "list tracefile		# lists the current trace file name\n"
512*7c478bd9Sstevel@tonic-gate "\n"
513*7c478bd9Sstevel@tonic-gate "# commands to list probes or to list values\n"
514*7c478bd9Sstevel@tonic-gate "list <spec_list> probes $<set_name>	#eg. list probes $all\n"
515*7c478bd9Sstevel@tonic-gate "list <spec_list> probes <selector_list> #eg. list name probes file=test.c\n"
516*7c478bd9Sstevel@tonic-gate "list values <spec_list>		# eg. list values keys\n"
517*7c478bd9Sstevel@tonic-gate "\n"
518*7c478bd9Sstevel@tonic-gate "# help command\n"
519*7c478bd9Sstevel@tonic-gate "help\n"
520*7c478bd9Sstevel@tonic-gate "\n"
521*7c478bd9Sstevel@tonic-gate "# source a file of prex commands\n"
522*7c478bd9Sstevel@tonic-gate "source <filename>\n"
523*7c478bd9Sstevel@tonic-gate "\n"
524*7c478bd9Sstevel@tonic-gate "# process control - ^C stops target and returns to 'prex>' prompt\n"
525*7c478bd9Sstevel@tonic-gate "# (In kernel mode, `continue' is a no-op, and 'quit' detaches prex\n"
526*7c478bd9Sstevel@tonic-gate "# from the kernel.)\n"
527*7c478bd9Sstevel@tonic-gate "continue		# continues target\n"
528*7c478bd9Sstevel@tonic-gate "quit kill		# quit prex, kill target\n"
529*7c478bd9Sstevel@tonic-gate "quit resume		# quit prex, continue target\n"
530*7c478bd9Sstevel@tonic-gate "quit suspend		# quit prex, leave target suspended\n"
531*7c478bd9Sstevel@tonic-gate "quit			# quit prex (continue or kill target)\n"
532*7c478bd9Sstevel@tonic-gate "\n"
533*7c478bd9Sstevel@tonic-gate 
534*7c478bd9Sstevel@tonic-gate "\n"
535*7c478bd9Sstevel@tonic-gate "# Kernel mode commands\n"
536*7c478bd9Sstevel@tonic-gate "# \"master switch\" enabling/disabling all tracing\n"
537*7c478bd9Sstevel@tonic-gate "ktrace on		# Enabled probes will generate trace output\n"
538*7c478bd9Sstevel@tonic-gate "ktrace off		# All trace output suppressed\n"
539*7c478bd9Sstevel@tonic-gate "# Create, destroy, or show the size of the kernel trace buffer\n"
540*7c478bd9Sstevel@tonic-gate "buffer [ alloc [ size ] | dealloc ]\n"
541*7c478bd9Sstevel@tonic-gate "# Control per-process kernel trace filtering\n"
542*7c478bd9Sstevel@tonic-gate "pfilter off		# Filtering off:  trace all processes\n"
543*7c478bd9Sstevel@tonic-gate "pfilter on		# Filtering on:  trace only processes in filter set\n"
544*7c478bd9Sstevel@tonic-gate "pfilter add <pidlist>		# Add specified process ids to the filter set\n"
545*7c478bd9Sstevel@tonic-gate "pfilter delete <pidlist>	# Drop specified pids from the filter set\n"
546*7c478bd9Sstevel@tonic-gate "\n"
547*7c478bd9Sstevel@tonic-gate ;
548*7c478bd9Sstevel@tonic-gate 
549*7c478bd9Sstevel@tonic-gate void
help(void)550*7c478bd9Sstevel@tonic-gate help(void)
551*7c478bd9Sstevel@tonic-gate {
552*7c478bd9Sstevel@tonic-gate 	(void) fputs(helpstr, stdout);
553*7c478bd9Sstevel@tonic-gate 
554*7c478bd9Sstevel@tonic-gate }				/* end help */
555*7c478bd9Sstevel@tonic-gate 
556*7c478bd9Sstevel@tonic-gate void
help_on_topic(char * topic)557*7c478bd9Sstevel@tonic-gate help_on_topic(char *topic)
558*7c478bd9Sstevel@tonic-gate {
559*7c478bd9Sstevel@tonic-gate 	int i;
560*7c478bd9Sstevel@tonic-gate 
561*7c478bd9Sstevel@tonic-gate 	if (topic && strlen(topic)) {
562*7c478bd9Sstevel@tonic-gate 		for (i = 0; i < NUMHELPTOPICS; i++)
563*7c478bd9Sstevel@tonic-gate 		if (strcmp(topic, helptopics[i]) == 0)
564*7c478bd9Sstevel@tonic-gate 		    break;
565*7c478bd9Sstevel@tonic-gate 		if (i < NUMHELPTOPICS)
566*7c478bd9Sstevel@tonic-gate 		    fputs(helptopicstrings[i], stdout);
567*7c478bd9Sstevel@tonic-gate 		else {
568*7c478bd9Sstevel@tonic-gate 			printf("No help for %s\n",  topic);
569*7c478bd9Sstevel@tonic-gate 			help();
570*7c478bd9Sstevel@tonic-gate 		}
571*7c478bd9Sstevel@tonic-gate 	}
572*7c478bd9Sstevel@tonic-gate }
573*7c478bd9Sstevel@tonic-gate 
574*7c478bd9Sstevel@tonic-gate 
575*7c478bd9Sstevel@tonic-gate void
help_on_command(int cmd)576*7c478bd9Sstevel@tonic-gate help_on_command(int cmd)
577*7c478bd9Sstevel@tonic-gate {
578*7c478bd9Sstevel@tonic-gate 	switch (cmd) {
579*7c478bd9Sstevel@tonic-gate 	case CONTINUE:
580*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_continue, stdout);
581*7c478bd9Sstevel@tonic-gate 		break;
582*7c478bd9Sstevel@tonic-gate 	case DISABLE:
583*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_disable, stdout);
584*7c478bd9Sstevel@tonic-gate 		break;
585*7c478bd9Sstevel@tonic-gate 	case ENABLE:
586*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_enable, stdout);
587*7c478bd9Sstevel@tonic-gate 		break;
588*7c478bd9Sstevel@tonic-gate 	case HELP:
589*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_help, stdout);
590*7c478bd9Sstevel@tonic-gate 		break;
591*7c478bd9Sstevel@tonic-gate 	case LIST:
592*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_list, stdout);
593*7c478bd9Sstevel@tonic-gate 		break;
594*7c478bd9Sstevel@tonic-gate 	case QUIT:
595*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_quit, stdout);
596*7c478bd9Sstevel@tonic-gate 		break;
597*7c478bd9Sstevel@tonic-gate 	case SOURCE:
598*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_source, stdout);
599*7c478bd9Sstevel@tonic-gate 		break;
600*7c478bd9Sstevel@tonic-gate 	case TRACE:
601*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_trace, stdout);
602*7c478bd9Sstevel@tonic-gate 		break;
603*7c478bd9Sstevel@tonic-gate 	case UNTRACE:
604*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_untrace, stdout);
605*7c478bd9Sstevel@tonic-gate 		break;
606*7c478bd9Sstevel@tonic-gate 	case BUFFER:
607*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_buffer, stdout);
608*7c478bd9Sstevel@tonic-gate 		break;
609*7c478bd9Sstevel@tonic-gate 	case KTRACE:
610*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_ktrace, stdout);
611*7c478bd9Sstevel@tonic-gate 		break;
612*7c478bd9Sstevel@tonic-gate 	case PFILTER:
613*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_pfilter, stdout);
614*7c478bd9Sstevel@tonic-gate 		break;
615*7c478bd9Sstevel@tonic-gate 	case CLEAR:
616*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_clear, stdout);
617*7c478bd9Sstevel@tonic-gate 		break;
618*7c478bd9Sstevel@tonic-gate 	case CONNECT:
619*7c478bd9Sstevel@tonic-gate 		fputs(helpstr_connect, stdout);
620*7c478bd9Sstevel@tonic-gate 		break;
621*7c478bd9Sstevel@tonic-gate 	default:
622*7c478bd9Sstevel@tonic-gate 		fputs("No help for this command\n", stdout);
623*7c478bd9Sstevel@tonic-gate 		break;
624*7c478bd9Sstevel@tonic-gate 	}
625*7c478bd9Sstevel@tonic-gate 
626*7c478bd9Sstevel@tonic-gate }				/* end help */
627