Subject: Re: ddb help command patch
To: Adam Hamsik <haaaad@gmail.com>
From: Bill Stouder-Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 06/27/2007 11:03:10
--U3s59FfKcByyGl+j
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Jun 26, 2007 at 05:48:32PM +0200, Adam Hamsik wrote:
>=20
> 2) I think about dynamic ddb command/help API which could be used for =20
> registering/unregistering ddb commands. Now all ddb commands are =20
> stored in static array db_command_table. Problem is that if every =20
> kernel component want to add some ddb_commands kernel programer have =20
> to add entry to the ddb_command_table. If we use dynamic structure =20
> like linked list we can add/remove commands in realtime.

Sounds good.

> API:
>=20
> int
> db_reg_command(struct cmd_list *cmd_list, struct cmd_list **cmd_command,
> char *cmd_name,*cmd_func);
>=20
> db_reg_help(*cmd_command,char* descr, char** cmd_func_arg);
>=20
> db_unreg_command(*cmd_list, char* cmd_name);
>=20
> struct cmd_list*
> db_search_command(struct cmd_list*, char* cmd_name);
>=20
> /*this function will create default list of commands*/
> db_init(struct cmd_list**);
>=20
> (db_get_help,db_get_func,db_get_cmd) ??
>=20
> Pro:
>=20
> LKM and other parts of kernel can register/unregister ddb commands in =20
> easy way.
>=20
> more useable ddb.
>=20
>=20
> Cons:
> I have to initialize this list when ddb is run.(lot of malloc's for =20
> every added command 2 one for command structure and second for help=20
> (not needed))

Actually, I think if we are clever about our list creation, we don't have=
=20
too much of an issue.

Make the list a list of tables. So built-in commands are in one static=20
table, and we have a static command list head. We then have a malloc'd=20
list of:

struct ddb_command_list_entry {
	TAILQ_ENTRY(ddb_command_list_entry)
				ddbcl_next;
	int			ddbcl_count;		/* count of cmds */
	struct ddb_command	*ddbcl_commands;
};

Yes, there will probably be a pad int in there too on LP64.

The upshot of this is that everything other than these list entries can be=
=20
in text sections. We only need to malloc one of these command list entry=20
structures per table of commands.

Take care,

Bill

--U3s59FfKcByyGl+j
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)

iD8DBQFGgqZeWz+3JHUci9cRAroAAJwMiIbi0M+RAfsF09ngJzvXtXiRRQCggNVC
kdwe3B8RB2QBZTQPRP1L6xw=
=9rFv
-----END PGP SIGNATURE-----

--U3s59FfKcByyGl+j--