It is possible to use DB_COMMAND to add commands to ddb from the kernel.
Using DB_COMMAND from a kernel module, however, is not working. I have
altered the ddb code to do so.
Fix: The patch is provided as an attachment. I have also written a man page,
because I found out that DB_COMMAND was undocumented. The text for the
man page is pasted hereafter:
.Dd August 27, 2008
.Dt DB_COMMAND 9
.Nm DB_COMMAND ,
.Nm DB_SHOW_COMMAND ,
.Nd Extends the ddb command set.
.Fn DB_SHOW_COMMAND "command_name" "command_function"
.Fn DB_SHOW_ALL_COMMAND "command_name" "command_function"
to the list of top-level commands. Invoking
from ddb will call
.Fa command_function .
are roughly equivalent to
but in these cases,
is a sub-command of the ddb
.Sy show all
The general command syntax:
.Cm command Ns Op Li \&/ Ns Ar modifier
.Ar address Ns Op Li , Ns Ar count ,
translates into the following parameters for
.Fa command_function :
.It Fa addr
The address passed to the command as an argument.
.It Fa have_addr
A boolean value that is true if the addr field is valid.
.It Fa count
The number of quad words starting at offset
that the command must process.
.It Fa 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
command will display words in decimal form if it is passed the modifier "d".
In your module, the command is declared as:
db_printf("Calling my command with address %p\\n", addr);
Then, when in ddb:
db> mycmd 0x1000
Calling my command with address 0x1000
.Sh "SEE ALSO"
.Xr ddb 4
This manual page was written by
.An Guillaume Ballet Aq email@example.com .
Patch attached with submission follows:
How-To-Repeat: Create a module and use DB_COMMAND (example below). Then drop inside ddb.
db_printf("Calling my command with address %p\n", addr);
For bugs matching the following criteria:
Status: In Progress Changed: (is less than) 2014-06-01
Reset to default assignee and clear in-progress tags.
Mail being skipped