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