DB_COMMAND(9)

πŸ’– DB_COMMAND(9) πŸ’–

okay bestie, welcome to the Kernel Developer's Manual ✨ this one's all about DB_COMMAND, DB_SHOW_COMMAND, and DB_SHOW_ALL_COMMAND β€” the little macros that let you ✨extend the ddb command set✨. iykyk. πŸŽ€


🌸 NAME 🌸

DB_COMMAND, DB_SHOW_COMMAND, DB_SHOW_ALL_COMMAND β€” literally just out here extending the ddb command set, no big deal πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <ddb/ddb.h>

DB_COMMAND(command_name, command_function);

DB_SHOW_COMMAND(command_name, command_function);

DB_SHOW_ALL_COMMAND(command_name, command_function);

✨ DESCRIPTION ✨

so the DB_COMMAND() macro? it adds command_name to the list of top-level commands, periodt. πŸ‘‘ and then when you invoke command_name from ddb, it calls command_function. that's it, that's the whole vibe. 🫢

DB_SHOW_COMMAND() and DB_SHOW_ALL_COMMAND() are roughly equivalent to DB_COMMAND() β€” like, cousins, sisters, same energy fr fr β€” but in these cases, command_name is a sub-command of the ddb show command and show all command, respectively. 🌈

okay so the general command syntax:

command[/modifier] address[,count]

...translates into the following parameters for command_function:

  • addr β€” the address passed to the command as an argument. πŸ“
  • have_addr β€” a boolean value that is true if the addr field is valid. βœ…
  • count β€” the number of quad words starting at offset addr that 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, the examine command will display words in decimal form if it is passed the modifier "d". πŸ’…

πŸŽ€ EXAMPLE πŸŽ€

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);
}

then, when in ddb:

db> mycmd 0x1000
Calling my command with address 0x1000
db>

ate. no crumbs. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’œ AUTHORS πŸ’œ

this manual page was written by Guillaume Ballet <gballet@gmail.com>. iconic behavior honestly 🫢


and that's the whole page bestie!! this one's coming to you from the Debian crew, dated August 27, 2008 🌸 (yes it's giving vintage but it still slays) β€” DB_COMMAND(9), mwah, bye πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from