xref: /freebsd/share/man/man9/DB_COMMAND.9 (revision 81ad6265)
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 June 24, 2022
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_ALIAS ,
38.Nm DB_ALIAS_FLAGS ,
39.Nm DB_SHOW_ALIAS ,
40.Nm DB_SHOW_ALIAS_FLAGS ,
41.Nm DB_SHOW_ALL_ALIAS
42.Nd Extends the ddb command set
43.Sh SYNOPSIS
44.In ddb/ddb.h
45.Fn DB_COMMAND "command_name" "command_function"
46.Fn DB_COMMAND_FLAGS "command_name" "command_function" "flags"
47.Fn DB_SHOW_COMMAND "command_name" "command_function"
48.Fn DB_SHOW_COMMAND_FLAGS "command_name" "command_function" "flags"
49.Fn DB_SHOW_ALL_COMMAND "command_name" "command_function"
50.Fn DB_ALIAS "alias_name" "command_function"
51.Fn DB_ALIAS_FLAGS "alias_name" "command_function" "flags"
52.Fn DB_SHOW_ALIAS "alias_name" "command_function"
53.Fn DB_SHOW_ALIAS_FLAGS "alias_name" "command_function" "flags"
54.Fn DB_SHOW_ALL_ALIAS "alias_name" "command_function"
55.Sh DESCRIPTION
56The
57.Fn DB_COMMAND
58macro adds
59.Fa command_name
60to the list of top-level commands.
61Invoking
62.Fa command_name
63from ddb will call
64.Fa command_function .
65.Pp
66The
67.Fn DB_SHOW_COMMAND
68and
69.Fn DB_SHOW_ALL_COMMAND
70macros are roughly equivalent to
71.Fn DB_COMMAND
72but in these cases,
73.Fa command_name
74is a sub-command of the ddb
75.Sy show
76command and
77.Sy show all
78command, respectively.
79.Pp
80The
81.Fn DB_ALIAS ,
82.Fn DB_SHOW_ALIAS ,
83and
84.Fn DB_SHOW_ALL_ALIAS
85macros register the existing
86.Fa command_function
87under the alternative command name
88.Fa alias_name .
89.Pp
90The _FLAGS variants of these commands allow the programmer to specify a value
91for the
92.Fa flag
93field of the command structure.
94The possible flag values are defined alongside
95.Ft struct db_command
96in
97.In ddb/ddb.h .
98.Pp
99The general command syntax:
100.Cm command Ns Op Li \&/ Ns Ar modifier
101.Ar address Ns Op , Ns Ar count ,
102translates into the following parameters for
103.Fa command_function :
104.Bl -tag -width Fa -offset indent
105.It Fa addr
106The address passed to the command as an argument.
107.It Fa have_addr
108A boolean value that is true if the addr field is valid.
109.It Fa count
110The number of quad words starting at offset
111.Fa addr
112that the command must process.
113.It Fa modif
114A pointer to the string of modifiers.
115That is, a series of symbols used to pass some options to the command.
116For example, the
117.Sy examine
118command will display words in decimal form if it is passed the modifier "d".
119.El
120.Sh EXAMPLES
121In your module, the command is declared as:
122.Bd -literal
123DB_COMMAND(mycmd, my_cmd_func)
124{
125	if (have_addr)
126		db_printf("Calling my command with address %p\\n", addr);
127}
128.Ed
129.Pp
130An alias for this command is declared as:
131.Bd -literal
132DB_ALIAS(mycmd2, my_cmd_func);
133.Ed
134.Pp
135Then, when in ddb:
136.Bd -literal
137.Bf Sy
138db> mycmd 0x1000
139Calling my command with address 0x1000
140db> mycmd2 0x2500
141Calling my command with address 0x2500
142db>
143.Ef
144.Ed
145.Sh SEE ALSO
146.Xr ddb 4
147.Sh AUTHORS
148This manual page was written by
149.An Guillaume Ballet Aq Mt gballet@gmail.com .
150