Page MenuHomeFreeBSD

Make INVARIANTS enable DEBUG in DTrace
AbandonedPublic

Authored by domagoj.stolfa_gmail.com on Mar 26 2018, 10:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 26 2024, 9:33 AM
Unknown Object (File)
Jan 31 2024, 12:08 PM
Unknown Object (File)
Jan 5 2024, 7:27 PM
Unknown Object (File)
Jan 1 2024, 2:46 PM
Unknown Object (File)
Dec 20 2023, 7:58 AM
Unknown Object (File)
Dec 10 2023, 3:24 PM
Unknown Object (File)
Nov 14 2023, 11:14 PM
Unknown Object (File)
Nov 9 2023, 9:39 PM
Subscribers

Details

Reviewers
markj
gnn
Group Reviewers
DTrace
Summary

DTrace has a number of conditionally compiled assertions and checks. Previously, INVARIANTS has not enabled these checks, making DTrace difficult to debug. This patch checks for INVARIANTS, and if they are defined, it adds -DDEBUG to CFLAGS in the DTrace kernel module build.

Sponsored by: DARPA/AFRL

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/modules/dtrace/Makefile
38 ↗(On Diff #40772)

This isn't really sufficient: dtrace can be compiled into the kernel.

Also, how does INVARIANTS get defined as a make variable?

I think that some header ought to #define DEBUG if INVARIANTS is defined. Perhaps it would work to add -DDEBUG=INVARIANTS to CDDL_CFLAGS.

sys/modules/dtrace/Makefile
38 ↗(On Diff #40772)

That's a good point. I'm not sure that -DDEBUG=INVARIANTS would be a good idea for CDDL_FLAGS, as this would propagate to ZFS as well -- which might lead to surprises.

The solution you suggest with:

#ifdef INVARIANTS
#define DEBUG
#endif

seems like the easiest and most self-contained way to do this. I'll add this to dtrace.h.

FWIW, rS253996 is what I did to translate INVARIANTS to DEBUG for ZFS.
Seems like the commit even touched some dtrace modules.

In D14862#312653, @avg wrote:

FWIW, rS253996 is what I did to translate INVARIANTS to DEBUG for ZFS.
Seems like the commit even touched some dtrace modules.

Interestingly, this does seem to define DEBUG and using:

#ifdef DEBUG
_Static_assert(0, "DEBUG");
#endif

works just fine once I run it on a clean installation. It must have been something in my environment and I'd missed that. Sorry for the false alarm. Closing this as it actually does work.

Thanks @avg for pointing that commit out.