* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef STRACE_DEFS_H
+#define STRACE_DEFS_H
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <features.h>
-#ifdef HAVE_STDBOOL_H
-# include <stdbool.h>
-#endif
+#include <stdbool.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
-#include <sys/syscall.h>
+#include <asm/unistd.h>
#include "mpers_type.h"
#include "gcc_compat.h"
# define ERESTART_RESTARTBLOCK 516
#endif
-#if defined(SPARC) || defined(SPARC64)
-# define PERSONALITY0_WORDSIZE 4
-# if defined(SPARC64)
-# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY1_WORDSIZE 8
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
-# endif
-#endif
-
-#ifdef X86_64
+#if defined X86_64
# define SUPPORTED_PERSONALITIES 3
-# define PERSONALITY0_WORDSIZE 8
-# define PERSONALITY1_WORDSIZE 4
# define PERSONALITY2_WORDSIZE 4
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
-# ifdef HAVE_MX32_MPERS
-# define PERSONALITY2_INCLUDE_FUNCS "mx32_funcs.h"
-# define PERSONALITY2_INCLUDE_PRINTERS_DECLS "mx32_printer_decls.h"
-# define PERSONALITY2_INCLUDE_PRINTERS_DEFS "mx32_printer_defs.h"
-# define MPERS_mx32_IOCTL_MACROS "ioctl_redefs2.h"
-# endif
-#endif
-
-#ifdef X32
+#elif defined AARCH64 \
+ || defined POWERPC64 \
+ || defined RISCV \
+ || defined SPARC64 \
+ || defined TILE \
+ || defined X32
# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY0_WORDSIZE 4
-# define PERSONALITY1_WORDSIZE 4
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
-#endif
-
-#ifdef ARM
-/* one personality */
+#else
+# define SUPPORTED_PERSONALITIES 1
#endif
-#ifdef AARCH64
-/* The existing ARM personality, then AArch64 */
-# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY0_WORDSIZE 8
-# define PERSONALITY1_WORDSIZE 4
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
+#if defined TILE && defined __tilepro__
+# define DEFAULT_PERSONALITY 1
+#else
+# define DEFAULT_PERSONALITY 0
#endif
-#ifdef POWERPC64
-# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY0_WORDSIZE 8
-# define PERSONALITY1_WORDSIZE 4
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
-#endif
+#define PERSONALITY0_WORDSIZE SIZEOF_LONG
+#define PERSONALITY0_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
+#define PERSONALITY0_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
-#ifdef TILE
-# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY0_WORDSIZE 8
+#if SUPPORTED_PERSONALITIES > 1
# define PERSONALITY1_WORDSIZE 4
-# ifdef __tilepro__
-# define DEFAULT_PERSONALITY 1
-# endif
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
#endif
-#ifndef SUPPORTED_PERSONALITIES
-# define SUPPORTED_PERSONALITIES 1
-#endif
-#ifndef DEFAULT_PERSONALITY
-# define DEFAULT_PERSONALITY 0
-#endif
-#ifndef PERSONALITY0_WORDSIZE
-# define PERSONALITY0_WORDSIZE SIZEOF_LONG
-#endif
-
-#ifndef PERSONALITY0_INCLUDE_PRINTERS_DECLS
-# define PERSONALITY0_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
-#endif
-#ifndef PERSONALITY0_INCLUDE_PRINTERS_DEFS
-# define PERSONALITY0_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
-#endif
-
-#ifndef PERSONALITY1_INCLUDE_PRINTERS_DECLS
+#if SUPPORTED_PERSONALITIES > 1 && defined HAVE_M32_MPERS
+# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
+# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
+# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
+# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
+#else
# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
-#endif
-#ifndef PERSONALITY1_INCLUDE_PRINTERS_DEFS
# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
+# define PERSONALITY1_INCLUDE_FUNCS "empty.h"
#endif
-#ifndef PERSONALITY2_INCLUDE_PRINTERS_DECLS
+#if SUPPORTED_PERSONALITIES > 2 && defined HAVE_MX32_MPERS
+# define PERSONALITY2_INCLUDE_FUNCS "mx32_funcs.h"
+# define PERSONALITY2_INCLUDE_PRINTERS_DECLS "mx32_printer_decls.h"
+# define PERSONALITY2_INCLUDE_PRINTERS_DEFS "mx32_printer_defs.h"
+# define MPERS_mx32_IOCTL_MACROS "ioctl_redefs2.h"
+#else
# define PERSONALITY2_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
-#endif
-#ifndef PERSONALITY2_INCLUDE_PRINTERS_DEFS
# define PERSONALITY2_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
-#endif
-
-#ifndef PERSONALITY1_INCLUDE_FUNCS
-# define PERSONALITY1_INCLUDE_FUNCS "empty.h"
-#endif
-#ifndef PERSONALITY2_INCLUDE_FUNCS
# define PERSONALITY2_INCLUDE_FUNCS "empty.h"
#endif
int curcol; /* Output column for this process */
FILE *outf; /* Output file for this process */
const char *auxstr; /* Auxiliary info from syscall (see RVAL_STR) */
+ void *_priv_data; /* Private data for syscall decoding functions */
+ void (*_free_priv_data)(void *); /* Callback for freeing priv_data */
const struct_sysent *s_ent; /* sysent[scno] or dummy struct for bad scno */
const struct_sysent *s_prev_ent; /* for "resuming interrupted SYSCALL" msg */
struct timeval stime; /* System time usage as of last process wait */
|| defined(BFIN) \
|| defined(M68K) \
|| defined(MICROBLAZE) \
+ || defined(RISCV) \
|| defined(S390) \
|| defined(SH) || defined(SH64) \
|| defined(SPARC) || defined(SPARC64) \
extern void temporarily_clear_syserror(struct tcb *);
extern void restore_cleared_syserror(struct tcb *);
+extern void *get_tcb_priv_data(const struct tcb *);
+extern int set_tcb_priv_data(struct tcb *, void *priv_data,
+ void (*free_priv_data)(void *));
+extern void free_tcb_priv_data(struct tcb *);
+
+static inline unsigned long get_tcb_priv_ulong(const struct tcb *tcp)
+{
+ return (unsigned long) get_tcb_priv_data(tcp);
+}
+
+static inline int set_tcb_priv_ulong(struct tcb *tcp, unsigned long val)
+{
+ return set_tcb_priv_data(tcp, (void *) val, 0);
+}
+
extern int umoven(struct tcb *, long, unsigned int, void *);
#define umove(pid, addr, objp) \
umoven((pid), (addr), sizeof(*(objp)), (void *) (objp))
extern void addflags(const struct xlat *, uint64_t);
extern int printflags64(const struct xlat *, uint64_t, const char *);
extern const char *sprintflags(const char *, const struct xlat *, uint64_t);
-extern const char *sprintmode(unsigned int);
extern const char *sprinttime(time_t);
-extern bool fetch_msghdr_namelen(struct tcb *, long, int *);
-extern void decode_msghdr(struct tcb *, const int *, long, unsigned long);
+extern void print_symbolic_mode_t(unsigned int);
+extern void print_numeric_umode_t(unsigned short);
+extern void print_numeric_long_umask(unsigned long);
extern void dumpiov_in_msghdr(struct tcb *, long, unsigned long);
extern void dumpiov_in_mmsghdr(struct tcb *, long);
extern void dumpiov_upto(struct tcb *, int, long, unsigned long);
extern void print_seccomp_filter(struct tcb *, unsigned long);
extern void print_seccomp_fprog(struct tcb *, unsigned long, unsigned short);
+struct strace_stat;
+extern void print_struct_stat(struct tcb *tcp, const struct strace_stat *const st);
+
struct strace_statfs;
extern void print_struct_statfs(struct tcb *tcp, long);
extern void print_struct_statfs64(struct tcb *tcp, long, unsigned long);
#endif
/*
- * Widen without sign-extension a signed integer type to unsigned long long.
+ * Zero-extend a signed integer type to unsigned long long.
*/
-#define widen_to_ull(v) \
- (sizeof(v) == sizeof(int) ? (unsigned long long) (unsigned int) (v) : \
+#define zero_extend_signed_to_ull(v) \
+ (sizeof(v) == sizeof(short) ? (unsigned long long) (unsigned short) (v) : \
+ sizeof(v) == sizeof(int) ? (unsigned long long) (unsigned int) (v) : \
sizeof(v) == sizeof(long) ? (unsigned long long) (unsigned long) (v) : \
(unsigned long long) (v))
+/*
+ * Sign-extend an unsigned integer type to long long.
+ */
+#define sign_extend_unsigned_to_ll(v) \
+ (sizeof(v) == sizeof(short) ? (long long) (short) (v) : \
+ sizeof(v) == sizeof(int) ? (long long) (int) (v) : \
+ sizeof(v) == sizeof(long) ? (long long) (long) (v) : \
+ (long long) (v))
+
extern const struct_sysent sysent0[];
extern const char *const errnoent0[];
extern const char *const signalent0[];
#endif /* !IN_MPERS_BOOTSTRAP */
/*
- * If you need non-NULL sysent[scno].sys_func and sysent[scno].sys_name
+ * If you need non-NULL sysent[scno].sys_func, non-NULL sysent[scno].sys_name,
+ * and non-indirect sysent[scno].sys_flags.
*/
#define SCNO_IS_VALID(scno) \
- ((unsigned long)(scno) < nsyscalls && sysent[scno].sys_func)
+ ((unsigned long)(scno) < nsyscalls \
+ && sysent[scno].sys_func \
+ && !(sysent[scno].sys_flags & TRACE_INDIRECT_SUBCALL))
/* Only ensures that sysent[scno] isn't out of range */
#define SCNO_IN_RANGE(scno) \
#define PRI__d64 PRI__64"d"
#define PRI__u64 PRI__64"u"
#define PRI__x64 PRI__64"x"
+
+#endif /* !STRACE_DEFS_H */