xref: /freebsd/share/man/man9/DB_COMMAND.9 (revision 884eaacd24bdb85c1571d31145278847bad6e55b)
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.\"
265a2637d2SSam Leffler.\" $FreeBSD$
275a2637d2SSam Leffler.\"
28*884eaacdSJohn Baldwin.Dd July 5, 2023
295a2637d2SSam Leffler.Dt DB_COMMAND 9
305a2637d2SSam Leffler.Os
315a2637d2SSam Leffler.Sh NAME
325a2637d2SSam Leffler.Nm DB_COMMAND ,
33b83d53cbSMitchell Horne.Nm DB_COMMAND_FLAGS ,
345a2637d2SSam Leffler.Nm DB_SHOW_COMMAND ,
35b83d53cbSMitchell Horne.Nm DB_SHOW_COMMAND_FLAGS ,
36b83d53cbSMitchell Horne.Nm DB_SHOW_ALL_COMMAND ,
37*884eaacdSJohn Baldwin.Nm DB_TABLE_COMMAND ,
38*884eaacdSJohn Baldwin.Nm DB_TABLE_COMMAND_FLAGS ,
39b83d53cbSMitchell Horne.Nm DB_ALIAS ,
40b83d53cbSMitchell Horne.Nm DB_ALIAS_FLAGS ,
41b83d53cbSMitchell Horne.Nm DB_SHOW_ALIAS ,
42b83d53cbSMitchell Horne.Nm DB_SHOW_ALIAS_FLAGS ,
43*884eaacdSJohn Baldwin.Nm DB_SHOW_ALL_ALIAS ,
44*884eaacdSJohn Baldwin.Nm DB_TABLE_ALIAS ,
45*884eaacdSJohn Baldwin.Nm DB_TABLE_ALIAS_FLAGS
46*884eaacdSJohn Baldwin.Nm DB_DECLARE_TABLE ,
47*884eaacdSJohn Baldwin.Nm DB_DEFINE_TABLE ,
4873bbeaa5SGlen Barber.Nd Extends the ddb command set
495a2637d2SSam Leffler.Sh SYNOPSIS
505a2637d2SSam Leffler.In ddb/ddb.h
51b83d53cbSMitchell Horne.Fn DB_COMMAND "command_name" "command_function"
52b83d53cbSMitchell Horne.Fn DB_COMMAND_FLAGS "command_name" "command_function" "flags"
535a2637d2SSam Leffler.Fn DB_SHOW_COMMAND "command_name" "command_function"
54b83d53cbSMitchell Horne.Fn DB_SHOW_COMMAND_FLAGS "command_name" "command_function" "flags"
555a2637d2SSam Leffler.Fn DB_SHOW_ALL_COMMAND "command_name" "command_function"
56*884eaacdSJohn Baldwin.Fn DB_TABLE_COMMAND "table" "command_name" "command_function"
57*884eaacdSJohn Baldwin.Fn DB_TABLE_COMMAND_FLAGS "table" "command_name" "command_function" "flags"
58b83d53cbSMitchell Horne.Fn DB_ALIAS "alias_name" "command_function"
59b83d53cbSMitchell Horne.Fn DB_ALIAS_FLAGS "alias_name" "command_function" "flags"
60b83d53cbSMitchell Horne.Fn DB_SHOW_ALIAS "alias_name" "command_function"
61b83d53cbSMitchell Horne.Fn DB_SHOW_ALIAS_FLAGS "alias_name" "command_function" "flags"
62b83d53cbSMitchell Horne.Fn DB_SHOW_ALL_ALIAS "alias_name" "command_function"
63*884eaacdSJohn Baldwin.Fn DB_TABLE_ALIAS "table" "alias_name" "command_function"
64*884eaacdSJohn Baldwin.Fn DB_TABLE_ALIAS_FLAGS "table" "alias_name" "command_function" "flags"
65*884eaacdSJohn Baldwin.Fn DB_DEFINE_TABLE "parent" "name" "table"
66*884eaacdSJohn Baldwin.Fn DB_DECLARE_TABLE "table"
675a2637d2SSam Leffler.Sh DESCRIPTION
685a2637d2SSam LefflerThe
695a2637d2SSam Leffler.Fn DB_COMMAND
705a2637d2SSam Lefflermacro adds
715a2637d2SSam Leffler.Fa command_name
725a2637d2SSam Lefflerto the list of top-level commands.
735a2637d2SSam LefflerInvoking
745a2637d2SSam Leffler.Fa command_name
755a2637d2SSam Lefflerfrom ddb will call
765a2637d2SSam Leffler.Fa command_function .
775a2637d2SSam Leffler.Pp
785a2637d2SSam LefflerThe
795a2637d2SSam Leffler.Fn DB_SHOW_COMMAND
805a2637d2SSam Lefflerand
815a2637d2SSam Leffler.Fn DB_SHOW_ALL_COMMAND
82b83d53cbSMitchell Hornemacros are roughly equivalent to
835a2637d2SSam Leffler.Fn DB_COMMAND
845a2637d2SSam Lefflerbut in these cases,
855a2637d2SSam Leffler.Fa command_name
865a2637d2SSam Leffleris a sub-command of the ddb
875a2637d2SSam Leffler.Sy show
885a2637d2SSam Lefflercommand and
895a2637d2SSam Leffler.Sy show all
905a2637d2SSam Lefflercommand, respectively.
915a2637d2SSam Leffler.Pp
92b83d53cbSMitchell HorneThe
93*884eaacdSJohn Baldwin.Fn DB_TABLE_COMMAND
94*884eaacdSJohn Baldwinmacro is also similar to
95*884eaacdSJohn Baldwin.Fn DB_COMMAND
96*884eaacdSJohn Baldwinbut adds the new command as a sub-command of the ddb command
97*884eaacdSJohn Baldwin.Fa table .
98*884eaacdSJohn Baldwin.Pp
99*884eaacdSJohn BaldwinThe
100b83d53cbSMitchell Horne.Fn DB_ALIAS ,
101b83d53cbSMitchell Horne.Fn DB_SHOW_ALIAS ,
102*884eaacdSJohn Baldwin.Fn DB_SHOW_ALL_ALIAS ,
103b83d53cbSMitchell Horneand
104*884eaacdSJohn Baldwin.Fn DB_TABLE_ALIAS
10562bca9c4SMitchell Hornemacros register the existing
106b83d53cbSMitchell Horne.Fa command_function
107b83d53cbSMitchell Horneunder the alternative command name
108b83d53cbSMitchell Horne.Fa alias_name .
109b83d53cbSMitchell Horne.Pp
110b83d53cbSMitchell HorneThe _FLAGS variants of these commands allow the programmer to specify a value
111b83d53cbSMitchell Hornefor the
112b83d53cbSMitchell Horne.Fa flag
113b83d53cbSMitchell Hornefield of the command structure.
114b83d53cbSMitchell HorneThe possible flag values are defined alongside
115b83d53cbSMitchell Horne.Ft struct db_command
116b83d53cbSMitchell Hornein
117b83d53cbSMitchell Horne.In ddb/ddb.h .
118b83d53cbSMitchell Horne.Pp
1195a2637d2SSam LefflerThe general command syntax:
1205a2637d2SSam Leffler.Cm command Ns Op Li \&/ Ns Ar modifier
1211e9469d1SChristian Brueffer.Ar address Ns Op , Ns Ar count ,
1225a2637d2SSam Lefflertranslates into the following parameters for
1235a2637d2SSam Leffler.Fa command_function :
1249255dffdSGlen Barber.Bl -tag -width Fa -offset indent
1255a2637d2SSam Leffler.It Fa addr
1265a2637d2SSam LefflerThe address passed to the command as an argument.
1275a2637d2SSam Leffler.It Fa have_addr
1285a2637d2SSam LefflerA boolean value that is true if the addr field is valid.
1295a2637d2SSam Leffler.It Fa count
1305a2637d2SSam LefflerThe number of quad words starting at offset
1315a2637d2SSam Leffler.Fa addr
1325a2637d2SSam Lefflerthat the command must process.
1335a2637d2SSam Leffler.It Fa modif
13470284f85SEnji CooperA pointer to the string of modifiers.
13570284f85SEnji CooperThat is, a series of symbols used to pass some options to the command.
13670284f85SEnji CooperFor example, the
1375a2637d2SSam Leffler.Sy examine
1385a2637d2SSam Lefflercommand will display words in decimal form if it is passed the modifier "d".
1395a2637d2SSam Leffler.El
140*884eaacdSJohn Baldwin.Pp
141*884eaacdSJohn BaldwinThe
142*884eaacdSJohn Baldwin.Fn DB_DEFINE_TABLE
143*884eaacdSJohn Baldwinmacro adds a new command
144*884eaacdSJohn Baldwin.Fa name
145*884eaacdSJohn Baldwinas a sub-command of the existing command table
146*884eaacdSJohn Baldwin.Fa parent .
147*884eaacdSJohn BaldwinThe new command defines a table named
148*884eaacdSJohn Baldwin.Fa table
149*884eaacdSJohn Baldwinwhich contains sub-commands.
150*884eaacdSJohn BaldwinNew commands and aliases can be added to this table by passing
151*884eaacdSJohn Baldwin.Fa table
152*884eaacdSJohn Baldwinas the first argument to one of the DB_TABLE_ macros.
153b83d53cbSMitchell Horne.Sh EXAMPLES
1545a2637d2SSam LefflerIn your module, the command is declared as:
1555a2637d2SSam Leffler.Bd -literal
1565a2637d2SSam LefflerDB_COMMAND(mycmd, my_cmd_func)
1575a2637d2SSam Leffler{
1585a2637d2SSam Leffler	if (have_addr)
1595a2637d2SSam Leffler		db_printf("Calling my command with address %p\\n", addr);
1605a2637d2SSam Leffler}
1615a2637d2SSam Leffler.Ed
1625a2637d2SSam Leffler.Pp
163b83d53cbSMitchell HorneAn alias for this command is declared as:
164b83d53cbSMitchell Horne.Bd -literal
165b83d53cbSMitchell HorneDB_ALIAS(mycmd2, my_cmd_func);
166b83d53cbSMitchell Horne.Ed
167b83d53cbSMitchell Horne.Pp
1685a2637d2SSam LefflerThen, when in ddb:
1695a2637d2SSam Leffler.Bd -literal
1705a2637d2SSam Leffler.Bf Sy
1715a2637d2SSam Lefflerdb> mycmd 0x1000
1725a2637d2SSam LefflerCalling my command with address 0x1000
173b83d53cbSMitchell Hornedb> mycmd2 0x2500
174b83d53cbSMitchell HorneCalling my command with address 0x2500
1755a2637d2SSam Lefflerdb>
1765a2637d2SSam Leffler.Ef
1775a2637d2SSam Leffler.Ed
1788a7314fcSBaptiste Daroussin.Sh SEE ALSO
1795a2637d2SSam Leffler.Xr ddb 4
1808a7314fcSBaptiste Daroussin.Sh AUTHORS
1815a2637d2SSam LefflerThis manual page was written by
1828a7314fcSBaptiste Daroussin.An Guillaume Ballet Aq Mt gballet@gmail.com .
183