15a2637d2SSam Leffler.\"- 25a2637d2SSam Leffler.\" Copyright (c) 2008 Guillaume Ballet 35a2637d2SSam Leffler.\" All rights reserved. 45a2637d2SSam Leffler.\" 55a2637d2SSam Leffler.\" Redistribution and use in source and binary forms, with or without 65a2637d2SSam Leffler.\" modification, are permitted provided that the following conditions 75a2637d2SSam Leffler.\" are met: 85a2637d2SSam Leffler.\" 1. Redistributions of source code must retain the above copyright 95a2637d2SSam Leffler.\" notice, this list of conditions and the following disclaimer. 105a2637d2SSam Leffler.\" 2. Redistributions in binary form must reproduce the above copyright 115a2637d2SSam Leffler.\" notice, this list of conditions and the following disclaimer in the 125a2637d2SSam Leffler.\" documentation and/or other materials provided with the distribution. 135a2637d2SSam Leffler.\" 145a2637d2SSam Leffler.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 155a2637d2SSam Leffler.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 165a2637d2SSam Leffler.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 175a2637d2SSam Leffler.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 185a2637d2SSam Leffler.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 195a2637d2SSam Leffler.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 205a2637d2SSam Leffler.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 215a2637d2SSam Leffler.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 225a2637d2SSam Leffler.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 235a2637d2SSam Leffler.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 245a2637d2SSam Leffler.\" SUCH DAMAGE. 255a2637d2SSam Leffler.\" 26*884eaacdSJohn Baldwin.Dd July 5, 2023 275a2637d2SSam Leffler.Dt DB_COMMAND 9 285a2637d2SSam Leffler.Os 295a2637d2SSam Leffler.Sh NAME 305a2637d2SSam Leffler.Nm DB_COMMAND , 31b83d53cbSMitchell Horne.Nm DB_COMMAND_FLAGS , 325a2637d2SSam Leffler.Nm DB_SHOW_COMMAND , 33b83d53cbSMitchell Horne.Nm DB_SHOW_COMMAND_FLAGS , 34b83d53cbSMitchell Horne.Nm DB_SHOW_ALL_COMMAND , 35*884eaacdSJohn Baldwin.Nm DB_TABLE_COMMAND , 36*884eaacdSJohn Baldwin.Nm DB_TABLE_COMMAND_FLAGS , 37b83d53cbSMitchell Horne.Nm DB_ALIAS , 38b83d53cbSMitchell Horne.Nm DB_ALIAS_FLAGS , 39b83d53cbSMitchell Horne.Nm DB_SHOW_ALIAS , 40b83d53cbSMitchell Horne.Nm DB_SHOW_ALIAS_FLAGS , 41*884eaacdSJohn Baldwin.Nm DB_SHOW_ALL_ALIAS , 42*884eaacdSJohn Baldwin.Nm DB_TABLE_ALIAS , 43*884eaacdSJohn Baldwin.Nm DB_TABLE_ALIAS_FLAGS 44*884eaacdSJohn Baldwin.Nm DB_DECLARE_TABLE , 45*884eaacdSJohn Baldwin.Nm DB_DEFINE_TABLE , 4673bbeaa5SGlen Barber.Nd Extends the ddb command set 475a2637d2SSam Leffler.Sh SYNOPSIS 485a2637d2SSam Leffler.In ddb/ddb.h 49b83d53cbSMitchell Horne.Fn DB_COMMAND "command_name" "command_function" 50b83d53cbSMitchell Horne.Fn DB_COMMAND_FLAGS "command_name" "command_function" "flags" 515a2637d2SSam Leffler.Fn DB_SHOW_COMMAND "command_name" "command_function" 52b83d53cbSMitchell Horne.Fn DB_SHOW_COMMAND_FLAGS "command_name" "command_function" "flags" 535a2637d2SSam Leffler.Fn DB_SHOW_ALL_COMMAND "command_name" "command_function" 54*884eaacdSJohn Baldwin.Fn DB_TABLE_COMMAND "table" "command_name" "command_function" 55*884eaacdSJohn Baldwin.Fn DB_TABLE_COMMAND_FLAGS "table" "command_name" "command_function" "flags" 56b83d53cbSMitchell Horne.Fn DB_ALIAS "alias_name" "command_function" 57b83d53cbSMitchell Horne.Fn DB_ALIAS_FLAGS "alias_name" "command_function" "flags" 58b83d53cbSMitchell Horne.Fn DB_SHOW_ALIAS "alias_name" "command_function" 59b83d53cbSMitchell Horne.Fn DB_SHOW_ALIAS_FLAGS "alias_name" "command_function" "flags" 60b83d53cbSMitchell Horne.Fn DB_SHOW_ALL_ALIAS "alias_name" "command_function" 61*884eaacdSJohn Baldwin.Fn DB_TABLE_ALIAS "table" "alias_name" "command_function" 62*884eaacdSJohn Baldwin.Fn DB_TABLE_ALIAS_FLAGS "table" "alias_name" "command_function" "flags" 63*884eaacdSJohn Baldwin.Fn DB_DEFINE_TABLE "parent" "name" "table" 64*884eaacdSJohn Baldwin.Fn DB_DECLARE_TABLE "table" 655a2637d2SSam Leffler.Sh DESCRIPTION 665a2637d2SSam LefflerThe 675a2637d2SSam Leffler.Fn DB_COMMAND 685a2637d2SSam Lefflermacro adds 695a2637d2SSam Leffler.Fa command_name 705a2637d2SSam Lefflerto the list of top-level commands. 715a2637d2SSam LefflerInvoking 725a2637d2SSam Leffler.Fa command_name 735a2637d2SSam Lefflerfrom ddb will call 745a2637d2SSam Leffler.Fa command_function . 755a2637d2SSam Leffler.Pp 765a2637d2SSam LefflerThe 775a2637d2SSam Leffler.Fn DB_SHOW_COMMAND 785a2637d2SSam Lefflerand 795a2637d2SSam Leffler.Fn DB_SHOW_ALL_COMMAND 80b83d53cbSMitchell Hornemacros are roughly equivalent to 815a2637d2SSam Leffler.Fn DB_COMMAND 825a2637d2SSam Lefflerbut in these cases, 835a2637d2SSam Leffler.Fa command_name 845a2637d2SSam Leffleris a sub-command of the ddb 855a2637d2SSam Leffler.Sy show 865a2637d2SSam Lefflercommand and 875a2637d2SSam Leffler.Sy show all 885a2637d2SSam Lefflercommand, respectively. 895a2637d2SSam Leffler.Pp 90b83d53cbSMitchell HorneThe 91*884eaacdSJohn Baldwin.Fn DB_TABLE_COMMAND 92*884eaacdSJohn Baldwinmacro is also similar to 93*884eaacdSJohn Baldwin.Fn DB_COMMAND 94*884eaacdSJohn Baldwinbut adds the new command as a sub-command of the ddb command 95*884eaacdSJohn Baldwin.Fa table . 96*884eaacdSJohn Baldwin.Pp 97*884eaacdSJohn BaldwinThe 98b83d53cbSMitchell Horne.Fn DB_ALIAS , 99b83d53cbSMitchell Horne.Fn DB_SHOW_ALIAS , 100*884eaacdSJohn Baldwin.Fn DB_SHOW_ALL_ALIAS , 101b83d53cbSMitchell Horneand 102*884eaacdSJohn Baldwin.Fn DB_TABLE_ALIAS 10362bca9c4SMitchell Hornemacros register the existing 104b83d53cbSMitchell Horne.Fa command_function 105b83d53cbSMitchell Horneunder the alternative command name 106b83d53cbSMitchell Horne.Fa alias_name . 107b83d53cbSMitchell Horne.Pp 108b83d53cbSMitchell HorneThe _FLAGS variants of these commands allow the programmer to specify a value 109b83d53cbSMitchell Hornefor the 110b83d53cbSMitchell Horne.Fa flag 111b83d53cbSMitchell Hornefield of the command structure. 112b83d53cbSMitchell HorneThe possible flag values are defined alongside 113b83d53cbSMitchell Horne.Ft struct db_command 114b83d53cbSMitchell Hornein 115b83d53cbSMitchell Horne.In ddb/ddb.h . 116b83d53cbSMitchell Horne.Pp 1175a2637d2SSam LefflerThe general command syntax: 1185a2637d2SSam Leffler.Cm command Ns Op Li \&/ Ns Ar modifier 1191e9469d1SChristian Brueffer.Ar address Ns Op , Ns Ar count , 1205a2637d2SSam Lefflertranslates into the following parameters for 1215a2637d2SSam Leffler.Fa command_function : 1229255dffdSGlen Barber.Bl -tag -width Fa -offset indent 1235a2637d2SSam Leffler.It Fa addr 1245a2637d2SSam LefflerThe address passed to the command as an argument. 1255a2637d2SSam Leffler.It Fa have_addr 1265a2637d2SSam LefflerA boolean value that is true if the addr field is valid. 1275a2637d2SSam Leffler.It Fa count 1285a2637d2SSam LefflerThe number of quad words starting at offset 1295a2637d2SSam Leffler.Fa addr 1305a2637d2SSam Lefflerthat the command must process. 1315a2637d2SSam Leffler.It Fa modif 13270284f85SEnji CooperA pointer to the string of modifiers. 13370284f85SEnji CooperThat is, a series of symbols used to pass some options to the command. 13470284f85SEnji CooperFor example, the 1355a2637d2SSam Leffler.Sy examine 1365a2637d2SSam Lefflercommand will display words in decimal form if it is passed the modifier "d". 1375a2637d2SSam Leffler.El 138*884eaacdSJohn Baldwin.Pp 139*884eaacdSJohn BaldwinThe 140*884eaacdSJohn Baldwin.Fn DB_DEFINE_TABLE 141*884eaacdSJohn Baldwinmacro adds a new command 142*884eaacdSJohn Baldwin.Fa name 143*884eaacdSJohn Baldwinas a sub-command of the existing command table 144*884eaacdSJohn Baldwin.Fa parent . 145*884eaacdSJohn BaldwinThe new command defines a table named 146*884eaacdSJohn Baldwin.Fa table 147*884eaacdSJohn Baldwinwhich contains sub-commands. 148*884eaacdSJohn BaldwinNew commands and aliases can be added to this table by passing 149*884eaacdSJohn Baldwin.Fa table 150*884eaacdSJohn Baldwinas the first argument to one of the DB_TABLE_ macros. 151b83d53cbSMitchell Horne.Sh EXAMPLES 1525a2637d2SSam LefflerIn your module, the command is declared as: 1535a2637d2SSam Leffler.Bd -literal 1545a2637d2SSam LefflerDB_COMMAND(mycmd, my_cmd_func) 1555a2637d2SSam Leffler{ 1565a2637d2SSam Leffler if (have_addr) 1575a2637d2SSam Leffler db_printf("Calling my command with address %p\\n", addr); 1585a2637d2SSam Leffler} 1595a2637d2SSam Leffler.Ed 1605a2637d2SSam Leffler.Pp 161b83d53cbSMitchell HorneAn alias for this command is declared as: 162b83d53cbSMitchell Horne.Bd -literal 163b83d53cbSMitchell HorneDB_ALIAS(mycmd2, my_cmd_func); 164b83d53cbSMitchell Horne.Ed 165b83d53cbSMitchell Horne.Pp 1665a2637d2SSam LefflerThen, when in ddb: 1675a2637d2SSam Leffler.Bd -literal 1685a2637d2SSam Leffler.Bf Sy 1695a2637d2SSam Lefflerdb> mycmd 0x1000 1705a2637d2SSam LefflerCalling my command with address 0x1000 171b83d53cbSMitchell Hornedb> mycmd2 0x2500 172b83d53cbSMitchell HorneCalling my command with address 0x2500 1735a2637d2SSam Lefflerdb> 1745a2637d2SSam Leffler.Ef 1755a2637d2SSam Leffler.Ed 1768a7314fcSBaptiste Daroussin.Sh SEE ALSO 1775a2637d2SSam Leffler.Xr ddb 4 1788a7314fcSBaptiste Daroussin.Sh AUTHORS 1795a2637d2SSam LefflerThis manual page was written by 1808a7314fcSBaptiste Daroussin.An Guillaume Ballet Aq Mt gballet@gmail.com . 181