Jonathan Adams wrote: > On Mon, Jun 30, 2008 at 06:27:17PM +0800, Yu Xiangning wrote: >> Hi mdb gurus, >> >> While compiling the mdb modules with DEBUG mode, we found that -DDEBUG >> is not passed to the compiler. >> >> To fix this, we have to add a line manually to >> usr/src/cmd/mdb/Makefile.module: >> >> $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG >> >> So I'm a bit confused, shouldn't we always pass DEBUG to the compiler >> while doing a debug build? > > mdb and kmdb are built with -DDEBUG, but modules typically are not. > Normally, most datastructures in the kernel are identical for DEBUG > and non-DEBUG builds, so this isn't a problem. It's important that > there not be two versions of the MDB modules (one debug and one non-debug); > it's very common to be debugging a non-debug dump on a DEBUG build, and > vice-versa. > > Because of this, adding -DDEBUG to Makefile.module when compiling > under DEBUG isn't the solution. Something like what's done in > usr/src/cmd/mdb/common/modules/dtrace/dtrace.c is better: > > 30 * explicitly define DTRACE_ERRDEBUG to pull in definition of > dtrace_errhash_t > ... > 33 #define DTRACE_ERRDEBUG > > What, exactly, is the problem you are running into? >
The problem is that, it brings some trouble doing sizeof() or accessing the structure members under DEBUG/non-DEBUG kernel if a data structure in kernel header file is defined as follows: struct XXX { ... #ifdef DEBUG /* some debug facilities */ ... #endif ... }; I agree with Meem that adding DEBUG switch to the data structure brings more pain than benefits. - yxn > Cheers, > - jonathan > _______________________________________________ > Volo-dev mailing list > Volo-dev at opensolaris.org > http://mail.opensolaris.org/mailman/listinfo/volo-dev