libsysdecode: Add a new ABI type, SYSDECODE_ABI_CLOUDABI32.

In order to let truss(8) support tracing of 32-bit CloudABI
applications, we need to add a new ABI type to libsysdecode. We can
reuse the existing errno mapping table. Also link in the cloudabi32
system call table to translate system call names.

While there, remove all of the architecture ifdefs. There are not
needed, as the CloudABI data types and system call tables build fine on
any architecture. Building this unconditionally will make it easier to
do tracing for different compat modes, emulation, etc.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D13516
This commit is contained in:
Ed Schouten
2017-12-16 19:37:55 +00:00
parent 5bf0d7ad74
commit 87f69beea3
4 changed files with 15 additions and 13 deletions
+2 -6
View File
@@ -58,7 +58,6 @@ static int bsd_to_linux_errno[ELAST + 1] = {
}; };
#endif #endif
#if defined(__aarch64__) || defined(__amd64__)
#include <contrib/cloudabi/cloudabi_types_common.h> #include <contrib/cloudabi/cloudabi_types_common.h>
static const int cloudabi_errno_table[] = { static const int cloudabi_errno_table[] = {
@@ -139,7 +138,6 @@ static const int cloudabi_errno_table[] = {
[CLOUDABI_EXDEV] = EXDEV, [CLOUDABI_EXDEV] = EXDEV,
[CLOUDABI_ENOTCAPABLE] = ENOTCAPABLE, [CLOUDABI_ENOTCAPABLE] = ENOTCAPABLE,
}; };
#endif
int int
sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi, int error) sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi, int error)
@@ -165,13 +163,12 @@ sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi, int error)
break; break;
} }
#endif #endif
#if defined(__aarch64__) || defined(__amd64__) case SYSDECODE_ABI_CLOUDABI32:
case SYSDECODE_ABI_CLOUDABI64: case SYSDECODE_ABI_CLOUDABI64:
if (error >= 0 && if (error >= 0 &&
(unsigned int)error < nitems(cloudabi_errno_table)) (unsigned int)error < nitems(cloudabi_errno_table))
return (cloudabi_errno_table[error]); return (cloudabi_errno_table[error]);
break; break;
#endif
default: default:
break; break;
} }
@@ -193,7 +190,7 @@ sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi, int error)
return (bsd_to_linux_errno[error]); return (bsd_to_linux_errno[error]);
break; break;
#endif #endif
#if defined(__aarch64__) || defined(__amd64__) case SYSDECODE_ABI_CLOUDABI32:
case SYSDECODE_ABI_CLOUDABI64: { case SYSDECODE_ABI_CLOUDABI64: {
unsigned int i; unsigned int i;
@@ -203,7 +200,6 @@ sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi, int error)
} }
break; break;
} }
#endif
default: default:
break; break;
} }
+6 -4
View File
@@ -63,10 +63,10 @@ static
#include <amd64/linux32/linux32_syscalls.c> #include <amd64/linux32/linux32_syscalls.c>
#endif #endif
#if defined(__amd64__) || defined(__aarch64__) static
#include <compat/cloudabi32/cloudabi32_syscalls.c>
static static
#include <compat/cloudabi64/cloudabi64_syscalls.c> #include <compat/cloudabi64/cloudabi64_syscalls.c>
#endif
const char * const char *
sysdecode_syscallname(enum sysdecode_abi abi, unsigned int code) sysdecode_syscallname(enum sysdecode_abi abi, unsigned int code)
@@ -95,12 +95,14 @@ sysdecode_syscallname(enum sysdecode_abi abi, unsigned int code)
return (linux32_syscallnames[code]); return (linux32_syscallnames[code]);
break; break;
#endif #endif
#if defined(__amd64__) || defined(__aarch64__) case SYSDECODE_ABI_CLOUDABI32:
if (code < nitems(cloudabi32_syscallnames))
return (cloudabi32_syscallnames[code]);
break;
case SYSDECODE_ABI_CLOUDABI64: case SYSDECODE_ABI_CLOUDABI64:
if (code < nitems(cloudabi64_syscallnames)) if (code < nitems(cloudabi64_syscallnames))
return (cloudabi64_syscallnames[code]); return (cloudabi64_syscallnames[code]);
break; break;
#endif
default: default:
break; break;
} }
+5 -2
View File
@@ -25,7 +25,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd November 24, 2017 .Dd December 16, 2017
.Dt SYSDECODE 3 .Dt SYSDECODE 3
.Os .Os
.Sh NAME .Sh NAME
@@ -61,9 +61,12 @@ Supported on amd64 and i386.
.It Li SYSDECODE_ABI_LINUX32 .It Li SYSDECODE_ABI_LINUX32
32-bit Linux binaries. 32-bit Linux binaries.
Supported on amd64. Supported on amd64.
.It Li SYSDECODE_ABI_CLOUDABI32
32-bit CloudABI binaries.
Supported on all platforms.
.It Li SYSDECODE_ABI_CLOUDABI64 .It Li SYSDECODE_ABI_CLOUDABI64
64-bit CloudABI binaries. 64-bit CloudABI binaries.
Supported on aarch64 and amd64. Supported on all platforms.
.It Li SYSDECODE_ABI_UNKNOWN .It Li SYSDECODE_ABI_UNKNOWN
A placeholder for use when the ABI is not known. A placeholder for use when the ABI is not known.
.El .El
+2 -1
View File
@@ -35,7 +35,8 @@ enum sysdecode_abi {
SYSDECODE_ABI_FREEBSD32, SYSDECODE_ABI_FREEBSD32,
SYSDECODE_ABI_LINUX, SYSDECODE_ABI_LINUX,
SYSDECODE_ABI_LINUX32, SYSDECODE_ABI_LINUX32,
SYSDECODE_ABI_CLOUDABI64 SYSDECODE_ABI_CLOUDABI64,
SYSDECODE_ABI_CLOUDABI32
}; };
int sysdecode_abi_to_freebsd_errno(enum sysdecode_abi _abi, int _error); int sysdecode_abi_to_freebsd_errno(enum sysdecode_abi _abi, int _error);