Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109644634
D40819.id124047.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
D40819.id124047.diff
View Options
diff --git a/share/man/man9/DB_COMMAND.9 b/share/man/man9/DB_COMMAND.9
--- a/share/man/man9/DB_COMMAND.9
+++ b/share/man/man9/DB_COMMAND.9
@@ -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, 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 @@
.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
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -983,7 +983,13 @@
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 \
diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h
--- a/sys/ddb/ddb.h
+++ b/sys/ddb/ddb.h
@@ -85,21 +85,32 @@
*/
extern vm_offset_t ksymtab, kstrtab, ksymtab_size, ksymtab_relbase;
-/*
- * There are three "command tables":
- * - One for simple commands; a list of these is displayed
- * by typing 'help' at the debugger prompt.
- * - One for sub-commands of 'show'; to see this type 'show'
- * without any arguments.
- * - The last one for sub-commands of 'show all'; type 'show all'
- * without any argument to get a list.
- */
+/* Command tables contain a list of commands. */
struct db_command;
LIST_HEAD(db_command_table, db_command);
-extern struct db_command_table db_cmd_table;
-extern struct db_command_table db_show_table;
-extern struct db_command_table db_show_all_table;
-extern struct db_command_table db_show_active_table;
+
+#define _DB_TABLE_NAME(table) db_##table##_table
+
+#define DB_DEFINE_TABLE(parent, name, table) \
+ struct db_command_table _DB_TABLE_NAME(table) = \
+ LIST_HEAD_INITIALIZER(_DB_TABLE_NAME(table)); \
+ _DB_SET(parent, name, NULL, 0, &_DB_TABLE_NAME(table))
+
+#define DB_DECLARE_TABLE(table) \
+ extern struct db_command_table _DB_TABLE_NAME(table)
+
+/*
+ * Builtin command tables:
+ * - cmd: Top-level command table; a list of these is displayed
+ * by typing 'help' at the debugger prompt.
+ * - show: Sub-commands of 'show'
+ * - show_all: Sub-commands of 'show all'
+ * - show_active: Sub-commands of 'show active'
+ */
+DB_DECLARE_TABLE(cmd);
+DB_DECLARE_TABLE(show);
+DB_DECLARE_TABLE(show_all);
+DB_DECLARE_TABLE(show_active);
/*
* Type signature for a function implementing a ddb command.
@@ -133,26 +144,36 @@
* in modules in which case they will be available only when
* the module is loaded.
*/
-#define _DB_SET(_suffix, _name, _func, list, _flag, _more) \
-static struct db_command __CONCAT(_name,_suffix) = { \
+#define _DB_SET(_table, _name, _func, _flag, _more) \
+static struct db_command db_##_table##_##_name##_cmd = { \
.name = __STRING(_name), \
.fcn = _func, \
.flag = _flag, \
.more = _more \
}; \
-static void __CONCAT(__CONCAT(_name,_suffix),_add)(void *arg __unused) \
- { db_command_register(&list, &__CONCAT(_name,_suffix)); } \
-SYSINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \
- __CONCAT(__CONCAT(_name,_suffix),_add), NULL); \
-static void __CONCAT(__CONCAT(_name,_suffix),_del)(void *arg __unused) \
- { db_command_unregister(&list, &__CONCAT(_name,_suffix)); } \
-SYSUNINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \
- __CONCAT(__CONCAT(_name,_suffix),_del), NULL);
+ \
+static void \
+db##_table##_##_name##_add(void *arg __unused) \
+{ \
+ db_command_register(&_DB_TABLE_NAME(_table), \
+ &db_##_table##_##_name##_cmd); \
+} \
+SYSINIT(db_##_table##_##_name, SI_SUB_KLD, SI_ORDER_ANY, \
+ db##_table##_##_name##_add, NULL); \
+ \
+static void \
+db##_table##_##_name##_del(void *arg __unused) \
+{ \
+ db_command_unregister(&_DB_TABLE_NAME(_table), \
+ &db_##_table##_##_name##_cmd); \
+} \
+SYSUNINIT(db_##_table##_##_name, SI_SUB_KLD, SI_ORDER_ANY, \
+ db##_table##_##_name##_del, NULL)
/*
* Like _DB_SET but also create the function declaration which
* must be followed immediately by the body; e.g.
- * _DB_FUNC(_cmd, panic, db_panic, db_cmd_table, 0, NULL)
+ * DB_TABLE_COMMAND_FLAGS(_cmd, panic, db_panic, 0)
* {
* ...panic implementation...
* }
@@ -160,38 +181,41 @@
* This macro is mostly used to define commands placed in one of
* the ddb command tables; see DB_COMMAND, etc. below.
*/
-#define _DB_FUNC(_suffix, _name, _func, list, _flag, _more) \
+#define DB_TABLE_COMMAND_FLAGS(_table, _name, _func, _flag) \
static db_cmdfcn_t _func; \
-_DB_SET(_suffix, _name, _func, list, _flag, _more); \
+_DB_SET(_table, _name, _func, _flag, NULL); \
static void \
_func(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
-/* common idom provided for backwards compatibility */
-#define DB_FUNC(_name, _func, list, _flag, _more) \
- _DB_FUNC(_cmd, _name, _func, list, _flag, _more)
+#define DB_TABLE_COMMAND(_table, _name, _func) \
+ DB_TABLE_COMMAND_FLAGS(_table, _name, _func, 0)
+
+/* Wrappers around _DB_SET used for aliases. */
+#define DB_TABLE_ALIAS_FLAGS(_table, _name, _func, _flag) \
+ _DB_SET(_table, _name, _func, _flag, NULL)
+#define DB_TABLE_ALIAS(_table, _name, _func) \
+ DB_TABLE_ALIAS_FLAGS(_table, _name, _func, 0)
#define DB_COMMAND_FLAGS(cmd_name, func_name, flags) \
- _DB_FUNC(_cmd, cmd_name, func_name, db_cmd_table, flags, NULL)
+ DB_TABLE_COMMAND_FLAGS(cmd, cmd_name, func_name, flags)
#define DB_COMMAND(cmd_name, func_name) \
DB_COMMAND_FLAGS(cmd_name, func_name, 0)
#define DB_ALIAS_FLAGS(alias_name, func_name, flags) \
- _DB_SET(_cmd, alias_name, func_name, db_cmd_table, flags, NULL)
+ DB_TABLE_ALIAS_FLAGS(cmd, alias_name, func_name, flags)
#define DB_ALIAS(alias_name, func_name) \
DB_ALIAS_FLAGS(alias_name, func_name, 0)
#define DB_SHOW_COMMAND_FLAGS(cmd_name, func_name, flags) \
- _DB_FUNC(_show, cmd_name, func_name, db_show_table, flags, NULL)
+ DB_TABLE_COMMAND_FLAGS(show, cmd_name, func_name, flags)
#define DB_SHOW_COMMAND(cmd_name, func_name) \
DB_SHOW_COMMAND_FLAGS(cmd_name, func_name, 0)
#define DB_SHOW_ALIAS_FLAGS(alias_name, func_name, flags) \
- _DB_SET(_show, alias_name, func_name, db_show_table, flags, NULL)
+ DB_TABLE_ALIAS_FLAGS(show, alias_name, func_name, flags)
#define DB_SHOW_ALIAS(alias_name, func_name) \
DB_SHOW_ALIAS_FLAGS(alias_name, func_name, 0)
#define DB_SHOW_ALL_COMMAND(cmd_name, func_name) \
- _DB_FUNC(_show_all, cmd_name, func_name, db_show_all_table, \
- DB_CMD_MEMSAFE, NULL)
+ DB_TABLE_COMMAND_FLAGS(show_all, cmd_name, func_name, DB_CMD_MEMSAFE)
#define DB_SHOW_ALL_ALIAS(alias_name, func_name) \
- _DB_SET(_show_all, alias_name, func_name, db_show_all_table, \
- DB_CMD_MEMSAFE, NULL)
+ DB_TABLE_ALIAS_FLAGS(show_all, alias_name, func_name, DB_CMD_MEMSAFE)
extern db_expr_t db_maxoff;
extern int db_indent;
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -12921,10 +12921,9 @@
} while (i != first && !db_pager_quit);
}
-static struct db_command_table db_t4_table = LIST_HEAD_INITIALIZER(db_t4_table);
-_DB_SET(_show, t4, NULL, db_show_table, 0, &db_t4_table);
+static DB_DEFINE_TABLE(show, t4, show_t4);
-DB_FUNC(devlog, db_show_devlog, db_t4_table, CS_OWN, NULL)
+DB_TABLE_COMMAND_FLAGS(show_t4, devlog, db_show_devlog, CS_OWN)
{
device_t dev;
int t;
@@ -12950,7 +12949,7 @@
t4_dump_devlog(device_get_softc(dev));
}
-DB_FUNC(tcb, db_show_t4tcb, db_t4_table, CS_OWN, NULL)
+DB_TABLE_COMMAND_FLAGS(show_t4, tcb, db_show_t4tcb, CS_OWN)
{
device_t dev;
int radix, tid, t;
diff --git a/sys/net/route/route_ddb.c b/sys/net/route/route_ddb.c
--- a/sys/net/route/route_ddb.c
+++ b/sys/net/route/route_ddb.c
@@ -166,7 +166,7 @@
return (0);
}
-DB_SHOW_COMMAND(routetable, db_show_routetable_cmd)
+DB_SHOW_COMMAND(routetable, db_show_routetable)
{
struct rib_head *rnh;
int error, i, lim;
@@ -204,7 +204,7 @@
}
}
-DB_SHOW_COMMAND_FLAGS(route, db_show_route_cmd, CS_OWN)
+DB_SHOW_COMMAND_FLAGS(route, db_show_route, CS_OWN)
{
char abuf[INET6_ADDRSTRLEN], *buf, *end;
struct rib_head *rh;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 8, 10:01 PM (20 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16529723
Default Alt Text
D40819.id124047.diff (10 KB)
Attached To
Mode
D40819: ddb: Rework macros to make it easier to add new command tables.
Attached
Detach File
Event Timeline
Log In to Comment