aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2023-07-05 23:00:47 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2023-07-05 23:02:01 +0000
commit884eaacd24bdb85c1571d31145278847bad6e55b (patch)
tree3f726d3f78c96aa2f7a1c05a6106b80d4fd8d1e9 /share
parent3a9e3ed6b003cdf60f11c109bdeaa337b3f3466d (diff)
downloadsrc-884eaacd24bdb85c1571d31145278847bad6e55b.tar.gz
src-884eaacd24bdb85c1571d31145278847bad6e55b.zip
ddb: Rework macros to make it easier to add new command tables.
- Add new DB_DEFINE_TABLE and DB_DECLARE_TABLE macros to define new command tables. DB_DECLARE_TABLE is intended for use in headers similar to MALLOC_DECLARE and SYSCTL_DECL. DB_DEFINE_TABLE takes three arguments, the name of the parent table, the command name, and the name of the table itself, e.g. DB_DEFINE_TABLE(show, foo, show_foo) defines a new "show foo" table. - DB_TABLE_COMMAND, DB_TABLE_COMMAND_FLAGS, DB_TABLE_ALIAS, and DB_ALIAS_FLAGS allow new commands and aliases to be defined. These are similar to the existing DB_COMMAND, etc. except that they take an initial argument giving the name of the parent table, e.g.: DB_TABLE_COMMAND(show_foo, bar, db_show_foo_bar) defines a new "show foo bar" command. This provides a cleaner interface than the ad-hoc use of internal macros like _DB_SET that was required previously (e.g. in cxgbe(4)). This retires DB_FUNC macro as well as the internal _DB_FUNC macro. Reviewed by: melifaro, kib, markj Differential Revision: https://reviews.freebsd.org/D40819
Diffstat (limited to 'share')
-rw-r--r--share/man/man9/DB_COMMAND.939
-rw-r--r--share/man/man9/Makefile8
2 files changed, 43 insertions, 4 deletions
diff --git a/share/man/man9/DB_COMMAND.9 b/share/man/man9/DB_COMMAND.9
index 15c2adce3580..ebf15f8b73f3 100644
--- a/share/man/man9/DB_COMMAND.9
+++ b/share/man/man9/DB_COMMAND.9
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 24, 2022
+.Dd July 5, 2023
.Dt DB_COMMAND 9
.Os
.Sh NAME
@@ -34,11 +34,17 @@
.Nm DB_SHOW_COMMAND ,
.Nm DB_SHOW_COMMAND_FLAGS ,
.Nm DB_SHOW_ALL_COMMAND ,
+.Nm DB_TABLE_COMMAND ,
+.Nm DB_TABLE_COMMAND_FLAGS ,
.Nm DB_ALIAS ,
.Nm DB_ALIAS_FLAGS ,
.Nm DB_SHOW_ALIAS ,
.Nm DB_SHOW_ALIAS_FLAGS ,
-.Nm DB_SHOW_ALL_ALIAS
+.Nm DB_SHOW_ALL_ALIAS ,
+.Nm DB_TABLE_ALIAS ,
+.Nm DB_TABLE_ALIAS_FLAGS
+.Nm DB_DECLARE_TABLE ,
+.Nm DB_DEFINE_TABLE ,
.Nd Extends the ddb command set
.Sh SYNOPSIS
.In ddb/ddb.h
@@ -47,11 +53,17 @@
.Fn DB_SHOW_COMMAND "command_name" "command_function"
.Fn DB_SHOW_COMMAND_FLAGS "command_name" "command_function" "flags"
.Fn DB_SHOW_ALL_COMMAND "command_name" "command_function"
+.Fn DB_TABLE_COMMAND "table" "command_name" "command_function"
+.Fn DB_TABLE_COMMAND_FLAGS "table" "command_name" "command_function" "flags"
.Fn DB_ALIAS "alias_name" "command_function"
.Fn DB_ALIAS_FLAGS "alias_name" "command_function" "flags"
.Fn DB_SHOW_ALIAS "alias_name" "command_function"
.Fn DB_SHOW_ALIAS_FLAGS "alias_name" "command_function" "flags"
.Fn DB_SHOW_ALL_ALIAS "alias_name" "command_function"
+.Fn DB_TABLE_ALIAS "table" "alias_name" "command_function"
+.Fn DB_TABLE_ALIAS_FLAGS "table" "alias_name" "command_function" "flags"
+.Fn DB_DEFINE_TABLE "parent" "name" "table"
+.Fn DB_DECLARE_TABLE "table"
.Sh DESCRIPTION
The
.Fn DB_COMMAND
@@ -78,10 +90,18 @@ command and
command, respectively.
.Pp
The
+.Fn DB_TABLE_COMMAND
+macro is also similar to
+.Fn DB_COMMAND
+but adds the new command as a sub-command of the ddb command
+.Fa table .
+.Pp
+The
.Fn DB_ALIAS ,
.Fn DB_SHOW_ALIAS ,
+.Fn DB_SHOW_ALL_ALIAS ,
and
-.Fn DB_SHOW_ALL_ALIAS
+.Fn DB_TABLE_ALIAS
macros register the existing
.Fa command_function
under the alternative command name
@@ -117,6 +137,19 @@ For example, the
.Sy examine
command will display words in decimal form if it is passed the modifier "d".
.El
+.Pp
+The
+.Fn DB_DEFINE_TABLE
+macro adds a new command
+.Fa name
+as a sub-command of the existing command table
+.Fa parent .
+The new command defines a table named
+.Fa table
+which contains sub-commands.
+New commands and aliases can be added to this table by passing
+.Fa table
+as the first argument to one of the DB_TABLE_ macros.
.Sh EXAMPLES
In your module, the command is declared as:
.Bd -literal
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index 2a320cf0fcba..45f9ec9b0515 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -983,7 +983,13 @@ MLINKS+=DB_COMMAND.9 DB_ALIAS.9 \
DB_COMMAND.9 DB_SHOW_ALL_ALIAS.9 \
DB_COMMAND.9 DB_SHOW_ALL_COMMAND.9 \
DB_COMMAND.9 DB_SHOW_COMMAND.9 \
- DB_COMMAND.9 DB_SHOW_COMMAND_FLAGS.9
+ DB_COMMAND.9 DB_SHOW_COMMAND_FLAGS.9 \
+ DB_COMMAND.9 DB_DECLARE_TABLE.9 \
+ DB_COMMAND.9 DB_DEFINE_TABLE.9 \
+ DB_COMMAND.9 DB_TABLE_COMMAND.9 \
+ DB_COMMAND.9 DB_TABLE_COMMAND_FLAGS.9 \
+ DB_COMMAND.9 DB_TABLE_ALIAS.9 \
+ DB_COMMAND.9 DB_TABLE_ALIAS_FLAGS.9
MLINKS+=DECLARE_MODULE.9 DECLARE_MODULE_TIED.9
MLINKS+=dev_clone.9 drain_dev_clone_events.9
MLINKS+=dev_refthread.9 devvn_refthread.9 \