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