Page MenuHomeFreeBSD

exterror: support %d in error messages
ClosedPublic

Authored by kib on Sat, Dec 27, 3:49 PM.
Tags
None
Referenced Files
F141173974: D54380.id168644.diff
Thu, Jan 1, 9:53 PM
F141108483: D54380.id168663.diff
Wed, Dec 31, 11:34 PM
Unknown Object (File)
Wed, Dec 31, 12:03 PM
Unknown Object (File)
Wed, Dec 31, 11:39 AM
Unknown Object (File)
Wed, Dec 31, 11:26 AM
Unknown Object (File)
Tue, Dec 30, 6:15 PM
Unknown Object (File)
Tue, Dec 30, 5:11 PM
Unknown Object (File)
Tue, Dec 30, 5:05 PM
Subscribers

Details

Summary
libc/gen/err.c: remove 'extended error' herald from extended error output


exterror: add support for the format specifiers in the extended error msg

Note that we trust kernel code to only request the printout of integer
types, and use the 'j' modifier always.


exterror: Add EXTERROR_VERBOSE env variable to control verbosity

If the variable is set and the process is not suid, __uexterr_format(),
used by err(3), prints errno/category/source line/pX always, not only
when there is no kernel message provided.


vm/vm_mmap.c: inline erronous argument values for extended errors

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Sat, Dec 27, 3:49 PM

Much more useful output to the user.

lib/libc/gen/uexterr_format.c
69–70

I should be able to request getting this information if I want to see it. I suggest a new err.3 function like setverbose(level) where level 0 is default but with level 1 also includes this information. Without an environment variable, I still have to add an option to call this function but at least it is easily possible and a documented way to do it.

share/man/man9/exterror.9
99–103

suggest wording as:
format modifier to accept only the types
.Vt intmax_t
or
.Vt uintmax_t .

This revision is now accepted and ready to land.Sat, Dec 27, 11:46 PM
kib marked an inline comment as done.
kib edited the summary of this revision. (Show Details)

EXTERROR_VERBOSE

This revision now requires review to proceed.Sun, Dec 28, 12:40 AM
lib/libc/gen/uexterr_format.c
69–70

Ok, I just added EXTERROR_VERBOSE env variable support for !setugid processes.

This revision is now accepted and ready to land.Sun, Dec 28, 3:07 AM

Print the source file name for verbose exterror output.

This revision now requires review to proceed.Sun, Dec 28, 2:26 PM

Tag the generated file with "@generated"

emaste added inline comments.
tools/build/make_libc_exterr_cat_filenames.sh
14

To avoid phab falsely detecting this script as a generated file can use something like:

atsymbol=@
echo " * Automatically ${atsymbol}generated, use" >>"${target}"

or e.g. printf " * Automatically %sgenerated, use\n" @

This revision is now accepted and ready to land.Sun, Dec 28, 5:29 PM
kib marked an inline comment as done.

Avoid literal @generated in the script.

This revision now requires review to proceed.Sun, Dec 28, 6:33 PM

Providing the file names is a great improvement. I like the way you have automated their generation.

The EXTERROR_VERBOSE environment variable needs to be documented in environment.7 and err.3 and perhaps in exterror.9.

lib/libc/gen/uexterr_format.c
84

I suggest making the pathname complete by adding sys/, i.e. (src sys/%s:%u)

sys/sys/exterr_cat.h
17

extra / between build and make in pathname

kib marked an inline comment as done.

Remove extra slash in comment.
Add some documentation to err.3 and environment.7.

lib/libc/gen/uexterr_format.c
84

I specifically removed the sys/ from the path, since I do not see it useful: we already know that the reported path is from the kernel.

If you insist, I will remove the sub() call from the script' awk invocation. But IMO it would only consume the screen space in the already cluttered line.

Coming down the home stretch. Just three more comments.

lib/libc/gen/err.3
116–117 ↗(On Diff #168666)

If the kernel returned an extended error string in addition to the

127–128 ↗(On Diff #168666)

environment variable is present, an additional report is printed.
The report includes at least the category of the error, the name of the source file

lib/libc/gen/uexterr_format.c
84

People like you and me know that these are subdirectories of sys, but someone less knowledgeable about the kernel see something like net/if_bridge.c and have no idea where to look for that file. If it says sys/net/if_bridge.c then it is much more obvious where to find the file.

I recommend leaving the sub() call in the script. There is no need to have a huge number of "sys/" strings in exterr_cat_filenames.h wasting memory. Just add the sys/ in the snprintf above

kib marked 5 inline comments as done.

Add the sys/ prefix.
Fix grammar in err.3.

This is a great step ahead. Looking forward to having it in production.

This revision is now accepted and ready to land.Sun, Dec 28, 11:32 PM

One small typo

lib/libc/gen/err.3
117 ↗(On Diff #168670)
kib marked an inline comment as done.Mon, Dec 29, 12:52 AM