db_command.h revision 1.28 1 /* $NetBSD: db_command.h,v 1.28 2007/09/22 18:40:27 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_command_loop(void);
73 void db_error(const char *) __attribute__((__noreturn__));
74
75 extern db_addr_t db_dot; /* current location */
76 extern db_addr_t db_last_addr; /* last explicit address typed */
77 extern db_addr_t db_prev; /* last address examined
78 or written */
79 extern db_addr_t db_next; /* next address to be examined
80 or written */
81
82 extern char db_cmd_on_enter[];
83
84 struct db_command;
85
86
87
88 /*
89 * Macro include help when DDB_VERBOSE_HELP option(9) is used
90 */
91 #ifdef DDB_VERBOSE_HELP
92 #define DDB_ADD_CMD(name,funct,type,cmd_descr,cmd_arg,arg_desc)\
93 name,funct,type,cmd_descr,cmd_arg,arg_desc
94 #else
95 #define DDB_ADD_CMD(name,funct,type,cmd_descr,cmd_arg,arg_desc)\
96 name,funct,type
97 #endif
98
99
100
101 /*
102 * we have two types of lists one for base commands like reboot
103 * and another list for show subcommands.
104 */
105
106 #define DDB_BASE_CMD 0
107 #define DDB_SHOW_CMD 1
108 #define DDB_MACH_CMD 2
109
110
111 int db_register_tbl(uint8_t, const struct db_command *);
112 int db_unregister_tbl(uint8_t, const struct db_command *);
113
114 /*
115 * Command table
116 */
117 struct db_command {
118 const char *name; /* command name */
119
120 /* function to call */
121 void (*fcn)(db_expr_t, bool, db_expr_t, const char *);
122 /*
123 *Flag is used for modifing command behaviour.
124 *CS_OWN && CS_MORE are specify type of command arguments.
125 *CS_OWN commandmanage arguments in own way.
126 *CS_MORE db_command() prepare argument list.
127 *
128 *CS_COMPAT is set for all level 2 commands with level 3 childs (show all pages)
129 *
130 *CS_SHOW identify show command in BASE command list
131 *CS_MACH identify mach command in BASE command list
132 *
133 *CS_SET_DOT specify if this command is put to last added command memory.
134 *CS_NOREPEAT this command does not repeat
135 */
136 uint16_t flag; /* extra info: */
137 #define CS_OWN 0x1 /* non-standard syntax */
138 #define CS_MORE 0x2 /* standard syntax, but may have other
139 words at end */
140 #define CS_COMPAT 0x4 /*is set for compatibilty with old ddb versions*/
141
142 #define CS_SHOW 0x8 /*select show list*/
143 #define CS_MACH 0x16 /*select machine dependent list*/
144
145 #define CS_SET_DOT 0x100 /* set dot after command */
146 #define CS_NOREPEAT 0x200 /* don't set last_command */
147 #ifdef DDB_VERBOSE_HELP
148 const char *cmd_descr; /*description of command*/
149 const char *cmd_arg; /*command arguments*/
150 const char *cmd_arg_help; /* arguments description */
151 #endif
152 };
153
154 #endif /*_DDB_COMMAND_*/
155
156