From owner-freebsd-hackers@FreeBSD.ORG Tue Oct 12 13:14:46 2010 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 4235B106566C for ; Tue, 12 Oct 2010 13:14:46 +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 126DA8FC1C for ; Tue, 12 Oct 2010 13:14:46 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id BC8B546B51; Tue, 12 Oct 2010 09:14:45 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 977278A01D; Tue, 12 Oct 2010 09:14:44 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Tue, 12 Oct 2010 08:30:19 -0400 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20100819; KDE/4.4.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201010120830.19872.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Tue, 12 Oct 2010 09:14:44 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.9 required=4.2 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: Garrett Cooper , Jilles Tjoelker Subject: Re: [PATCH] Fix /bin/sh compilation with CFLAGS += -DDEBUG > 1 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: Tue, 12 Oct 2010 13:14:46 -0000 On Tuesday, October 12, 2010 6:47:49 am Garrett Cooper wrote: > Hi, > It looks like the format strings are broken on 64-bit archs in > /bin/sh's TRACE functionality (can be enabled by uncommenting -DDEBUG > > 1 in bin/sh/Makefile). The attached patch fixes this functionality > again so one can trace sh's calls with TRACE, which may or may be > helpful to those debugging /bin/sh. > Tested build and execution on amd64; tested build on i386. > Thanks! > -Garrett I don't think the Makefile bits are needed, you can just use 'make DEBUG_FLAGS="-g -DDEBUG=2"' instead. Also, if you plan on using -g you should generally set DEBUG_FLAGS anyway so binaries are not stripped. The use of things like PRIoMAX is not done in FreeBSD as it is ugly. You can use things like '%t' to print ptrdiff_t types instead. So for example, for the first hunk, I would change the type of 'startloc' to ptrdiff_t and use this: TRACE(("evalbackq: size=%td: \"%.*s\"\n", (dest - stackblock()) - startloc, (int)((dest - stackblock()) - startloc), stackblock() + startloc)); Also, in your change here, you used %j to print a size_t. That will break on i386. You should use %z to print size_t's, but even better is to just use %t to print a ptrdiff_t (which is the type that holds the difference of two pointers). The various changes in jobs.c should use '%td' as well rather than (int) casts. -- John Baldwin