DDB(9) | Kernel Developer's Manual | DDB(9)

# NAME

`ddb` — in-kernel debugger

# 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

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.

The type argument is one of:

`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.

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.

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.
`CS_NOREPEAT`
  The command should not be automatically repeated by the REPL when the user enters an empty command after it.
`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.
`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.

# SEE ALSO

ddb(4)

October 30, 2020 | NetBSD 11.0