[PATCH v2] Implemented -e trace=%clock option for clock_* related syscalls

Dmitry V. Levin ldv at altlinux.org
Thu Mar 16 02:15:52 UTC 2017


On Thu, Mar 16, 2017 at 12:17:08AM +0530, Rishi Bhatt wrote:
> linux/*/syscallent.h part is modified automatically by:
> 
>     git grep -Fl 'SEN(clock_' linux/ | xargs sed -i \
>         's/0\(,[[:space:]]*SEN(clock_\)/TC\1/'

I think TC is too short, let's use 3-letter abbreviations for new classes,
e.g. TCL.

> 	* syscall.c: Alias TC to TRACE_CLOCK around syscallent.h inclusion.
> 	* sysent.h (TRACE_CLOCK): New definition.
> 	* qualify.c (lookup_class): Add TRACE_CLOCK for "%clock".
> 	* strace.1 (.SS Filtering): Add information about %clock syscall class.
> 	* linux/32/syscallent.h: Add TSC flag for sched_* sycalls.

For sched_* sycalls?  Really?  When you do a cut-n-paste from commit
811638e9c1805438a63c14f9704b8b00ac922623, please do not copy its typos.

> 	* linux/64/syscallent.h: Likewise.
> 	* linux/alpha/syscallent.h: Likewise.
> 	* linux/arm/syscallent.h: Likewise.
> 	* linux/avr32/syscallent.h: Likewise.
> 	* linux/bfin/syscallent.h: Likewise.
> 	* linux/crisv10/syscallent.h: Likewise.
> 	* linux/hppa/syscallent.h: Likewise.
> 	* linux/i386/syscallent.h: Likewise.
> 	* linux/ia64/syscallent.h: Likewise.
> 	* linux/m68k/syscallent.h: Likewise.
> 	* linux/microblaze/syscallent.h: Likewise.
> 	* linux/mips/syscallent-n32.h: Likewise.
> 	* linux/mips/syscallent-n64.h: Likewise.
> 	* linux/mips/syscallent-o32.h: Likewise.
> 	* linux/powerpc/syscallent.h: Likewise.
> 	* linux/powerpc64/syscallent.h: Likewise.
> 	* linux/s390/syscallent.h: Likewise.
> 	* linux/s390x/syscallent.h: Likewise.
> 	* linux/sh/syscallent.h: Likewise.
> 	* linux/sh64/syscallent.h: Likewise.
> 	* linux/sparc/syscallent.h: Likewise.
> 	* linux/sparc64/syscallent.h: Likewise.
> 	* linux/x32/syscallent.h: Likewise.
> 	* linux/x86_64/syscallent.h: Likewise.
> 	* linux/xtensa/syscallent.h: Likewise.
> 	* tests/Makefile.am (DECODER_TESTS): Add clock.test.
> 	* tests/ksysent.c: Define TC to 0.
> 	* tests/nsyscalls.c: Define TC to 0

Use "Likewise".

> 	* tests/clock.test: New test.

The idiom is
	* tests/clock.test: New test.
	* tests/Makefile.am (DECODER_TESTS): Add it.

[...]
> --- a/strace.1
> +++ b/strace.1
> @@ -429,6 +429,9 @@ Trace all memory mapping related system calls.
>  .BR "\-e\ trace" = %sched
>  Trace all scheduler-related (sched_*) system calls.
>  .TP
> +.BR "\-e\ trace" = %clock
> +Trace all clock-related (clock_*) system calls

Please terminate sentences.

> +.TP
>  \fB\-e\ abbrev\fR=\,\fIset\fR
>  Abbreviate the output from printing each member of large structures.
>  The default is
> diff --git a/syscall.c b/syscall.c
> index 569055f2..c7980c40 100644
> --- a/syscall.c
> +++ b/syscall.c
> @@ -77,6 +77,7 @@
>  #define TS TRACE_SIGNAL
>  #define TM TRACE_MEMORY
>  #define TSC TRACE_SCHED
> +#define TC TRACE_CLOCK
>  #define NF SYSCALL_NEVER_FAILS
>  #define MA MAX_ARGS
>  #define SI STACKTRACE_INVALIDATE_CACHE
> @@ -113,6 +114,7 @@ static const struct_sysent sysent2[] = {
>  #undef TS
>  #undef TM
>  #undef TSC
> +#undef TC
>  #undef NF
>  #undef MA
>  #undef SI
> diff --git a/sysent.h b/sysent.h
> index f4eaa930..7e95ab3a 100644
> --- a/sysent.h
> +++ b/sysent.h
> @@ -22,5 +22,5 @@ typedef struct sysent {
>  #define TRACE_INDIRECT_SUBCALL	02000	/* Syscall is an indirect socket/ipc subcall. */
>  #define COMPAT_SYSCALL_TYPES	04000	/* A compat syscall that uses compat types. */
>  #define TRACE_SCHED		010000  /* Trace scheduler-related syscalls. */
> -
> +#define TRACE_CLOCK		020000  /*Trace clock-related syscalls. */

Why removing the empty line.

>  #endif /* !STRACE_SYSENT_H */
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index c5c124c0..7a22d421 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -503,6 +503,7 @@ DECODER_TESTS = \
>  	chown.test \
>  	chown32.test \
>  	chroot.test \
> +	clock.test \
>  	clock_adjtime.test \
>  	clock_nanosleep.test \
>  	clock_xettime.test \
> diff --git a/tests/clock.test b/tests/clock.test
> new file mode 100755
> index 00000000..8e3e1bd2
> --- /dev/null
> +++ b/tests/clock.test
> @@ -0,0 +1,41 @@
> +#!/bin/sh
> +# Check -e trace=%clock option

Please terminate sentences.

This file is modelled after tests/sched.test which has been changed
yesterday, please rebase.

> +# Positive Test cases.
> +CLOCK_TESTS='40 clock_nanosleep
> +37 clock_adjtime
> +36 clock_xettime'
> +
> +# Negative Test Cases.
> +NON_CLOCK_TESTS='11 fchdir
> +27 futex
> +10 fsync'
> +
> +# Declaring the init.sh
> +. "${srcdir=.}/init.sh"
> +
> +#
> +# Tracing Clock_* related syscalls.
> +#
> +echo "$CLOCK_TESTS" | while read w i
> +do
> +	run_prog ./$i > /dev/null
> +	run_strace -a$w -e trace=%clock,setitimer ./$i > "$EXP"
> +	match_diff "$LOG" "$EXP"
> +
> +done
> +
> +echo '+++ exited with 0 +++' > "$EXP"
> +#
> +# Tracing NON_CLOCK related syscalls
> +# /dev/null for ignoring print statements
> +# from the executable.

Everybody knows what /dev/null is for, no need to mention it.


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


More information about the Strace-devel mailing list