Date: Tue, 12 Oct 2010 08:30:19 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-hackers@freebsd.org Cc: Garrett Cooper <yanegomi@gmail.com>, Jilles Tjoelker <jilles@stack.nl> Subject: Re: [PATCH] Fix /bin/sh compilation with CFLAGS += -DDEBUG > 1 Message-ID: <201010120830.19872.jhb@freebsd.org> In-Reply-To: <AANLkTinHi6jaLY%2BbZdnhL=gEY3hWGrzcfFG8nO6VMc5n@mail.gmail.com> References: <AANLkTinHi6jaLY%2BbZdnhL=gEY3hWGrzcfFG8nO6VMc5n@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010120830.19872.jhb>