Page MenuHomeFreeBSD

queue(3): Debug macros: Finer control knobs, userland support
ClosedPublic

Authored by olce on Apr 23 2025, 10:04 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 14, 11:50 PM
Unknown Object (File)
Tue, Aug 12, 6:17 PM
Unknown Object (File)
Mon, Aug 11, 10:38 AM
Unknown Object (File)
Sat, Aug 2, 11:56 PM
Unknown Object (File)
Sat, Aug 2, 7:40 PM
Unknown Object (File)
Fri, Aug 1, 7:42 PM
Unknown Object (File)
Wed, Jul 30, 3:24 AM
Unknown Object (File)
Jul 21 2025, 4:37 PM
Subscribers

Details

Summary

Support enabling debugging macros for userland and _STANDALONE builds,
in addition to the already existing kernel support. On runtime error,
panic() is used for kernel and _STANDALONE builds, and a simple
fprintf() + abort() combination for userland ones. These can be
overriden if needed by defining the new QMD_PANIC() macro.

The expansion of queue debug macros can now be controlled more finely
thanks to the QUEUE_MACRO_DEBUG_ASSERTIONS and
QUEUE_MACRO_NO_DEBUG_ASSERTIONS macros. The first one serves to
forcibly enable debug code and the second to forcibly disable it. These
are meant to be used as compile options only, and should normally not be
defined in a source file. It is an error to have both of them defined.

If none of the two above-mentioned macros are defined, an automatic
determination is performed. When compiling kernel code,
QUEUE_MACRO_DEBUG_ASSERTIONS is defined if INVARIANTS has been defined
(as before). For userland and _STANDALONE builds, no debug code is ever
automatically inserted even if NDEBUG is not defined, as doing so would
inflate code size and users may want to have working assert() calls
without this overhead by default.

queue.3: Document check debug code control under DIAGNOSTICS

While here, rework a bit the rest of the DIAGNOSTICS section.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63669
Build 60553: arc lint + arc unit

Event Timeline

olce requested review of this revision.Apr 23 2025, 10:04 AM

Fix new documentation in queue.3 (was mentioning automatic insertion of check debug code on absence of NDEBUG in userland and _STANDALONE, which was removed from the initial patch).

markj added inline comments.
share/man/man3/queue.3
1407
sys/sys/queue.h
195
202
This revision is now accepted and ready to land.Apr 23 2025, 9:10 PM
olce marked 3 inline comments as done.Apr 28 2025, 9:04 AM
olce added inline comments.
share/man/man3/queue.3
1407

I settled for "check code" everywhere instead.

This revision was automatically updated to reflect the committed changes.
olce marked an inline comment as done.