1.\"- 2.\" Copyright (c) 2008 Guillaume Ballet 3.\" All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" SUCH DAMAGE. 25.\" 26.\" $FreeBSD$ 27.\" 28.Dd July 5, 2023 29.Dt DB_COMMAND 9 30.Os 31.Sh NAME 32.Nm DB_COMMAND , 33.Nm DB_COMMAND_FLAGS , 34.Nm DB_SHOW_COMMAND , 35.Nm DB_SHOW_COMMAND_FLAGS , 36.Nm DB_SHOW_ALL_COMMAND , 37.Nm DB_TABLE_COMMAND , 38.Nm DB_TABLE_COMMAND_FLAGS , 39.Nm DB_ALIAS , 40.Nm DB_ALIAS_FLAGS , 41.Nm DB_SHOW_ALIAS , 42.Nm DB_SHOW_ALIAS_FLAGS , 43.Nm DB_SHOW_ALL_ALIAS , 44.Nm DB_TABLE_ALIAS , 45.Nm DB_TABLE_ALIAS_FLAGS 46.Nm DB_DECLARE_TABLE , 47.Nm DB_DEFINE_TABLE , 48.Nd Extends the ddb command set 49.Sh SYNOPSIS 50.In ddb/ddb.h 51.Fn DB_COMMAND "command_name" "command_function" 52.Fn DB_COMMAND_FLAGS "command_name" "command_function" "flags" 53.Fn DB_SHOW_COMMAND "command_name" "command_function" 54.Fn DB_SHOW_COMMAND_FLAGS "command_name" "command_function" "flags" 55.Fn DB_SHOW_ALL_COMMAND "command_name" "command_function" 56.Fn DB_TABLE_COMMAND "table" "command_name" "command_function" 57.Fn DB_TABLE_COMMAND_FLAGS "table" "command_name" "command_function" "flags" 58.Fn DB_ALIAS "alias_name" "command_function" 59.Fn DB_ALIAS_FLAGS "alias_name" "command_function" "flags" 60.Fn DB_SHOW_ALIAS "alias_name" "command_function" 61.Fn DB_SHOW_ALIAS_FLAGS "alias_name" "command_function" "flags" 62.Fn DB_SHOW_ALL_ALIAS "alias_name" "command_function" 63.Fn DB_TABLE_ALIAS "table" "alias_name" "command_function" 64.Fn DB_TABLE_ALIAS_FLAGS "table" "alias_name" "command_function" "flags" 65.Fn DB_DEFINE_TABLE "parent" "name" "table" 66.Fn DB_DECLARE_TABLE "table" 67.Sh DESCRIPTION 68The 69.Fn DB_COMMAND 70macro adds 71.Fa command_name 72to the list of top-level commands. 73Invoking 74.Fa command_name 75from ddb will call 76.Fa command_function . 77.Pp 78The 79.Fn DB_SHOW_COMMAND 80and 81.Fn DB_SHOW_ALL_COMMAND 82macros are roughly equivalent to 83.Fn DB_COMMAND 84but in these cases, 85.Fa command_name 86is a sub-command of the ddb 87.Sy show 88command and 89.Sy show all 90command, respectively. 91.Pp 92The 93.Fn DB_TABLE_COMMAND 94macro is also similar to 95.Fn DB_COMMAND 96but adds the new command as a sub-command of the ddb command 97.Fa table . 98.Pp 99The 100.Fn DB_ALIAS , 101.Fn DB_SHOW_ALIAS , 102.Fn DB_SHOW_ALL_ALIAS , 103and 104.Fn DB_TABLE_ALIAS 105macros register the existing 106.Fa command_function 107under the alternative command name 108.Fa alias_name . 109.Pp 110The _FLAGS variants of these commands allow the programmer to specify a value 111for the 112.Fa flag 113field of the command structure. 114The possible flag values are defined alongside 115.Ft struct db_command 116in 117.In ddb/ddb.h . 118.Pp 119The general command syntax: 120.Cm command Ns Op Li \&/ Ns Ar modifier 121.Ar address Ns Op , Ns Ar count , 122translates into the following parameters for 123.Fa command_function : 124.Bl -tag -width Fa -offset indent 125.It Fa addr 126The address passed to the command as an argument. 127.It Fa have_addr 128A boolean value that is true if the addr field is valid. 129.It Fa count 130The number of quad words starting at offset 131.Fa addr 132that the command must process. 133.It Fa modif 134A pointer to the string of modifiers. 135That is, a series of symbols used to pass some options to the command. 136For example, the 137.Sy examine 138command will display words in decimal form if it is passed the modifier "d". 139.El 140.Pp 141The 142.Fn DB_DEFINE_TABLE 143macro adds a new command 144.Fa name 145as a sub-command of the existing command table 146.Fa parent . 147The new command defines a table named 148.Fa table 149which contains sub-commands. 150New commands and aliases can be added to this table by passing 151.Fa table 152as the first argument to one of the DB_TABLE_ macros. 153.Sh EXAMPLES 154In your module, the command is declared as: 155.Bd -literal 156DB_COMMAND(mycmd, my_cmd_func) 157{ 158 if (have_addr) 159 db_printf("Calling my command with address %p\\n", addr); 160} 161.Ed 162.Pp 163An alias for this command is declared as: 164.Bd -literal 165DB_ALIAS(mycmd2, my_cmd_func); 166.Ed 167.Pp 168Then, when in ddb: 169.Bd -literal 170.Bf Sy 171db> mycmd 0x1000 172Calling my command with address 0x1000 173db> mycmd2 0x2500 174Calling my command with address 0x2500 175db> 176.Ef 177.Ed 178.Sh SEE ALSO 179.Xr ddb 4 180.Sh AUTHORS 181This manual page was written by 182.An Guillaume Ballet Aq Mt gballet@gmail.com . 183