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