diff options
author | jhb <jhb@FreeBSD.org> | 2016-02-23 20:00:55 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-02-23 20:00:55 +0000 |
commit | ca284988772507a1b799a619df4b7041a4dc9369 (patch) | |
tree | 2e652af1c6fc8f563dbb36930037dca0ed084d27 /usr.bin/kdump | |
parent | dbabd325530e7767fe427e64ff9bdec867e18af9 (diff) | |
download | FreeBSD-src-ca284988772507a1b799a619df4b7041a4dc9369.zip FreeBSD-src-ca284988772507a1b799a619df4b7041a4dc9369.tar.gz |
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().
Reviewed by: bdrewery, kib
Helpful notes: wblock (manpage)
Differential Revision: https://reviews.freebsd.org/D5314
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r-- | usr.bin/kdump/kdump.c | 71 |
1 files changed, 3 insertions, 68 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 8fe03ea..b4a1f69 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -142,28 +142,6 @@ static struct ktr_header ktr_header; c = ','; \ } while (0) -#if defined(__amd64__) || defined(__i386__) - -void linux_ktrsysret(struct ktr_sysret *, u_int); - -/* - * from linux.h - * Linux syscalls return negative errno's, we do positive and map them - */ -static int bsd_to_linux_errno[ELAST + 1] = { - -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, - -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, - -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, - -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, - -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, - -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, - -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, - -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, - -72, -67, -71 -}; -#endif - struct proc_info { TAILQ_ENTRY(proc_info) info; @@ -393,13 +371,7 @@ main(int argc, char *argv[]) ktrsyscall((struct ktr_syscall *)m, sv_flags); break; case KTR_SYSRET: -#if defined(__amd64__) || defined(__i386__) - if ((sv_flags & SV_ABI_MASK) == SV_ABI_LINUX) - linux_ktrsysret((struct ktr_sysret *)m, - sv_flags); - else -#endif - ktrsysret((struct ktr_sysret *)m, sv_flags); + ktrsysret((struct ktr_sysret *)m, sv_flags); break; case KTR_NAMEI: case KTR_SYSCTL: @@ -1366,7 +1338,8 @@ ktrsysret(struct ktr_sysret *ktr, u_int sv_flags) else if (error == EJUSTRETURN) printf("JUSTRETURN"); else { - printf("-1 errno %d", ktr->ktr_error); + printf("-1 errno %d", sysdecode_freebsd_to_abi_errno( + syscallabi(sv_flags), error)); if (fancy) printf(" %s", strerror(ktr->ktr_error)); } @@ -1852,44 +1825,6 @@ ktrfaultend(struct ktr_faultend *ktr) printf("\n"); } -#if defined(__amd64__) || defined(__i386__) -void -linux_ktrsysret(struct ktr_sysret *ktr, u_int sv_flags) -{ - register_t ret = ktr->ktr_retval; - int error = ktr->ktr_error; - - syscallname(ktr->ktr_code, sv_flags); - printf(" "); - - if (error == 0) { - if (fancy) { - printf("%ld", (long)ret); - if (ret < 0 || ret > 9) - printf("/%#lx", (unsigned long)ret); - } else { - if (decimal) - printf("%ld", (long)ret); - else - printf("%#lx", (unsigned long)ret); - } - } else if (error == ERESTART) - printf("RESTART"); - else if (error == EJUSTRETURN) - printf("JUSTRETURN"); - else { - if (ktr->ktr_error <= ELAST + 1) - error = abs(bsd_to_linux_errno[ktr->ktr_error]); - else - error = 999; - printf("-1 errno %d", error); - if (fancy) - printf(" %s", strerror(ktr->ktr_error)); - } - putchar('\n'); -} -#endif - void usage(void) { |