DDB(9)

πŸ“¦ version 11.0, in nixpkgs unstable

🌸 NAME 🌸

okay bestie, welcome to ddb(9) from the Kernel Developer's Manual β€” the page for the in-kernel debugger (ddb). This is where devices and kernel modules learn how to add shiny new commands to the debugger and remove them again. kernel-dev main character energy, no cap. πŸ’–

✨ SYNOPSIS ✨

#include <ddb/ddb.h>

int
db_register_tbl(uint8_t type, const struct db_command *commands);

int
db_unregister_tbl(uint8_t type, const struct db_command *commands);

void
(*pf)(db_expr_t addr, bool have_addr, db_expr_t count,
    const char *modif);

DDB_ADD_CMD(const char *name,
    void (*pf)(db_expr_t, bool, db_expr_t, const char *),
    uint16_t flags, const char *cmd_descr, const char *cmd_arg,
    const char *arg_desc);

πŸ’… DESCRIPTION πŸ’…

Okay so picture this: devices and kernel modules can add new commands to the ddb(4) in-kernel debugger with db_register_tbl() and remove previously added commands with db_unregister_tbl() respectively. slay. πŸŽ€

The type argument is one of these absolute icons:

  • DDB_BASE_CMD β€” top-level commands.
  • DDB_MACH_CMD β€” sub-commands of the top-level mach command.
  • DDB_SHOW_CMD β€” sub-commands of the top-level show command.

The commands argument is an array of struct db_command entries. The initializer list for the array should use the DDB_ADD_CMD() macro for its entries. The name argument is the name of the debugger command. An entry with NULL name terminates the array. yes bestie, NULL is the little end-of-array signal πŸ›‘

The pf argument is the function that implements the command. The debugger's REPL parses the usual command format documented in ddb(4) and invokes the implementation with the values obtained. literally handing your function the parsed little snack it asked for πŸ“

The flags argument is a bitwise OR of the following values:

  • CS_MORE β€” the command takes the usual arguments but may additionally parse the remainder of its command line. extra nibbles? iconic.
  • CS_NOREPEAT β€” the command should not be automatically repeated by the REPL when the user enters an empty command after it. no accidental encore, periodt.
  • CS_OWN β€” the command doesn't follow the normal ddb(4) conventions and parses its command line itself. The REPL doesn't try to parse the command line. The values passed to its implementation are dummies. so if you pick this, you're on your own parser duties, no cap πŸ’€
  • CS_SET_DOT β€” the command sets the dot.

The remaining parameters are strings that provide documentation for the command and its arguments. That documentation is available to the user via the help command if the kernel was compiled with the DDB_VERBOSE_HELP option. love that for documentation girlies 🫢

πŸ¦‹ SEE ALSO πŸ¦‹


Cute little footer sign-off: this page is from the Debian edition, dated October 30, 2020 β€” DDB(9) forever, bestie! πŸ’…βœ¨

πŸ“¦ where this page comes from