Page MenuHomeFreeBSD

Refinement to kernel extended error reporting
ClosedPublic

Authored by mckusick on Wed, Feb 25, 12:28 AM.
Tags
None
Referenced Files
F145956376: D55494.id172750.diff
Thu, Feb 26, 12:43 PM
Unknown Object (File)
Thu, Feb 26, 11:47 AM
Unknown Object (File)
Wed, Feb 25, 11:44 PM
Unknown Object (File)
Wed, Feb 25, 1:51 PM
Unknown Object (File)
Wed, Feb 25, 1:22 PM
Subscribers

Details

Summary

When kernel external errors are available they are included in the err(3) library function messages. In addition to the extended error itself, the kernel also tracks the kernel file and line number at which the error was generated. This additional information is not included in the err(3) messages unless the EXTERROR_VERBOSE environment variable is present. Currently, when EXTERROR_VERBOSE is present, all the internal extended error information associated with the error is printed most of which is redundant with the formatted error message printed by err(3). This change will add only the kernel file and line number to the err(3) message when EXTERROR_VERBOSE is present and set to "brief".

In summary:
setenv EXTERROR_VERBOSE brief
adds just the kernel file and line number to the err(3) message.
Kernel strings not available or setenv EXTERROR_VERBOSE
produces the full external error state to be added to the err(3) message

Test Plan

Verify that extended error messages print the expected values with and without the EXTERROR_VERBOSE present.

Sample output with bad protection bits to mmap:

guest_16 % ./Example bigfile
Example: mmap bigfile: Invalid argument (unknown PROT bits 0x8)

guest_16 % setenv EXTERROR_VERBOSE
guest_16 % ./Example bigfile
Example: mmap bigfile: Invalid argument (unknown PROT bits 0x8 errno 22 category 1 (src sys/vm/vm_mmap.c:200) p1 0x8 p2 0)

guest_16 % setenv EXTERROR_VERBOSE brief
guest_16 % ./Example bigfile
Example: mmap bigfile: Invalid argument (unknown PROT bits 0x8 (src sys/vm/vm_mmap.c:200))

Diff Detail

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

Event Timeline

lib/libc/gen/uexterr_format.c
90

This would match any string starting with '1'. Why not using proper strcmp()?

In fact, I suggest to go backward, and print the short version if the variable has some specific value, like 'brief'. Otherwise, do not change the output.

Sorry for spamming.

More, I suggest to implement it by adding the new value to the exterr_verbose_state enum. The value of the variable would be checked only once then.

In D55494#1269805, @kib wrote:

Sorry for spamming.

More, I suggest to implement it by adding the new value to the exterr_verbose_state enum. The value of the variable would be checked only once then.

I implemented it in D55498. Feel free to take that revision. Or I might commit it, and you would update the man page.

mckusick edited the test plan for this revision. (Show Details)

Incorporate changes recommended by kib.

kib added inline comments.
lib/libc/gen/uexterr_format.c
93

This line should only have +4 spaces indent against the line above it.

This revision is now accepted and ready to land.Wed, Feb 25, 10:13 PM
mckusick marked an inline comment as done.
mckusick added inline comments.
lib/libc/gen/uexterr_format.c
90

I agree that style says that it should be four, but aesthetically I think it looks better as I did it. That said, I will check it in under the strict rules.

This revision was not accepted when it landed; it landed in state Changes Planned.Thu, Feb 26, 6:29 AM
This revision was automatically updated to reflect the committed changes.