db_command.h revision 1.29 1 /* $NetBSD: db_command.h,v 1.29 2007/09/23 23:55:54 martin Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Adam Hamsik.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Mach Operating System
41 * Copyright (c) 1991,1990 Carnegie Mellon University
42 * All Rights Reserved.
43 *
44 * Permission to use, copy, modify and distribute this software and its
45 * documentation is hereby granted, provided that both the copyright
46 * notice and this permission notice appear in all copies of the
47 * software, derivative works or modified versions, and any portions
48 * thereof, and that both notices appear in supporting documentation.
49 *
50 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
51 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
52 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
53 *
54 * Carnegie Mellon requests users of this software to return to
55 *
56 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
64 * Author: David B. Golub, Carnegie Mellon University
65 * Date: 7/90
66 */
67
68 #ifndef _DDB_COMMAND_
69 #define _DDB_COMMAND_
70
71 void db_skip_to_eol(void);
72 void db_init_commands(void);
73 void db_command_loop(void);
74 void db_error(const char *) __attribute__((__noreturn__));
75
76 extern db_addr_t db_dot; /* current location */
77 extern db_addr_t db_last_addr; /* last explicit address typed */
78 extern db_addr_t db_prev; /* last address examined
79 or written */
80 extern db_addr_t db_next; /* next address to be examined
81 or written */
82
83 extern char db_cmd_on_enter[];
84
85 struct db_command;
86
87
88
89 /*
90 * Macro include help when DDB_VERBOSE_HELP option(9) is used
91 */
92 #ifdef DDB_VERBOSE_HELP
93 #define DDB_ADD_CMD(name,funct,type,cmd_descr,cmd_arg,arg_desc)\
94 name,funct,type,cmd_descr,cmd_arg,arg_desc
95 #else
96 #define DDB_ADD_CMD(name,funct,type,cmd_descr,cmd_arg,arg_desc)\
97 name,funct,type
98 #endif
99
100
101
102 /*
103 * we have two types of lists one for base commands like reboot
104 * and another list for show subcommands.
105 */
106
107 #define DDB_BASE_CMD 0
108 #define DDB_SHOW_CMD 1
109 #define DDB_MACH_CMD 2
110
111
112 int db_register_tbl(uint8_t, const struct db_command *);
113 int db_unregister_tbl(uint8_t, const struct db_command *);
114
115 /*
116 * Command table
117 */
118 struct db_command {
119 const char *name; /* command name */
120
121 /* function to call */
122 void (*fcn)(db_expr_t, bool, db_expr_t, const char *);
123 /*
124 *Flag is used for modifing command behaviour.
125 *CS_OWN && CS_MORE are specify type of command arguments.
126 *CS_OWN commandmanage arguments in own way.
127 *CS_MORE db_command() prepare argument list.
128 *
129 *CS_COMPAT is set for all level 2 commands with level 3 childs (show all pages)
130 *
131 *CS_SHOW identify show command in BASE command list
132 *CS_MACH identify mach command in BASE command list
133 *
134 *CS_SET_DOT specify if this command is put to last added command memory.
135 *CS_NOREPEAT this command does not repeat
136 */
137 uint16_t flag; /* extra info: */
138 #define CS_OWN 0x1 /* non-standard syntax */
139 #define CS_MORE 0x2 /* standard syntax, but may have other
140 words at end */
141 #define CS_COMPAT 0x4 /*is set for compatibilty with old ddb versions*/
142
143 #define CS_SHOW 0x8 /*select show list*/
144 #define CS_MACH 0x16 /*select machine dependent list*/
145
146 #define CS_SET_DOT 0x100 /* set dot after command */
147 #define CS_NOREPEAT 0x200 /* don't set last_command */
148 #ifdef DDB_VERBOSE_HELP
149 const char *cmd_descr; /*description of command*/
150 const char *cmd_arg; /*command arguments*/
151 const char *cmd_arg_help; /* arguments description */
152 #endif
153 };
154
155 #endif /*_DDB_COMMAND_*/
156
157