From owner-freebsd-hackers@FreeBSD.ORG Mon Feb 2 18:44:46 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 F32821065746 for ; Mon, 2 Feb 2009 18:44:45 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id B598B8FC0A for ; Mon, 2 Feb 2009 18:44:44 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id E3B8846B0C; Mon, 2 Feb 2009 13:44:43 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n12IiPOj042733; Mon, 2 Feb 2009 13:44:38 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: "Matthew Fleming" Date: Mon, 2 Feb 2009 11:52:47 -0500 User-Agent: KMail/1.9.7 References: <1233337318.13748.101.camel@amaretto> <200902020846.33072.jhb@freebsd.org> <1233591461.7789.25.camel@amaretto> In-Reply-To: <1233591461.7789.25.camel@amaretto> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902021152.48020.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Mon, 02 Feb 2009 13:44:38 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/8941/Mon Feb 2 10:34:46 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx 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: Mon, 02 Feb 2009 18:44:46 -0000 On Monday 02 February 2009 11:17:41 am Matthew Fleming wrote: > > In general it is far easier to just add sysinit's than to hack directly on the > > kernel linker. There are very few ddb commands, so one extra pointer or two > > per command is not a lot of space. > > Respectfully, I disagree, for several reasons. > > First, in order to make sysinit and sysctl work, the kernel linker > needed to know that there are a set of elf sections that have special > meaning. Yes, using sysinits means that there are still only two elf > sections of interest. Yes, that is precisely the point, to keep the special knowledge in the kernel linker to a minimum. This is why kernel modules use sysinit's as well, and thus device drivers, etc. The kernel linker is already a bit complex, and I'd much prefer to keep non-linker related knowledge out of it as much as possible. > Second, as I mentioned before, having ddb commands added mixed in with > sysinits means that, if I have a bug in my sysinit I may not be able to > use some of my ddb commands to debug it. Even if DB_*COMMAND used > SI_ORDER_FIRST, any sysinit with the same priority may come first. You can still debug it, just not using your new commands. But actually, as long as your sysinit's are after SI_SUB_KLD (as most of them are), then you can still use your debugging commands just fine. > Next, if you want commands sorted globally, it could be done with either > implementation. But I think that commands that are defined by a module > should be listed with others from that module. Well, one of the "features" of ddb (IIRC) is that it allows "automatic" nicknames in that if you have a 'reallylongname' command you can just use 're' as an alias for it if 'reallylongname' is the only command that starts with 're'. Handling that basically requires a sorted list. Also, if you want to group commands in your module, that is easily accomplished by using an appropriate namespace. E.g., prior to this when I used to use 'call foo()' as a poor-man's substitute, I added commands to debug de(4) and had them all start with 'tulip_*'. You could use a similar practice to group your commands if desired. > Last, changing struct command introduces a binary compatibility issue. > Any older driver that had a ddb command (even if they never realized > they couldn't access it) would need to be recompiled. I am not sure of > FreeBSD's binary compatibility policy, though, and it would presumably > be across a major OS revision number. So this is not a very compelling > argument. Correct, it is across major OS revisions, so it is ok to change it for 8.0. -- John Baldwin