From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 30 18:29:37 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 864C8106566B for ; Fri, 30 Jan 2009 18:29:37 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from ebb.errno.com (ebb.errno.com [69.12.149.25]) by mx1.freebsd.org (Postfix) with ESMTP id 5C8668FC16 for ; Fri, 30 Jan 2009 18:29:36 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from trouble.errno.com (trouble.errno.com [10.0.0.248]) (authenticated bits=0) by ebb.errno.com (8.13.6/8.12.6) with ESMTP id n0UITaIY048045 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 30 Jan 2009 10:29:36 -0800 (PST) (envelope-from sam@freebsd.org) Message-ID: <49834710.9070908@freebsd.org> Date: Fri, 30 Jan 2009 10:29:36 -0800 From: Sam Leffler Organization: FreeBSD Project User-Agent: Thunderbird 2.0.0.18 (X11/20081209) MIME-Version: 1.0 To: Matthew Fleming References: <1233337318.13748.101.camel@amaretto> In-Reply-To: <1233337318.13748.101.camel@amaretto> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DCC-sonic.net-Metrics: ebb.errno.com; whitelist Cc: freebsd-hackers@freebsd.org Subject: Re: Dynamic ddb commands X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jan 2009 18:29:37 -0000 Matthew Fleming wrote: > I'm working on BSD 6.x and of course the set of ddb commands is static > to whatever is in the kernel at compile. I see that BSD 7.1 has dynamic > commands using sysinits and sysuninit's to call a new > db_[un]register_cmd. > > I see this, though, only after I have spent a day or so adding a > linker_file_[un]register_ddb() that works similarly to how sysinits are > merged for the boot-time modules (malloc and copy pointers). It seems > to me that this solution (have the linker look for db_set and db_cmd_set > and, if there are any entries, malloc and save pointers to commands) is > more efficient in terms of space than adding a LIST to the command > structure and then forcing sysinits to run. > I haven't looked at your approach so not sure how to respond. The existing code was simple. > I'm curious as to why the current method was chosen when something > lighter-weight was available... or so it seems from my perspective > looking at the 6.x code base. > > As another side note, lexicographic order for the commands doesn't seem > to add anything, except that command insert/delete are O(n/2) instead of > O(n). It can make it harder to use ddb to debug ddb, though. If, e.g. > there's a pointer problem somewhere in the command list, if the most > basic commands are up front like examine and write, then at least those > can be used to possibly repair ddb so a debug session can continue. > > If I recall it was painful to find entries in the help listing w/o sorting. Feel free to propose an alternative implementation; noone's wed to what's in the tree. Sam