1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 24 */ 25 26 #include <stdio.h> 27 #include <libelf.h> 28 #include <string.h> 29 30 #include "rdb.h" 31 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; 37 38 static void 39 break_help() 40 { 41 (void) printf("Break Help:\n" 42 "\tbreak - list breakpoints\n" 43 "\tbreak <address> - set break point at <address\n"); 44 } 45 46 static void 47 delete_help() 48 { 49 (void) printf("Delete Help:\n" 50 "\tdelete <address> - delete breakpoint at <address>\n"); 51 } 52 53 static void 54 dis_help() 55 { 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"); 60 } 61 62 static void 63 echo_help() 64 { 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"); 72 } 73 74 static void 75 print_help() 76 { 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"); 86 } 87 88 static void 89 step_help() 90 { 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"); 96 } 97 98 static void 99 value_help() 100 { 101 (void) printf("Value Help:\n" 102 "\tvalue <symbol name> -\tdisplay the value associated with\n" 103 "\t\t\t\tsymbol <symbol name>.\n"); 104 } 105 106 static void 107 varname_help() 108 { 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"); 122 } 123 124 static const help_topics htops[] = { 125 { 126 "break", 127 "Set and display breakpoints", 128 break_help 129 }, 130 { 131 "cont", 132 "continue execution of process", 133 0 134 }, 135 { 136 "delete", 137 "delete breakpoints", 138 delete_help 139 }, 140 { 141 "dis", 142 "Help on the Disassemble Command", 143 dis_help 144 }, 145 { 146 "echo", 147 "Help on the Echo Command", 148 echo_help 149 }, 150 { 151 "event", 152 "event [on|off] to enable or disable event information", 153 0 154 }, 155 { 156 "getmaps", 157 "Read Link_Map structure from run-time linker", 158 0 159 }, 160 { 161 "linkmaps", 162 "Display link-map information", 163 0 164 }, 165 { 166 "maps", 167 "Display memory mapping information", 168 0 169 }, 170 { 171 "objpad", 172 "Set object padding for ld.so.1 mmap'ed objects", 173 0 174 }, 175 { 176 "pltskip", 177 "Enables and disables stepping through PLT's", 178 0 179 }, 180 { 181 "print", 182 "Display memory at <address>", 183 print_help 184 }, 185 { 186 "step", 187 "Help on the Step Command", 188 step_help 189 }, 190 { 191 "value", 192 "Help on the Value Command", 193 value_help 194 }, 195 { 196 "varname", 197 "Help on $variable values", 198 varname_help 199 }, 200 { 201 "where", 202 "Display stack trace", 203 0 204 }, 205 { 206 0, 207 0, 208 0 209 } 210 }; 211 212 void 213 rdb_help(const char *topic) { 214 int i; 215 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; 226 } 227 } 228 (void) printf("Help not available for topic: %s\n", topic); 229 } 230 231 (void) printf("The following commands are available\n"); 232 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'); 238 } 239 (void) printf("\n(*) more help is available by typing " 240 "'help <topic>'\n\n"); 241 } 242