Page MenuHomeFreeBSD

Add DEBUG_PRINTF to stand.h
ClosedPublic

Authored by sjg on Jul 11 2025, 10:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 3:32 AM
Unknown Object (File)
Sat, Oct 11, 12:03 AM
Unknown Object (File)
Fri, Oct 10, 12:30 PM
Unknown Object (File)
Fri, Oct 10, 12:29 PM
Unknown Object (File)
Fri, Oct 10, 12:29 PM
Unknown Object (File)
Fri, Oct 10, 5:41 AM
Unknown Object (File)
Wed, Oct 8, 2:54 AM
Unknown Object (File)
Fri, Oct 3, 1:07 PM
Subscribers

Details

Reviewers
imp
stevek
kevans
manu
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rGe67aef419093: Add DEBUG_PRINTF to stand.h
Summary

stand/ is mostly debugged with printfs, in an ad hoc and sometimes
fragile manner. For example BOOTP_DEBUG in bootp.c cannot be defined
unless NETIF_DEBUG is defined in dev_net.c or build fails for lack of the
symbol debug.

The DEBUG_PRINTF implementation in stand.h addresses that and allows
for more control over debug output. It is compatible with the
usage in libsecureboot.

Simply define _DEBUG_LEVEL to the desired level of debug
or in the case of libsecureboot _DEBUG_LEVEL_VAR to the variable that
will hold that value - default is _debug which is static so each
translation unit can be controlled independently.

The 1st arg to DEBUG_PRINTF is a level which must be greater than or
equal to _DEBUG_LEVEL_VAR if the printf is to be called.
See libsecureboot for more examples.

Sponsored by: Juniper Networks, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Jul 11 2025, 10:36 PM
sjg requested review of this revision.Jul 11 2025, 10:36 PM

Tweak the #ifdef in stand.h

This looks good.

It would be nice if there was a loader command to set the debug level, but that's a separate thing and isn't universally useful since a lot of this code runs before the OK prompt.

stand/libsa/pkgfs.c
740

Fun!

This revision is now accepted and ready to land.Jul 17 2025, 10:01 PM
In D51269#1173596, @imp wrote:

This looks good.

It would be nice if there was a loader command to set the debug level, but that's a separate thing and isn't universally useful since a lot of this code runs before the OK prompt.

The DebugVe value used by libsecureboot can be set via loader.conf etc, but for most of stand, that's less appropriate - stuff works or it doesn't ;-)

This revision was automatically updated to reflect the committed changes.