1*12927SRod.Evans@Sun.COM /*
2*12927SRod.Evans@Sun.COM * CDDL HEADER START
3*12927SRod.Evans@Sun.COM *
4*12927SRod.Evans@Sun.COM * The contents of this file are subject to the terms of the
5*12927SRod.Evans@Sun.COM * Common Development and Distribution License (the "License").
6*12927SRod.Evans@Sun.COM * You may not use this file except in compliance with the License.
7*12927SRod.Evans@Sun.COM *
8*12927SRod.Evans@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12927SRod.Evans@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*12927SRod.Evans@Sun.COM * See the License for the specific language governing permissions
11*12927SRod.Evans@Sun.COM * and limitations under the License.
12*12927SRod.Evans@Sun.COM *
13*12927SRod.Evans@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*12927SRod.Evans@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12927SRod.Evans@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*12927SRod.Evans@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*12927SRod.Evans@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*12927SRod.Evans@Sun.COM *
19*12927SRod.Evans@Sun.COM * CDDL HEADER END
20*12927SRod.Evans@Sun.COM */
21*12927SRod.Evans@Sun.COM
22*12927SRod.Evans@Sun.COM /*
23*12927SRod.Evans@Sun.COM * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
24*12927SRod.Evans@Sun.COM */
25*12927SRod.Evans@Sun.COM
26*12927SRod.Evans@Sun.COM #include <stdio.h>
27*12927SRod.Evans@Sun.COM #include <libelf.h>
28*12927SRod.Evans@Sun.COM #include <string.h>
29*12927SRod.Evans@Sun.COM
30*12927SRod.Evans@Sun.COM #include "rdb.h"
31*12927SRod.Evans@Sun.COM
32*12927SRod.Evans@Sun.COM typedef struct {
33*12927SRod.Evans@Sun.COM char *ht_key; /* HELP keyword for topic */
34*12927SRod.Evans@Sun.COM char *ht_desc; /* description of topic */
35*12927SRod.Evans@Sun.COM void (*ht_func)(); /* detailed info on topic */
36*12927SRod.Evans@Sun.COM } help_topics;
37*12927SRod.Evans@Sun.COM
38*12927SRod.Evans@Sun.COM static void
break_help()39*12927SRod.Evans@Sun.COM break_help()
40*12927SRod.Evans@Sun.COM {
41*12927SRod.Evans@Sun.COM (void) printf("Break Help:\n"
42*12927SRod.Evans@Sun.COM "\tbreak - list breakpoints\n"
43*12927SRod.Evans@Sun.COM "\tbreak <address> - set break point at <address\n");
44*12927SRod.Evans@Sun.COM }
45*12927SRod.Evans@Sun.COM
46*12927SRod.Evans@Sun.COM static void
delete_help()47*12927SRod.Evans@Sun.COM delete_help()
48*12927SRod.Evans@Sun.COM {
49*12927SRod.Evans@Sun.COM (void) printf("Delete Help:\n"
50*12927SRod.Evans@Sun.COM "\tdelete <address> - delete breakpoint at <address>\n");
51*12927SRod.Evans@Sun.COM }
52*12927SRod.Evans@Sun.COM
53*12927SRod.Evans@Sun.COM static void
dis_help()54*12927SRod.Evans@Sun.COM dis_help()
55*12927SRod.Evans@Sun.COM {
56*12927SRod.Evans@Sun.COM (void) printf("Disassemble Help:\n"
57*12927SRod.Evans@Sun.COM "\tdis -\t\t\tdisassemble from current PC\n"
58*12927SRod.Evans@Sun.COM "\tdis <address> [count] -\tdisassemble from address for\n"
59*12927SRod.Evans@Sun.COM "\t\t\t\t<count> instructions\n");
60*12927SRod.Evans@Sun.COM }
61*12927SRod.Evans@Sun.COM
62*12927SRod.Evans@Sun.COM static void
echo_help()63*12927SRod.Evans@Sun.COM echo_help()
64*12927SRod.Evans@Sun.COM {
65*12927SRod.Evans@Sun.COM (void) printf("Echo Help:\n"
66*12927SRod.Evans@Sun.COM "\tEcho '<quoted string>'\n"
67*12927SRod.Evans@Sun.COM "\t\tthe echo command can be used to display output to\n"
68*12927SRod.Evans@Sun.COM "\t\tthe main terminal. This is useful when running\n"
69*12927SRod.Evans@Sun.COM "\t\tcommand scripts and wanting to display status\n"
70*12927SRod.Evans@Sun.COM "\n"
71*12927SRod.Evans@Sun.COM "\t\tcurrently only <quoted strings> may be displayed\n");
72*12927SRod.Evans@Sun.COM }
73*12927SRod.Evans@Sun.COM
74*12927SRod.Evans@Sun.COM static void
print_help()75*12927SRod.Evans@Sun.COM print_help()
76*12927SRod.Evans@Sun.COM {
77*12927SRod.Evans@Sun.COM (void) printf("Print Help:\n"
78*12927SRod.Evans@Sun.COM "\tprint <address> [count [format]]\n"
79*12927SRod.Evans@Sun.COM "\t\tcount - number of units to print (default 4)\n"
80*12927SRod.Evans@Sun.COM "\t\tformat - how to display data:\n"
81*12927SRod.Evans@Sun.COM "\t\t\t\tX - Hex Words (default)\n"
82*12927SRod.Evans@Sun.COM "\t\t\t\tb - unsigned hex bytes\n"
83*12927SRod.Evans@Sun.COM "\t\t\t\ts - string\n"
84*12927SRod.Evans@Sun.COM "\tprint <varname>\n"
85*12927SRod.Evans@Sun.COM "\t\thelp varname for more info\n");
86*12927SRod.Evans@Sun.COM }
87*12927SRod.Evans@Sun.COM
88*12927SRod.Evans@Sun.COM static void
step_help()89*12927SRod.Evans@Sun.COM step_help()
90*12927SRod.Evans@Sun.COM {
91*12927SRod.Evans@Sun.COM (void) printf("Step Help:\n");
92*12927SRod.Evans@Sun.COM (void) printf("\tstep - step one instruction.\n");
93*12927SRod.Evans@Sun.COM (void) printf("\tstep count [silent] - step count instructions\n");
94*12927SRod.Evans@Sun.COM (void) printf("\t\t\t\tif silent is specified to not disassemble\n"
95*12927SRod.Evans@Sun.COM "\t\t\t\tinstr. during stepping\n");
96*12927SRod.Evans@Sun.COM }
97*12927SRod.Evans@Sun.COM
98*12927SRod.Evans@Sun.COM static void
value_help()99*12927SRod.Evans@Sun.COM value_help()
100*12927SRod.Evans@Sun.COM {
101*12927SRod.Evans@Sun.COM (void) printf("Value Help:\n"
102*12927SRod.Evans@Sun.COM "\tvalue <symbol name> -\tdisplay the value associated with\n"
103*12927SRod.Evans@Sun.COM "\t\t\t\tsymbol <symbol name>.\n");
104*12927SRod.Evans@Sun.COM }
105*12927SRod.Evans@Sun.COM
106*12927SRod.Evans@Sun.COM static void
varname_help()107*12927SRod.Evans@Sun.COM varname_help()
108*12927SRod.Evans@Sun.COM {
109*12927SRod.Evans@Sun.COM (void) printf("Variable Name Help:\n"
110*12927SRod.Evans@Sun.COM "\tVariable names are in the form of $<name> and are used\n"
111*12927SRod.Evans@Sun.COM "\tto access special information. Possible varnames\n"
112*12927SRod.Evans@Sun.COM "\tare:\n"
113*12927SRod.Evans@Sun.COM "\t\tcommon:\n"
114*12927SRod.Evans@Sun.COM "\t\t\t$regs - display all registers\n"
115*12927SRod.Evans@Sun.COM "\t\tsparc:\n"
116*12927SRod.Evans@Sun.COM "\t\t\t$ins - display IN registers\n"
117*12927SRod.Evans@Sun.COM "\t\t\t$globs - display GLOBAL registers\n"
118*12927SRod.Evans@Sun.COM "\t\t\t$outs - display OUT registers\n"
119*12927SRod.Evans@Sun.COM "\t\t\t$locs - display LOCAL registers\n"
120*12927SRod.Evans@Sun.COM "\t\t\t$specs - display SPECIAL registers\n"
121*12927SRod.Evans@Sun.COM "\t\ti86pc:\n");
122*12927SRod.Evans@Sun.COM }
123*12927SRod.Evans@Sun.COM
124*12927SRod.Evans@Sun.COM static const help_topics htops[] = {
125*12927SRod.Evans@Sun.COM {
126*12927SRod.Evans@Sun.COM "break",
127*12927SRod.Evans@Sun.COM "Set and display breakpoints",
128*12927SRod.Evans@Sun.COM break_help
129*12927SRod.Evans@Sun.COM },
130*12927SRod.Evans@Sun.COM {
131*12927SRod.Evans@Sun.COM "cont",
132*12927SRod.Evans@Sun.COM "continue execution of process",
133*12927SRod.Evans@Sun.COM 0
134*12927SRod.Evans@Sun.COM },
135*12927SRod.Evans@Sun.COM {
136*12927SRod.Evans@Sun.COM "delete",
137*12927SRod.Evans@Sun.COM "delete breakpoints",
138*12927SRod.Evans@Sun.COM delete_help
139*12927SRod.Evans@Sun.COM },
140*12927SRod.Evans@Sun.COM {
141*12927SRod.Evans@Sun.COM "dis",
142*12927SRod.Evans@Sun.COM "Help on the Disassemble Command",
143*12927SRod.Evans@Sun.COM dis_help
144*12927SRod.Evans@Sun.COM },
145*12927SRod.Evans@Sun.COM {
146*12927SRod.Evans@Sun.COM "echo",
147*12927SRod.Evans@Sun.COM "Help on the Echo Command",
148*12927SRod.Evans@Sun.COM echo_help
149*12927SRod.Evans@Sun.COM },
150*12927SRod.Evans@Sun.COM {
151*12927SRod.Evans@Sun.COM "event",
152*12927SRod.Evans@Sun.COM "event [on|off] to enable or disable event information",
153*12927SRod.Evans@Sun.COM 0
154*12927SRod.Evans@Sun.COM },
155*12927SRod.Evans@Sun.COM {
156*12927SRod.Evans@Sun.COM "getmaps",
157*12927SRod.Evans@Sun.COM "Read Link_Map structure from run-time linker",
158*12927SRod.Evans@Sun.COM 0
159*12927SRod.Evans@Sun.COM },
160*12927SRod.Evans@Sun.COM {
161*12927SRod.Evans@Sun.COM "linkmaps",
162*12927SRod.Evans@Sun.COM "Display link-map information",
163*12927SRod.Evans@Sun.COM 0
164*12927SRod.Evans@Sun.COM },
165*12927SRod.Evans@Sun.COM {
166*12927SRod.Evans@Sun.COM "maps",
167*12927SRod.Evans@Sun.COM "Display memory mapping information",
168*12927SRod.Evans@Sun.COM 0
169*12927SRod.Evans@Sun.COM },
170*12927SRod.Evans@Sun.COM {
171*12927SRod.Evans@Sun.COM "objpad",
172*12927SRod.Evans@Sun.COM "Set object padding for ld.so.1 mmap'ed objects",
173*12927SRod.Evans@Sun.COM 0
174*12927SRod.Evans@Sun.COM },
175*12927SRod.Evans@Sun.COM {
176*12927SRod.Evans@Sun.COM "pltskip",
177*12927SRod.Evans@Sun.COM "Enables and disables stepping through PLT's",
178*12927SRod.Evans@Sun.COM 0
179*12927SRod.Evans@Sun.COM },
180*12927SRod.Evans@Sun.COM {
181*12927SRod.Evans@Sun.COM "print",
182*12927SRod.Evans@Sun.COM "Display memory at <address>",
183*12927SRod.Evans@Sun.COM print_help
184*12927SRod.Evans@Sun.COM },
185*12927SRod.Evans@Sun.COM {
186*12927SRod.Evans@Sun.COM "step",
187*12927SRod.Evans@Sun.COM "Help on the Step Command",
188*12927SRod.Evans@Sun.COM step_help
189*12927SRod.Evans@Sun.COM },
190*12927SRod.Evans@Sun.COM {
191*12927SRod.Evans@Sun.COM "value",
192*12927SRod.Evans@Sun.COM "Help on the Value Command",
193*12927SRod.Evans@Sun.COM value_help
194*12927SRod.Evans@Sun.COM },
195*12927SRod.Evans@Sun.COM {
196*12927SRod.Evans@Sun.COM "varname",
197*12927SRod.Evans@Sun.COM "Help on $variable values",
198*12927SRod.Evans@Sun.COM varname_help
199*12927SRod.Evans@Sun.COM },
200*12927SRod.Evans@Sun.COM {
201*12927SRod.Evans@Sun.COM "where",
202*12927SRod.Evans@Sun.COM "Display stack trace",
203*12927SRod.Evans@Sun.COM 0
204*12927SRod.Evans@Sun.COM },
205*12927SRod.Evans@Sun.COM {
206*12927SRod.Evans@Sun.COM 0,
207*12927SRod.Evans@Sun.COM 0,
208*12927SRod.Evans@Sun.COM 0
209*12927SRod.Evans@Sun.COM }
210*12927SRod.Evans@Sun.COM };
211*12927SRod.Evans@Sun.COM
212*12927SRod.Evans@Sun.COM void
rdb_help(const char * topic)213*12927SRod.Evans@Sun.COM rdb_help(const char *topic) {
214*12927SRod.Evans@Sun.COM int i;
215*12927SRod.Evans@Sun.COM
216*12927SRod.Evans@Sun.COM if (topic) {
217*12927SRod.Evans@Sun.COM for (i = 0; htops[i].ht_key; i++) {
218*12927SRod.Evans@Sun.COM if (strcmp(htops[i].ht_key, topic) == 0) {
219*12927SRod.Evans@Sun.COM if (htops[i].ht_func)
220*12927SRod.Evans@Sun.COM htops[i].ht_func();
221*12927SRod.Evans@Sun.COM else
222*12927SRod.Evans@Sun.COM (void) printf("no additional help "
223*12927SRod.Evans@Sun.COM "available for %s\n",
224*12927SRod.Evans@Sun.COM htops[i].ht_key);
225*12927SRod.Evans@Sun.COM return;
226*12927SRod.Evans@Sun.COM }
227*12927SRod.Evans@Sun.COM }
228*12927SRod.Evans@Sun.COM (void) printf("Help not available for topic: %s\n", topic);
229*12927SRod.Evans@Sun.COM }
230*12927SRod.Evans@Sun.COM
231*12927SRod.Evans@Sun.COM (void) printf("The following commands are available\n");
232*12927SRod.Evans@Sun.COM
233*12927SRod.Evans@Sun.COM for (i = 0; htops[i].ht_key; i++) {
234*12927SRod.Evans@Sun.COM (void) printf("\t%10s\t%s", htops[i].ht_key, htops[i].ht_desc);
235*12927SRod.Evans@Sun.COM if (htops[i].ht_func)
236*12927SRod.Evans@Sun.COM (void) putchar('*');
237*12927SRod.Evans@Sun.COM (void) putchar('\n');
238*12927SRod.Evans@Sun.COM }
239*12927SRod.Evans@Sun.COM (void) printf("\n(*) more help is available by typing "
240*12927SRod.Evans@Sun.COM "'help <topic>'\n\n");
241*12927SRod.Evans@Sun.COM }
242