Global variables get clobbered with debug kernel

Hi,

I built a kernel with debug/tracing/witness enabled and my module-wide global and static variables are getting clobbered. This does not occur with the generic kernel.

I have a FreeBSD 8.0-RELEASE i386 kernel. I took the GENERIC file and made the following changes based upon the FreeBSD web site recommendations:

1. uncommented the KDTRACE_HOOKS option.
2. Added options for KDB, DDB, GDB, INVARIANTS, INVARIANTS_SUPPORT, WITNESS, WITNESS_SKIPSPIN, DEBUG_LOCKS, DEBUG_VFS_LOCKS, DIAGNOSTIC and DEBUG_MEMGUARD.

I am new to the FreeBSD kernel but I have several years of Linux kernel development. I am developing a dynamically loaded module. I was trying to trace a lock problem and WITNESS sounds like a fantastic tool so I built a new kernel to enable the kernel debugging tools.

With the kernel I built, simple initialization flags like 'static int init_flag=0;' do not work as the variable 'init_flag' has garbage as soon as I enter the module loader (I print it). The same applies to non-static global variables.

I expect that I am doing something wrong but I can't figure it out. The kernel is very sweet and the build was smooth and the instructions are clear.

Any help would be greatly appreciated,

Thank you.
 
Good idea. I'll try to isolate the problem further by enabling the kernel options one at a time.

Thank you,
 
Back
Top