diff options
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | ptrace_backend.c | 4 | ||||
-rw-r--r-- | ptrace_backend.h | 4 | ||||
-rw-r--r-- | tcb_wait_data.h | 13 | ||||
-rw-r--r-- | tracing_backend.c | 16 | ||||
-rw-r--r-- | tracing_backend.h | 65 |
6 files changed, 103 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index 9bf64c339..28fc714dc 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,8 @@ AC_SUBST([COPYRIGHT_YEAR], [copyright_year]) AC_DEFINE([MANPAGE_DATE], "[manpage_date]", [Date]) AC_SUBST([MANPAGE_DATE], [manpage_date]) +m4_define([additional_tracing_backends], [0]) + AC_MSG_CHECKING([for supported architecture]) arch_m32= arch_mx32= @@ -916,6 +918,9 @@ st_MPERS([mx32], [x86_64]) AX_VALGRIND_DFLT([sgcheck], [off]) AX_VALGRIND_CHECK +AC_DEFINE([ADDITIONAL_TRACING_BACKENDS], additional_tracing_backends, + [Whether additional tracing backends are available]) + AC_CONFIG_FILES([Makefile tests/Makefile tests-m32/Makefile diff --git a/ptrace_backend.c b/ptrace_backend.c index 06ce89dec..173969036 100644 --- a/ptrace_backend.c +++ b/ptrace_backend.c @@ -12,6 +12,8 @@ #include "ptrace_backend.h" #include "ptrace_wait_data.h" +#if ADDITIONAL_TRACING_BACKENDS + const struct tracing_backend ptrace_backend = { .name = "ptrace", @@ -60,3 +62,5 @@ const struct tracing_backend ptrace_backend = { .sendmsg = local_sendmsg, .recvmsg = local_recvmsg, }; + +#endif /* ADDITIONAL_TRACING_BACKENDS */ diff --git a/ptrace_backend.h b/ptrace_backend.h index 3e28c487c..4e32f44e9 100644 --- a/ptrace_backend.h +++ b/ptrace_backend.h @@ -49,6 +49,10 @@ extern int ptrace_upeek(struct tcb *tcp, unsigned long off, kernel_ulong_t *res); extern int ptrace_upoke(struct tcb *tcp, unsigned long off, kernel_ulong_t val); +#if ADDITIONAL_TRACING_BACKENDS + extern const struct tracing_backend ptrace_backend; +#endif /* ADDITIONAL_TRACING_BACKENDS */ + #endif /* !STRACE_PTRACE_BACKEND_H */ diff --git a/tcb_wait_data.h b/tcb_wait_data.h index acc4e899c..dc26e6d8c 100644 --- a/tcb_wait_data.h +++ b/tcb_wait_data.h @@ -28,6 +28,8 @@ struct tcb_wait_data { siginfo_t si; /**< siginfo, returned by PTRACE_GETSIGINFO */ }; +#if ADDITIONAL_TRACING_BACKENDS + static inline size_t trace_wait_data_size(struct tcb *tcp) { @@ -74,4 +76,15 @@ free_trace_wait_data(struct tcb_wait_data *wd) } } +#else /* !ADDITIONAL_TRACING_BACKENDS */ + +# include "ptrace_wait_data.h" + +# define trace_wait_data_size(tcp_) sizeof(struct ptrace_wait_data) +# define init_trace_wait_data ptrace_init_trace_wait_data +# define copy_trace_wait_data ptrace_copy_trace_wait_data +# define free_trace_wait_data ptrace_free_trace_wait_data + +#endif /* ADDITIONAL_TRACING_BACKENDS */ + #endif /* !STRACE_TCB_WAIT_DATA_H */ diff --git a/tracing_backend.c b/tracing_backend.c index 858bd586f..86aebac86 100644 --- a/tracing_backend.c +++ b/tracing_backend.c @@ -9,19 +9,25 @@ #include "defs.h" -#include <assert.h> #include <fcntl.h> + +#include <sys/stat.h> +#include <sys/types.h> + +#include "tracing_backend.h" + + +#if ADDITIONAL_TRACING_BACKENDS + +#include <assert.h> #include <limits.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> -#include <sys/stat.h> -#include <sys/types.h> #include <sys/xattr.h> -#include "tracing_backend.h" #include "ptrace_backend.h" /* Tracing backeng management functions */ @@ -164,3 +170,5 @@ local_recvmsg(struct tcb *tcp, int fd, struct msghdr *msg, int flags) { return recvmsg(fd, msg, flags); } + +#endif /* ADDITIONAL_TRACING_BACKENDS */ diff --git a/tracing_backend.h b/tracing_backend.h index 8140ae4fd..3e00b4326 100644 --- a/tracing_backend.h +++ b/tracing_backend.h @@ -14,6 +14,7 @@ #include "trace_event.h" + #if defined IN_MPERS || defined IN_MPERS_BOOTSTRAP typedef int strace_stat_t; #else @@ -22,6 +23,8 @@ typedef int strace_stat_t; strace_stat_t; #endif +#if ADDITIONAL_TRACING_BACKENDS + struct msghdr; @@ -482,4 +485,66 @@ tracee_recvmsg(struct tcb *tcp, int fd, struct msghdr *msg, int flags) return error_set_errno(ENOSYS); } +#else /* !ADDITIONAL_TRACING_BACKENDS */ + +# include "ptrace_backend.h" + +# define tracing_backend_name() "ptrace" +# define tracing_backend_handle_arg(a_, o_) false +# define tracing_backend_init ptrace_init +# define tracing_backend_post_init() ((void) 0) +# define tracing_backend_cleanup(s_) ((void) 0) + +# define startup_child ptrace_startup_child +# define attach_tcb ptrace_attach_tcb +# define detach ptrace_detach + +# define next_event ptrace_next_event +# define handle_group_stop ptrace_handle_group_stop +# define handle_exec ptrace_handle_exec +# define restart_process ptrace_restart_process + +# define clear_regs ptrace_clear_regs +# define get_regs ptrace_get_regs +# define get_scno ptrace_get_scno +# define set_scno ptrace_set_scno +# define set_error ptrace_set_error +# define set_success ptrace_set_success +# define get_instruction_pointer ptrace_get_instruction_pointer +# define get_stack_pointer ptrace_get_stack_pointer +# define get_syscall_args ptrace_get_syscall_args +# define get_syscall_result ptrace_get_syscall_result + +# define umoven ptrace_umoven +# define umovestr ptrace_umovestr +# define upeek ptrace_upeek +# define upoke ptrace_upoke + +# define tracee_kill(tcp_, sig_) \ + kill((tcp_)->pid, (sig_)) +# define tracee_realpath(tcp_, path_, resolved_path_) \ + realpath((path_), (resolved_path_)) +# define tracee_open(tcp_, path_, flags_, mode_) \ + open_file((path_), (flags_), (mode_)) +# define tracee_pread(tcp_, fd_, buf_, count_, offset_) \ + pread((fd_), (buf_), (count_), (offset_)) +# define tracee_close(tcp_, fd_) \ + close(fd_) +# define tracee_readlink(tcp_, path_, buf_, buf_size_) \ + readlink((path_), (buf_), (buf_size_)) +# define tracee_stat(tcp_, path_, buf_) \ + stat_file((path_), (buf_)) +# define tracee_fstat(tcp_, fd_, buf_) \ + fstat_file((fd_), (buf_)) +# define tracee_getxattr(tcp_, path_, name_, buf_, buf_size_) \ + getxattr((path_), (name_), (buf_), (buf_size_)) +# define tracee_socket(tcp_, domain_, type_, protocol_) \ + socket((domain_), (type_), (protocol_)) +# define tracee_sendmsg(tcp_, fd_, msg_, flags_) \ + sendmsg((fd_), (msg_), (flags_)) +# define tracee_recvmsg(tcp_, fd_, msg_, flags_) \ + recvmsg((fd_), (msg_), (flags_)) + +#endif /* !ADDITIONAL_TRACING_BACKENDS */ + #endif /* !STRACE_TRACING_BACKEND_H */ |