Page MenuHomeFreeBSD

Add handling for non-native error values to libsysdecode.
ClosedPublic

Authored by jhb on Feb 17 2016, 6:53 PM.
Tags
None
Referenced Files
F103471110: D5314.diff
Mon, Nov 25, 11:17 AM
Unknown Object (File)
Fri, Nov 15, 8:39 AM
Unknown Object (File)
Wed, Nov 6, 1:03 PM
Unknown Object (File)
Wed, Nov 6, 1:03 PM
Unknown Object (File)
Wed, Nov 6, 1:02 PM
Unknown Object (File)
Tue, Nov 5, 12:03 AM
Unknown Object (File)
Tue, Oct 29, 9:24 PM
Unknown Object (File)
Sep 29 2024, 11:25 PM

Details

Summary

Add handling for non-native error values to libsysdecode.

Add two new functions, sysdecode_abi_to_freebsd_errno() and
sysdecode_freebsd_to_abi_errno(), which convert errno values between
the native FreeBSD ABI and other supported ABIs. Note that the
mappings are not necessarily perfect meaning in some cases multiple
errors in one ABI might map to a single error in another ABI. In that
case, the reverse mapping will return one of the errors that maps, but
which error is non-deterministic.

Change truss to always report the raw error value to the user but
use libsysdecode to map it to a native errno value that can be used
with strerror() to generate a description. Previously truss reported
the "converted" error value. Now the user will always see the exact
error value that the application sees.

Change kdump to report the truly raw error value to the user. Previously
kdump would report the absolute value of the raw error value (so for
Linux binaries it didn't output the FreeBSD error value, but the positive
value of the Linux error). Now it reports the real (i.e. negative) error
value for Linux binaries. Also, use libsysdecode to convert the native
FreeBSD error reported in the ktrace record to the raw error used by the
ABI. This means that the Linux ABI can now be handled directly in
ktrsysret() and removes the need for linux_ktrsysret().

Test Plan
  • Compared output of truss / kdump on native and Linux binaries (/bin/ls from linux-base-c6). Linux binaries now report the raw error value, but otherwise the output is identical.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 2541
Build 2558: arc lint + arc unit

Event Timeline

jhb retitled this revision from to Add handling for non-native error values to libsysdecode..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: bdrewery, kib.
lib/libsysdecode/errno.c
61

It seems to be 100% 1-to-1 mapping. Did I miss something?

It could be auto generated: awk '/#define[[:space:]]CLOUDABI_E/ && !/CLOUDABI_EVENT/ { printf "\t[%s]\t= %s,\n", $2, substr($2, 10) }' sys/contrib/cloudabi/syscalldefs_mi.h

usr.bin/truss/syscalls.c
2079

Unrelated. I just noticed this abi->abi. Perhaps the first should be renamed to procabi, or the sysdecode enum abi to something else.

wblock added inline comments.
lib/libsysdecode/sysdecode_abi_to_freebsd_errno.3
60

"function the error value" appears to have left out a.

80

I'd suggest "can" rather than "may".

jhb marked an inline comment as done.Feb 18 2016, 1:40 AM
jhb added inline comments.
lib/libsysdecode/errno.c
61

I just copied this from truss sources where Ed had done it this way. It hasn't needed to change since it was added there so I don't imagine it will need much in the way of future changes either. The in-kernel errno fixup uses a similar table (but in reverse).

lib/libsysdecode/sysdecode_abi_to_freebsd_errno.3
60

I used 'function returns the error value', but I definitely missed a word, thanks!

usr.bin/truss/syscalls.c
2079

It's not ideal but it is also already present from the earlier change to use sysdecode_syscallname(). If it is changed I think that should be a separate commit rather than part of this change. If I had to rename one I'd probably do the enum, maybe to sd_abi or something (though that also seems clumsy).

kib edited edge metadata.
This revision is now accepted and ready to land.Feb 18 2016, 1:04 PM
bdrewery edited edge metadata.
bdrewery added inline comments.
usr.bin/truss/syscalls.c
2079

Yes definitely a separate commit if we do it. It's not a big deal though.

This revision was automatically updated to reflect the committed changes.