Bug 127265 - [patch] ddb(4): Adding the ddb command set from modules
Summary: [patch] ddb(4): Adding the ddb command set from modules
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 7.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-10 08:40 UTC by Guillaume Ballet
Modified: 2017-12-31 22:35 UTC (History)
0 users

See Also:


Attachments
file.diff (14.14 KB, patch)
2008-09-10 08:40 UTC, Guillaume Ballet
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Ballet 2008-09-10 08:40:01 UTC
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
.Os
.Sh NAME
.Nm DB_COMMAND ,
.Nm DB_SHOW_COMMAND ,
.Nm DB_SHOW_ALL_COMMAND
.Nd Extends the ddb command set.
.Sh SYNOPSIS
.In ddb/ddb.h
.Fo DB_COMMAND
.Fa command_name
.Fa command_function
.Fc 
.Fn DB_SHOW_COMMAND "command_name" "command_function" 
.Fn DB_SHOW_ALL_COMMAND "command_name" "command_function" 
.Sh DESCRIPTION
.Pp
The
.Fn DB_COMMAND
macro adds
.Fa command_name
to the list of top-level commands. Invoking 
.Fa command_name
from ddb will call 
.Fa command_function .
.Pp
The
.Fn DB_SHOW_COMMAND
and
.Fn DB_SHOW_ALL_COMMAND
are roughly equivalent to
.Fn DB_COMMAND
but in these cases,
.Fa command_name
is a sub-command of the ddb 
.Sy show
command and
.Sy show all
command, respectively.
.Pp
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 :
.Bl -tag
.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
.Fa addr
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
.Sy examine
command will display words in decimal form if it is passed the modifier "d".
.El
.Sh EXAMPLE
In your module, the command is declared as:
.Pp
.Bd -literal
DB_COMMAND(mycmd, my_cmd_func)
{
	if (have_addr)
		db_printf("Calling my command with address %p\\n", addr);
}
.Ed
.Pp
Then, when in ddb:
.Pp
.Bd -literal
.Bf Sy
db> mycmd 0x1000
Calling my command with address 0x1000
db>
.Ef
.Ed
.Sh "SEE ALSO"
.Xr ddb 4
.Sh AUTHOR
This manual page was written by
.An Guillaume Ballet Aq gballet@gmail.com .


Patch attached with submission follows:
How-To-Repeat: Create a module and use DB_COMMAND (example below). Then drop inside ddb.
Nothing happens.

     DB_COMMAND(mycmd, my_cmd_func)
     {
             if (have_addr)
                     db_printf("Calling my command with address %p\n", addr);
     }
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:09 UTC
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