[PATCH v1 1/2] syscall.c: split trace_syscall() into 5 functions

Dmitry V. Levin ldv at altlinux.org
Sun Jun 4 23:47:41 UTC 2017


On Sun, Jun 04, 2017 at 01:59:16AM +0300, Victor Krapivensky wrote:
> This change removes the trace_syscall function. Now, the code that uses
> syscall.c trace functions is expected to check whether it is a syscall
> entry or exit (with entering(tcp)/exiting(tcp)) itself, and then make an
> appropriate sequence of function calls.
> 
> * defs.h: Change comment on TCB_INSYSCALL, remove the prototype of
> trace_syscall, add prototypes for the new functions.
> * strace.c (trace_syscall): A static replacement for old trace_syscall.
> * syscall.c (trace_syscall): Remove.
> (trace_syscall_entering): Split into...
> (syscall_entering_decode, syscall_entering_trace,
> syscall_entering_finish): ...new functions.
> (trace_syscall_exiting): Split into...
> (syscall_exiting_prepare, syscall_exiting_trace): ...new functions.
[...]
> @@ -2459,6 +2459,26 @@ next_event(int *pstatus, siginfo_t *si)
>  	}
>  }
>  
> +static inline int
> +trace_syscall(struct tcb *tcp, unsigned int *sig)
> +{
> +	if (entering(tcp)) {
> +		int res = syscall_entering_decode(tcp);
> +		switch (res) {
> +		case 0:
> +			return 0;
> +		case 1:
> +			res = syscall_entering_trace(tcp, sig);
> +		}
> +		syscall_entering_finish(tcp, res);
> +		return res;
> +	} else {
> +		struct timeval tv = {};
> +		syscall_exiting_prepare(tcp, &tv);
> +		return syscall_exiting_trace(tcp, tv);
> +	}
> +}

Looks like this change doesn't change anything, which is good. :)

Why "static inline"?  Is it important whether the function is actually
inlined or not?  If not, no need to insist on inlining.

Why syscall_entering_decode was given this name?  It does get_scno,
get_syscall_args, decode_mips_subcall, decode_socket_subcall,
decode_ipc_subcall - in other words, it fetches syscall number
and arguments.

This split is not the only one possible, what was the rationale for this
one?  For example, get_scno and get_syscall_args are not invoked by
syscall_entering_trace, but get_regs and get_syscall_result are invoked by
syscall_exiting_trace - why?


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170605/e6019f53/attachment.bin>


More information about the Strace-devel mailing list