DB_COMMAND(9)
π DB_COMMAND(9) π
okay bestie, welcome to the Kernel Developer's Manual corner where ddb gets its command set extended. This page is all about the DB_* macros that add commands, aliases, and command tables so ddb can do more iconic things. π«Άβ¨
β¨ NAME β¨
DB_COMMAND, DB_COMMAND_FLAGS, DB_SHOW_COMMAND, DB_SHOW_COMMAND_FLAGS, DB_SHOW_ALL_COMMAND, DB_TABLE_COMMAND, DB_TABLE_COMMAND_FLAGS, DB_ALIAS, DB_ALIAS_FLAGS, DB_SHOW_ALIAS, DB_SHOW_ALIAS_FLAGS, DB_SHOW_ALL_ALIAS, DB_TABLE_ALIAS, DB_TABLE_ALIAS_FLAGS DB_DECLARE_TABLE, DB_DEFINE_TABLE, β Extends the ddb command set π
πΈ SYNOPSIS πΈ
#include <ddb/ddb.h>
DB_COMMAND(command_name, command_function);
DB_COMMAND_FLAGS(command_name, command_function, flags);
DB_SHOW_COMMAND(command_name, command_function);
DB_SHOW_COMMAND_FLAGS(command_name, command_function, flags);
DB_SHOW_ALL_COMMAND(command_name, command_function);
DB_TABLE_COMMAND(table, command_name, command_function);
DB_TABLE_COMMAND_FLAGS(table, command_name, command_function, flags);
DB_ALIAS(alias_name, command_function);
DB_ALIAS_FLAGS(alias_name, command_function, flags);
DB_SHOW_ALIAS(alias_name, command_function);
DB_SHOW_ALIAS_FLAGS(alias_name, command_function, flags);
DB_SHOW_ALL_ALIAS(alias_name, command_function);
DB_TABLE_ALIAS(table, alias_name, command_function);
DB_TABLE_ALIAS_FLAGS(table, alias_name, command_function, flags);
DB_DEFINE_TABLE(parent, name, table);
DB_DECLARE_TABLE(table);
π¦ DESCRIPTION π¦
okay so the big vibe here: these macros are how you extend the ddb command set. They register commands, subcommands, aliases, and whole command tables. Letβs break it down, bestie. π
DB_COMMAND()β addscommand_nameto the list of top-level commands. Invokingcommand_namefrom ddb will callcommand_function. β¨DB_SHOW_COMMAND()andDB_SHOW_ALL_COMMAND()β roughly equivalent toDB_COMMAND(), but in these casescommand_nameis a sub-command of the ddbshowcommand andshow allcommand, respectively. πDB_TABLE_COMMAND()β also similar toDB_COMMAND(), but it adds the new command as a sub-command of the ddb command table. π οΈDB_ALIAS(),DB_SHOW_ALIAS(),DB_SHOW_ALL_ALIAS(), andDB_TABLE_ALIAS()β register the existingcommand_functionunder the alternative command namealias_name. π¦- The
_FLAGSvariants of these commands β let the programmer specify a value for theflagfield of the command structure. The possible flag values are defined alongsidestruct db_commandin<ddb/ddb.h>. π₯
The general command syntax is command[/modifier] address[,count], and it translates into these parameters for command_function:
addrβ the address passed to the command as an argument. πhave_addrβ a boolean value that is true if theaddrfield is valid. βcountβ the number of quad words starting at offsetaddrthat the command must process. π’modifβ a pointer to the string of modifiers. That is, a series of symbols used to pass some options to the command. For example, theexaminecommand will display words in decimal form if it is passed the modifier"d". π§
DB_DEFINE_TABLE() β adds a new command name as a sub-command of the existing command table parent. The new command defines a table named table which contains sub-commands. New commands and aliases can be added to this table by passing table as the first argument to one of the DB_TABLE_ macros. π
π EXAMPLES π
In your module, the command is declared as:
DB_COMMAND(mycmd, my_cmd_func)
{
if (have_addr)
db_printf("Calling my command with address %p\n", addr);
}
An alias for this command is declared as:
DB_ALIAS(mycmd2, my_cmd_func);
Then, when in ddb:
db> mycmd 0x1000
Calling my command with address 0x1000
db> mycmd2 0x2500
Calling my command with address 0x2500
db>
π SEE ALSO π
ddb(4) β go read it, bestie. ππ
π AUTHORS π
This manual page was written by Guillaume Ballet <gballet@gmail.com>. Give them their flowers. ππ
signed off in Debian on July 5, 2023 β stay iconic, bestie ππ
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2008 Guillaume Ballet
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms