[strace PATCH v2] Introduce s390_sthyi system call decoder

2018-01-22 Thread Eugene Syromyatnikov
* s390.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/s390/syscallent.h ([380]): Change decoder to s390_sthyi.
* linux/s390x/syscallent.h: Likewise.
* xlat/s390_sthyi_function_codes.in: New file.
---
 Makefile.am   |1 +
 linux/s390/syscallent.h   |1 +
 linux/s390x/syscallent.h  |1 +
 s390.c| 1033 +
 xlat/s390_sthyi_function_codes.in |1 +
 5 files changed, 1037 insertions(+)
 create mode 100644 s390.c
 create mode 100644 xlat/s390_sthyi_function_codes.in

diff --git a/Makefile.am b/Makefile.am
index db822c5..7355ec9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -269,6 +269,7 @@ strace_SOURCES =\
rtnl_rule.c \
rtnl_tc.c   \
rtnl_tc_action.c \
+   s390.c  \
sched.c \
sched_attr.h\
scsi.c  \
diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h
index 5482c53..dd1fbb1 100644
--- a/linux/s390/syscallent.h
+++ b/linux/s390/syscallent.h
@@ -409,6 +409,7 @@
 [377] = { 6,   TD, SEN(pwritev2),  "pwritev2"  
},
 [378] = { 2,   0,  SEN(printargs), 
"s390_guarded_storage"  },
 [379] = { 5,   TD|TF|TSTA, SEN(statx), "statx" 
},
+[380] = { 4,   0,  SEN(s390_sthyi),"s390_sthyi"
},
 
 #define SYS_socket_subcall 400
 #include "subcall.h"
diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h
index 36b1aef..fe5b252 100644
--- a/linux/s390x/syscallent.h
+++ b/linux/s390x/syscallent.h
@@ -393,6 +393,7 @@
 [377] = { 6,   TD, SEN(pwritev2),  "pwritev2"  
},
 [378] = { 2,   0,  SEN(printargs), 
"s390_guarded_storage"  },
 [379] = { 5,   TD|TF|TSTA, SEN(statx), "statx" 
},
+[380] = { 4,   0,  SEN(s390_sthyi),"s390_sthyi"
},
 
 #define SYS_socket_subcall 400
 #include "subcall.h"
diff --git a/s390.c b/s390.c
new file mode 100644
index 000..0f49369
--- /dev/null
+++ b/s390.c
@@ -0,0 +1,1033 @@
+/*
+ * s390-specific syscalls decoders.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "defs.h"
+
+#if defined S390 || defined S390X
+
+#include 
+
+#include "print_fields.h"
+
+#include "xlat/s390_sthyi_function_codes.h"
+
+/*
+ * Since, for some reason, kernel doesn't expose all these nice constants and
+ * structures in UAPI, we have to re-declare them ourselves.
+ */
+
+/**
+ * "The header section is placed at the beginning of the response buffer and
+ * identifies the location and length of all other sections. Valid sections 
have
+ * nonzero offset values in the header. Each section provides information about
+ * validity of fields within that section."
+ */
+struct sthyi_hdr {
+   /**
+* Header Flag Byte 1 - These flag settings indicate the environment
+* that the instruction was executed in and may influence the value of
+* the validity bits. The validity bits, and not these flags, should be
+* used to determine if a field is valid.
+*  - 0x80 - Global Performance Data unavailable
+*  - 0x40 - One or more hypervisor levels below this level does not
+*   support the STHYI instruction. When this flag is set the
+*   value of INFGPDU is not meaningful because the state of the

[strace PATCH v2] tests: check s390_sthyi system call decoder

2018-01-22 Thread Eugene Syromyatnikov
* configure.ac (AC_CHECK_FUNCS): Add iconv_open.
(AC_CHECK_HEADERS): Add iconv.h.
* tests/s390_sthyi-v.c: New file.
* tests/s390_sthyi.c: Likewise.
* tests/.gitignore: Add s390_sthyi, s390_sthyi-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_sthyi, s390_sthyi): New tests.
---
 configure.ac|   2 +
 tests/.gitignore|   2 +
 tests/gen_tests.in  |   2 +
 tests/pure_executables.list |   2 +
 tests/s390_sthyi-v.c|   2 +
 tests/s390_sthyi.c  | 786 
 6 files changed, 796 insertions(+)
 create mode 100644 tests/s390_sthyi-v.c
 create mode 100644 tests/s390_sthyi.c

diff --git a/configure.ac b/configure.ac
index d962f19..001dfa8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -287,6 +287,7 @@ AC_CHECK_FUNCS(m4_normalize([
fstatat
ftruncate
futimens
+   iconv_open
if_indextoname
open64
prctl
@@ -394,6 +395,7 @@ AC_CHECK_HEADERS(m4_normalize([
asm/sysmips.h
bluetooth/bluetooth.h
elf.h
+   iconv.h
inttypes.h
linux/bsg.h
linux/cryptouser.h
diff --git a/tests/.gitignore b/tests/.gitignore
index 4c54589..19aa493 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -357,6 +357,8 @@ rt_sigsuspend
 rt_sigtimedwait
 rt_tgsigqueueinfo
 run_expect_termsig
+s390_sthyi
+s390_sthyi-v
 sched_get_priority_mxx
 sched_rr_get_interval
 sched_xetaffinity
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index 93b1687..968f6e4 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -303,6 +303,8 @@ rt_sigreturn-esignal='!USR1'
 rt_sigsuspend  -a20 -esignal=none
 rt_sigtimedwait-a38
 rt_tgsigqueueinfo  -esignal=none
+s390_sthyi -a47
+s390_sthyi-v   -e trace=s390_sthyi -a47
 sched  test_trace_expr times -e/sched
 sched_get_priority_mxx -a33 -e 
trace=sched_get_priority_min,sched_get_priority_max
 sched_rr_get_interval  -a31
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index 8f5ff31..d8b997d 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -296,6 +296,8 @@ rt_sigreturn
 rt_sigsuspend
 rt_sigtimedwait
 rt_tgsigqueueinfo
+s390_sthyi
+s390_sthyi-v
 sched_get_priority_mxx
 sched_rr_get_interval
 sched_xetaffinity
diff --git a/tests/s390_sthyi-v.c b/tests/s390_sthyi-v.c
new file mode 100644
index 000..8605520
--- /dev/null
+++ b/tests/s390_sthyi-v.c
@@ -0,0 +1,2 @@
+#define VERBOSE 1
+#include "s390_sthyi.c"
diff --git a/tests/s390_sthyi.c b/tests/s390_sthyi.c
new file mode 100644
index 000..8b241dd
--- /dev/null
+++ b/tests/s390_sthyi.c
@@ -0,0 +1,786 @@
+/*
+ * Check decoding of s390_sthyi syscall.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include 
+
+#if defined HAVE_ICONV_H && defined HAVE_ICONV_OPEN && defined __NR_s390_sthyi
+
+# include 
+# include 
+# include 
+# include 
+# include 
+# include 
+# include 
+
+# include 
+
+# define EBCDIC_MAX_LEN 16
+
+# ifndef VERBOSE
+#  define VERBOSE 0
+# endif
+
+static bool
+print_0x8(const char *prefix, unsigned char *buf, unsigned int offs, bool zero)
+{
+   if (!zero && !buf[offs])
+   return false;
+
+   printf("%s=%#02hhx", prefix, buf[offs]);
+
+   return true;
+}
+
+static bool
+print_u8(const char *prefix, unsigned char *buf, unsigned int offs, bool zero)
+{
+   if (!zero && !buf[offs])
+   return false;
+
+   printf("%s=%hhu", prefix, buf[offs]);
+
+   return true;
+}

[PATCH 2/2] tests: check riscv_flush_icache syscall decoder

2018-01-22 Thread Eugene Syromyatnikov
* tests/riscv_flush_icache.c: New file.
* tests/.gitignore: Add riscv_flush_icache.
* tests/gen_tests.in: Likewise.
* tests/pure_executables.list: Likewise.
---
 tests/.gitignore|  1 +
 tests/gen_tests.in  |  1 +
 tests/pure_executables.list |  1 +
 tests/riscv_flush_icache.c  | 93 +
 4 files changed, 96 insertions(+)
 create mode 100644 tests/riscv_flush_icache.c

diff --git a/tests/.gitignore b/tests/.gitignore
index 4c54589..2a95c6c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -347,6 +347,7 @@ renameat
 renameat2
 request_key
 restart_syscall
+riscv_flush_icache
 rmdir
 rt_sigaction
 rt_sigpending
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index 93b1687..7ede93b 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -295,6 +295,7 @@ rename  -a35
 renameat
 renameat2
 request_key-a33 -s12
+riscv_flush_icache -a34
 rmdir  -a22
 rt_sigpending  -a20
 rt_sigprocmask
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index 8f5ff31..710d76e 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -287,6 +287,7 @@ rename
 renameat
 renameat2
 request_key
+riscv_flush_icache
 rmdir
 rt_sigaction
 rt_sigpending
diff --git a/tests/riscv_flush_icache.c b/tests/riscv_flush_icache.c
new file mode 100644
index 000..8aaeda5
--- /dev/null
+++ b/tests/riscv_flush_icache.c
@@ -0,0 +1,93 @@
+/*
+ * Check decoding of riscv_flush_icache syscall.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+
+#include 
+
+#include "scno.h"
+
+#ifdef __NR_riscv_flush_icache
+
+# include 
+# include 
+# include 
+
+int main(void)
+{
+   static struct {
+   kernel_ulong_t addr;
+   const char *str;
+   } addrs[] = {
+   { (kernel_ulong_t) (uintptr_t) ARG_STR(NULL) },
+   { (kernel_ulong_t) 0xbadc0deddeadf157ULL,
+   sizeof(kernel_ulong_t) == 8 ? "0xbadc0deddeadf157" :
+   "0xdeadf157" },
+   };
+   static struct {
+   kernel_ulong_t val;
+   const char *str;
+   } flags[] = {
+   { ARG_STR(0) },
+   { 1, "SYS_RISCV_FLUSH_ICACHE_LOCAL" },
+   { (kernel_ulong_t) 0xfacefeedfffeULL,
+   sizeof(kernel_ulong_t) == 8 ?
+   "0xfacefeedfffe /* SYS_RISCV_FLUSH_ICACHE_??? */" :
+   "0xfffe /* SYS_RISCV_FLUSH_ICACHE_??? */" },
+   { (kernel_ulong_t) 0xfacefeedULL,
+   sizeof(kernel_ulong_t) == 8 ?
+   "SYS_RISCV_FLUSH_ICACHE_LOCAL|0xfacefeedfffe" :
+   "SYS_RISCV_FLUSH_ICACHE_LOCAL|0xfffe" },
+   };
+
+   for (size_t i = 0; i < ARRAY_SIZE(addrs); i++) {
+   for (size_t j = 0; j < ARRAY_SIZE(addrs); j++) {
+   for (size_t k = 0; k < ARRAY_SIZE(flags); k++) {
+   long rc = syscall(__NR_riscv_flush_icache,
+ addrs[i].addr,
+ addrs[j].addr,
+ flags[k].val);
+
+   printf("riscv_flush_icache(%s, %s, %s) = %s\n",
+  addrs[i].str, addrs[j].str, flags[k].str,
+  sprintrc(rc));
+   }
+   }
+   }
+
+   

[RFC PATCH] mpers.awk: enable support for gawk 3

2018-01-18 Thread Eugene Syromyatnikov
---
 mpers.awk | 132 +++---
 1 file changed, 58 insertions(+), 74 deletions(-)

diff --git a/mpers.awk b/mpers.awk
index 6545052..8374b3b 100644
--- a/mpers.awk
+++ b/mpers.awk
@@ -27,19 +27,10 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-function compare_indices(i1, v1, i2, v2, \
-c1, c2)
-{
-   c1 = strtonum(sprintf("%s", i1))
-   c2 = strtonum(sprintf("%s", i2))
-   if (c1 < c2)
-   return -1
-   return (c1 != c2)
-}
 function array_get(array_idx, array_member, \
   array_return)
 {
-   array_return = array[array_idx][array_member]
+   array_return = array[array_idx, array_member]
if ("" == array_return) {
printf("%s: index [%s] without %s\n",
   FILENAME, array_idx, array_member) > "/dev/stderr"
@@ -47,12 +38,16 @@ function array_get(array_idx, array_member, \
}
return array_return
 }
+function norm_idx(idx)
+{
+   return sprintf("%016s", idx)
+}
 function array_seq(array_idx)
 {
-   if ("seq" in array[array_idx])
-   return array[array_idx]["seq"]
+   if ((array_idx, "seq") in array)
+   return array[array_idx, "seq"]
index_seq++
-   array[array_idx]["seq"] = index_seq
+   array[array_idx, "seq"] = index_seq
return index_seq
 }
 function enter(array_idx,
@@ -75,72 +70,63 @@ function leave(array_idx, to_return)
 function update_upper_bound(idx, val, \
count)
 {
-   count = array[idx]["count"]
+   count = array[idx, "count"]
if (count == "")
count = 1
-   array[idx]["count"] = count * val
-   array[idx]["upper_bound"] = array[idx]["upper_bound"] "[" val "]"
+   array[idx, "count"] = count * val
+   array[idx, "upper_bound"] = array[idx, "upper_bound"] "[" val "]"
 }
 function what_is(what_idx, \
 item, loc_diff, location, prev_location, prev_returned_size, \
-special, to_return, type_idx)
+special, to_return, type_idx, enc)
 {
enter(what_idx)
special = array_get(what_idx, "special")
-   switch (special) {
-   case "base_type":
-   switch (array_get(what_idx, "encoding")) {
-   case 5: # signed
+   if (special == "base_type") {
+   enc = array_get(what_idx, "encoding")
+   if (enc == 5) { # signed
printf("int%s_t ",
   8 * array_get(what_idx, "byte_size"))
-   break
-   case 7: # unsigned
+   } else if (enc == 7) { # unsigned
printf("uint%s_t ",
   8 * array_get(what_idx, "byte_size"))
-   break
-   default: # float, signed/unsigned char
+   } else { # float, signed/unsigned char
printf("%s ", array_get(what_idx, "name"))
-   break
}
returned_size = array_get(what_idx, "byte_size")
-   break
-   case "enumeration_type":
+   } else if (special == "enumeration_type") {
returned_size = array_get(what_idx, "byte_size")
printf("uint%s_t ", 8 * returned_size)
-   break
-   case "pointer_type":
+   } else if (special == "pointer_type") {
printf("mpers_ptr_t ")
returned_size = array_get(what_idx, "byte_size")
-   break
-   case "array_type":
+   } else if (special == "array_type") {
type_idx = array_get(what_idx, "type")
what_is(type_idx)
-   to_return = array[what_idx]["upper_bound"]
+   to_return = array[what_idx, "upper_bound"]
if ("" == to_return)
to_return = "[0]"
-   returned_size = array[what_idx]["count"] * returned_size
+   returned_size = array[what_idx, "count"] * returned_size
return leave(what_idx, to_return)
-   break
-   case "structure_type":
+   } else if (special == "structure_type") {
print "struct {"
prev_location = 0
location = 0
returned_size = 0
prev_returned_size = 0
-   for (item in array) {
-   if ("parent" in array[item] && \
-   array_get(item, "parent") == what_idx) {
-   location = array_get(item, "location")
+   for (item = 1; item <= parents_cnt; item+=1) {
+   if (array_parents[aparents_sorted[item]] == what_idx) {
+   location = array_get(aparents_sorted[item], 

[strace PATCH 01/12] Add compat support for s390x

2018-01-17 Thread Eugene Syromyatnikov
By very popular demand.

While we are here, let's refactor the condition for old_mmap_pgoff into
an arch-specific one, as it is used more than in one place.

* NEWS: Mention this.
* configure.ac (case "$host_cpu" in) : Set arch_m32 to s390, set
cc_flags_m32 to -m31.
(st_MPERS([m32])): Add s390x.
* defs.h [S390X]: Define NEED_UID16_PARSERS.
* linux/s390/arch_sigreturn.c [!S390_FRAME_PTR] (S390_FRAME_PTR): New
macro, define to s390_frame_ptr.
[!SIGNAL_FRAMESIZE] (SIGNAL_FRAMESIZE): New macro, define to
__SIGNAL_FRAMESIZE.
[!PTR_TYPE] (PTR_TYPE): New macro, define to unsigned long.
(arch_sigreturn): Use S390_FRAME_PTR, SIGNAL_FRAMESIZE, and PTR_TYPE
instead of s390_frame_ptr, __SIGNAL_FRAMESIZE, and pointer-sized type,
respectively.
* linux/s390/get_error.c [!ARCH_REGSET] (ARCH_REGSET): New macro, define
* to s390_regset.
(get_error): Use it instead of s390_regset.
* linux/s390/get_scno.c (arch_get_scno): Likewise.
* linux/s390/get_syscall_args.c (get_syscall_args): Likewise.
* linux/s390/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/s390/set_scno.c (arch_set_scno): Likewise.
* linux/s390x/arch_regs.c (psw_compat_t, s390_compat_regs,
s390x_regs_union, s390_frame_ptr, s390x_frame_ptr, s390x_io): New
variable.
(s390_regset, s390x_regset, ARCH_REGS_FOR_GETREGSET,
ARCH_IOVEC_FOR_GETREGSET, ARCH_PC_REG, ARCH_PERSONALITY_0_IOV_SIZE,
ARCH_PERSONALITY_1_IOV_SIZE): New macro.
* linux/s390x/arch_regs.h (s390_frame_ptr, s390x_frame_ptr): New
external definitions.
* linux/s390x/arch_rt_sigframe.c: Behave based on tcp->currpers.
* linux/s390x/arch_sigreturn.c: Likewise.
* linux/s390x/get_error.c: Likewise.
* linux/s390x/get_scno.c: Likewise.
* linux/s390x/get_syscall_args.c: Likewise.
* linux/s390x/set_error.c: Likewise.
* linux/s390x/set_scno.c: Likewise.
* linux/s390x/errnoent1.h: New file.
* linux/s390x/ioctls_arch1.h: Likewise.
* linux/s390x/ioctls_inc1.h: Likewise.
* linux/s390x/signalent1.h: Likewise.
* linux/s390x/syscallent1.h: Likewise.
* supported_personalities.h [S390X]: Define SUPPORTED_PERSONALITIES to
2.
* tests/strace-V.test: Add s390 to the list of architectures that have
m32 personality.
* linux/s390/arch_defs.h (HAVE_ARCH_OLD_MMAP_PGOFF): New definition.
* linux/s390x/arch_defs.h: Likewise.
* mem.c: Replace #ifdef S390 with #ifdef HAVE_ARCH_OLD_MMAP_PGOFF.
* pathtrace.c: Likewise.
---
 NEWS   |  1 +
 configure.ac   |  4 +++-
 defs.h |  2 +-
 linux/s390/arch_defs.h |  1 +
 linux/s390/arch_sigreturn.c| 16 +---
 linux/s390/get_error.c | 10 +++---
 linux/s390/get_scno.c  |  8 ++--
 linux/s390/get_syscall_args.c  | 16 ++--
 linux/s390/set_error.c |  8 ++--
 linux/s390/set_scno.c  |  6 +-
 linux/s390x/arch_defs.h|  1 +
 linux/s390x/arch_regs.c| 37 -
 linux/s390x/arch_regs.h|  3 ++-
 linux/s390x/arch_rt_sigframe.c |  5 -
 linux/s390x/arch_sigreturn.c   | 26 ++
 linux/s390x/errnoent1.h|  1 +
 linux/s390x/get_error.c| 23 ++-
 linux/s390x/get_scno.c | 21 -
 linux/s390x/get_syscall_args.c | 22 +-
 linux/s390x/ioctls_arch1.h |  1 +
 linux/s390x/ioctls_inc1.h  |  1 +
 linux/s390x/set_error.c| 34 +-
 linux/s390x/set_scno.c | 21 -
 linux/s390x/signalent1.h   |  1 +
 linux/s390x/syscallent1.h  |  1 +
 mem.c  |  4 ++--
 pathtrace.c|  2 +-
 supported_personalities.h  |  1 +
 tests/strace-V.test|  2 +-
 29 files changed, 248 insertions(+), 31 deletions(-)
 create mode 100644 linux/s390x/errnoent1.h
 create mode 100644 linux/s390x/ioctls_arch1.h
 create mode 100644 linux/s390x/ioctls_inc1.h
 create mode 100644 linux/s390x/signalent1.h
 create mode 100644 linux/s390x/syscallent1.h

diff --git a/NEWS b/NEWS
index 0dc23d6..550fc38 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,7 @@ Noteworthy changes in release ?.?? (-??-??)
   * Updated lists of MSG_*, NT_*, and SHM_* constants.
   * Added manual page for the strace-log-merge command.
   * Updated lists of ioctl commands from Linux 4.15.
+  * Implemented biarch support for s390x.
   * Implemented an optional support for symbol demangling in strace -k output
 (activated by --with-libiberty configure option).
   * Information about availability of demangling and reliable personality
diff --git a/configure.ac b/configure.ac
index 5af..a1391c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,8 @@ s390)
;;
 s390x)
arch=s390x
+   arch_m32=s390
+   cc_flags_m32=-m31
AC_DEFINE([S390X], 1, [Define for the S390x architecture.])
;;
 hppa*|parisc*)
@@ -980,7 +982,7 @@ AC_ARG_ENABLE([mpers],
 esac],
[enable_mpers=yes])
 
-st_MPERS([m32], 

[strace PATCH 12/12] Update NEWS

2018-01-17 Thread Eugene Syromyatnikov
---
 NEWS | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 550fc38..8b98a40 100644
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,9 @@ Noteworthy changes in release ?.?? (-??-??)
 BPF_MAP_GET_NEXT_ID, BPF_PROG_GET_FD_BY_ID, BPF_MAP_GET_FD_BY_ID,
 and BPF_OBJ_GET_INFO_BY_FD commands of bpf syscall.
   * Enhanced decoding of get_thread_area, memfd_create, modify_ldt,
-perf_event_open, reboot, set_thread_area, and shmget syscalls.
+perf_event_open, reboot, s390_guarded_storage, s390_pcio_mmio_read,
+s390_pci_mmio_write, s390_runtime_instr, s390_sthyi, set_thread_area,
+and shmget syscalls.
   * Implemented decoding of KVM_* ioctl commands.
   * Enhanced decoding of getsockopt and setsockopt syscalls for SOL_NETLINK
 level.
-- 
2.1.4


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[strace PATCH 02/12] Add print_quoted_string flag to generate comment

2018-01-17 Thread Eugene Syromyatnikov
Because there are never enough print_quoted_string flags.

* defs.h (QUOTE_EMIT_COMMENT): New quoting flag macro constant.
* util.c (string_quote): Emit " /* " in the beginning and " */" in the
end if QUOTE_EMIT_COMMENT is passed.
(print_quoted_string): Increase alloc_size by 7 if QUOTE_EMIT_COMMENT is
passed.
---
 defs.h | 1 +
 util.c | 9 -
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/defs.h b/defs.h
index 2311d86..51b1355 100644
--- a/defs.h
+++ b/defs.h
@@ -530,6 +530,7 @@ str_strip_prefix_len(const char *str, const char *prefix, 
size_t prefix_len)
 #define QUOTE_OMIT_LEADING_TRAILING_QUOTES 0x02
 #define QUOTE_OMIT_TRAILING_0  0x08
 #define QUOTE_FORCE_HEX0x10
+#define QUOTE_EMIT_COMMENT 0x20
 
 extern int string_quote(const char *, char *, unsigned int, unsigned int);
 extern int print_quoted_string(const char *, unsigned int, unsigned int);
diff --git a/util.c b/util.c
index 49cb81b..9a99e1a 100644
--- a/util.c
+++ b/util.c
@@ -497,6 +497,8 @@ string_quote(const char *instr, char *outstr, const 
unsigned int size,
}
}
 
+   if (style & QUOTE_EMIT_COMMENT)
+   s = stpcpy(s, " /* ");
if (!(style & QUOTE_OMIT_LEADING_TRAILING_QUOTES))
*s++ = '\"';
 
@@ -576,6 +578,8 @@ string_quote(const char *instr, char *outstr, const 
unsigned int size,
 
if (!(style & QUOTE_OMIT_LEADING_TRAILING_QUOTES))
*s++ = '\"';
+   if (style & QUOTE_EMIT_COMMENT)
+   s = stpcpy(s, " */");
*s = '\0';
 
/* Return zero if we printed entire ASCIZ string (didn't truncate it) */
@@ -591,6 +595,8 @@ string_quote(const char *instr, char *outstr, const 
unsigned int size,
  asciz_ended:
if (!(style & QUOTE_OMIT_LEADING_TRAILING_QUOTES))
*s++ = '\"';
+   if (style & QUOTE_EMIT_COMMENT)
+   s = stpcpy(s, " */");
*s = '\0';
/* Return zero: we printed entire ASCIZ string (didn't truncate it) */
return 0;
@@ -632,7 +638,8 @@ print_quoted_string(const char *str, unsigned int size,
tprints("???");
return -1;
}
-   alloc_size += 1 + (style & QUOTE_OMIT_LEADING_TRAILING_QUOTES ? 0 : 2);
+   alloc_size += 1 + (style & QUOTE_OMIT_LEADING_TRAILING_QUOTES ? 0 : 2) +
+   (style & QUOTE_EMIT_COMMENT ? 7 : 0);
 
if (use_alloca(alloc_size)) {
outstr = alloca(alloc_size);
-- 
2.1.4


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[strace PATCH 05/12] tests: check s390_sthyi system call decoder

2018-01-17 Thread Eugene Syromyatnikov
* configure.ac (AC_CHECK_FUNCS): Add iconv_open.
(AC_CHECK_HEADERS): Add iconv.h.
* tests/s390_sthyi-v.c: New file.
* tests/s390_sthyi.c: Likewise.
* tests/.gitignore: Add s390_sthyi, s390_sthyi-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_sthyi, s390_sthyi): New tests.
---
 configure.ac|   2 +
 tests/.gitignore|   2 +
 tests/gen_tests.in  |   2 +
 tests/pure_executables.list |   2 +
 tests/s390_sthyi-v.c|   2 +
 tests/s390_sthyi.c  | 786 
 6 files changed, 796 insertions(+)
 create mode 100644 tests/s390_sthyi-v.c
 create mode 100644 tests/s390_sthyi.c

diff --git a/configure.ac b/configure.ac
index a1391c7..63595ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -287,6 +287,7 @@ AC_CHECK_FUNCS(m4_normalize([
fstatat
ftruncate
futimens
+   iconv_open
if_indextoname
open64
prctl
@@ -394,6 +395,7 @@ AC_CHECK_HEADERS(m4_normalize([
asm/sysmips.h
bluetooth/bluetooth.h
elf.h
+   iconv.h
inttypes.h
linux/bsg.h
linux/cryptouser.h
diff --git a/tests/.gitignore b/tests/.gitignore
index 4c54589..19aa493 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -357,6 +357,8 @@ rt_sigsuspend
 rt_sigtimedwait
 rt_tgsigqueueinfo
 run_expect_termsig
+s390_sthyi
+s390_sthyi-v
 sched_get_priority_mxx
 sched_rr_get_interval
 sched_xetaffinity
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index 93b1687..968f6e4 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -303,6 +303,8 @@ rt_sigreturn-esignal='!USR1'
 rt_sigsuspend  -a20 -esignal=none
 rt_sigtimedwait-a38
 rt_tgsigqueueinfo  -esignal=none
+s390_sthyi -a47
+s390_sthyi-v   -e trace=s390_sthyi -a47
 sched  test_trace_expr times -e/sched
 sched_get_priority_mxx -a33 -e 
trace=sched_get_priority_min,sched_get_priority_max
 sched_rr_get_interval  -a31
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index 8f5ff31..d8b997d 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -296,6 +296,8 @@ rt_sigreturn
 rt_sigsuspend
 rt_sigtimedwait
 rt_tgsigqueueinfo
+s390_sthyi
+s390_sthyi-v
 sched_get_priority_mxx
 sched_rr_get_interval
 sched_xetaffinity
diff --git a/tests/s390_sthyi-v.c b/tests/s390_sthyi-v.c
new file mode 100644
index 000..8605520
--- /dev/null
+++ b/tests/s390_sthyi-v.c
@@ -0,0 +1,2 @@
+#define VERBOSE 1
+#include "s390_sthyi.c"
diff --git a/tests/s390_sthyi.c b/tests/s390_sthyi.c
new file mode 100644
index 000..1554daf
--- /dev/null
+++ b/tests/s390_sthyi.c
@@ -0,0 +1,786 @@
+/*
+ * Check decoding of s390_sthyi syscall.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include 
+
+#if defined HAVE_ICONV_H && defined HAVE_ICONV_OPEN && defined __NR_s390_sthyi
+
+# include 
+# include 
+# include 
+# include 
+# include 
+# include 
+# include 
+
+# include 
+
+# define EBCDIC_MAX_LEN 16
+
+# ifndef VERBOSE
+#  define VERBOSE 0
+# endif
+
+static bool
+print_0x8(const char *prefix, unsigned char *buf, unsigned int offs, bool zero)
+{
+   if (!zero && !buf[offs])
+   return false;
+
+   printf("%s=%#02hhx", prefix, buf[offs]);
+
+   return true;
+}
+
+static bool
+print_u8(const char *prefix, unsigned char *buf, unsigned int offs, bool zero)
+{
+   if (!zero && !buf[offs])
+   return false;
+
+   printf("%s=%hhu", prefix, buf[offs]);
+
+   return true;
+}

[strace PATCH 06/12] Introduce s390_guarded_storage system call decoder

2018-01-17 Thread Eugene Syromyatnikov
* linux/s390/syscallent.h ([378]): Change decoder to s390_guarded_storage.
* linux/s390x/syscallent.h: Likewise.
* s390.c (struct guard_storage_control_block,
struct guard_storage_event_parameter_list): New structure type
definition.
(guard_storage_print_gsepl, guard_storage_print_gscb,
SYS_FUNC(s390_guarded_storage)): New function.
(DIV_ROUND_UP): New macro.
* xlat/s390_guarded_storage_commands.in: New file.
---
 linux/s390/syscallent.h   |   2 +-
 linux/s390x/syscallent.h  |   2 +-
 s390.c| 180 ++
 xlat/s390_guarded_storage_commands.in |   5 +
 4 files changed, 187 insertions(+), 2 deletions(-)
 create mode 100644 xlat/s390_guarded_storage_commands.in

diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h
index dd1fbb1..522c641 100644
--- a/linux/s390/syscallent.h
+++ b/linux/s390/syscallent.h
@@ -407,7 +407,7 @@
 [375] = { 6,   TD, SEN(copy_file_range),   
"copy_file_range"   },
 [376] = { 6,   TD, SEN(preadv2),   "preadv2"   
},
 [377] = { 6,   TD, SEN(pwritev2),  "pwritev2"  
},
-[378] = { 2,   0,  SEN(printargs), 
"s390_guarded_storage"  },
+[378] = { 2,   0,  SEN(s390_guarded_storage),  
"s390_guarded_storage"  },
 [379] = { 5,   TD|TF|TSTA, SEN(statx), "statx" 
},
 [380] = { 4,   0,  SEN(s390_sthyi),"s390_sthyi"
},
 
diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h
index fe5b252..8e068c9 100644
--- a/linux/s390x/syscallent.h
+++ b/linux/s390x/syscallent.h
@@ -391,7 +391,7 @@
 [375] = { 6,   TD, SEN(copy_file_range),   
"copy_file_range"   },
 [376] = { 6,   TD, SEN(preadv2),   "preadv2"   
},
 [377] = { 6,   TD, SEN(pwritev2),  "pwritev2"  
},
-[378] = { 2,   0,  SEN(printargs), 
"s390_guarded_storage"  },
+[378] = { 2,   0,  SEN(s390_guarded_storage),  
"s390_guarded_storage"  },
 [379] = { 5,   TD|TF|TSTA, SEN(statx), "statx" 
},
 [380] = { 4,   0,  SEN(s390_sthyi),"s390_sthyi"
},
 
diff --git a/s390.c b/s390.c
index daaf6a0..a7efd29 100644
--- a/s390.c
+++ b/s390.c
@@ -35,6 +35,7 @@
 
 #include "print_fields.h"
 
+#include "xlat/s390_guarded_storage_commands.h"
 #include "xlat/s390_sthyi_function_codes.h"
 
 /*
@@ -1030,4 +1031,183 @@ SYS_FUNC(s390_sthyi)
return 0;
 }
 
+
+/*
+ * Structures are written based on
+ * 
https://www-304.ibm.com/support/docview.wss?uid=isg29c69415c1e82603c852576700058075a=1#page=85
+ */
+
+struct guard_storage_control_block {
+   uint64_t reserved;
+   /**
+* Guard Storage Designation
+*  - Bits 0..J, J == 64-GSC - Guard Storage Origin (GSO)
+*  - Bits 53..55 - Guard Load Shift (GLS)
+*  - Bits 58..63 - Guard Storage Characteristic (GSC), this is J from
+*  the first item, valud values are 25..56.
+*/
+   uint64_t gsd;
+   uint64_t gssm;   /**< Guard Storage Section Mask */
+   uint64_t gs_epl_a; /**< Guard Storage Event Parameter List Address */
+};
+
+struct guard_storage_event_parameter_list {
+   uint8_t  pad1;
+   /**
+* Guard Storage Event Addressing Mode
+*  - 0x40 - Extended addressing mode (E)
+*  - 0x80 - Basic addressing mode (B)
+*/
+   uint8_t  gs_eam;
+   /**
+* Guard Storage Event Cause indication
+*  - 0x01 - CPU was in transaction execution mode (TX)
+*  - 0x02 - CPU was in constrained transaction execution mode (CX)
+*  - 0x80 - Instruction causing the event: 0 - LGG, 1 - LLGFGS
+*/
+   uint8_t  gs_eci;
+   /**
+* Guard Storage Event Access Information
+*  - 0x01 - DAT mode
+*  - Bits 1..2 - Address space indication
+*  - Bits 4..7 - AR number
+*/
+   uint8_t  gs_eai;
+   uint32_t pad2;
+   uint64_t gs_eha; /**< Guard Storage Event Handler Address */
+   uint64_t gs_eia; /**< Guard Storage Event Instruction Address */
+   uint64_t gs_eoa; /**< Guard Storage Event Operation Address */
+   uint64_t gs_eir; /**< Guard Storage Event Intermediate Result */
+   uint64_t gs_era; /**< Guard Storage Event Return Address */
+};
+
+static void
+guard_storage_print_gsepl(struct tcb *tcp, uint64_t addr)
+{
+   struct guard_storage_event_parameter_list gsepl;
+
+   /* Since it is 64-bit even on 31-bit s390... */
+   if (sizeof(addr) > current_klongsize &&
+   addr >= (1ULL << (current_klongsize * 8))) {
+   tprintf("%#" PRIx64, addr);
+
+   return;
+   }
+
+   if (umove_or_printaddr(tcp, addr, ))
+  

[strace PATCH 03/12] print_fields.h: add macro to print hexadecimal array field

2018-01-17 Thread Eugene Syromyatnikov
* print_fields.h (PRINT_FIELD_HEX_ARRAY): New macro, prints target
array with QUOTE_FORCE_HEX.
---
 print_fields.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/print_fields.h b/print_fields.h
index 0af087a..b2c6a30 100644
--- a/print_fields.h
+++ b/print_fields.h
@@ -107,6 +107,15 @@
 sizeof((where_).field_));  \
} while (0)
 
+#define PRINT_FIELD_HEX_ARRAY(prefix_, where_, field_) \
+   do {\
+   STRACE_PRINTF("%s%s=", (prefix_), #field_); \
+   print_quoted_string((const char *)(where_).field_,  \
+sizeof((where_).field_) +  \
+   MUST_BE_ARRAY((where_).field_), \
+   QUOTE_FORCE_HEX); \
+   } while (0)
+
 #define PRINT_FIELD_INET_ADDR(prefix_, where_, field_, af_)\
do {\
STRACE_PRINTF(prefix_); \
-- 
2.1.4


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[strace PATCH 08/12] Introduce s390_runtime_instr system call decoder

2018-01-17 Thread Eugene Syromyatnikov
* linux/s390/syscallent.h ([342]): Change decoder to s390_runtime_instr.
* linux/s390x/syscallent.h: Likewise.
* s390.c (SYS_FUNC(s390_runtime_instr)): New function.
* xlat/s390_runtime_instr_commands.in: New file.
---
 linux/s390/syscallent.h |  2 +-
 linux/s390x/syscallent.h|  2 +-
 s390.c  | 31 +++
 xlat/s390_runtime_instr_commands.in |  2 ++
 4 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 xlat/s390_runtime_instr_commands.in

diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h
index 522c641..a807c95 100644
--- a/linux/s390/syscallent.h
+++ b/linux/s390/syscallent.h
@@ -371,7 +371,7 @@
 [339] = { 2,   TD, SEN(setns), "setns" 
},
 [340] = { 6,   0,  SEN(process_vm_readv),  
"process_vm_readv"  },
 [341] = { 6,   0,  SEN(process_vm_writev), 
"process_vm_writev" },
-[342] = { 2,   0,  SEN(printargs), 
"s390_runtime_instr"},
+[342] = { 2,   0,  SEN(s390_runtime_instr),
"s390_runtime_instr"},
 [343] = { 5,   0,  SEN(kcmp),  "kcmp"  
},
 [344] = { 3,   TD, SEN(finit_module),  "finit_module"  
},
 [345] = { 3,   0,  SEN(sched_setattr), "sched_setattr" 
},
diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h
index 8e068c9..c4a770d 100644
--- a/linux/s390x/syscallent.h
+++ b/linux/s390x/syscallent.h
@@ -355,7 +355,7 @@
 [339] = { 2,   TD, SEN(setns), "setns" 
},
 [340] = { 6,   0,  SEN(process_vm_readv),  
"process_vm_readv"  },
 [341] = { 6,   0,  SEN(process_vm_writev), 
"process_vm_writev" },
-[342] = { 2,   0,  SEN(printargs), 
"s390_runtime_instr"},
+[342] = { 2,   0,  SEN(s390_runtime_instr),
"s390_runtime_instr"},
 [343] = { 5,   0,  SEN(kcmp),  "kcmp"  
},
 [344] = { 3,   TD, SEN(finit_module),  "finit_module"  
},
 [345] = { 3,   0,  SEN(sched_setattr), "sched_setattr" 
},
diff --git a/s390.c b/s390.c
index a7efd29..dc7bf36 100644
--- a/s390.c
+++ b/s390.c
@@ -36,6 +36,7 @@
 #include "print_fields.h"
 
 #include "xlat/s390_guarded_storage_commands.h"
+#include "xlat/s390_runtime_instr_commands.h"
 #include "xlat/s390_sthyi_function_codes.h"
 
 /*
@@ -1210,4 +1211,34 @@ SYS_FUNC(s390_guarded_storage)
return RVAL_DECODED;
 }
 
+SYS_FUNC(s390_runtime_instr)
+{
+   int command = (int) tcp->u_arg[0];
+   int signum = (int) tcp->u_arg[1];
+
+   const char *command_descr =
+   xlookup(s390_runtime_instr_commands, command);
+
+   tprintf("%d", command);
+   tprints_comment(command_descr ? command_descr :
+   "S390_RUNTIME_INSTR_???");
+
+   /*
+* signum is ignored since Linux 4.4, but let's print it for start
+* command anyway.
+*/
+   switch (command) {
+   case S390_RUNTIME_INSTR_START:
+   tprints(", ");
+   tprints(signame(signum));
+   break;
+
+   case S390_RUNTIME_INSTR_STOP:
+   default:
+   break;
+   }
+
+   return RVAL_DECODED;
+}
+
 #endif /* defined S390 || defined S390X */
diff --git a/xlat/s390_runtime_instr_commands.in 
b/xlat/s390_runtime_instr_commands.in
new file mode 100644
index 000..395afc4
--- /dev/null
+++ b/xlat/s390_runtime_instr_commands.in
@@ -0,0 +1,2 @@
+S390_RUNTIME_INSTR_START   0x1
+S390_RUNTIME_INSTR_STOP0x2
-- 
2.1.4


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[strace PATCH 04/12] Introduce s390_sthyi system call decoder

2018-01-17 Thread Eugene Syromyatnikov
* s390.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/s390/syscallent.h ([380]): Change decoder to s390_sthyi.
* linux/s390x/syscallent.h: Likewise.
* xlat/s390_sthyi_function_codes.in: New file.
---
 Makefile.am   |1 +
 linux/s390/syscallent.h   |1 +
 linux/s390x/syscallent.h  |1 +
 s390.c| 1033 +
 xlat/s390_sthyi_function_codes.in |1 +
 5 files changed, 1037 insertions(+)
 create mode 100644 s390.c
 create mode 100644 xlat/s390_sthyi_function_codes.in

diff --git a/Makefile.am b/Makefile.am
index 2515876..02e2f3e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -267,6 +267,7 @@ strace_SOURCES =\
rtnl_rule.c \
rtnl_tc.c   \
rtnl_tc_action.c \
+   s390.c  \
sched.c \
sched_attr.h\
scsi.c  \
diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h
index 5482c53..dd1fbb1 100644
--- a/linux/s390/syscallent.h
+++ b/linux/s390/syscallent.h
@@ -409,6 +409,7 @@
 [377] = { 6,   TD, SEN(pwritev2),  "pwritev2"  
},
 [378] = { 2,   0,  SEN(printargs), 
"s390_guarded_storage"  },
 [379] = { 5,   TD|TF|TSTA, SEN(statx), "statx" 
},
+[380] = { 4,   0,  SEN(s390_sthyi),"s390_sthyi"
},
 
 #define SYS_socket_subcall 400
 #include "subcall.h"
diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h
index 36b1aef..fe5b252 100644
--- a/linux/s390x/syscallent.h
+++ b/linux/s390x/syscallent.h
@@ -393,6 +393,7 @@
 [377] = { 6,   TD, SEN(pwritev2),  "pwritev2"  
},
 [378] = { 2,   0,  SEN(printargs), 
"s390_guarded_storage"  },
 [379] = { 5,   TD|TF|TSTA, SEN(statx), "statx" 
},
+[380] = { 4,   0,  SEN(s390_sthyi),"s390_sthyi"
},
 
 #define SYS_socket_subcall 400
 #include "subcall.h"
diff --git a/s390.c b/s390.c
new file mode 100644
index 000..daaf6a0
--- /dev/null
+++ b/s390.c
@@ -0,0 +1,1033 @@
+/*
+ * s390-specific syscalls decoders.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "defs.h"
+
+#if defined S390 || defined S390X
+
+#include 
+
+#include "print_fields.h"
+
+#include "xlat/s390_sthyi_function_codes.h"
+
+/*
+ * Since, for some reason, kernel doesn't expose all these nice constants and
+ * structures in UAPI, we have to re-declare them ourselves.
+ */
+
+/**
+ * "The header section is placed at the beginning of the response buffer and
+ * identifies the location and length of all other sections. Valid sections 
have
+ * nonzero offset values in the header. Each section provides information about
+ * validity of fields within that section."
+ */
+struct sthyi_hdr {
+   /**
+* Header Flag Byte 1 - These flag settings indicate the environment
+* that the instruction was executed in and may influence the value of
+* the validity bits. The validity bits, and not these flags, should be
+* used to determine if a field is valid.
+*  - 0x80 - Global Performance Data unavailable
+*  - 0x40 - One or more hypervisor levels below this level does not
+*   support the STHYI instruction. When this flag is set the
+*   value of INFGPDU is not meaningful because the state of the

[strace PATCH 10/12] Introduce s390_pci_mmio_read, s390_pci_mmio_write system call decoders

2018-01-17 Thread Eugene Syromyatnikov
* linux/s390/syscallent.h ([352]): Change decoder to s390_pci_mmio_write.
([353]): Change decoder to s390_pci_mmio_read.
* linux/s390x/syscallent.h: Likewise.
* s390.c (SYS_FUNC(s390_pci_mmio_write), SYS_FUNC(s390_pci_mmio_read)):
New function.
---
 linux/s390/syscallent.h  |  4 ++--
 linux/s390x/syscallent.h |  4 ++--
 s390.c   | 33 +
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h
index a807c95..d34cd42 100644
--- a/linux/s390/syscallent.h
+++ b/linux/s390/syscallent.h
@@ -381,8 +381,8 @@
 [349] = { 3,   0,  SEN(getrandom), "getrandom" 
},
 [350] = { 2,   TD, SEN(memfd_create),  "memfd_create"  
},
 [351] = { 3,   TD, SEN(bpf),   "bpf"   
},
-[352] = { 3,   0,  SEN(printargs), 
"s390_pci_mmio_write"   },
-[353] = { 3,   0,  SEN(printargs), 
"s390_pci_mmio_read"},
+[352] = { 3,   0,  SEN(s390_pci_mmio_write),   
"s390_pci_mmio_write"   },
+[353] = { 3,   0,  SEN(s390_pci_mmio_read),
"s390_pci_mmio_read"},
 [354] = { 5,   TD|TF|TP|SE|SI, SEN(execveat),  "execveat"  
},
 [355] = { 1,   TD, SEN(userfaultfd),   "userfaultfd"   
},
 [356] = { 2,   0,  SEN(membarrier),"membarrier"
},
diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h
index c4a770d..0c84274 100644
--- a/linux/s390x/syscallent.h
+++ b/linux/s390x/syscallent.h
@@ -365,8 +365,8 @@
 [349] = { 3,   0,  SEN(getrandom), "getrandom" 
},
 [350] = { 2,   TD, SEN(memfd_create),  "memfd_create"  
},
 [351] = { 3,   TD, SEN(bpf),   "bpf"   
},
-[352] = { 3,   0,  SEN(printargs), 
"s390_pci_mmio_write"   },
-[353] = { 3,   0,  SEN(printargs), 
"s390_pci_mmio_read"},
+[352] = { 3,   0,  SEN(s390_pci_mmio_write),   
"s390_pci_mmio_write"   },
+[353] = { 3,   0,  SEN(s390_pci_mmio_read),
"s390_pci_mmio_read"},
 [354] = { 5,   TD|TF|TP|SE|SI, SEN(execveat),  "execveat"  
},
 [355] = { 1,   TD, SEN(userfaultfd),   "userfaultfd"   
},
 [356] = { 2,   0,  SEN(membarrier),"membarrier"
},
diff --git a/s390.c b/s390.c
index dc7bf36..4b23e7a 100644
--- a/s390.c
+++ b/s390.c
@@ -1241,4 +1241,37 @@ SYS_FUNC(s390_runtime_instr)
return RVAL_DECODED;
 }
 
+SYS_FUNC(s390_pci_mmio_write)
+{
+   kernel_ulong_t mmio_addr = tcp->u_arg[0];
+   kernel_ulong_t user_buf  = tcp->u_arg[1];
+   kernel_ulong_t length= tcp->u_arg[2];
+
+   tprintf("%#" PRI_klx ", ", mmio_addr);
+   printstr_ex(tcp, user_buf, length, QUOTE_FORCE_HEX);
+   tprintf(", %" PRI_klu, length);
+
+   return RVAL_DECODED;
+}
+
+SYS_FUNC(s390_pci_mmio_read)
+{
+   kernel_ulong_t mmio_addr = tcp->u_arg[0];
+   kernel_ulong_t user_buf  = tcp->u_arg[1];
+   kernel_ulong_t length= tcp->u_arg[2];
+
+   if (entering(tcp)) {
+   tprintf("%#" PRI_klx ", ", mmio_addr);
+   } else {
+   if (!syserror(tcp))
+   printstr_ex(tcp, user_buf, length, QUOTE_FORCE_HEX);
+   else
+   printaddr(user_buf);
+
+   tprintf(", %" PRI_klu, length);
+   }
+
+   return 0;
+}
+
 #endif /* defined S390 || defined S390X */
-- 
2.1.4


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[strace PATCH 09/12] tests: check s390_runtime_instr system call decoder

2018-01-17 Thread Eugene Syromyatnikov
* tests/s390_runtime_instr.c: New file.
* tests/.gitignore: Add s390_runtime_instr.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_runtime_instr): New test.
---
 tests/.gitignore|  1 +
 tests/gen_tests.in  |  1 +
 tests/pure_executables.list |  1 +
 tests/s390_runtime_instr.c  | 99 +
 4 files changed, 102 insertions(+)
 create mode 100644 tests/s390_runtime_instr.c

diff --git a/tests/.gitignore b/tests/.gitignore
index 379d8c1..eaa1141 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -359,6 +359,7 @@ rt_tgsigqueueinfo
 run_expect_termsig
 s390_guarded_storage
 s390_guarded_storage-v
+s390_runtime_instr
 s390_sthyi
 s390_sthyi-v
 sched_get_priority_mxx
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index 5a9e4ed..a6dea9f 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -305,6 +305,7 @@ rt_sigtimedwait -a38
 rt_tgsigqueueinfo  -esignal=none
 s390_guarded_storage   -a32
 s390_guarded_storage-v -e trace=s390_guarded_storage -a32 -v
+s390_runtime_instr -a50
 s390_sthyi -a47
 s390_sthyi-v   -e trace=s390_sthyi -a47 -v
 sched  test_trace_expr times -e/sched
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index dc43a93..9c61da2 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -298,6 +298,7 @@ rt_sigtimedwait
 rt_tgsigqueueinfo
 s390_guarded_storage
 s390_guarded_storage-v
+s390_runtime_instr
 s390_sthyi
 s390_sthyi-v
 sched_get_priority_mxx
diff --git a/tests/s390_runtime_instr.c b/tests/s390_runtime_instr.c
new file mode 100644
index 000..861bbd4
--- /dev/null
+++ b/tests/s390_runtime_instr.c
@@ -0,0 +1,99 @@
+/*
+ * Check decoding of s390_runtime_instr syscall.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include 
+
+#if defined __NR_s390_runtime_instr
+
+# include 
+# include 
+# include 
+# include 
+
+int
+main(void)
+{
+   static struct {
+   kernel_ulong_t cmd;
+   const char * cmd_str;
+   } cmd_args[] = {
+   { 0, "???" },
+   { 4, "???" },
+   { (kernel_ulong_t) 0xdeafbeefdeadc0deULL, "???" },
+   { 2, "STOP",  },
+   };
+
+   static struct {
+   kernel_ulong_t sig;
+   const char * sig_str;
+   } start_sig_args[] = {
+   { 0, "SIG_0" },
+   { (kernel_ulong_t) 0xfacefeedac0ffeedULL, NULL },
+   { ARG_STR(SIGALRM) },
+   { 33, "SIGRT_1" },
+   { 63, "SIGRT_31" },
+   };
+
+   unsigned int i;
+   long rc;
+
+   for (i = 0; i < ARRAY_SIZE(cmd_args); i++) {
+   rc = syscall(__NR_s390_runtime_instr, cmd_args[i].cmd, 0xdead);
+   printf("s390_runtime_instr(%d /* S390_RUNTIME_INSTR_%s */) = "
+  "%s\n",
+  (int) cmd_args[i].cmd, cmd_args[i].cmd_str,
+  sprintrc(rc));
+   }
+
+   for (i = 0; i < ARRAY_SIZE(start_sig_args); i++) {
+   long saved_errno;
+
+   rc = syscall(__NR_s390_runtime_instr, 1, start_sig_args[i].sig);
+   saved_errno = errno;
+   printf("s390_runtime_instr(1 /* S390_RUNTIME_INSTR_START */, ");
+
+   if (start_sig_args[i].sig_str)
+   printf("%s", start_sig_args[i].sig_str);
+   else
+   printf("%d", (int) start_sig_args[i].sig);
+
+   errno = saved_errno;
+   

[strace PATCH 07/12] tests: check s390_guarded_storage system call decoder

2018-01-17 Thread Eugene Syromyatnikov
* configure.ac (AC_CHECK_HEADERS): Add asm/guarded_storage.h.
* tests/s390_guarded_storage-v.c: New file.
* tests/s390_guarded_storage.c: Likewise.
* tests/.gitignore: Add s390_guarded_storage, s390_guarded_storage-v.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_guarded_storage, s390_guarded_storage-v):
New tests.
---
 configure.ac   |   1 +
 tests/.gitignore   |   2 +
 tests/gen_tests.in |   4 +-
 tests/pure_executables.list|   2 +
 tests/s390_guarded_storage-v.c |   2 +
 tests/s390_guarded_storage.c   | 229 +
 6 files changed, 239 insertions(+), 1 deletion(-)
 create mode 100644 tests/s390_guarded_storage-v.c
 create mode 100644 tests/s390_guarded_storage.c

diff --git a/configure.ac b/configure.ac
index 63595ce..fc164c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -392,6 +392,7 @@ AC_CHECK_MEMBERS(m4_normalize([
 
 AC_CHECK_HEADERS(m4_normalize([
asm/cachectl.h
+   asm/guarded_storage.h
asm/sysmips.h
bluetooth/bluetooth.h
elf.h
diff --git a/tests/.gitignore b/tests/.gitignore
index 19aa493..379d8c1 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -357,6 +357,8 @@ rt_sigsuspend
 rt_sigtimedwait
 rt_tgsigqueueinfo
 run_expect_termsig
+s390_guarded_storage
+s390_guarded_storage-v
 s390_sthyi
 s390_sthyi-v
 sched_get_priority_mxx
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index 968f6e4..5a9e4ed 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -303,8 +303,10 @@ rt_sigreturn   -esignal='!USR1'
 rt_sigsuspend  -a20 -esignal=none
 rt_sigtimedwait-a38
 rt_tgsigqueueinfo  -esignal=none
+s390_guarded_storage   -a32
+s390_guarded_storage-v -e trace=s390_guarded_storage -a32 -v
 s390_sthyi -a47
-s390_sthyi-v   -e trace=s390_sthyi -a47
+s390_sthyi-v   -e trace=s390_sthyi -a47 -v
 sched  test_trace_expr times -e/sched
 sched_get_priority_mxx -a33 -e 
trace=sched_get_priority_min,sched_get_priority_max
 sched_rr_get_interval  -a31
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index d8b997d..dc43a93 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -296,6 +296,8 @@ rt_sigreturn
 rt_sigsuspend
 rt_sigtimedwait
 rt_tgsigqueueinfo
+s390_guarded_storage
+s390_guarded_storage-v
 s390_sthyi
 s390_sthyi-v
 sched_get_priority_mxx
diff --git a/tests/s390_guarded_storage-v.c b/tests/s390_guarded_storage-v.c
new file mode 100644
index 000..05afd9f
--- /dev/null
+++ b/tests/s390_guarded_storage-v.c
@@ -0,0 +1,2 @@
+#define VERBOSE 1
+#include "s390_guarded_storage.c"
diff --git a/tests/s390_guarded_storage.c b/tests/s390_guarded_storage.c
new file mode 100644
index 000..ab67c15
--- /dev/null
+++ b/tests/s390_guarded_storage.c
@@ -0,0 +1,229 @@
+/*
+ * Check decoding of s390_guarded_storage syscall.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include 
+
+#if defined __NR_s390_guarded_storage && defined HAVE_ASM_GUARDED_STORAGE_H
+
+# include 
+# include 
+# include 
+# include 
+# include 
+
+# include 
+
+# ifndef VERBOSE
+#  define VERBOSE 0
+# endif
+
+static void
+gs_no_arg(kernel_ulong_t val, const char *val_str)
+{
+   static const kernel_ulong_t bogus_addr =
+   (kernel_ulong_t) 0xcaffeedadeadbed5ULL;
+   static const kernel_ulong_t bogus_cmd_mask =
+   (kernel_ulong_t) 0xbadc0dedULL;
+   long rc;
+
+   rc = syscall(__NR_s390_guarded_storage, val | bogus_cmd_mask,
+

[strace PATCH 11/12] tests: check s390_pci_mmio_read and s390_pci_mmio_write decoders

2018-01-17 Thread Eugene Syromyatnikov
* tests/s390_pci_mmio_read_write.c: New file.
* tests/.gitignore: Add s390_pci_mmio_read_write.
* tests/pure_executables.list: Likewise.
* tests/gen_tests.in (s390_pci_mmio_read_write): New test.
---
 tests/.gitignore |   1 +
 tests/gen_tests.in   |   1 +
 tests/pure_executables.list  |   1 +
 tests/s390_pci_mmio_read_write.c | 159 +++
 4 files changed, 162 insertions(+)
 create mode 100644 tests/s390_pci_mmio_read_write.c

diff --git a/tests/.gitignore b/tests/.gitignore
index eaa1141..7dbd84d 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -359,6 +359,7 @@ rt_tgsigqueueinfo
 run_expect_termsig
 s390_guarded_storage
 s390_guarded_storage-v
+s390_pci_mmio_read_write
 s390_runtime_instr
 s390_sthyi
 s390_sthyi-v
diff --git a/tests/gen_tests.in b/tests/gen_tests.in
index a6dea9f..ae9ba63 100644
--- a/tests/gen_tests.in
+++ b/tests/gen_tests.in
@@ -305,6 +305,7 @@ rt_sigtimedwait -a38
 rt_tgsigqueueinfo  -esignal=none
 s390_guarded_storage   -a32
 s390_guarded_storage-v -e trace=s390_guarded_storage -a32 -v
+s390_pci_mmio_read_write   -e trace=s390_pci_mmio_read,s390_pci_mmio_write 
-a30
 s390_runtime_instr -a50
 s390_sthyi -a47
 s390_sthyi-v   -e trace=s390_sthyi -a47 -v
diff --git a/tests/pure_executables.list b/tests/pure_executables.list
index 9c61da2..77a29b0 100755
--- a/tests/pure_executables.list
+++ b/tests/pure_executables.list
@@ -298,6 +298,7 @@ rt_sigtimedwait
 rt_tgsigqueueinfo
 s390_guarded_storage
 s390_guarded_storage-v
+s390_pci_mmio_read_write
 s390_runtime_instr
 s390_sthyi
 s390_sthyi-v
diff --git a/tests/s390_pci_mmio_read_write.c b/tests/s390_pci_mmio_read_write.c
new file mode 100644
index 000..8968d4e
--- /dev/null
+++ b/tests/s390_pci_mmio_read_write.c
@@ -0,0 +1,159 @@
+/*
+ * Check decoding of s390_pci_mmio_read and s390_pci_mmio_write syscalls.
+ *
+ * Copyright (c) 2018 The strace developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include 
+
+#if defined __NR_s390_pci_mmio_read && defined __NR_s390_pci_mmio_write
+
+# include 
+# include 
+# include 
+# include 
+# include 
+
+# ifndef MIN
+#  define MIN(a, b) ((a) < (b) ? (a) : (b))
+# endif
+
+static void
+do_call(bool wr, kernel_ulong_t mmio_addr, kernel_ulong_t buf,
+   kernel_ulong_t len, bool buf_valid, const char *buf_str)
+{
+   long saved_errno = 0;
+   long rc = 0;
+
+   printf("s390_pci_mmio_%s(%#llx, ", wr ? "write" : "read",
+  (unsigned long long) mmio_addr);
+
+   if (!wr) {
+   rc = syscall(__NR_s390_pci_mmio_read, mmio_addr, buf, len);
+   saved_errno = errno;
+   }
+
+   if (buf_valid && !rc) {
+   char *buf_ptr = (char *) (uintptr_t) buf;
+
+   print_quoted_hex(buf_ptr,
+len > DEFAULT_STRLEN ? DEFAULT_STRLEN : len);
+
+   if (len > DEFAULT_STRLEN)
+   printf("...");
+   } else {
+   if (buf_str)
+   printf("%s", buf_str);
+   else
+   printf("%#llx", (unsigned long long) buf);
+   }
+
+   printf(", %llu) = ", (unsigned long long) len);
+
+   if (wr)
+   rc = syscall(__NR_s390_pci_mmio_write, mmio_addr, buf, len);
+   else
+   errno = saved_errno;
+
+   puts(sprintrc(rc));
+}
+
+int
+main(void)
+{
+   static const size_t buf_size = DEFAULT_STRLEN + 10;
+
+   char *buf = tail_alloc(buf_size);
+
+   bool bools[] = { true, false };
+

Re: Introduction

2017-12-26 Thread Eugene Syromyatnikov
On Tue, Dec 26, 2017 at 1:44 PM, Kommuru jai shankar reddy
<kommurujaishankarre...@gmail.com> wrote:
> Yes,  I am interested in the micro project of adding tests to the test
> suite. Could you please provide suggestions  on getting started to this  ?

Sure. I'd suggest starting with ioctl decoders that are not shown as
covered in LCOV reports, these are rather low-hanging fruits. The next
thing is rarely used features that have no tests or are poorly tested,
like path tracing or stack printing. It would be also benefitical to
add some tests that cover some not previously test-covered aspects of
strace's behaviour, like daemonized tracer, but in order to do that
properly, some understanding of the strace internal workings is
needed, and it might be difficult at first.

The tests themselves reside in tests directory. The make target of
interest is "make check", and you might be interested in
--enable-code-coverage configuration option.

Note also that code that is not covered by tests is more likely to
contain errors (especially if it is some obscure ioctl one rarely
cares about), so do not hesitate to fix it in case discrepancies
between kernel's and strace's interpretation of syscall arguments are
observed.

> On Mon, Dec 25, 2017 at 11:49 PM, Eugene Syromyatnikov <evg...@gmail.com>
> wrote:
>>
>> On Mon, Dec 25, 2017 at 5:06 PM, Kommuru jai shankar reddy
>> <kommurujaishankarre...@gmail.com> wrote:
>> > Hello,
>> >I'm jaya shankar,. Computer science student of national institute
>> > of
>> > technology andhra pradesh, India
>> > I have used strace for my mini project for tracing system calls of
>> > malware
>> > executables and it helped me a lot.
>> > I want to contribute to the community and apply as student for GSOC
>> > 2k18.
>> > I'm having knowledge of kernel, C, git and basics of networking.
>> > So, it would be great if any one suggest me some tasks for micro
>> > projects
>> > for gsoc, some bugs to fix for a beginner like me.
>>
>> Thank you for showing interest in strace.
>>
>> Please take a look at [1], [2], and [3] as starting points. As Chen
>> JingPiao also noted recently [4], there is an ongoing effort to add
>> netlink protocol decoding support to strace, which may be of interest,
>> taking in account aforementioned background.
>>
>> If you have any specific questions, don't hesitate to ask.
>>
>> [1]
>> https://sourceforge.net/p/strace/wiki/Guide%20for%20new%20contributors/
>> [2] https://sourceforge.net/p/strace/wiki/Microprojects/
>> [3] https://sourceforge.net/p/strace/wiki/FeatureRequests/
>> [4] https://sourceforge.net/p/strace/mailman/message/36168713/
>>
>> --
>> Eugene Syromyatnikov
>> mailto:evg...@gmail.com
>> xmpp:esyr@jabber.{ru|org}
>>
>>
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> ___
>> Strace-devel mailing list
>> Strace-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/strace-devel
>
>
>
>
> --
> Thanks
>
> K.jaishankar reddy
>
>
> ------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Introduction

2017-12-25 Thread Eugene Syromyatnikov
On Mon, Dec 25, 2017 at 5:06 PM, Kommuru jai shankar reddy
<kommurujaishankarre...@gmail.com> wrote:
> Hello,
>I'm jaya shankar,. Computer science student of national institute of
> technology andhra pradesh, India
> I have used strace for my mini project for tracing system calls of malware
> executables and it helped me a lot.
> I want to contribute to the community and apply as student for GSOC 2k18.
> I'm having knowledge of kernel, C, git and basics of networking.
> So, it would be great if any one suggest me some tasks for micro projects
> for gsoc, some bugs to fix for a beginner like me.

Thank you for showing interest in strace.

Please take a look at [1], [2], and [3] as starting points. As Chen
JingPiao also noted recently [4], there is an ongoing effort to add
netlink protocol decoding support to strace, which may be of interest,
taking in account aforementioned background.

If you have any specific questions, don't hesitate to ask.

[1] https://sourceforge.net/p/strace/wiki/Guide%20for%20new%20contributors/
[2] https://sourceforge.net/p/strace/wiki/Microprojects/
[3] https://sourceforge.net/p/strace/wiki/FeatureRequests/
[4] https://sourceforge.net/p/strace/mailman/message/36168713/

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Introduction

2017-11-19 Thread Eugene Syromyatnikov
On Sun, Nov 19, 2017 at 1:49 PM, gou4shi1 <ad...@goushi.me> wrote:
> Hello everyone
Hello.

> I'm Guangqing Chen, an undergraduate from South China Normal University,
> China.
>
> I have some knowledge about C and Unix programming.
>
> I want to know how to get started to read the source code of strace.

Thank you for showing interest in strace.

strace project uses git for source control. strace git repositories
are available
at [1] and [2], and at [3] and [4] the respective web interfaces are present.

[1] git://git.code.sf.net/p/strace/code
[2] https://github.com/strace/strace.git
[3] https://sourceforge.net/p/strace/code/ci/master/tree/
[4] https://github.com/strace/strace

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Introduction

2017-11-18 Thread Eugene Syromyatnikov
On Sat, Nov 18, 2017 at 8:38 PM, Manvendra Singh
<manvendra021...@gmail.com> wrote:
> Hi everyone
Hello.

> I'm Manvendra Singh and doing under-graduation in Computer Science &
> Engineering from ITM University, Gwalior, India.
>
> I have knowledge of C, git and shell programming(basic). I wanted to
> contribute to the community.
> Can anybody please help me get started.

Thank you for showing interest in strace.

Please take a look at [1], [2], and [3] as starting points. If you have
any specific questions, don't hesitate to ask.

[1] https://sourceforge.net/p/strace/wiki/Guide%20for%20new%20contributors/
[2] https://sourceforge.net/p/strace/wiki/Microprojects/
[3] https://sourceforge.net/p/strace/wiki/FeatureRequests/

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 1/3] xlat/gen.sh: add some rudimentary support for comments

2017-09-13 Thread Eugene Syromyatnikov
---
 xlat/gen.sh | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/xlat/gen.sh b/xlat/gen.sh
index 06c1b17..9efa0ab 100755
--- a/xlat/gen.sh
+++ b/xlat/gen.sh
@@ -135,6 +135,9 @@ gen_header()
# 1st pass: output directives.
while read line; do
LC_COLLATE=C
+   line=$(printf "%s" "$line" | \
+   sed "s|[[:space:]]*/\*.*\*/[[:space:]]*||")
+
case $line in
'#stop')
exit 0
@@ -196,6 +199,9 @@ gen_header()
# 2nd pass: output everything.
while read line; do
LC_COLLATE=C
+   line=$(printf "%s" "$line" | \
+   sed "s|[[:space:]]*/\*.*\*/[[:space:]]*||")
+
case ${line} in
'#conditional')
unconditional=
-- 
2.1.4


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 3/3] term: improve decoding of termios and termio structures

2017-09-13 Thread Eugene Syromyatnikov
---
 term.c | 145 ++---
 xlat/term_cflags.in|   9 +++
 xlat/term_cflags_csize.in  |   4 ++
 xlat/term_iflags.in|  15 +
 xlat/term_lflags.in|  17 ++
 xlat/term_oflags.in|  15 +
 xlat/term_oflags_bsdly.in  |   2 +
 xlat/term_oflags_crdly.in  |   4 ++
 xlat/term_oflags_ffdly.in  |   2 +
 xlat/term_oflags_nldly.in  |   4 ++
 xlat/term_oflags_tabdly.in |   8 +++
 xlat/term_oflags_vtdly.in  |   2 +
 xlat/termio_cc.in  |  10 
 xlat/termios_cc.in |  18 ++
 14 files changed, 234 insertions(+), 21 deletions(-)
 create mode 100644 xlat/term_cflags.in
 create mode 100644 xlat/term_cflags_csize.in
 create mode 100644 xlat/term_iflags.in
 create mode 100644 xlat/term_lflags.in
 create mode 100644 xlat/term_oflags.in
 create mode 100644 xlat/term_oflags_bsdly.in
 create mode 100644 xlat/term_oflags_crdly.in
 create mode 100644 xlat/term_oflags_ffdly.in
 create mode 100644 xlat/term_oflags_nldly.in
 create mode 100644 xlat/term_oflags_tabdly.in
 create mode 100644 xlat/term_oflags_vtdly.in
 create mode 100644 xlat/termio_cc.in
 create mode 100644 xlat/termios_cc.in

diff --git a/term.c b/term.c
index 28f562f..25497b9 100644
--- a/term.c
+++ b/term.c
@@ -38,6 +38,121 @@
 #include "xlat/baud_options.h"
 #include "xlat/modem_flags.h"
 
+#include "xlat/term_cflags.h"
+#include "xlat/term_cflags_csize.h"
+#include "xlat/term_iflags.h"
+#include "xlat/term_lflags.h"
+#include "xlat/term_oflags.h"
+#include "xlat/term_oflags_bsdly.h"
+#include "xlat/term_oflags_crdly.h"
+#include "xlat/term_oflags_ffdly.h"
+#include "xlat/term_oflags_nldly.h"
+#include "xlat/term_oflags_tabdly.h"
+#include "xlat/term_oflags_vtdly.h"
+
+#include "xlat/termio_cc.h"
+#include "xlat/termios_cc.h"
+
+static void
+decode_oflag(uint64_t val)
+{
+   static const struct {
+   const struct xlat *xl;
+   uint64_t mask;
+   const char *dfl;
+   } xlats[] = {
+   { term_oflags_bsdly,  BSDLY,  "BS?"  },
+   { term_oflags_crdly,  CRDLY,  "CR?"  },
+   { term_oflags_ffdly,  FFDLY,  "FF?"  },
+   { term_oflags_nldly,  NLDLY,  "NL?"  },
+   { term_oflags_tabdly, TABDLY, "TAB?" },
+   { term_oflags_vtdly,  VTDLY,  "VT?"  },
+   };
+
+   unsigned i;
+
+   for (i = 0; i < ARRAY_SIZE(xlats); i++) {
+   printxval64(xlats[i].xl, val & xlats[i].mask, xlats[i].dfl);
+   tprints("|");
+
+   val &= ~xlats[i].mask;
+   }
+
+   printflags64(term_oflags, val, NULL);
+}
+
+static void
+decode_cflag(uint64_t val)
+{
+   printxval64(baud_options, val & CBAUD, "B???");
+   tprints("|");
+   printxval64(baud_options, (val & CIBAUD) >> IBSHIFT, "B???");
+   tprintf("<str; xl++) {
+   if (xl->val >= size)
+   continue;
+
+   print_cc_char(, data, xl->str, xl->val);
+   not_printed &= ~(1 << xl->val);
+   }
+
+   while (not_printed) {
+   if (not_printed & 1)
+   print_cc_char(, data, NULL, i);
+
+   not_printed >>= 1;
+   i++;
+   }
+
+   tprints("}");
+}
+
 static void
 decode_termios(struct tcb *const tcp, const kernel_ulong_t addr)
 {
@@ -56,16 +171,14 @@ decode_termios(struct tcb *const tcp, const kernel_ulong_t 
addr)
(tios.c_lflag & ECHO) ? "" : "-");
return;
}
-   tprintf("{c_iflags=%#lx, c_oflags=%#lx, ",
-   (long) tios.c_iflag, (long) tios.c_oflag);
-   tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
-   (long) tios.c_cflag, (long) tios.c_lflag);
-   tprintf("c_line=%u, ", tios.c_line);
+   tprints("{");
+  

Re: Feature Request: Process Lineage in Filenames.

2017-09-01 Thread Eugene Syromyatnikov
On Sat, Mar 4, 2017 at 12:08 AM, Eugene Syromyatnikov <evg...@gmail.com> wrote:
> On Fri, Mar 3, 2017 at 11:54 PM, Ralph Corderoy <ra...@inputplus.co.uk> wrote:
>> Hi,
>>
>> Second request.  I had a bunch of filename.pid outputs from -ff the
>> other day and to better understand what occurred, I examined and renamed
>> them to show their ancestry.
>>
>> 1000.man
>> 1008.man-preconv
>> 1009.man-tbl
>> 1010.man-nroff
>> 1011.man-col
>> 1013.man-nroff-locale
>> 1016.man-nroff-groff
>> 1018.man-nroff-groff-troff
>> 1019.man-nroff-groff-grotty
>>
>> I was thinking something similar could happen automatically.  Not using
>> the name of the program execve()'d, because that comes later, but a list
>> of PIDs starting with the ancestor.  So
>>
>> strace -o foo -fff /usr/bin/foo
>>
>> might produce
>>
>> foo.100
>>
>> and as that forks
>>
>> foo.100-102
>>
>> and forks again
>>
>> foo.100-102-103
>>
>> foo.100-109 would be 102's sibling.
>>
>> It would make it that bit easier when grep-ing through them all, etc.,
>> to interpret the results.
> Well, something like { echo 'digraph {'; for i in *; do sed -n
> "/clone/s/.* \([0-9]*\)\$/${i#*.} -> \1;/p" $i; done; echo '}'; } |
> dot -Tpng  > pid_graph.png can ease the task, but it is not always
> that easy [1]. Thanks for the sugestion, since strace indeed can track
> this sort of process relations.

As it turns out, PTRACE_EVENT_(CLONE|FORK|VFORK) is delivered only
after new task is run, which results in a race between attach-stop
from the new task (which triggers allocation of the new tcb and
creation of the new file) and this aforementioned ptrace event from
the old one, and using child's proc for deriving parent PID looks even
more racy (imagine parent has been killed while we trying to open
/proc/pid/stat and try to go through it). So, this one is not as easy
as it seemed on the first look.

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: strace-k.test

2017-08-31 Thread Eugene Syromyatnikov
On Wed, Aug 30, 2017 at 12:42 PM, Andreas Schwab <sch...@suse.de> wrote:
> The strace-k test always fails if getpid is implemented as a vsyscall:

Can you please provide some information about the environment in order
to reproduce it? It's quite unusual to me that vsyscall is used
somewhere.

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Edgar Kaziakhmedov's GSoC status report - #8 of 13

2017-07-27 Thread Eugene Syromyatnikov
On Thu, Jul 27, 2017 at 9:39 PM, Edgar Kaziakhmedov
<edgar.kaziakhme...@virtuozzo.com> wrote:
>
> Accomplishment:
> asinfo for now completely is able to print out all info about all
> supported architectures with get-arch option(taking into account
> all personalities)
>
> Thus, arch_dispatcher is completed fully.
>
> Also, I have made syscall_dispatcher, but it has some cases when it
> doesn't work, literally in 1 day it's going to be debugged.

Would you mind to consider sending WIP patches or providing a link to
a repository so we can look at the current state of the project?

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v9 0/3] Add LuaJIT scripting support

2017-07-26 Thread Eugene Syromyatnikov
On Wed, Jul 26, 2017 at 2:56 PM, Victor Krapivensky
<krapivenskiy...@phystech.edu> wrote:
> * All the Lua functions that previously took an optional "pers" argument
> now take a mandatory "pers_spec" argument, which can be either an
> integer personality number, or a cdata struct tcb *, from which a
> personality number if copied.
> * For all the Lua functions that take a "when" argument, it can now be a
> two-element array (that is, a table with keys 1 and 2) of booleans;
> first of them controls if hooking should done on syscall entry, and the
> second one if on syscall exit;
> * strace.monitor_all now takes a "when" argument;
> * New Lua function strace.monitor_name.
> * Certain Lua functions that are described in the man page section as
> taking a *string* argument (where a *string* is defined as either a Lua
> string or a cdata C string) now actually support cdata C strings.
> * Fixed upoken's behaviour when process_vm_writev is not available
> and modifying the middle of a word is requested.
> * Some other minor fixes.

Thanks!

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v9 0/3] Add LuaJIT scripting support

2017-07-26 Thread Eugene Syromyatnikov
On Tue, Jul 25, 2017 at 12:59 PM, Victor Krapivensky
<krapivenskiy...@phystech.edu> wrote:
> Victor Krapivensky (3):
>   Initial support for LuaJIT scripting
>   Introduce upoken function and expose it to LuaJIT scripts
>   tests: check LuaJIT scripting support

It's quite handy to have patch changelog here, especially if you claim
that the issues pointed out during the previous review are partially
touched.

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v4 2/6] Introduce new filtering architecture

2017-07-25 Thread Eugene Syromyatnikov
On Tue, Jul 25, 2017 at 5:19 AM, Nikolay Marchuk
<marchuk.nikola...@gmail.com> wrote:
> What indentation should I use? I used DECL_* macros from defs.h as a
> reference.
After discussion with Dmitry it has been decided that comments after such macro
definitions should be put in order to signify their termination, please refer
to commit 861e50b6 [1].

[1] 
https://github.com/strace/strace/commit/861e50b6df434ac690613c54ad75aaefc9743e74

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v3 2/6] Introduce new filtering architecture

2017-07-05 Thread Eugene Syromyatnikov
On Wed, Jul 5, 2017 at 9:47 AM, Nikolay Marchuk
<marchuk.nikola...@gmail.com> wrote:
>>> +void
>>> +set_filters_qualify_mode(struct filter **filters, unsigned int *nfilters)
>>> +{
>>> +unsigned int i;
>>> +for (i = 0; i < *nfilters - 1; ++i) {
>>> +free_filter(*filters + i);
>>> +}
>>> +**filters = (*filters)[*nfilters - 1];
>>> +*filters = xreallocarray(*filters, 1, sizeof(struct filter));
>> I'm pretty sure realloc() can't be expected to be able to handle 
>> re-allocating
>> memory hunk which is provided by pointer not pointing at the beginning
>> of the hunk. IOW, allocators are not expected to work with arbitrary 
>> pointers,
>> only with ones that are returned by those allocators.
> But pointer isn't changed between allocations.
>>> +
>>> +DECL_FILTER_ACTION_PARSER(null);
>>> +DECL_FILTER_ACTION_PARSER(inject);
>>> +
>>> +#undef DECL_FILTER_ACTION_PARSER
>>> +
>>> +#define FILTER_ACTION_TYPE(NAME, PRIORITY, PARSER, PREFILTER)  
>>>  \
>>> +{#NAME, sizeof(#NAME) - 1,PRIORITY, parse_ ## PARSER, free_ ## PARSER, 
>>>  \
>>> + PREFILTER, apply_ ## NAME}
>> Missing indentation of the macro definition. Incorrect indentation of
>> the structure definition continuation.
> I can't find any references for multi-line structure definitions.
> What indentation should I use?
The default is single tab character, and I see no reason for using
something else in case of structure definition.


-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v3 5/6] Optimize default filtering

2017-07-03 Thread Eugene Syromyatnikov
On Mon, Jul 3, 2017 at 6:43 PM, Victor Krapivensky
<krapivenskiy...@phystech.edu> wrote:
> Actually, passing a non-dereferencable pointer as a first argument to
> qsort is UB, even if the second argument is 0:
My bad, didn't notice that filter_actions is invalid in that case, thanks!


-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH RFC v1 1/1] Initial support for Lua scripting

2017-06-15 Thread Eugene Syromyatnikov
On Thu, Jun 15, 2017 at 3:28 PM, Eugene Syromiatnikov <e...@redhat.com> wrote:
> Overall looks good.

Well, except that mpers_defs.h also has STRINGIFY() macro and
undef'ing it in defs_reuse.h leads to breaking of mpers header
generation and breaking of the (clean) build, as a result. I'd suggest
renaming STRINGIFY() macro in defs_reuse.h.

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH 1/8] netlink: add a basic socket diag parser of AF_NETLINK messages

2017-06-13 Thread Eugene Syromyatnikov
On Tue, Jun 13, 2017 at 8:13 PM, Dmitry V. Levin <l...@altlinux.org> wrote:
> On Tue, Jun 13, 2017 at 10:13:18PM +0800, JingPiao Chen wrote:
>> +/* deprecated since 4.6 */
>
> Do we really need this comment?
Yes, we do, as otherwise it's quite difficult to figure out where is
the constant from when it is not defined in actual version of the
kernel headers and these headers have suffered several iterations of
refectoring.

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


IRC channel

2017-05-14 Thread Eugene Syromyatnikov
Hello.

As some already know, strace project has an IRC channel (#strace) on
the FreeNode network [1]. I, for my part, suggest GSoC students
consider joining it, as it might be more familiar way of communication
for some.

Note, however, that it in no way replaces communication via the
mailing list, as the latter definitely has far broader reach and is
much more "archive-able" way of communication, so it is more suitable
for open discussions.

[1] https://sourceforge.net/p/strace/mailman/message/35631132/

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Testcase failed

2017-05-09 Thread Eugene Syromyatnikov
On Sun, May 7, 2017 at 3:36 PM, Sumit Sardana <sardana.sumi...@gmail.com> wrote:
> Hi
Hello.

> What is attach-p-cmd.test ?
It is test for simultaneous attaching and running a tracee provided in
command line arguments, as test description states.

> After ```make check``` I got this test-case failed
It has some race which has yet to be addressed. It might be some
kernel bug, judging by unexpected ENOSYS.

> FAIL: attach-p-cmd
> ==
>
> 4c4,5
> < 30903 chdir("attach-p-cmd.test -p") = -1 ENOENT (No such file or
> directory)
> ---
>> 30903 syscall_18446744073709551615(0x1, 0x1c0, 0, 0x8, 0, 0) = -1 (errno
>> 38)
>> 30903 chdir("attach-p-cmd.test -p") = -1 ENOSYS (Function not implemented)
> attach-p-cmd.test: failed test: ../../strace -a30 -echdir -p 30903
> ../attach-p-cmd-cmd output mismatch
> FAIL attach-p-cmd.test (exit status: 1)
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH 1/2] v4l2: Add decoding for VIDIOC_G/S_TUNER's arg

2017-05-01 Thread Eugene Syromyatnikov
, ) < 0) {
>> > +   tprints("}");
>> > +   return 1;
>> > +   }
>> > +   tprints(is_get ? ", " : " => ");
>> > +   }
>> > +
>> > +   tprints("name=");
>> > +   print_quoted_string((const char *) c.name, sizeof(c.name),
>> > +   QUOTE_0_TERMINATED);
>> > +   tprints(", type=");
>> > +   printxval(v4l2_tuner_types, c.type, "V4L2_TUNER_TYPE_???");
>> > +   tprints(", capability=");
>> > +   printxval(v4l2_tuner_capabilities, c.capability,
>> > + "V4L2_TUNER_CAP_???");
>> > +   tprintf(", rangelow=%u, rangehigh=%u, rxsubchans=",
>> > +   c.rangelow, c.rangehigh);
>> > +   printxval(v4l2_tuner_rxsubchanses, c.rxsubchans,
>> > + "V4L2_TUNER_SUB_???");
>> > +   tprints(", audmode=");
>> > +   printxval(v4l2_tuner_audmodes, c.audmode,
>> > + "V4L2_TUNER_MODE_???");
>> > +   tprintf(", signal=%d, afc=%d", c.signal, c.afc);
>> > +
>> > +   if (exiting(tcp))
>> > +   tprints("}");
>> > +   return 1;
>> > +}
>> > +
>> >  #include "xlat/v4l2_control_types.h"
>> >  #include "xlat/v4l2_control_flags.h"
>> >
>> > @@ -971,6 +1020,10 @@ MPERS_PRINTER_DECL(int, v4l2_ioctl, struct tcb
>> > *const tcp, case VIDIOC_S_CTRL: /* RW */
>> > return print_v4l2_control(tcp, arg, code ==
>> > VIDIOC_G_CTRL);
>> > +   case VIDIOC_G_TUNER: /* RW */
>> > +   case VIDIOC_S_TUNER: /* RW */
>> > +   return print_v4l2_tuner(tcp, arg, code ==
>> > VIDIOC_G_TUNER); +
>> > case VIDIOC_QUERYCTRL: /* RW */
>> > return print_v4l2_queryctrl(tcp, arg);
>> >
>> > diff --git a/xlat/v4l2_tuner_audmodes.in
>> > b/xlat/v4l2_tuner_audmodes.in new file mode 100644
>> > index ..82decabf
>> > --- /dev/null
>> > +++ b/xlat/v4l2_tuner_audmodes.in
>> > @@ -0,0 +1,6 @@
>> > +V4L2_TUNER_MODE_MONO
>> > +V4L2_TUNER_MODE_STEREO
>> > +V4L2_TUNER_MODE_LANG2
>> > +V4L2_TUNER_MODE_SAP
>> > +V4L2_TUNER_MODE_LANG1
>> > +V4L2_TUNER_MODE_LANG1_LANG2
>> > diff --git a/xlat/v4l2_tuner_capabilities.in
>> > b/xlat/v4l2_tuner_capabilities.in new file mode 100644
>> > index ..4aec41eb
>> > --- /dev/null
>> > +++ b/xlat/v4l2_tuner_capabilities.in
>> > @@ -0,0 +1,14 @@
>> > +V4L2_TUNER_CAP_LOW
>> > +V4L2_TUNER_CAP_NORM
>> > +V4L2_TUNER_CAP_HWSEEK_BOUNDED
>> > +V4L2_TUNER_CAP_HWSEEK_WRAP
>> > +V4L2_TUNER_CAP_STEREO
>> > +V4L2_TUNER_CAP_LANG2
>> > +V4L2_TUNER_CAP_SAP
>> > +V4L2_TUNER_CAP_LANG1
>> > +V4L2_TUNER_CAP_RDS
>> > +V4L2_TUNER_CAP_RDS_BLOCK_IO
>> > +V4L2_TUNER_CAP_RDS_CONTROLS
>> > +V4L2_TUNER_CAP_FREQ_BANDS
>> > +V4L2_TUNER_CAP_HWSEEK_PROG_LIM
>> > +V4L2_TUNER_CAP_1HZ
>> > diff --git a/xlat/v4l2_tuner_rxsubchanses.in
>> > b/xlat/v4l2_tuner_rxsubchanses.in new file mode 100644
>> > index ..c6d59e95
>> > --- /dev/null
>> > +++ b/xlat/v4l2_tuner_rxsubchanses.in
>> > @@ -0,0 +1,6 @@
>> > +V4L2_TUNER_SUB_MONO
>> > +V4L2_TUNER_SUB_STEREO
>> > +V4L2_TUNER_SUB_LANG2
>> > +V4L2_TUNER_SUB_SAP
>> > +V4L2_TUNER_SUB_LANG1
>> > +V4L2_TUNER_SUB_RDS
>> > diff --git a/xlat/v4l2_tuner_types.in b/xlat/v4l2_tuner_types.in
>> > new file mode 100644
>> > index ..59a9f3a3
>> > --- /dev/null
>> > +++ b/xlat/v4l2_tuner_types.in
>> > @@ -0,0 +1,6 @@
>> > +V4L2_TUNER_RADIO
>> > +V4L2_TUNER_ANALOG_TV
>> > +V4L2_TUNER_DIGITAL_TV
>> > +V4L2_TUNER_ADC
>> > +V4L2_TUNER_SDR
>> > +V4L2_TUNER_RF
>>
>> I'm sorry for disturbing, but are you going to look the last one
>> patch?
>
> I'm sorry for disturbing, but are you going to look the last one patch?
Are you referring to commit 99bade991795dea26a0234ddd9b2c54aa2f2b737,
which was applied 9 days ago?

> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: strace-V test fails next year

2017-04-21 Thread Eugene Syromyatnikov
On Tue, Apr 4, 2017 at 9:05 AM, Andreas Schwab <sch...@suse.de> wrote:
> FAIL: strace-V
> ==
>
> 2c2
> < Copyright (C) 1991-2017 The strace developers <https://strace.io>.
> ---
>> Copyright (C) 1991-2018 The strace developers <https://strace.io>.
> strace-V.test: failed test: ../strace -V output mismatch

The issue is fixed in v4.16-150-gcd838da.

> Andreas.
>
> --
> Andreas Schwab, SUSE Labs, sch...@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [RFC] GSoC 2017 proposal draft: advanced syscall tampering and filtering with Lua

2017-04-03 Thread Eugene Syromyatnikov
On Thu, Mar 30, 2017 at 5:56 PM, Victor Krapivensky
<krapivenskiy...@phystech.edu> wrote:
> On Thu, Mar 30, 2017 at 05:28:55AM +0200, Eugene Syromyatnikov wrote:
>> The one quite interesting aspect, from my point of view, is the way you
>> expect to access (and modify) argument data. For example, some syscalls
>> (like sendmsg or evdev/dm ioctls or siginfo-related ones) have quite
>> non-trivial argument semantics — pointers upon pointers upon pointers;
>> related decoders have quite significant amount of code in order to
>> retrieve them. Note also, that argument decoding also depends on
>> tracee's ABI and the values of other arguments (various "dispatcher"
>> calls like ioctl or prctl are good example).  Do you have any ideas
>> regarding the subject?
>
> But it is still possible to access such arguments by means of FFI
> library -- one just needs ptr_to_kulong() and information on current
> architecture/personality. And what's the problem with the "dispatcher"
> calls?
>
> A Lua library that provides definitions of various structures and
> decodes syscalls can later be implemented on top of that, but this is
> not a part of my proposal.
The problem with accessing data is that you should replicate all the
decoder's knowledge regarding argument semantics in Lua in order to
access them properly. But looks like indeed this is outside of the
scope of your proposal, so let's keep it this way.

> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: GSOC: 2017 : I want to contribute

2017-04-02 Thread Eugene Syromyatnikov
On Sun, Apr 2, 2017 at 2:41 PM, sandhya bankar
<bankarsandhya...@gmail.com> wrote:
> Hello,
Hello.

>   I am Sandhya, an opensource enthusiast and a  contributor to the
> linux-kernel project. I'm currently an Kernel Intern at The Linux Foundation
> through Outreachy Dec-2016. I started contributing to open source almost 1
> year before.
> I would like to join strace project and work on the same. I have used strace
> so many times in academics and in my project. I would like to contribute to
> this magical utility.
>
> I have one doubt, Can anybody quickly guide me ?
Please take a look at the following:
* https://sourceforge.net/p/strace/mailman/strace-devel/ is an archive
of this mailing list, it contains lots of information and worth
searching
* https://sourceforge.net/p/strace/wiki/Guide%20for%20new%20contributors/
is a short guide for new contributors
* https://github.com/strace/strace/blob/master/README-hacking contains
some information regarding contribution requirements. Other README*
files are also worth a look.

> I have added couple of testcases but not able to build and test it. How we
> should build and execute the test available in tests folder ?
Test suite can be run with "make check". Specific test can be run with
make check TESTS="test_name".

> Thanks,
> Sandhya Bankar

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [RFC] GSoC 2017 proposal draft: advanced syscall tampering and filtering with Lua

2017-03-29 Thread Eugene Syromyatnikov
Hello.

On Sat, Mar 25, 2017 at 10:58:16PM +0300, Victor Krapivensky wrote:
> The first draft of my proposal can be found here:
> 
> https://gist.github.com/shdown/a1f3f2bce1210f55389bacf406030b25
> 
> As for now, it is incomplete (does not even contain schedule) and will
> surely be updated and enhanced later.
> 
> Please provide some feedback.

The one quite interesting aspect, from my point of view, is the way you
expect to access (and modify) argument data. For example, some syscalls
(like sendmsg or evdev/dm ioctls or siginfo-related ones) have quite
non-trivial argument semantics — pointers upon pointers upon pointers;
related decoders have quite significant amount of code in order to
retrieve them. Note also, that argument decoding also depends on
tracee's ABI and the values of other arguments (various "dispatcher"
calls like ioctl or prctl are good example).  Do you have any ideas
regarding the subject?

There was some project last year [1], which constructed some internal
representation of retrieved syscall arguments as a byproduct of its
implementation, but it is strictly tailored for usage by the output
formatting backend.

[1] https://github.com/lineprinter/strace/wiki/GSoC-related-information

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Introduction and [PATCH V1]

2017-03-24 Thread Eugene Syromyatnikov
On Fri, Mar 24, 2017 at 8:12 AM, Rohan Rajak <rajakroha...@gmail.com> wrote:
> Hi Sir,
>
> I am not really understanding whether we are covering majority of strace
> code and kernel as well.
Well, covering the kernel code is not a target of the test suite. Test
suite is aimed to check that strace's behaviour is correct (in many
senses). Significant part of it checks decoders, and in terms of
decoder tests there are the following criterias:
 * All code paths should be covered. Unfortunately, current system
counts coverage independent of callee, thus if some utility function
is called at least once, it deemed covered. What is more important,
however, is that all relevant code (including common utility) has been
covered for each decoder, as it allows for checking all thecorner
cases specific to each decoder (for example, printstr_ex has a lot of
options and we should make sure that right options are called in right
cases and we are getting output we expected in regards to trimming,
ellipsis, quotes, escaping, etc).
 * As it is intended to make strace the debugging tool, it is aimed
that strace's output mimics the way kernel interprets incoming
arguments. It's quite difficult to formalise this properly, as it
boils down to the syscall code and its callees (for example, how uid
65535/4294967295 should be printed, if some syscalls interpret it as a
special value and others just as an invalid one; or how to interpret
ignored arguments). However, in term of testcase we at least
definitely know that we should at least cover this case and check that
it prints what we decide it should print.
 * As strace's output is for people, not machines, it can be shortened
and abbreviated in various ways. As it creates some variation and some
peculiarity to strace's output, all these cases should be covered too
(whether all hese shorthands are used only in case we expect it and
nowhere else).

> Also there is a difference of coverage on codecov
> site and on other systems I have tested, how would you suggest to solve that
> .

As noted in [1], some tests (and, to some extent, strace's behaviour)
are dependent on the version of kernel headers, libc, and kernel ABI
used for building strace or tests, respectively. thus the discrepancy.

[1] https://sourceforge.net/p/strace/mailman/message/35732562/

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Introduction and [PATCH V1]

2017-03-21 Thread Eugene Syromyatnikov
On Sun, Mar 19, 2017 at 03:27:18PM +0530, Rohan Rajak wrote:
> Hi,
> I am Rohan Rajak a 3rd year computer science student at IIT Kharagpur,
> (India).
> My interest lies in System Programming. I have taken courses like operating
> system, computer networks etc. And I am familiar with multithreaded and
> shell programming.
> 
> I am looking forward to work in comprehensive test suite project of strace
> in GSOC 2017. I have gone through most of the conversation in the mailing
> list (recent and archive), I know I took time to get started as I was
> trying hard to understand it.
> 
> 
> I have implemented an exit and an error message in the file test/skodic.c
> to demonstrate races.
> I have exited with -1 when the file descriptor haven't found any file.
> 
> please review my patch

Thanks for your contribution. Unfortunately, this demo program (as well as other
ones in the test directory) is long abandoned. However, your e-mail has
motivated to update both this demo (see commit ec548045) and description
for the whole directory (see commit f9390b96). It may worth noting that
currently strace employs test suite located in tests directory. It can
be run with `make check' command, "check" being a standard target in
accordance with GNU coding guidelines.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Q: statfs related syscalls (was: Re: GSOC: Introduction)

2017-03-21 Thread Eugene Syromyatnikov
On Sat, Mar 18, 2017 at 08:29:46PM +0530, Abhishek Tiwari wrote:
> fixed. Patch attached.
Please look at the rest of the e-mail you have replied to.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v6] Implement -e trace=%statfs option for tracing statfs like syscalls

2017-03-21 Thread Eugene Syromyatnikov
> None of stat related syscalls have their corresponding flag set.
> $  grep -nr '_\(\|f\|l\)stat' linux/*/syscallent*
> 
> Should these be updated with their corresponding tags ?
> fstatfs*-> TD
> lstat*-> TD
> {,old_}stat*-> TF
> or are they intensional?
Most probably these compatibility calls has been overlooked. As they are
has the same semantics, they indeed should be a part of appropriate
syscall groups.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v4] Implemented -e trace=%clock option

2017-03-21 Thread Eugene Syromyatnikov
On Sun, Mar 19, 2017 at 07:37:22AM +0530, Rishi Bhatt wrote:
> On Sun, Mar 19, 2017 at 6:34 AM, Dmitry V. Levin  wrote:
> > > From: Rishi Bhatt 
> > > Subject: [PATCH v4] Implemented -e trace=%clock option
> >
> > v4? Again?
> >
> 
> So which one is it?
Judging by the amount of patches sent, it's more like v8. But I think
Dmitry refers to the fact that you had already sent e-mail which had subject
"[PATCH v4] Implemented..."

Also, regarding the subject, in strace project traditionally commit message
should be phrased as a sentence in active voice, present simple tense.

> > > +#define TRACE_CLOCK  02  /*Trace clock-related syscalls. */
> >
> > Unfortunately, I have to repeat myself:
> >
> > "Please follow the style used in the file you are patching,
> > in particular, the style of comments."
> >
> 
> In clock.test,and any other file?
In clock.test and any other file. I assume Dmitry refers to absence of
space character before the start of comment body.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH 1/2] Add ioctl namespace entries from Linux 4.11

2017-03-18 Thread Eugene Syromyatnikov
On Sat, Mar 18, 2017 at 07:47:46PM +0700, Nikolay Marchuk wrote:

git am applies this mail as a single commit, it this behaviour intended?

It also (still) does not contain a summary of changes, as I noted
yesterday.

The compilation warnings and dubious rc check noted in the previous e-mail are
still present.

> ---
>  linux/32/ioctls_inc_align16.h | 2 ++
>  linux/32/ioctls_inc_align32.h | 2 ++
>  linux/32/ioctls_inc_align64.h | 2 ++
>  linux/64/ioctls_inc.h | 2 ++
>  linux/x32/ioctls_inc0.h   | 2 ++
>  5 files changed, 10 insertions(+)
> 
> diff --git a/linux/32/ioctls_inc_align16.h b/linux/32/ioctls_inc_align16.h
> index 71c9d18..4e90801 100644
> --- a/linux/32/ioctls_inc_align16.h
> +++ b/linux/32/ioctls_inc_align16.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> diff --git a/linux/32/ioctls_inc_align32.h b/linux/32/ioctls_inc_align32.h
> index 699eb90..4fcada1 100644
> --- a/linux/32/ioctls_inc_align32.h
> +++ b/linux/32/ioctls_inc_align32.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> diff --git a/linux/32/ioctls_inc_align64.h b/linux/32/ioctls_inc_align64.h
> index fcd9d8c..3734082 100644
> --- a/linux/32/ioctls_inc_align64.h
> +++ b/linux/32/ioctls_inc_align64.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> diff --git a/linux/64/ioctls_inc.h b/linux/64/ioctls_inc.h
> index f59fe11..b75abec 100644
> --- a/linux/64/ioctls_inc.h
> +++ b/linux/64/ioctls_inc.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> diff --git a/linux/x32/ioctls_inc0.h b/linux/x32/ioctls_inc0.h
> index 46303d1..81dd21c 100644
> --- a/linux/x32/ioctls_inc0.h
> +++ b/linux/x32/ioctls_inc0.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> -- 
> 2.1.4
> 
> 
> >From c9d54f099021f69ead791da8c5a533f14bb40a8a Mon Sep 17 00:00:00 2001
> From: Nikolay Marchuk 
> Date: Sat, 18 Mar 2017 19:23:06 +0700
> Subject: [PATCH 2/2] Implemented parser for NS_* ioctl commands.
> 
> ---
>  Makefile.am   |   1 +
>  configure.ac  |   1 +
>  defs.h|   1 +
>  ioctl.c   |   2 +
>  nsfs.c|  94 

Re: [PATCH] Implemented parser for NS_* ioctl commands.

2017-03-18 Thread Eugene Syromyatnikov
Please avoid using mail clients which break formatting. This patch does
not apply.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH] Implemented parser for NS_* ioctl commands.

2017-03-18 Thread Eugene Syromyatnikov
This patch does not apply with the following diagnostics:

fatal: corrupt patch at line 15
error: could not build fake ancestor
Patch failed at 0001 Add ioctl namespace entries from Linux 4.11

then,

error: patch failed: Makefile.am:172
error: Makefile.am: patch does not apply
error: patch failed: configure.ac:366
error: configure.ac: patch does not apply
error: patch failed: ioctl.c:280
error: ioctl.c: patch does not apply
error: patch failed: tests/Makefile.am:184
error: tests/Makefile.am: patch does not apply


On Sat, Mar 18, 2017 at 03:55:46PM +0700, Nikolay Marchuk wrote:
> >From 33d0341f2705e067b7617a6ec30e442d707714d0 Mon Sep 17 00:00:00 2001
> From: Nikolay Marchuk 
> Date: Thu, 16 Mar 2017 17:49:25 +0700
> Subject: [PATCH 1/2] Add ioctl namespace entries from Linux 4.11
> 
> ---
>  linux/32/ioctls_inc_align16.h | 2 ++
>  linux/32/ioctls_inc_align32.h | 2 ++
>  linux/32/ioctls_inc_align64.h | 2 ++
>  linux/64/ioctls_inc.h | 2 ++
>  linux/x32/ioctls_inc0.h   | 2 ++
>  5 files changed, 10 insertions(+)
> 
> diff --git a/linux/32/ioctls_inc_align16.h b/linux/32/ioctls_inc_align16.h
> index 71c9d18..4e90801 100644
> --- a/linux/32/ioctls_inc_align16.h
> +++ b/linux/32/ioctls_inc_align16.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c,
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18
> },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE,
> 0x4e41, 0x48 },
> diff --git a/linux/32/ioctls_inc_align32.h b/linux/32/ioctls_inc_align32.h
> index 699eb90..4fcada1 100644
> --- a/linux/32/ioctls_inc_align32.h
> +++ b/linux/32/ioctls_inc_align32.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c,
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18
> },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE,
> 0x4e41, 0x48 },
> diff --git a/linux/32/ioctls_inc_align64.h b/linux/32/ioctls_inc_align64.h
> index fcd9d8c..3734082 100644
> --- a/linux/32/ioctls_inc_align64.h
> +++ b/linux/32/ioctls_inc_align64.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c,
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18
> },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE,
> 0x4e41, 0x48 },
> diff --git a/linux/64/ioctls_inc.h b/linux/64/ioctls_inc.h
> index f59fe11..b75abec 100644
> --- a/linux/64/ioctls_inc.h
> +++ b/linux/64/ioctls_inc.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c,
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18
> },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE,
> 0x4e41, 0x48 },
> diff --git a/linux/x32/ioctls_inc0.h b/linux/x32/ioctls_inc0.h
> index 46303d1..81dd21c 100644
> --- a/linux/x32/ioctls_inc0.h
> +++ b/linux/x32/ioctls_inc0.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c,
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18
> },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", 

Re: Q: statfs related syscalls (was: Re: GSOC: Introduction)

2017-03-18 Thread Eugene Syromyatnikov
On Sat, Mar 18, 2017 at 02:49:48PM +0530, Abhishek Tiwari wrote:
> Going with the above description for narrow statfs->
> 
> Is naming %statfs = statfs+statfs64 as TRACE_NSTATFS and shorthand as TNS 
> fine ?

So, after some thinking, I have the following scheme in mind:

{old,}stat{,64} TRACE_STAT  TST
{old,}lstat{,64}TRACE_LSTAT TLST
{old,new,}fstat{,at}64  TRACE_FSTAT TFST
{old,new,}{,l,f}stat{,x,at}{,64}
TRACE_STAT_LIKE TSTA ("stat alike")
statfs{,64} TRACE_STATFSTSF
fstatfs{,64}TRACE_FSTATFS   TFSF
{,f}statfs{,64}, ustat  TRACE_STATFS_LIKE   TSFA ("statfs alike")

Calls with bsd43_/osf_/posix_/svr4_/sysv_ prefixes go to the
corresponding calls without them.

I'm not really sure about {svr4,sysv}_{,f}statvfs, but they are decoded as
printargs and looks like they should be related to {,f}statfs calls.

Does it make any sense?

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v6] Implement decoding of statx syscall

2017-03-18 Thread Eugene Syromyatnikov
On Fri, Mar 17, 2017 at 08:08:29PM +0300, Victor Krapivensky wrote:
<...>
> --- /dev/null
> +++ b/statx.c
> @@ -0,0 +1,111 @@
> +/*
> + * Copyright (c) 2017 The strace developers.
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + * 3. The name of the author may not be used to endorse or promote products
> + *derived from this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#include "defs.h"
> +#include "statx.h"
> +
> +#include 
> +
> +#include "xlat/statx_masks.h"
> +#include "xlat/statx_attrs.h"
> +#include "xlat/at_statx_sync_types.h"
> +
> +SYS_FUNC(statx)
> +{
> + if (entering(tcp)) {
> + print_dirfd(tcp, tcp->u_arg[0]);
> + printpath(tcp, tcp->u_arg[1]);
> + tprints(", ");
> + if (printflags(at_flags, tcp->u_arg[2] & ~AT_STATX_SYNC_TYPE,
> +NULL))
> + {
> + tprints("|");
I haven't look at v7 of the patch yet, but coverage [1] shows that at least
this line is not covered by the test.

> + }
> + printxval(at_statx_sync_types,
> +   tcp->u_arg[2] & AT_STATX_SYNC_TYPE, "AT_STATX_???");
> + tprints(", ");
> + printflags(statx_masks, tcp->u_arg[3], "STATX_???");
> + tprints(", ");
> + } else {
> +#define PRINT_FIELD_U(field) \
> + tprintf(", %s=%llu", #field, (unsigned long long) stx.field)
> +
> +#define PRINT_FIELD_TIME(field)  
> \
> + do {\
> + tprints(", " #field "=");   \
> + tprints(sprinttime(stx.field.sec)); \
> + if (stx.field.nsec) \
Only one branch in regards of of stx.field.nsec value is covered in all
instances of this macro.

> + tprintf(".%09" PRId32, stx.field.nsec); \
> + } while (0)
> +
> + struct_statx stx;
> + if (umove_or_printaddr(tcp, tcp->u_arg[4], )) {
> + return 0;
> + }
> +
> + tprints("{stx_mask=");
> + printflags(statx_masks, stx.stx_mask, "STATX_???");
> +
> + if (!abbrev(tcp)) {
Only branch with abbrev(tcp) == 0 is covered.

> + PRINT_FIELD_U(stx_blksize);
> + }
> +
> + tprints(", stx_attributes=");
> + printflags(statx_attrs, stx.stx_attributes, "STATX_ATTR_???");
> +
> + if (!abbrev(tcp)) {
> + PRINT_FIELD_U(stx_nlink);
> + printuid(", stx_uid=", stx.stx_uid);
> + printuid(", stx_gid=", stx.stx_gid);
> + }
> +
> + tprints(", stx_mode=");
> + print_symbolic_mode_t(stx.stx_mode);
> +
> + if (!abbrev(tcp)) {
> + PRINT_FIELD_U(stx_ino);
> + }
> +
> + PRINT_FIELD_U(stx_size);
> +
> + if (!abbrev(tcp)) {
> + PRINT_FIELD_U(stx_blocks);
> + PRINT_FIELD_TIME(stx_atime);
> + PRINT_FIELD_TIME(stx_btime);
> + PRINT_FIELD_TIME(stx_ctime);
> + PRINT_FIELD_TIME(stx_mtime);
> + PRINT_FIELD_U(stx_rdev_major);
> + PRINT_FIELD_U(stx_rdev_minor);
> + PRINT_FIELD_U(stx_dev_major);
> + PRINT_FIELD_U(stx_dev_minor);
> + } else {
> + tprints(", ...");
... and this one, but this is a common problem of all current *stat*
checks.

> + 

Re: Q: statfs related syscalls (was: Re: GSOC: Introduction)

2017-03-18 Thread Eugene Syromyatnikov
On Thu, Mar 16, 2017 at 12:24 AM, Dmitry V. Levin <l...@altlinux.org> wrote:
> On Wed, Mar 15, 2017 at 11:14:29PM +0530, Abhishek Tiwari wrote:
> [...]
>> Is it fine to group statfs+ statfs64+ fstatfs + fstatfs64 + ustat  as
>> %statfs or it should be (statfs+statfs64 + ustat) and
>> (fstatfs+ftsatfs64) i.e. two different classes ?
>
> Well, I don't have a ready answer to this question.
>
> From one side, three narrow classes (%statfs == statfs+statfs64,
> %fstatfs == fstatfs+fstatfs64, and ustat itself) would be a finer
> instrument than a single wide class.  I'm not sure whether narrow statfs
> classes will be of any practical use, though.  If we've choosen this
> approach, we could use, say, %allstatfs as a name for the wide class.
>
> From another side, a single wide class is simpler to use.
> However, once %statfs is taken for the wide class, it wouldn't be easy to
> find a good alternative name if someday we decide to create narrow
> classes.
>
> Does anybody else have an opinion on this?

Since both wide and narrow syscall classes have they own use cases, it
makes sense to support both. Dmitry has suggested %%statfs designation
for a wide syscall class, and to me it looks like not a bad idea.

>
> --
> ldv
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: GSOC: Introduction

2017-03-17 Thread Eugene Syromyatnikov
On Thu, Mar 16, 2017 at 10:07:27PM +0530, Abhishek Tiwari wrote:
> From 38ea98c7ba87bc485d8af34fc401f46b05b2c035 Mon Sep 17 00:00:00 2001
> From: Abhishek Tiwari 
> Date: Thu, 16 Mar 2017 16:55:44 +0530
> Subject: [PATCH v4] Implement -e trace=%statfs option for tracing statfs like 
> syscalls.
> 
>   linux/*/syscallent.h part is modified automatically by:
> 
>   git grep -Fl 'statfs' linux/*/syscallent* | xargs sed -i 
> 's/TD\(,[[:space:]]*SEN(statfs\)/TD|SFS\1/'
>   git grep -Fl 'statfs' linux/*/syscallent* | xargs sed -i 
> 's/TF\(,[[:space:]]*SEN(statfs\)/TF|SFS\1/'
>   git grep -Fl 'statfs' linux/*/syscallent* | xargs sed -i 
> 's/0\(,[[:space:]]*SEN(osf_statfs\)/SFS\1/'
>   git grep -Fl 'statfs' linux/*/syscallent* | xargs sed -i 
> 's/0\(,[[:space:]]*SEN(.*_statfs\)/SFS\1/'
>   git grep -Fl 'ustat' linux/*/syscallent* | xargs sed -i 
> 's/0\(,[[:space:]]*SEN(.*_ustat\)/SFS\1/'
> 
> * linux/32/syscallent.h: Add SFS flag for stat-like sycalls.
"T" in these shorthand flags is for "trace", maybe it is a good idea to
follow this convention. On the other side, if blindly follow this rule, size of
shorthand would be gargantuan 4 chars.

Also, from my point of view, it's quite strange to include ustat and do
not include fstatfs, since, well, they are equivalently similar to statfs.

> * linux/64/syscallent.h: Likewise.
> * linux/aarch64/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-compat.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.
> * qualify.c (lookup_class): Add SCHED_STAT for "%statfs".
> * strace.1 (.SS Filtering): Add information about %statfs syscall class.
> * syscall.c: Alias SFS to TRACE_STATFS around syscallent.h inclusion.
> * sysent.h (TRACE_STATFS): New definition.
> * tests/Makefile.am (DECODER_TESTS): Add trace_statfs.test.
> * tests/ksysent.c: Define SFS to 0.
> * tests/nsyscalls.c: Likewise.
> * tests/trace_statfs.test: New test.
> ---
>  linux/32/syscallent.h  |  2 +-
>  linux/64/syscallent.h  |  2 +-
>  linux/aarch64/syscallent.h |  4 +--
>  linux/alpha/syscallent.h   |  8 +++---
>  linux/arm/syscallent.h |  6 ++---
>  linux/avr32/syscallent.h   |  6 ++---
>  linux/bfin/syscallent.h|  6 ++---
>  linux/crisv10/syscallent.h |  6 ++---
>  linux/hppa/syscallent.h|  6 ++---
>  linux/i386/syscallent.h|  6 ++---
>  linux/ia64/syscallent.h|  6 ++---
>  linux/m68k/syscallent.h|  6 ++---
>  linux/microblaze/syscallent.h  |  6 ++---
>  linux/mips/syscallent-compat.h |  8 +++---
>  linux/mips/syscallent-n32.h|  6 ++---
>  linux/mips/syscallent-n64.h|  4 +--
>  linux/mips/syscallent-o32.h|  6 ++---
>  linux/powerpc/syscallent.h |  6 ++---
>  linux/powerpc64/syscallent.h   |  6 ++---
>  linux/s390/syscallent.h|  6 ++---
>  linux/s390x/syscallent.h   |  6 ++---
>  linux/sh/syscallent.h  |  6 ++---
>  linux/sh64/syscallent.h|  6 ++---
>  linux/sparc/syscallent.h   |  6 ++---
>  linux/sparc64/syscallent.h |  6 ++---
>  linux/x32/syscallent.h |  4 +--
>  linux/x86_64/syscallent.h  |  4 +--
>  linux/xtensa/syscallent.h  |  6 ++---
>  qualify.c  |  1 +
>  strace.1   |  3 +++
>  syscall.c  |  2 ++
>  sysent.h   |  1 +
>  tests/Makefile.am  |  1 +
>  tests/ksysent.c|  1 +
>  tests/nsyscalls.c  |  1 +
>  tests/trace_statfs.test| 55 
> ++
>  36 files changed, 143 insertions(+), 78 deletions(-)
>  create mode 100755 tests/trace_statfs.test
> 
> diff --git a/linux/32/syscallent.h b/linux/32/syscallent.h
> index a8f9510..72a3ebe 100644
> --- a/linux/32/syscallent.h
> +++ b/linux/32/syscallent.h
> @@ -44,7 +44,7 @@
>  [ 40] = { 5, TF, SEN(mount), "mount" 
> },
>  [ 41] = { 2, TF, SEN(pivotroot), "pivot_root"
> },
>  [ 42] = { 3, 0,   

Re: [PATCH v6] Implement decoding of statx syscall

2017-03-17 Thread Eugene Syromyatnikov
On Fri, Mar 17, 2017 at 08:08:29PM +0300, Victor Krapivensky wrote:
> * linux/i386/syscallent.h [383]: Add statx entry.
> * linux/x32/syscallent.h [332]: Likewise.
> * linux/x86_64/syscallent.h [332]: Likewise.
> * pathtrace.c (pathtrace_match): Handle SEN_statx.
> * statx.c: New file.
> * statx.h: Likewise.
> * Makefile.am (strace_SOURCES): Add them.
> * tests/.gitignore: Add statx.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (DECODER_TESTS): Add statx.test.
> * tests/statx.c: New file.
> * tests/statx.test: Likewise.
> * tests/xstatx.c: Modify to support statx.
> * xlat/at_statx_sync_types.in: New file.
> * xlat/statx_attrs.in: Likewise.
> * xlat/statx_masks.in: Likewise.
> * NEWS: Mention this change.
> ---
>  Makefile.am |   2 +
>  NEWS|   1 +
>  linux/i386/syscallent.h |   1 +
>  linux/x32/syscallent.h  |   3 +-
>  linux/x86_64/syscallent.h   |   1 +
>  pathtrace.c |   1 +
>  statx.c | 111 ++
>  statx.h |  69 
>  tests/.gitignore|   1 +
>  tests/Makefile.am   |   2 +
>  tests/statx.c   |  70 +
>  tests/statx.test|   5 ++
>  tests/xstatx.c  | 188 
> 
>  xlat/at_statx_sync_types.in |   5 ++
>  xlat/statx_attrs.in |   6 ++
>  xlat/statx_masks.in |  15 
>  16 files changed, 465 insertions(+), 16 deletions(-)
>  create mode 100644 statx.c
>  create mode 100644 statx.h
>  create mode 100644 tests/statx.c
>  create mode 100755 tests/statx.test
>  create mode 100644 xlat/at_statx_sync_types.in
>  create mode 100644 xlat/statx_attrs.in
>  create mode 100644 xlat/statx_masks.in
> 
> diff --git a/Makefile.am b/Makefile.am
> index 7e837b3..65177a6 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -232,6 +232,8 @@ strace_SOURCES =  \
>   stat64.c\
>   statfs.c\
>   statfs.h\
> + statx.c \
> + statx.h \
>   strace.c\
>   swapon.c\
>   syscall.c   \
> diff --git a/NEWS b/NEWS
> index 77b6678..b2bb644 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -9,6 +9,7 @@ Noteworthy changes in release ?.?? (-??-??)
>  * Improvements
>* Enhanced decoding of sched_setattr syscall.
>* Added -e trace=%sched option for tracing sched_* syscalls.
> +  * Implemented decoding of statx syscall.
This hunk does not apply, please rebase to the latest version.

error: patch failed: NEWS:9
error: NEWS: patch does not apply

>  
>  * Bug fixes
>* Fixed decoding of flags argument of preadv2 and pwritev2 syscalls on x32.
> diff --git a/linux/i386/syscallent.h b/linux/i386/syscallent.h
> index 8ef1b1c..84c5bde 100644
> --- a/linux/i386/syscallent.h
> +++ b/linux/i386/syscallent.h
> @@ -408,6 +408,7 @@
>  [380] = { 4, TM|SI,  SEN(pkey_mprotect), "pkey_mprotect" 
> },
>  [381] = { 2, 0,  SEN(pkey_alloc),"pkey_alloc"
> },
>  [382] = { 1, 0,  SEN(pkey_free), "pkey_free" 
> },
> +[383] = { 5, TD|TF,  SEN(statx), "statx" 
> },
>  
>  #define SYS_socket_subcall   400
>  #include "subcall.h"
> diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h
> index 2699bc0..7f4e45b 100644
> --- a/linux/x32/syscallent.h
> +++ b/linux/x32/syscallent.h
> @@ -330,7 +330,8 @@
>  [329] = { 4, TM|SI,  SEN(pkey_mprotect), "pkey_mprotect" 
> },
>  [330] = { 2, 0,  SEN(pkey_alloc),"pkey_alloc"
> },
>  [331] = { 1, 0,  SEN(pkey_free), "pkey_free" 
> },
> -[332 ... 511] = { },
> +[332] = { 5, TD|TF,  SEN(statx), "statx" 
> },
> +[333 ... 511] = { },
>  /*
>   * x32-specific system call numbers start at 512 to avoid cache impact
>   * for native 64-bit operation.
> diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h
> index a1a268e..2624947 100644
> --- a/linux/x86_64/syscallent.h
> +++ b/linux/x86_64/syscallent.h
> @@ -330,3 +330,4 @@
>  [329] = { 4, TM|SI,  SEN(pkey_mprotect), "pkey_mprotect" 
> },
>  [330] = { 2, 0,  SEN(pkey_alloc),"pkey_alloc"
> },
>  [331] = { 1, 0,  SEN(pkey_free), "pkey_free" 
> },
> +[332] = { 5, TD|TF,  SEN(statx), "statx" 
> },
> diff --git a/pathtrace.c b/pathtrace.c
> index d991aed..90974f4 100644
> --- a/pathtrace.c
> +++ b/pathtrace.c
> @@ -183,6 +183,7 @@ pathtrace_match(struct tcb *tcp)
>   case SEN_newfstatat:
>   case SEN_openat:
>   case SEN_readlinkat:
> + case SEN_statx:
>   case SEN_unlinkat:
>   case SEN_utimensat:
>   /* fd, path */
> diff --git 

Re: Gsoc Introduction.

2017-03-17 Thread Eugene Syromyatnikov
On Fri, Mar 17, 2017 at 06:35:09PM +0100, Eugene Syromyatnikov wrote:
> Please format function declaration as following:
> 
> int
> nsfs_ioctl(struct tcb *tcp, unsigned int code, kernel_ulong_t arg) {
Oops. Opening curly brace should be on the next line, like this:

int
nsfs_ioctl(struct tcb *tcp, unsigned int code, kernel_ulong_t arg)
{

>   if (!umove_or_printaddr(tcp, arg, )) {
>   printuid(", [", uid);
>   tprints("]");
>   }
Ahem. I forgot that the comma should be also printed in case of address
printing too, so it should be written like this:

tprints(", ")
if (!umove_or_printaddr(tcp, arg, )) {
printuid("[", uid);
tprints("]");
}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Gsoc Introduction.

2017-03-17 Thread Eugene Syromyatnikov
On Fri, Mar 17, 2017 at 08:12:02AM +0700, Nikolay Marchuk wrote:
> Thank you for review. I have rewritten my code, but I still have some
> problems with NS_GET_NSTYPE parsing without additional argument. And new
> tests are not fully tested, because I haven't build kernel yet.

Please send patches inline if possible, it makes easier to review and discuss
them.

git am fails with the following diagnostics:

.git/rebase-apply/patch:268: trailing whitespace.

fatal: 1 line adds whitespace errors.


> From 8789c3c73f1ad0b260195a1a3214ff965d6f42d5 Mon Sep 17 00:00:00 2001
> From: Marchuk Nikolay 
> Date: Thu, 16 Mar 2017 17:49:25 +0700
> Subject: [PATCH 1/2] Add ioctl namespace entries from Linux 4.11
> 

Please provide a change summary in the GNU change log format. Please refer to
README-hacking and
https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html
for details.

> Signed-off-by: Marchuk Nikolay 

"Signed-off-by" is not used in strace project usually.

> ---
>  linux/32/ioctls_inc_align16.h | 2 ++
>  linux/32/ioctls_inc_align32.h | 2 ++
>  linux/32/ioctls_inc_align64.h | 2 ++
>  linux/64/ioctls_inc.h | 2 ++
>  linux/x32/ioctls_inc0.h   | 2 ++
>  5 files changed, 10 insertions(+)
> 
> diff --git a/linux/32/ioctls_inc_align16.h b/linux/32/ioctls_inc_align16.h
> index 71c9d18..4e90801 100644
> --- a/linux/32/ioctls_inc_align16.h
> +++ b/linux/32/ioctls_inc_align16.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> diff --git a/linux/32/ioctls_inc_align32.h b/linux/32/ioctls_inc_align32.h
> index 699eb90..4fcada1 100644
> --- a/linux/32/ioctls_inc_align32.h
> +++ b/linux/32/ioctls_inc_align32.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> diff --git a/linux/32/ioctls_inc_align64.h b/linux/32/ioctls_inc_align64.h
> index fcd9d8c..3734082 100644
> --- a/linux/32/ioctls_inc_align64.h
> +++ b/linux/32/ioctls_inc_align64.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> diff --git a/linux/64/ioctls_inc.h b/linux/64/ioctls_inc.h
> index f59fe11..b75abec 100644
> --- a/linux/64/ioctls_inc.h
> +++ b/linux/64/ioctls_inc.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 },
> +{ "linux/nsfs.h", "NS_GET_OWNER_UID", _IOC_NONE, 0xb704, 0x00 },
>  { "linux/nsfs.h", "NS_GET_PARENT", _IOC_NONE, 0xb702, 0x00 },
>  { "linux/nsfs.h", "NS_GET_USERNS", _IOC_NONE, 0xb701, 0x00 },
>  { "linux/nvme_ioctl.h", "NVME_IOCTL_ADMIN_CMD", _IOC_READ|_IOC_WRITE, 
> 0x4e41, 0x48 },
> diff --git a/linux/x32/ioctls_inc0.h b/linux/x32/ioctls_inc0.h
> index 46303d1..81dd21c 100644
> --- a/linux/x32/ioctls_inc0.h
> +++ b/linux/x32/ioctls_inc0.h
> @@ -1455,6 +1455,8 @@
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_ALLOC_RANGE", _IOC_WRITE, 0x6e8c, 
> 0x10 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SET_SUINFO", _IOC_WRITE, 0x6e8d, 0x18 },
>  { "linux/nilfs2_api.h", "NILFS_IOCTL_SYNC", _IOC_READ, 0x6e8a, 0x08 },
> +{ "linux/nsfs.h", "NS_GET_NSTYPE", _IOC_NONE, 0xb703, 0x00 

Re: [PATCH] Decode RUSAGE_THREAD

2017-03-15 Thread Eugene Syromyatnikov
Please do not answer in an existing thread and start a new thread for
a new separate patch.

On Wed, Mar 15, 2017 at 3:25 PM, Victor Krapivensky
<krapivenskiy...@phystech.edu> wrote:
> * xlat/usagewho.in: Add RUSAGE_THREAD.
> * tests/getrusage.c: Test decoding of RUSAGE_THREAD.
> ---
>  tests/getrusage.c | 21 +++--
>  xlat/usagewho.in  |  1 +
>  2 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/tests/getrusage.c b/tests/getrusage.c
> index 8b76eff..ba1a7ef 100644
> --- a/tests/getrusage.c
> +++ b/tests/getrusage.c
> @@ -25,7 +25,6 @@
>   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
>   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>   */
> -
Is this intentional?

>  #include "tests.h"
>  #include 
>
> @@ -36,17 +35,16 @@
>  # include 
>  # include 
>
> -int
> -main(void)
> +int invoke_print(int who, const char *who_str, struct rusage *usage)
Please follow the same coding style (function return type on the separate line).

>  {
> -   struct rusage *const usage = tail_alloc(sizeof(struct rusage));
> -   int rc = syscall(__NR_getrusage, RUSAGE_SELF, usage);
> -   printf("getrusage(RUSAGE_SELF, {ru_utime={tv_sec=%jd, tv_usec=%jd}"
> +   int rc = syscall(__NR_getrusage, who, usage);
> +   printf("getrusage(%s, {ru_utime={tv_sec=%jd, tv_usec=%jd}"
>", ru_stime={tv_sec=%jd, tv_usec=%jd}, ru_maxrss=%lu"
>", ru_ixrss=%lu, ru_idrss=%lu, ru_isrss=%lu, ru_minflt=%lu"
>", ru_majflt=%lu, ru_nswap=%lu, ru_inblock=%lu"
>", ru_oublock=%lu, ru_msgsnd=%lu, ru_msgrcv=%lu"
>", ru_nsignals=%lu, ru_nvcsw=%lu, ru_nivcsw=%lu}) = %d\n",
> +  who_str,
>(intmax_t) usage->ru_utime.tv_sec,
>(intmax_t) usage->ru_utime.tv_usec,
>(intmax_t) usage->ru_stime.tv_sec,
> @@ -56,6 +54,17 @@ main(void)
>usage->ru_nswap, usage->ru_inblock, usage->ru_oublock,
>usage->ru_msgsnd, usage->ru_msgrcv, usage->ru_nsignals,
>usage->ru_nvcsw, usage->ru_nivcsw, rc);
> +   return rc;
> +}
> +
> +int
> +main(void)
> +{
> +   struct rusage *const usage = tail_alloc(sizeof(struct rusage));
> +   (void) invoke_print(RUSAGE_SELF, "RUSAGE_SELF", usage);
> +# ifdef RUSAGE_THREAD
> +   (void) invoke_print(RUSAGE_THREAD, "RUSAGE_THREAD", usage);
You can try to use ARG_STR() macro here in order to avoid duplication
of the symbolic name, but it's a bit obscure.

> +# endif
>
> puts("+++ exited with 0 +++");
> return 0;
> diff --git a/xlat/usagewho.in b/xlat/usagewho.in
> index e2153b3..62e7352 100644
> --- a/xlat/usagewho.in
> +++ b/xlat/usagewho.in
> @@ -1,3 +1,4 @@
>  RUSAGE_SELF
>  RUSAGE_CHILDREN
>  RUSAGE_BOTH
> +RUSAGE_THREAD
It may be a good idea to add values for these xlat values (as long as
they are arch-independent) in order to depend less on kernel headers
(there is some effort to do so, but it's inconsistent and is enforced
case-by-case basis). In this case RUSAGE_THREAD can also be tested
regardless of kernel version, but it should be considered then that
kernel could return -EINVAL in case it doesn't support it.

Otherwise, patch looks good overall.

> --
> 2.10.2
>
>
> ------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Does strace support capturing session ID and process group ID?

2017-03-14 Thread Eugene Syromyatnikov
On Tue, Mar 14, 2017 at 4:42 PM, Leixiang Wu <leixiang...@stonybrook.edu> wrote:
> Hi,
>
> I am using strace to capture system call traces of a program. I would like
> to capture session ID and process group ID. Is this possible in strace? I
> looked the man page. It doens't say anything about those two process state
> information.
As strace is a system call tracer, this functionality is quite out of
its scope[1]. One can get this information from /proc/${pid}/stat, as
proc(5) suggests:

   /proc/[pid]/stat
  Status  information  about  the  process.  This is used
by ps(1).  It is defined in the kernel
  source file fs/proc/array.c.

  The fields, in order, with their proper scanf(3) format
specifiers, are listed below.  Whether
  or  not  certain of these fields display valid
information is governed by a ptrace access mode
  PTRACE_MODE_READ_FSCREDS | PTRACE_MODE_NOAUDIT check
(refer  to  ptrace(2)).   If  the  check
  denies access, then the field value is displayed as 0.
The affected fields are indicated with
  the marking [PT].

<...>

  (5) pgrp  %d
The process group ID of the process.

  (6) session  %d
The session ID of the process.

[1] You can, however, try to capture setpgid/getpgid and setsid/getsid
syscalls, in case you are sure tracee calls these.

> Best,
> Leixiang Wu
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Implemented -e trace=%clock option

2017-03-13 Thread Eugene Syromyatnikov
> diff --git a/strace.1 b/strace.1
> index 9b69ec22..c46ca3ba 100644
> --- 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.
Not sure that this plus sign in the beginning of the line is intended.

--
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: GSOC: Introduction

2017-03-13 Thread Eugene Syromyatnikov
On Sat, Mar 11, 2017 at 02:26:42PM +0530, Abhishek Tiwari wrote:
> On Sat, Mar 11, 2017 at 1:46 PM, Abhishek Tiwari
>  wrote:
> > Sir, I figured out that open system call is implemented corresponding
> > to kernel version it supports, so open syscall is inside
> > linux/x32/syscallent.h while openat is used in later versions.
> > Please verify that the open-like system call list is complete.
> >
> > Implemented -e trace=%stat class and submitting patch for the same.
> > Please review.
> > traces calls that matches following->
> > fstat*
> > stat*
> > lstat
> > ustat
> > newstat*
> 
> 
> Sorry, please ignore the previous patch. There is stat_like.test file
> left unstaged.
> Please consider following patch->
Per-file summary is not in GNU change log format, please refer to
https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html .
Specifically, it lacks asterisks at the beginning of each new file
description and has excess spaces between file part and description,
otherwise looks fine.

The patch wires up {,l}stat{,64}, fstatat/fstatat64 syscalls (used for obtaining
file status), ustat syscall (which is a deprecated way to get some FS
statistics) and some statfs syscalls (which are more contemporary way
obtaining FS statistics information). On the other side, at least
fstat/fstat64, fstatfs/fstatfs64, old{,f,l}stat, osf_{,f}statfs, and various
(mostly unsupported) syscalls with osf_, svr4_, sysv_, bsd43_, and posix_
prefixes, present on alpha and mips, are omitted. I'm not sure whether
it was intended.

There are minor tabulation irregularities introduced (at least) for
newfstatat and fstatat64 syscall entries, it is better to avoid this.

> From 522cf7c76cb48fad099da086148dc0b5a41d4808 Mon Sep 17 00:00:00 2001
> From: Abhishek Tiwari 
> Date: Sat, 11 Mar 2017 14:07:46 +0530
> Subject: [PATCH v2] Implement -e trace=%stat option for tracing stat like
>  syscalls.
> 
> linux/*/syscallent.h part is modified automatically by:
> 
> git grep -Fl 'SEN(stat' linux/ | xargs sed -i 
> 's/TF\(,[[:space:]]*SEN(stat\)/TF|TST\1/'
> git grep -Fl 'SEN(fstat' linux/ | xargs sed -i 
> 's/TF\(,[[:space:]]*SEN(fstat\)/TF|TST\1/'
> git grep -Fl 'SEN(lstat' linux/ | xargs sed -i 
> 's/TF\(,[[:space:]]*SEN(lstat\)/TF|TST\1/'
> git grep -Fl 'SEN(ustat' linux/ | xargs sed -i 
> 's/0\(,[[:space:]]*SEN(ustat\)/TST\1/'
> git grep -Fl 'SEN(newfstat' linux/ | xargs sed -i 
> 's/TF\(,[[:space:]]*SEN(newfstat\)/TF|TST\1/'
> 
> sysent.h (TRACE_STAT): New definition.
> syscall.c: Alias TST to TRACE_STAT around syscallent.h inclusion.
> linux/32/syscallent.h:  Add TST flag for stat-like sycalls.
> linux/64/syscallent.h:  Likewise.
> linux/aarch64/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.
> qualify.c (lookup_class):   Add SCHED_STAT for "%stat"
> strace.1 (.SS Filtering):   Add information about %sched syscall class.
> tests/Makefile.am (DECODER_TESTS): Add stat_like.test.
> tests/ksysent.c:Define TST to 0.
> tests/nsyscalls.c:  Likewise.
> tests/stat_like.test:   New test.
> ---
>  linux/32/syscallent.h |  4 +--
>  linux/64/syscallent.h |  4 +--
>  linux/aarch64/syscallent.h| 14 +--
>  linux/alpha/syscallent.h  | 14 +--
>  linux/arm/syscallent.h| 16 ++--
>  linux/avr32/syscallent.h  | 16 ++--
>  linux/bfin/syscallent.h   | 16 ++--
>  linux/crisv10/syscallent.h| 16 ++--
>  linux/hppa/syscallent.h   | 16 ++--
>  linux/i386/syscallent.h   | 16 ++--
>  linux/ia64/syscallent.h   | 16 ++--
>  linux/m68k/syscallent.h   | 16 ++--
>  linux/microblaze/syscallent.h | 16 ++--
>  linux/mips/syscallent-n32.h   | 12 -
>  linux/mips/syscallent-n64.h   | 10 
>  linux/mips/syscallent-o32.h   | 16 ++--
>  linux/powerpc/syscallent.h| 16 ++--
>  linux/powerpc64/syscallent.h  | 12 

Re: GSoC 2017 introduction

2017-03-13 Thread Eugene Syromyatnikov
On Sat, Mar 11, 2017 at 02:51:35PM +0300, Victor Krapivensky wrote:
> Removed a trailing semicolon in a macro definition in tests/xstatx.c
> and changed copyright holders of new files to "The strace developers".
> 
> Please review this one.
> 
> I've also found a possile buffer overflow bug in unwind.c. Attaching a
> separate patch.
> 
> 
> On 03/10/2017 09:59 PM, Victor Krapivensky wrote:
> >I've also added a test, so please review.

> >From 39a1edf60cefa42d9b6e8c72ba95f684ab652c53 Mon Sep 17 00:00:00 2001
> From: Victor Krapivensky 
> Date: Thu, 9 Mar 2017 20:26:14 +0300
> Subject: [PATCH v4] Add support for statx syscall
> 

Please add change log. Please refer to README-hacking and
https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html
for reference.

> ---
>  Makefile.am |   1 +
>  linux/i386/syscallent.h |   1 +
>  linux/x32/syscallent.h  |   3 +-
>  linux/x86_64/syscallent.h   |   1 +
>  pathtrace.c |   1 +
>  statx.c | 147 
> 
>  tests/.gitignore|   1 +
>  tests/Makefile.am   |   2 +
>  tests/statx.c   |  63 +++
>  tests/statx.test|   5 ++
>  tests/xstatx.c  |  88 +-
>  xlat/at_statx_sync_types.in |   3 +
>  xlat/statx_attrs.in |   6 ++
>  xlat/statx_masks.in |  12 
>  14 files changed, 319 insertions(+), 15 deletions(-)
>  create mode 100644 statx.c
>  create mode 100644 tests/statx.c
>  create mode 100755 tests/statx.test
>  create mode 100644 xlat/at_statx_sync_types.in
>  create mode 100644 xlat/statx_attrs.in
>  create mode 100644 xlat/statx_masks.in
> 
> diff --git a/Makefile.am b/Makefile.am
> index 7e837b3..e350fd2 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -232,6 +232,7 @@ strace_SOURCES =  \
>   stat64.c\
>   statfs.c\
>   statfs.h\
> + statx.c \
>   strace.c\
>   swapon.c\
>   syscall.c   \
> diff --git a/linux/i386/syscallent.h b/linux/i386/syscallent.h
> index 8ef1b1c..84c5bde 100644
> --- a/linux/i386/syscallent.h
> +++ b/linux/i386/syscallent.h
> @@ -408,6 +408,7 @@
>  [380] = { 4, TM|SI,  SEN(pkey_mprotect), "pkey_mprotect" 
> },
>  [381] = { 2, 0,  SEN(pkey_alloc),"pkey_alloc"
> },
>  [382] = { 1, 0,  SEN(pkey_free), "pkey_free" 
> },
> +[383] = { 5, TD|TF,  SEN(statx), "statx" 
> },
>  
>  #define SYS_socket_subcall   400
>  #include "subcall.h"
> diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h
> index 2699bc0..7f4e45b 100644
> --- a/linux/x32/syscallent.h
> +++ b/linux/x32/syscallent.h
> @@ -330,7 +330,8 @@
>  [329] = { 4, TM|SI,  SEN(pkey_mprotect), "pkey_mprotect" 
> },
>  [330] = { 2, 0,  SEN(pkey_alloc),"pkey_alloc"
> },
>  [331] = { 1, 0,  SEN(pkey_free), "pkey_free" 
> },
> -[332 ... 511] = { },
> +[332] = { 5, TD|TF,  SEN(statx), "statx" 
> },
> +[333 ... 511] = { },
>  /*
>   * x32-specific system call numbers start at 512 to avoid cache impact
>   * for native 64-bit operation.
> diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h
> index a1a268e..2624947 100644
> --- a/linux/x86_64/syscallent.h
> +++ b/linux/x86_64/syscallent.h
> @@ -330,3 +330,4 @@
>  [329] = { 4, TM|SI,  SEN(pkey_mprotect), "pkey_mprotect" 
> },
>  [330] = { 2, 0,  SEN(pkey_alloc),"pkey_alloc"
> },
>  [331] = { 1, 0,  SEN(pkey_free), "pkey_free" 
> },
> +[332] = { 5, TD|TF,  SEN(statx), "statx" 
> },
> diff --git a/pathtrace.c b/pathtrace.c
> index d991aed..90974f4 100644
> --- a/pathtrace.c
> +++ b/pathtrace.c
> @@ -183,6 +183,7 @@ pathtrace_match(struct tcb *tcp)
>   case SEN_newfstatat:
>   case SEN_openat:
>   case SEN_readlinkat:
> + case SEN_statx:
>   case SEN_unlinkat:
>   case SEN_utimensat:
>   /* fd, path */
> diff --git a/statx.c b/statx.c
> new file mode 100644
> index 000..f1e8549
> --- /dev/null
> +++ b/statx.c
> @@ -0,0 +1,147 @@
> +/*
> + * Copyright (c) 2017 The strace developers.
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of 

Re: Implemented -e trace=%clock option

2017-03-12 Thread Eugene Syromyatnikov
On Sat, Mar 11, 2017 at 10:16:42PM +0530, Rishi Bhatt wrote:
> Sorry, Ignore previous attachment.
> 
> The following  patch is the implementation.
> 

I've tried to apply this, but git-am(1) failed with the following
diagnostics:

.git/rebase-apply/patch:801: trailing whitespace.
#define TC TRACE_CLOCK 
.git/rebase-apply/patch:870: trailing whitespace.
#define TC 0 
fatal: 2 lines add whitespace errors.


> On Sat, Mar 11, 2017 at 9:48 PM, Rishi Bhatt 
> wrote:
> 
> > Hi,ldv
> > i have  implemented a test for the -e trace=%clock option.
> > (tests/Makefile.am: clock.test \ )
> >
> > On Fri, Mar 10, 2017 at 10:37 PM, Dmitry V. Levin 
> > wrote:
> >
> >> On Fri, Mar 10, 2017 at 08:30:55PM +0530, Rishi Bhatt wrote:
> >> > Hey,
> >> > So for extending a trace class option syntax,i have implemented clock_*
> >> > related syscall.
> >> >
> >> > The idea came in my mind after the scheduler option was committed
> >> recently.
> >> > I thought clock related syscalls would be good.
> >>
> >> Yes, why not.
> >>
> >> > So i have attached the patch,please review it and give me the feedback.
> >>
> >> Thanks.  Any change that adds new functionality needs an appropriate test,
> >> so please resubmit the patch with a test.
> >>
> >>
> >> --
> >> ldv
> >>
> >> 
> >> --
> >> Announcing the Oxford Dictionaries API! The API offers world-renowned
> >> dictionary content that is easy and intuitive to access. Sign up for an
> >> account today to start using our lexical data to power your apps and
> >> projects. Get started today and enter our developer competition.
> >> http://sdm.link/oxford
> >> ___
> >> Strace-devel mailing list
> >> Strace-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/strace-devel
> >>
> >>
> >

It is preferred that patches are sent inline.

> From afe2b0ecb21cf24daf65a6e11d8694638db52fed Mon Sep 17 00:00:00 2001
> From: Rishi Bhatt 
> Date: Sat, 11 Mar 2017 22:14:03 +0530
> Subject: [PATCH] Implemented -e trace=%clock option for clock_*
>  related-syscalls
> 

The change log is missing. Please refer to README-hacking and
https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html .

> ---
>  linux/32/syscallent.h | 10 +-
>  linux/64/syscallent.h | 10 +-
>  linux/alpha/syscallent.h  | 10 +-
>  linux/arm/syscallent.h| 10 +-
>  linux/avr32/syscallent.h  | 10 +-
>  linux/bfin/syscallent.h   | 10 +-
>  linux/crisv10/syscallent.h| 10 +-
>  linux/hppa/syscallent.h   | 10 +-
>  linux/i386/syscallent.h   | 10 +-
>  linux/ia64/syscallent.h   | 10 +-
>  linux/m68k/syscallent.h   | 10 +-
>  linux/microblaze/syscallent.h | 10 +-
>  linux/mips/syscallent-n32.h   | 10 +-
>  linux/mips/syscallent-n64.h   | 10 +-
>  linux/mips/syscallent-o32.h   | 10 +-
>  linux/powerpc/syscallent.h| 10 +-
>  linux/powerpc64/syscallent.h  | 10 +-
>  linux/s390/syscallent.h   | 10 +-
>  linux/s390x/syscallent.h  | 10 +-
>  linux/sh/syscallent.h | 10 +-
>  linux/sh64/syscallent.h   | 10 +-
>  linux/sparc/syscallent.h  | 10 +-
>  linux/sparc64/syscallent.h| 10 +-
>  linux/x32/syscallent.h| 10 +-
>  linux/x86_64/syscallent.h | 10 +-
>  linux/xtensa/syscallent.h | 10 +-
>  qualify.c |  1 +
>  strace.1  |  3 +++
>  syscall.c |  2 ++
>  sysent.h  |  1 +
>  tests/Makefile.am |  1 +
>  tests/clock.test  | 20 
>  tests/ksysent.c   |  1 +
>  tests/nsyscalls.c |  1 +
>  34 files changed, 160 insertions(+), 130 deletions(-)
>  create mode 100644 tests/clock.test
These permissions are incorrect, they lead to the following error when
this test is actually tried to be executed: "timeout: failed to run command
`./clock.test': Permission denied ". The correct permissions should be
100755.

When file access rights are corrected, test fails with the following 
diagnostics:

5d4
< setitimer(ITIMER_REAL, {it_interval={tv_sec=0, tv_usec=22}, 
it_value={tv_sec=0, tv_usec=11}}, NULL) = 0
clock.test: failed test: ../strace -a40 -e trace=%clock ./clock_nanosleep 
output mismatch


> diff --git a/linux/32/syscallent.h b/linux/32/syscallent.h
> index a8f95107..2e6fabbd 100644
> --- a/linux/32/syscallent.h
> +++ b/linux/32/syscallent.h
> @@ -117,10 +117,10 @@
>  [109] = { 1, 0,  SEN(timer_getoverrun),  
> "timer_getoverrun"  },
>  [110] = { 4, 0,  SEN(timer_settime), "timer_settime" 
> },
>  [111] = { 1, 0,  

Re: GSoC 2017 introduction

2017-03-09 Thread Eugene Syromyatnikov
On Thu, Mar 9, 2017 at 5:44 PM, Victor Krapivensky
<krapivenskiy...@phystech.edu> wrote:
> I would like to implement the parser for statx. Here is my current
> attempt (no tests yet).
> I've spotted the tests/statx.sh script. Unfortunately, due to that
> tests/init.sh expects the caller name to end with ".test", it just
> endlessly runs itself. What is it supposed to do?
This is a support script for various stat test flavors:
$ git grep statx.sh
<...>
tests/fstatat64.test:. "${srcdir=.}/statx.sh"
tests/lstat.test:. "${srcdir=.}/statx.sh"
tests/lstat64.test:. "${srcdir=.}/statx.sh"
tests/newfstatat.test:. "${srcdir=.}/statx.sh"
tests/oldlstat.test:. "${srcdir=.}/statx.sh"
tests/oldstat.test:. "${srcdir=.}/statx.sh"
tests/stat.test:. "${srcdir=.}/statx.sh"
tests/stat64.test:. "${srcdir=.}/statx.sh"

> Also, how do I get syscall numbers for all the platforms?
For not so new arches, syscalls are wired on case-by-case basis, so
there is no simple way. There is some attempt to automate it [1], but
it relies on architecture headers, and for these proper wiring is
needed in place.

PS. Btw, by a quick look at the patch (haven't reviewed it yet), I can
say that you at least forgot to wire up i386 arch [2], improperly
indented SEN(statx) and most probably would have problems with struct
statx name clash once glibc decided to support it.

[1] https://strace.io/logs/strace/2017-02-08#1066;
[2] 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/x86/entry/syscalls/syscall_32.tbl#n392

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH v2] Implement output staging for failed/successful syscalls

2017-03-07 Thread Eugene Syromyatnikov
> I had submitted below patch back 18th of  January 
> (https://sourceforge.net/p/strace/mailman/message/35611809/). Don't see that 
> it was merged nor did I receive any feedback so far.
> Was my submission just missed - or is the implemented feature (-z/-Z: filter 
> for successful/failed syscalls) considered not useful for the project?
Please look at https://sourceforge.net/p/strace/mailman/message/35647844/

I personally consider for putting this patch into a mergeable state,
one way or another, for the 4.17 release (among other things like
gdbserver backend), which is expected to be right after linux 4.11
release in about 7—8 weeks.


-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Introduction

2017-03-04 Thread Eugene Syromyatnikov
On Sat, Mar 4, 2017 at 5:15 PM, Rishi Bhatt <bhatt.rishi...@gmail.com> wrote:
> Thanks ldv,
> I have read the man pages and got basic idea about strace.Now where should i
> start understanding the code?The codebase is so big i dont know where to
> start.
The core is strace.c and syscall.c (mostly). Take a look at some
simple (umask.c, readahead.c, mount.c) and not so simple (time.c,
ioctl.c, net.c, signal.c, ipc.c) decoders. You can look at some tests
then, like umask, or aio, or sendmmsg, or btrfs. util.c contains
various utility functions, defs.h contains various utility macros and
inlines. linux directory contains various (mostly
architecture-specific) system definitions which are preferred to be
part of strace codebase. linux/*/syscallent.h contains wirings for
syscalls. xlat directory contains sources for generation of symbolic
constant headers.

> On Sat, Mar 4, 2017 at 4:25 AM, Dmitry V. Levin <l...@altlinux.org> wrote:
>>
>> Hi,
>>
>> On Fri, Mar 03, 2017 at 11:55:33PM +0530, Rishi Bhatt wrote:
>> > Hi ldv,
>> > thanks for the reply i have build the strace  source-code and when i
>> > was building it it skipped 50 test cases. So do you know why that
>> > happened? or is it the  matter that i should look into?
>>
>> Why skipped or why 50?
>>
>> A test can be skipped if
>> - it is not applicable for the architecture being tested, for example,
>>   the test is for a syscall that is not inplemented for this architecture;
>> - the test framework doesn't support the test, for example, a kernel
>>   module is not loaded, or the filesystem is not capable, etc.
>>
>> Currently there are two architectures where exactly 50 tests are skipped:
>> - native x86_64;
>> - native sparc64.
>>
>> I bet sparc64 is not your case, so you must be running the test suite
>> natively on x86_64.
>>
>> > And can you guide me where should i start to know about -e trace=class?
>>
>> I think the best is to start with reading the manual page, then look
>> at the code to understand how it's implemented.  As soon as you've
>> understood the implementation, it's easy to extend.
>>
>
>>
>> --
>> ldv
>>
>>
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>> ___
>> Strace-devel mailing list
>> Strace-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/strace-devel
>>
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: fsetxattr strings are not truncated

2017-03-03 Thread Eugene Syromyatnikov
On Thu, Dec 22, 2016 at 3:50 AM, Марк Коренберг <socketp...@gmail.com> wrote:
> Dear developers,
>
> Here is `strace -s 2` output:
>
> [pid  5236] fgetxattr(52, "us"..., "0", 2) = 2
> [pid  5236] flistxattr(52, NULL, 0) = 66
> [pid  5236] flistxattr(52, "us"..., 132) = 66
> [pid  5236] fgetxattr(52, "us"..., "\x10\x08
> \x01\x00\x00\x04\x03H\x00\x00\x00\x00\x00\x00\x00'\x00\x00\x00rbd_data.26dae2ae8944a.00a3\xfe\xff\xff\xff\xff\xff\xff\xff\xe7Q\xa6\x8c\x00\x00\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x06\x03\x1c\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\xf3\x02\x00\x00\x00\x00\x00\x00\xc2\x04\x00\x00\xf1\x02\x00\x00\x00\x00\x00\x00\xc2\x04\x00\x00\x02\x02\x15\x00\x00\x00\x08\xd6t\x02\x00\x00\x00\x00\x00\xbf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00qH[X\x89\xd1\xc7-\x02\x02\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf3\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
> 2048) = 250
> [pid  5236] fgetxattr(52, "us"...,
> "\x00\x00\x00\x004\x00\x00\x00qH[X@\xccK4pJ6|\xff\xff\xff\xff\x00\x00@\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00\x00",
> 1798) = 44
> [pid  5236] fgetxattr(52, "us"...,
> "\x02\x02\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
> 2048) = 31
> [pid  5236] fgetxattr(52, "us"..., 0x0, 0) = -1 ENODATA (No data available)
> [pid  5236] fsetxattr(52, "us"..., "\x10\x08
> \x01\x00\x00\x04\x03H\x00\x00\x00\x00\x00\x00\x00'\x00\x00\x00rbd_data.26dae2ae8944a.00a3\xfe\xff\xff\xff\xff\xff\xff\xff\xe7Q\xa6\x8c\x00\x00\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x06\x03\x1c\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\xf6\x02\x00\x00\x00\x00\x00\x00\xc2\x04\x00\x00\xf3\x02\x00\x00\x00\x00\x00\x00\xc2\x04\x00\x00\x02\x02\x15\x00\x00\x00\x08\xbax\x02\x00\x00\x00\x00\x00\xbd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x8bL[X\x7f#8/\x02\x02\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
> 250, 0) = 0
> [pid  5236] fsetxattr(52, "us"...,
> "\x00\x00\x00\x004\x00\x00\x00\x8bL[Xy2\xb76\x89\x19\x16\x1c\xff\xff\xff\xff\x00\x00@\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x00\x00\x00\x00\x00",
> 44, 0) = 0
> [pid  5236] fremovexattr(52, "us"...)   = -1 ENODATA (No data available)
> [pid  5236] fsetxattr(52, "us"...,
> "\x02\x02\x19\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
> 31, 0) = 0
>
>
> I expect that all strings should be truncated to 2 bytes. This does not
> happen for *xattr syscalls. So I consider this is a bug.
Thanks for the bug report. The issue has been fixed in
v4.15-62-gdd3548a (included in 4.16 release).

> Cheers,
> Mark
>
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today.http://sdm.link/intel
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Feature Request: Process Lineage in Filenames.

2017-03-03 Thread Eugene Syromyatnikov
On Fri, Mar 3, 2017 at 11:54 PM, Ralph Corderoy <ra...@inputplus.co.uk> wrote:
> Hi,
>
> Second request.  I had a bunch of filename.pid outputs from -ff the
> other day and to better understand what occurred, I examined and renamed
> them to show their ancestry.
>
> 1000.man
> 1008.man-preconv
> 1009.man-tbl
> 1010.man-nroff
> 1011.man-col
> 1013.man-nroff-locale
> 1016.man-nroff-groff
> 1018.man-nroff-groff-troff
> 1019.man-nroff-groff-grotty
>
> I was thinking something similar could happen automatically.  Not using
> the name of the program execve()'d, because that comes later, but a list
> of PIDs starting with the ancestor.  So
>
> strace -o foo -fff /usr/bin/foo
>
> might produce
>
> foo.100
>
> and as that forks
>
> foo.100-102
>
> and forks again
>
> foo.100-102-103
>
> foo.100-109 would be 102's sibling.
>
> It would make it that bit easier when grep-ing through them all, etc.,
> to interpret the results.
Well, something like { echo 'digraph {'; for i in *; do sed -n
"/clone/s/.* \([0-9]*\)\$/${i#*.} -> \1;/p" $i; done; echo '}'; } |
dot -Tpng  > pid_graph.png can ease the task, but it is not always
that easy [1]. Thanks for the sugestion, since strace indeed can track
this sort of process relations.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1035433

> --
> Cheers, Ralph.
> https://plus.google.com/+RalphCorderoy
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: GSOC : Introducing myself

2017-02-21 Thread Eugene Syromyatnikov
On Tue, Feb 21, 2017 at 11:24 AM, Animesh Kashyap
<annimesh2...@gmail.com> wrote:
> On Sun, Feb 19, 2017 at 12:20 AM, Eugene Syromyatnikov <evg...@gmail.com> 
> wrote:
>> Well, strace itself does not utilise bug tracker of any sort; bugs and
>> suggestions usually reported via this mailing list (like suggestion
>> [1], reported recently). You can try to have a look at lists of bugs
>> related to strace packages in various distributions (like [2] or [3]),
>> but these are mostly loosely related since they are reported against
>> old versions and most of them are ususally reported upstream and fixed
>> or get stale.
>
> Hello,
>
> I read the resources provided and am reading the mailing list. I have
> successfully cloned and built strace. There are two projects specified
> on the wiki page :
> "https://sourceforge.net/p/strace/wiki/GoogleSummerOfCode2017/; :
Well, it's not projects in term "GSoC project ideas" (which are
provided under "List of project ideas for students"), it's more like
some potential areas which still need improvement and do not require
much involment in order to tackle them, so they are deemed as a good
place to start.

> 1) Adding tests for better coverage
> 2) Adding new classes for -e trace=class.
Yes, that's correct.

> Should I start working on one of these or is there some other small
> feature that does not require much knowledge of internals of strace
> that I should work on?
I think I already mentioned [1], it requires some other knowledge
(regarding ANSI terminals and terminfo/termcap, mostly), however.
Overall, there is also vast field of work regarding support of various
ioctl() calls, but it is difficult to recommend since it already
requires some understanding of strace and kernel inner workings in
order to be done right (from my point of view).

[1] https://sourceforge.net/p/strace/mailman/message/35650550/


-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: GSOC : Introducing myself

2017-02-18 Thread Eugene Syromyatnikov
On Sat, Feb 18, 2017 at 6:24 PM, Animesh Kashyap <annimesh2...@gmail.com> wrote:
>
> Are there any flags indicating "easy-to-fix" bugs or "minor" bugs that
> I can get started with. That would be really helpful.
Well, strace itself does not utilise bug tracker of any sort; bugs and
suggestions usually reported via this mailing list (like suggestion
[1], reported recently). You can try to have a look at lists of bugs
related to strace packages in various distributions (like [2] or [3]),
but these are mostly loosely related since they are reported against
old versions and most of them are ususally reported upstream and fixed
or get stale.

[1] https://sourceforge.net/p/strace/mailman/message/35650550/
[2] https://bugs.debian.org/cgi-bin/pkgreport.cgi?dist=unstable;package=strace
[3] 
https://bugzilla.redhat.com/buglist.cgi?component=strace_id=7101439=bug_status%2Cpriority%2Cbug_severity=Fedora_based_on=_format=advanced

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: strace cant parse struct msghdr RHEL

2017-02-10 Thread Eugene Syromyatnikov
ags=MSG_CTRUNC|MSG_TRUNC|MSG_WAITALL|MSG_CONFIRM|0xbe00010},
>> MSG_WAITALL) = 4188
>> sendmsg(8, {msg_name=NULL, msg_namelen=-7623584, msg_iov=NULL,
>> msg_iovlen=33655230453052149, msg_control=./strace: umoven: short read
>> (13250 < 20480) @0xff8bac3e: Input/output error
>> 0x2ff8bac3e, msg_controllen=38647082208,
>> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_TRUNC|MSG_SYN|MSG_CONFIRM|MSG_ERRQUEUE|MSG_MORE|0xff8b0010},
>> 0) = 12
>> ./strace: Out of memory
>> recvmsg(8, {msg_name=NULL, msg_namelen=-7623488, msg_iov=NULL,
>> msg_iovlen=0, msg_control=NULL, msg_controllen=17869443930177667072,
>> msg_flags=MSG_CTRUNC|MSG_TRUNC|MSG_WAITALL|MSG_CONFIRM|0xbe00010},
>> MSG_WAITALL) = 12
>> recvmsg(8, {msg_name=NULL, msg_namelen=-7623488, msg_iov=NULL,
>> msg_iovlen=0, msg_control=NULL, msg_controllen=17869443930177667072,
>> msg_flags=MSG_CTRUNC|MSG_TRUNC|MSG_WAITALL|MSG_CONFIRM|0xbe00010},
>> MSG_WAITALL) = 4188
>> sendmsg(8, {msg_name=NULL, msg_namelen=-7623584, msg_iov=NULL,
>> msg_iovlen=33655230453052149, msg_control=./strace: umoven: short read
>> (13250 < 20480) @0xff8bac3e: Input/output error
>> 0x2ff8bac3e, msg_controllen=38647082208,
>> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_TRUNC|MSG_SYN|MSG_CONFIRM|MSG_ERRQUEUE|MSG_MORE|0xff8b0010},
>> 0) = 12
>> ./strace: Out of memory
>> recvmsg(8, {msg_name=NULL, msg_namelen=-7623488, msg_iov=NULL,
>> msg_iovlen=0, msg_control=NULL, msg_controllen=17869443930177667072,
>> msg_flags=MSG_CTRUNC|MSG_TRUNC|MSG_WAITALL|MSG_CONFIRM|0xbe00010},
>> MSG_WAITALL) = 4188
>> sendmsg(8, {msg_name=NULL, msg_namelen=-7631616, msg_iov=NULL,
>> msg_iovlen=10, msg_control=[{cmsg_len=17920, cmsg_level=SOL_IP,
>> cmsg_type=0x8d00 /* IP_??? */}, {cmsg_len=3158845,
>> cmsg_level=0x5f534d4e /* SOL_??? */, cmsg_type=0x4e5f534f}, ...],
>> msg_controllen=300847264664,
>> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_DONTWAIT|MSG_EOR|MSG_SYN|MSG_CONFIRM|MSG_MORE|0xff8b0010},
>> 0) = 74
>> sendmsg(8, {msg_name=NULL, msg_namelen=-7631504, msg_iov=NULL,
>> msg_iovlen=29510720283184520, msg_control=[{cmsg_len=2048,
>> cmsg_level=SOL_IP, cmsg_type=0x8d70 /* IP_??? */},
>> {cmsg_len=3971745833, cmsg_level=0x7ff00bc7 /* SOL_??? */,
>> cmsg_type=0xbda}, ...], msg_controllen=38647074288,
>> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_DONTWAIT|MSG_WAITALL|MSG_SYN|MSG_CONFIRM|MSG_MORE|0xff8b},
>> 0) = 12
>> ./strace: Out of memory
>> sendmsg(8, {msg_name=NULL, msg_namelen=-7623584, msg_iov=NULL,
>> msg_iovlen=33655230453052149, msg_control=./strace: umoven: short read
>> (13250 < 20480) @0xff8bac3e: Input/output error
>> 0x2ff8bac3e, msg_controllen=38647082208,
>> msg_flags=MSG_DONTROUTE|MSG_CTRUNC|MSG_TRUNC|MSG_SYN|MSG_CONFIRM|MSG_ERRQUEUE|MSG_MORE|0xff8b0010},
>> 0) = 12
>> ./strace: Out of memory
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Feature request: coloured output

2017-02-07 Thread Eugene Syromyatnikov
On Mon, Feb 6, 2017 at 3:41 PM, Philip Withnall <phi...@tecnocode.co.uk> wrote:
> Hi,
>
> I’ve got a feature request for strace: optional coloured output, which
> would use ANSI escape sequences (on supported terminals) to embolden
> and colourise various bits of the strace output to make it easier to
> read. Some suggestions for the highlighting:
>  • De-emphasise PIDs at the start of a line by putting them in grey
>  • Emphasise syscall names by emboldening them
>  • Emphasise error return values by colouring them red
>
> If piping through to another program, or running on a terminal which
> doesn’t support them, the escape sequences should not be used.

As it stands, implementation of this feature whould tackle quite an
amount of code, since printing routines are spread accross decoders.
It could be implemented partially for preamles, return codes and some
types (like UIDs), but not for the structure field names and inline
comments, for example.

Personally, I would hope that the structured output conversion would
be finalized and merged before the thermal death of the Universe, and
see this feature being implemented there, since in this case code
changes would be localised in the legacy formatter.

Otherwise, it could be implemented partially (for some preamble bits
and return values) now and decoder-related part later.

> Thanks,
> Philip
>
> (Please include me in CC in any replies, as I’m not subscribed to the
> list.)
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH 3/4] getrandom: print getrandom buffer as hex array

2017-01-06 Thread Eugene Syromyatnikov
On Fri, Jan 06, 2017 at 03:16:29PM +0800, JingPiao Chen wrote:
> In general, the random bytes is not number or letter, print
> as hex array is clear, use 0x%02x format print it, easy to
> konw each element is one byte, so 0 will print 0x00.

I think it is better (in terms of performance and readability) to print it as
hex-escaped string, something like this:

--
diff --git i/defs.h w/defs.h
index eeabfcf..1630385 100644
--- i/defs.h
+++ w/defs.h
@@ -505,6 +505,7 @@ extern int next_set_bit(const void *bit_array, unsigned 
cur_bit, unsigned size_b
 #define QUOTE_0_TERMINATED  0x01
 #define QUOTE_OMIT_LEADING_TRAILING_QUOTES  0x02
 #define QUOTE_OMIT_TRAILING_0   0x08
+#define QUOTE_FORCE_HEX 0x10
 
 extern int string_quote(const char *, char *, unsigned long, unsigned int);
 extern int print_quoted_string(const char *, unsigned long, unsigned int);
diff --git i/getrandom.c w/getrandom.c
index 0a353ad..ea9ad57 100644
--- i/getrandom.c
+++ w/getrandom.c
@@ -7,7 +7,8 @@ SYS_FUNC(getrandom)
if (syserror(tcp))
printaddr(tcp->u_arg[0]);
else
-   printstrn(tcp, tcp->u_arg[0], tcp->u_rval);
+   printstr_ex(tcp, tcp->u_arg[0], tcp->u_rval,
+   QUOTE_FORCE_HEX);
tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
printflags(getrandom_flags, tcp->u_arg[2], "GRND_???");
}
diff --git i/tests/getrandom.test w/tests/getrandom.test
index e06367c..ad34048 100755
--- i/tests/getrandom.test
+++ w/tests/getrandom.test
@@ -3,4 +3,4 @@
 # Check getrandom syscall decoding.
 
 . "${srcdir=.}/init.sh"
-run_strace_match_diff -a32 -xx -s3
+run_strace_match_diff -a32 -s3
diff --git i/util.c w/util.c
index a27c4e1..484f84e 100644
--- i/util.c
+++ w/util.c
@@ -660,9 +660,9 @@ string_quote(const char *instr, char *outstr, const 
unsigned long size,
eol = 0x100; /* this can never match a char */
 
usehex = 0;
-   if (xflag > 1)
+   if ((xflag > 1) || (style & QUOTE_FORCE_HEX)) {
usehex = 1;
-   else if (xflag) {
+   } else if (xflag) {
/* Check for presence of symbol which require
   to hex-quote the whole string. */
for (i = 0; i < size; ++i) {


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH 1/4] tests/.gitignore: add missing files that should be ignored

2017-01-05 Thread Eugene Syromyatnikov
On Tue, Dec 27, 2016 at 3:43 AM, JingPiao Chen <chenjingp...@gmail.com> wrote:
> * tests/.gitignore: Add add_key, attach-f-p-cmd and scno.h.
> ---
Hello.

Thank you for your contribution, the patch has been merged to master,
https://github.com/strace/strace/commit/f2d80518f7249e30b4850fa4d8266a5ee485e04e

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: Sending signals on syscalls

2016-12-24 Thread Eugene Syromyatnikov
Hello.

If you can run the executable under gdb, you can try to use "catch
syscall write".

On Sat, Dec 24, 2016 at 12:29 PM, Seraphime Kirkovski
<kirkser...@gmail.com> wrote:
> Hello straces devs !
>
> Recently, I had to do some reverse engineering on a malware for
> a somewhat exotic platform. As the malware had its .text encrypted my
> only possibility was strace. As always, it helped me to
> understand the binary, but after I knew what it did, I couldn't do much
> more because I couldn't see the decrypted code section. What I would
> have liked to do is send a coredump-ing signal when I think the code is
> completely decrypted, i.e. before a call to munmap, after an open call
> or something like this, or simply stop the process in order to attach
> gdb. (This isn't always possible: often, malware writers fork() before
> the main routine, which makes it more difficult to attach a debugger, as
> the pid changes, furthermore, if the text section is not decrypted the
> debugger would mess up checksums/keys/whatever.)
>
> So I thought of extending strace like this:
>
> strace -e sigonsys=<before|after>:: ./a.out
>
> sigonsys: specifies the signal SIG to be sent before or after a syscall
> SYSCALL is done.
>
> Example:
>
> strace -f -e sigonsys=after:open:SIGSEGV ./a.out
>
> This sends a SIGSEGV after a call to open(2).
>
> I've already taken a shot at it. And I've identified some limitations
> that
> 1) probably cannot be overcome from userpace
> 2) are due to the racy nature of what I'm trying to do
> 3) show some flaws in the kernel
>
> First, the before parameter doesn't change anything in practice. In most
> cases the offending syscall will be executed, checking at the very end
> of the kernel procedure whether there are any pending signals. This
> yields some strange results. For instance,
>
> int main(void)
> {
> puts("hello");
> }
>
> run with strace -e sigonsys=before:write:SIGSEGV, gives the following
> result:
>
> ...
> write(1, "hello\n", 6) hello
>
> = -ERESTARTSYS
>
> That it is, the syscall succeeds, it writes "hello" to stdout and before
> returning to userspace it checks for pending signals, there is one, so
> it returns ERESTARTSYS, which is apparently stupid.
>
> Another problem I found is related to the fact that signals are not
> delivered immediately. Consider the following program
>
> int main(void)
> {
> puts("");
> puts("");
> }
>
> Strace outputs:
>
> ..
> write(1, "\n", 5)  = -ERESTARTSYS
> 
> --- SIGNAL SIGSEGV ---
>
> Or even worse,
>
> int main(void)
> {
> puts("");
> _exit(0);
> puts("");
> }
>
> when run with
>
> strace -e sigonsys=before:write:SIGSEGV ./a.out
>
> yields as expected:
>
> write(1, "\n", 5)  = -RESTARTSYS
> --- SIGNAL SIGSEGV ---
>
> But when piped like so
>
> strace -e sigonsys=before:write:SIGSEGV ./a.out | less
>
> gives:
> group_exit(0)  = ??? (no write at all)
>
>
> ( I ran those examples on x86_64 and 4.7.0-1 kernel )
>
> That being said, I think this option may help kernel developers as well.
>
> What are your thoughts on extending strace like this ? Is it worth it ?
> Do you have any ideas how I may overcome some of these difficulties ?
> Currently, I modified the sources so the signal is send through
> ptrace(<GET|SET>SIGINFO... and ptrace_restart afterwards. I tried adding
> an additional kill(2), but that didn't change anything.
>
> Have a good Christams Eve,
> Seraphime Kirkovski
>
> ------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today.http://sdm.link/intel
> ___
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel



-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: tests: add prctl-name.test, prctl-pdeathsig.test and prctl-tsc.test

2016-12-07 Thread Eugene Syromyatnikov
On Wed, Dec 7, 2016 at 3:29 PM, JingPiao Chen <chenjingp...@foxmail.com> wrote:
>>Your patch has been applied in master,
>>https://github.com/strace/strace/commit/d945e74377fe069de0fe1aa2823442cf8dbdbb52
>>. Thank you for your contribution.
>
> What can I contribute more? This is my first times contribute open source
> software,
> lack of experience, I cann't find the way deep learning strace. Can you give
> me some
> advice? Thanks.
Well, there are two main fields which are easy to start from:
 * Better decoding of syscalls. From my point of view, the one thing
which significantly lacks support is various ioctl calls; Linux has a
tremendous amount of various ioctl calls supported by various drivers
and subsystems; the most likely candidates for adding are the most
useful, usually, some generic subsystems or commonly used device
drivers. One such example is a support for bluetooth ioctls: [1]
 * Test coverage. Since the structured output project is expected to
be merged in the one of the future releases, it is importnat to be
sure that nothing broken accidentally during the transition. Good set
of decoder tests is one (rather significant) part of making sure that
strace output would not changed unexpectedly. As Dmitry previously
pointed out, you can check out which parts of strace's code are not
covered with tests with LCOV (./configure CFLAGS='-O0'
--enable-code-coverage && make && make check && make
code-coverage-capture) or codecov page [3]. Note, hovewer, that not
all tests are the same and not simply coverage itself is important,
but actual testing of all the corner cases which checks whether
specific decoder works as intended (in accordance with documentation
and/or actual kernel implementation, from the original implementation
to the current one). As you may note, ioctl decoders (among other
things), again, lack proper test coverage.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=358248
[2] https://github.com/lineprinter/strace/blob/structured/README-structured.md
[3] https://codecov.io/gh/strace/strace

> --
> JingPiao Chen

-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: tests: add prctl-name.test, prctl-pdeathsig.test and prctl-tsc.test

2016-12-07 Thread Eugene Syromyatnikov
On Thu, Nov 17, 2016 at 1:17 PM, JingPiao Chen <chenjingp...@foxmail.com> wrote:
> ...

Your patch has been applied in master,
https://github.com/strace/strace/commit/d945e74377fe069de0fe1aa2823442cf8dbdbb52
. Thank you for your contribution.


-- 
Eugene Syromyatnikov
mailto:evg...@gmail.com
xmpp:esyr@jabber.{ru|org}

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: tests: add prctl-name.test, prctl-pdeathsig.test and prctl-tsc.test

2016-11-21 Thread Eugene Syromyatnikov
Hello.

Thank you for your contribution. Thanks to it, several bugs in current prctl
decoder implementation have been revealed. Please take a look

On Thu, Nov 17, 2016 at 09:17:27PM +0800, JingPiao Chen wrote:
> From 8995d87f0c27d40d574f032bf483f6ae2b5f7375 Mon Sep 17 00:00:00 2001
> From: JingPiao Chen 
> Date: Thu, 17 Nov 2016 21:15:51 +0800
> Subject: [PATCH] tests: add prctl-name.test, prctl-pdeathsig.test and
>  prctl-tsc.test
> 
> 
> * tests/prctl-name.c:New file.

Missing space.

> * tests/prctl-name.test: Likewise.

The established description format for the new *.test files is "New test".

> * tests/prctl-pdeathsig.c:Likewise.
> * tests/prctl-pdeathsig.test: Likewise.
> * tests/prctl-tsc.c: Likewise.
> * tests/prctl-tsc.test: Likewise

Summing up two previous notes, this part of commit message could be
rewritten as follows:

[[
* tests/prctl-name.c: New file.
* tests/prctl-pdeathsig.c:Likewise.
* tests/prctl-tsc.c: Likewise.
* tests/prctl-name.test: New test.
* tests/prctl-pdeathsig.test: Likewise.
* tests/prctl-tsc.test: Likewise
]]

> * tests/.gitignore: Add prctl-name, prctl-pdeathsig and prctl-tsc.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (DECODER_TESTS): Add prctl-name.test, prctl-pdeathsig.test and prctl-tsc.test
> ---
>  tests/.gitignore   |  3 +++
>  tests/Makefile.am  |  6 +
>  tests/prctl-name.c | 63 
> ++
>  tests/prctl-name.test  |  6 +
>  tests/prctl-pdeathsig.c| 61 
>  tests/prctl-pdeathsig.test |  6 +
>  tests/prctl-tsc.c  | 60 +++
>  tests/prctl-tsc.test   |  6 +
>  8 files changed, 211 insertions(+)
>  create mode 100644 tests/prctl-name.c
>  create mode 100755 tests/prctl-name.test
>  create mode 100644 tests/prctl-pdeathsig.c
>  create mode 100755 tests/prctl-pdeathsig.test
>  create mode 100644 tests/prctl-tsc.c
>  create mode 100755 tests/prctl-tsc.test
> 
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 6fc3cd1..8497dfa 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -207,8 +207,11 @@ pkey_free
>  pkey_mprotect
>  poll
>  ppoll
> +prctl-name
> +prctl-pdeathsig
>  prctl-seccomp-filter-v
>  prctl-seccomp-strict
> +prctl-tsc
>  pread64-pwrite64
>  preadv
>  preadv-pwritev
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index df5ddb2..744ed25 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -265,8 +265,11 @@ check_PROGRAMS = \
>   pkey_mprotect \
>   poll \
>   ppoll \
> + prctl-name \
> + prctl-pdeathsig \
>   prctl-seccomp-filter-v \
>   prctl-seccomp-strict \
> + prctl-tsc \
>   pread64-pwrite64 \
>   preadv \
>   preadv-pwritev \
> @@ -637,8 +640,11 @@ DECODER_TESTS = \
>   pkey_mprotect.test \
>   poll.test \
>   ppoll.test \
> + prctl-name.test \
> + prctl-pdeathsig.test \
>   prctl-seccomp-filter-v.test \
>   prctl-seccomp-strict.test \
> + prctl-tsc.test \
>   pread64-pwrite64.test \
>   preadv-pwritev.test \
>   preadv2-pwritev2.test \
> diff --git a/tests/prctl-name.c b/tests/prctl-name.c
> new file mode 100644
> index 000..a508969
> --- /dev/null
> +++ b/tests/prctl-name.c
> @@ -0,0 +1,63 @@
> +/*

It is recommended to have a brief description of the file in the beginning of
this comment block. For example, "Check decoding of prctl
PR_GET_NAME/PR_SET_NAME operations."

> + * Copyright (c) 2016 JingPiao Chen 
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + * 3. The name of the author may not be used to endorse or promote products
> + *derived from this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 

[Announce] Fault injection in upcoming strace 4.15

2016-11-16 Thread Eugene Syromyatnikov
This summer, as a part of his GSoC 2016 project, Nahim El Atmani has
implemented[1] a prototype of syscall fault injection. Fault injection is a
testing/debugging technique which tampers the system calls made by a program in
order to check (correctness of) program's behaviour in presence of errors.
In case of strace, syscalls are mangled in order to return failures of different
kinds (with a kind of failure signalled by appropriate errno).

Now, this feature has been finally merged into strace's master branch and going
to be part of the upcoming 4.15 release, which is expected somewhere in the
beginning on December (as some may recall, strace's release cycle is now
synchronised with kernel releases). Since this functionality is rather
unorthodox in comparison with other features already present in strace, strace's
development team encourages all enthusiastic strace users to give it a try in
order to determine its readiness for the upcoming release. More specifically:
 * Check out the provided documentation. Whether it is clear enough? If not,
   please suggest improvements.
 * Try to actually use it. During the course of its development, fault injection
   already enabled discovery of several bugs ([2], for example), and any
   feedback regarding various usage cases is appreciated.
 * Try it on different architectures. It has been tested on aarch64, alpha, arm,
   hppa, ia64, ppc, ppc64, s390, s390x, sparc, sparc64, x32, x86, and x86_64;
   other architectures are still untested.

How to get it:
 * Check out master branch of strace repository[3][4].
 * Install package from Fedora rawhide[5].
 * Install package from OBS[6].

---
[1] https://brokenpi.pe/tools/strace-fault-injection
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=20831
[3] https://sourceforge.net/p/strace/code/ci/master/tree/
[4] https://github.com/strace/strace
[5] https://apps.fedoraproject.org/packages/strace
[6] https://build.opensuse.org/package/show/home:ldv_alt/strace/

--
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


Re: [PATCH] device mapper ioctl

2016-11-10 Thread Eugene Syromyatnikov
On Wed, Oct 19, 2016 at 8:31 PM, Mikulas Patocka  wrote:
>
> Hi
>
> Here I'm sending the device mapper ioctl patch with these changes merged.

Hello.

Thank you for your contribution. The implementation of DM_* ioctl
decoding is now in strace's master, you can check it out at
https://github.com/strace/strace/commit/a507a0bb777c552e43e1e45f302703a09ffea1b8

Could you please review it and let us know if there are any issues?

> In this piece of code:
> +   dm_arg_open3->target3.next = 0xdeadbeef;
> +   dm_arg_open3->param3[0] = '\1';
> +   dm_arg_open3->param3[1] = '\2';
> +   dm_arg_open3->param1[2] = '\0';
> there should be "dm_arg_open3->param3[2]" instead of
> "dm_arg_open3->param1[2]". "dm_arg_open3->param1[2]" produces a warning
> about access beyond the end of array.
Thank you for noticing, it was an oversight on my part.

> Mikulas


-- 
Eugene "eSyr" Syromyatnikov
mailto:evg...@gmail.com
xmpp:eSyr@jabber.{ru|org}

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 03/26] bjm: Use getarg_ull for retrieving len parameter of init_module syscall

2016-10-23 Thread Eugene Syromyatnikov
Since it is of kernel_ulont_t type, in fact.

* bjm.c (SYS_FUNC(init_module)): Use "%llu" conversion specifier, obtain
len aargument via getarg_ull.
---
 bjm.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bjm.c b/bjm.c
index e77b73d..c8e8470 100644
--- a/bjm.c
+++ b/bjm.c
@@ -45,7 +45,7 @@ SYS_FUNC(delete_module)
 SYS_FUNC(init_module)
 {
printaddr(tcp->u_arg[0]);
-   tprintf(", %lu, ", tcp->u_arg[1]);
+   tprintf(", %llu, ", getarg_ull(tcp, 1));
printstr(tcp, tcp->u_arg[2], -1);
 
return RVAL_DECODED;
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 26/26] tests: Additional name_to_handle_at/open_by_handle_at checks

2016-10-23 Thread Eugene Syromyatnikov
* tests/file_handle.c: Additional name_to_handle_at/open_by_handle_at
checks.
---
 tests/file_handle.c |  266 +--
 1 file changed, 259 insertions(+), 7 deletions(-)

diff --git a/tests/file_handle.c b/tests/file_handle.c
index 42b89d8..976cd6a 100644
--- a/tests/file_handle.c
+++ b/tests/file_handle.c
@@ -30,13 +30,21 @@
 
 #if defined __NR_name_to_handle_at && defined __NR_open_by_handle_at
 
-# include 
 # include 
 # include 
+# include 
 # include 
 # include 
+# include 
 # include 
 
+# include "kernel_types.h"
+
+enum assert_rc {
+   ASSERT_NONE,
+   ASSERT_SUCCESS,
+   ASSERT_ERROR,
+};
 
 # ifndef MAX_HANDLE_SZ
 
@@ -50,26 +58,234 @@ struct file_handle {
 # endif /* !MAX_HANDLE_SZ */
 
 
+void
+print_handle_data(unsigned char *bytes, unsigned int size)
+{
+   unsigned int i;
+
+   if (size > MAX_HANDLE_SZ)
+   size = MAX_HANDLE_SZ;
+
+   printf("0x");
+   for (i = 0; i < size; ++i)
+   printf("%02x", bytes[i]);
+}
+
+void
+do_name_to_handle_at(kernel_ulong_t dirfd, const char *dirfd_str,
+kernel_ulong_t pathname, const char *pathname_str,
+kernel_ulong_t handle, const char *handle_str,
+kernel_ulong_t mount_id,
+kernel_ulong_t flags, const char *flags_str,
+enum assert_rc assert_rc, long assert_errno)
+{
+   long rc;
+   long saved_errno;
+
+   rc = syscall(__NR_name_to_handle_at, dirfd, pathname, handle, mount_id,
+   flags);
+   saved_errno = errno;
+
+   if (assert_rc != ASSERT_NONE)
+   assert(rc == (assert_rc == ASSERT_SUCCESS ? 0 : -1));
+   if (assert_errno)
+   assert(saved_errno != assert_errno);
+
+   printf("name_to_handle_at(%s, %s, %s",
+  dirfd_str, pathname_str, handle_str);
+
+   if (rc != -1) {
+   struct file_handle *fh =
+   (struct file_handle *) (uintptr_t) handle;
+   int *mount_id_ptr = (int *) (uintptr_t) mount_id;
+
+   printf(" => %u, handle_type=%d, f_handle=",
+   fh->handle_bytes, fh->handle_type);
+   print_handle_data((unsigned char *) fh +
+ sizeof(struct file_handle),
+ fh->handle_bytes);
+   printf("}, [%d]", *mount_id_ptr);
+   } else {
+   if (mount_id)
+   printf(", %#llx", (unsigned long long) mount_id);
+   else
+   printf(", NULL");
+   }
+
+   errno = saved_errno;
+   printf(", %s) = %s\n", flags_str, sprintrc(rc));
+}
+
+void
+do_open_by_handle_at(kernel_ulong_t mount_fd,
+kernel_ulong_t handle, bool valid_handle, bool valid_data,
+kernel_ulong_t flags, const char *flags_str)
+{
+   long rc;
+
+   printf("open_by_handle_at(%d, ", (int) mount_fd);
+   if (valid_handle) {
+   struct file_handle *fh =
+   (struct file_handle *) (uintptr_t) handle;
+
+   printf("{handle_bytes=%u, handle_type=%d", fh->handle_bytes,
+  fh->handle_type);
+
+   if (valid_data) {
+   printf(", f_handle=");
+   print_handle_data((unsigned char *) fh +
+ sizeof(struct file_handle),
+ fh->handle_bytes);
+   }
+
+   printf("}");
+   } else {
+   if (handle)
+   printf("%#llx", (unsigned long long) handle);
+   else
+   printf("NULL");
+   }
+   printf(", %s) = ", flags_str);
+
+   rc = syscall(__NR_open_by_handle_at, mount_fd, handle, flags);
+
+   printf("%s\n", sprintrc(rc));
+}
+
+struct strval {
+   kernel_ulong_t val;
+   const char *str;
+};
+
+#define STR16 "0123456789abcdef"
+#define STR64 STR16 STR16 STR16 STR16
+
 int
 main(void)
 {
+   enum {
+   PATH1_SIZE = 64,
+   };
+
+   static const kernel_ulong_t fdcwd =
+   (kernel_ulong_t) 0x87654321ff9cULL;
+   static const struct strval dirfds[] = {
+   { (kernel_ulong_t) 0xdeadca57badda7a1ULL, "-1159878751" },
+   { (kernel_ulong_t) 0x12345678ff9cULL, "AT_FDCWD" },
+   };
+   static const struct strval name_flags[] = {
+   { (kernel_ulong_t) 0xdeadf157ULL, "0" },
+   { (kernel_ulong_t) 0xbadc0ded1000ULL,
+   "AT_EMPTY_PATH" },
+   { (kernel_ulong_t) 0xdeadc0deda7a1457ULL,
+   "AT_SYMLINK_FOLLOW|AT_EMPTY_PATH|0xda7a0057" },
+   { (kernel_ulong_t) 0xdefaced1ebffULL,
+   "0xebff /* AT_??? */" },
+   };
+   static const kernel_ulong_t mount_fds[] = {

[PATCH 25/26] tests: Require only presence of __NR_* macros for file_handle test

2016-10-23 Thread Eugene Syromyatnikov
* tests/file_handle.c: replace fcntl.h include with asm/unistd.h.
[MAX_HANDLE_SZ]: change to defined __NR_name_to_handle_at
&& defined __NR_open_by_handle_at, add fcntl.h include
[!MAX_HANDLE_SZ]: Add definition of MAX_HANDLE_SZ and struct
file_handle.
(main): Change name_to_handle_at and open_by_handle_at calls to syscall.
---
 tests/file_handle.c |   33 ++---
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/tests/file_handle.c b/tests/file_handle.c
index ac2b358..42b89d8 100644
--- a/tests/file_handle.c
+++ b/tests/file_handle.c
@@ -26,14 +26,29 @@
  */
 
 #include "tests.h"
-#include 
+#include 
 
-#ifdef MAX_HANDLE_SZ
+#if defined __NR_name_to_handle_at && defined __NR_open_by_handle_at
 
 # include 
 # include 
 # include 
+# include 
 # include 
+# include 
+
+
+# ifndef MAX_HANDLE_SZ
+
+#  define MAX_HANDLE_SZ 128
+
+struct file_handle {
+   unsigned int handle_bytes;
+   int handle_type;
+   unsigned char f_handle[0];
+};
+# endif /* !MAX_HANDLE_SZ */
+
 
 int
 main(void)
@@ -47,20 +62,23 @@ main(void)
 
handle->handle_bytes = 0;
 
-   assert(name_to_handle_at(dirfd, ".", handle, _id, flags | 1) == 
-1);
+   assert(syscall(__NR_name_to_handle_at, dirfd, ".", handle, _id,
+   flags | 1) == -1);
if (EINVAL != errno)
perror_msg_and_skip("name_to_handle_at");
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=0}, %p"
   ", AT_SYMLINK_FOLLOW|0x1) = -1 EINVAL (%m)\n", _id);
 
-   assert(name_to_handle_at(dirfd, ".", handle, _id, flags) == -1);
+   assert(syscall(__NR_name_to_handle_at, dirfd, ".", handle, _id,
+   flags) == -1);
if (EOVERFLOW != errno)
perror_msg_and_skip("name_to_handle_at");
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=0 => %u}"
   ", %p, AT_SYMLINK_FOLLOW) = -1 EOVERFLOW (%m)\n",
   handle->handle_bytes, _id);
 
-   assert(name_to_handle_at(dirfd, ".", handle, _id, flags) == 0);
+   assert(syscall(__NR_name_to_handle_at, dirfd, ".", handle, _id,
+   flags) == 0);
printf("name_to_handle_at(AT_FDCWD, \".\", {handle_bytes=%u"
   ", handle_type=%d, f_handle=0x",
   handle->handle_bytes, handle->handle_type);
@@ -72,7 +90,8 @@ main(void)
   ", f_handle=0x", handle->handle_bytes, handle->handle_type);
for (i = 0; i < handle->handle_bytes; ++i)
printf("%02x", handle->f_handle[i]);
-   int rc = open_by_handle_at(-1, handle, O_RDONLY | O_DIRECTORY);
+   int rc = syscall(__NR_open_by_handle_at, -1, handle,
+   O_RDONLY | O_DIRECTORY);
printf("}, O_RDONLY|O_DIRECTORY) = %d %s (%m)\n", rc, errno2name());
 
puts("+++ exited with 0 +++");
@@ -81,6 +100,6 @@ main(void)
 
 #else
 
-SKIP_MAIN_UNDEFINED("MAX_HANDLE_SZ")
+SKIP_MAIN_UNDEFINED("__NR_name_to_handle_at && __NR_open_by_handle_at")
 
 #endif
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 22/26] bjm: Parse parameters of init_module as of kernel_ulong_t type

2016-10-23 Thread Eugene Syromyatnikov
init_module does not have compat on x32/n32, so its parameters should be
parsed as kernel_ulong_t.

* util.c (printaddr): Change type of addr parameter to kernel_ulong_t.
(printstr_ex): Change type of addr parameter to kernel_ulong_t, change
type of len parameter to kernel_long_t.
* defs.h: Include kernel_types.h. Update declaration of printaddr and
printstr_ex functions.
* bjm.c (SYS_FUNC(init_module)): Use getarg_ull for module_image and
param_values parameters.
---
 bjm.c  |4 ++--
 defs.h |7 ---
 util.c |   11 ++-
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/bjm.c b/bjm.c
index c8e8470..a6f30b3 100644
--- a/bjm.c
+++ b/bjm.c
@@ -44,9 +44,9 @@ SYS_FUNC(delete_module)
 
 SYS_FUNC(init_module)
 {
-   printaddr(tcp->u_arg[0]);
+   printaddr(getarg_ull(tcp, 0));
tprintf(", %llu, ", getarg_ull(tcp, 1));
-   printstr(tcp, tcp->u_arg[2], -1);
+   printstr(tcp, getarg_ull(tcp, 2), -1);
 
return RVAL_DECODED;
 }
diff --git a/defs.h b/defs.h
index 8f34679..04900e1 100644
--- a/defs.h
+++ b/defs.h
@@ -53,6 +53,7 @@
 #include 
 #include 
 
+#include "kernel_types.h"
 #include "mpers_type.h"
 #include "gcc_compat.h"
 
@@ -542,7 +543,7 @@ extern int getllval(struct tcb *, unsigned long long *, 
int);
 extern int printllval(struct tcb *, const char *, int)
ATTRIBUTE_FORMAT((printf, 2, 0));
 
-extern void printaddr(long);
+extern void printaddr(kernel_ulong_t addr);
 extern void printxvals(const uint64_t, const char *, const struct xlat *, ...)
ATTRIBUTE_SENTINEL;
 extern long long getarg_ll(struct tcb *tcp, int argn);
@@ -564,7 +565,7 @@ extern void dumpiov_upto(struct tcb *, int, long, unsigned 
long);
 #define dumpiov(tcp, len, addr) \
dumpiov_upto((tcp), (len), (addr), (unsigned long) -1L)
 extern void dumpstr(struct tcb *, long, int);
-extern void printstr_ex(struct tcb *, long addr, long len,
+extern void printstr_ex(struct tcb *, kernel_ulong_t addr, kernel_long_t len,
unsigned int user_style);
 extern bool printnum_short(struct tcb *, long, const char *)
ATTRIBUTE_FORMAT((printf, 3, 0));
@@ -673,7 +674,7 @@ extern void unwind_capture_stacktrace(struct tcb* tcp);
 #endif
 
 static inline void
-printstr(struct tcb *tcp, long addr, long len)
+printstr(struct tcb *tcp, kernel_ulong_t addr, kernel_long_t len)
 {
printstr_ex(tcp, addr, len, 0);
 }
diff --git a/util.c b/util.c
index e580eb2..59a65de 100644
--- a/util.c
+++ b/util.c
@@ -406,12 +406,12 @@ printflags64(const struct xlat *xlat, uint64_t flags, 
const char *dflt)
 }
 
 void
-printaddr(const long addr)
+printaddr(const kernel_ulong_t addr)
 {
if (!addr)
tprints("NULL");
else
-   tprintf("%#lx", addr);
+   tprintf("%#llx", (unsigned long long) addr);
 }
 
 #define DEF_PRINTNUM(name, type) \
@@ -798,7 +798,8 @@ printpath(struct tcb *tcp, long addr)
  * If string length exceeds `max_strlen', append `...' to the output.
  */
 void
-printstr_ex(struct tcb *tcp, long addr, long len, unsigned int user_style)
+printstr_ex(struct tcb *tcp, kernel_ulong_t addr, kernel_long_t len,
+   unsigned int user_style)
 {
static char *str = NULL;
static char *outstr;
@@ -833,8 +834,8 @@ printstr_ex(struct tcb *tcp, long addr, long len, unsigned 
int user_style)
style = QUOTE_0_TERMINATED;
}
else {
-   if (size > (unsigned long)len)
-   size = (unsigned long)len;
+   if (size > (kernel_ulong_t) len)
+   size = (kernel_ulong_t) len;
if (umoven(tcp, addr, size, str) < 0) {
printaddr(addr);
return;
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 24/26] tests: Proper type conversion in keyctl test

2016-10-23 Thread Eugene Syromyatnikov
* tests/keyctl.c (printarg): Add intermediate conversion of arg to uintptr_t
since kernel_ulong_t may be of different size.
---
 tests/keyctl.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/keyctl.c b/tests/keyctl.c
index a60dcfc..4b1e383 100644
--- a/tests/keyctl.c
+++ b/tests/keyctl.c
@@ -128,7 +128,8 @@ print_arg(kernel_ulong_t arg, const char *str, const char 
*fmt, size_t size,
else if (size == sizeof(uint32_t))
printf(fmt, (uint32_t)arg);
else
-   print_quoted_string_limit((void *)arg, size, rc);
+   print_quoted_string_limit((void *) (uintptr_t) arg,
+ size, rc);
}
 }
 
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 23/26] file_handle: Use separate xlat for name_ta_handle_at flags

2016-10-23 Thread Eugene Syromyatnikov
Since the only two flags supported are AT_SYMLINK_FOLLOW and
AT_EMPTY_PATH.

* xlat/name_to_handle_at_flags.in: New file.
* file_handle.c (SYS_FUNC(name_to_handle_at)): Use name_to_handle_at_flags
for printing flags parameter.
---
 file_handle.c   |7 +--
 xlat/name_to_handle_at_flags.in |2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 xlat/name_to_handle_at_flags.in

diff --git a/file_handle.c b/file_handle.c
index 21cf0f1..009915a 100644
--- a/file_handle.c
+++ b/file_handle.c
@@ -27,6 +27,8 @@
 
 #include "defs.h"
 
+#include "xlat/name_to_handle_at_flags.h"
+
 #ifndef MAX_HANDLE_SZ
 # define MAX_HANDLE_SZ 128
 #endif
@@ -58,7 +60,8 @@ SYS_FUNC(name_to_handle_at)
tprints(", ");
 
/* flags */
-   printflags(at_flags, tcp->u_arg[4], "AT_???");
+   printflags(name_to_handle_at_flags, tcp->u_arg[4],
+  "AT_???");
 
return RVAL_DECODED;
}
@@ -95,7 +98,7 @@ SYS_FUNC(name_to_handle_at)
tprints(", ");
 
/* flags */
-   printflags(at_flags, tcp->u_arg[4], "AT_???");
+   printflags(name_to_handle_at_flags, tcp->u_arg[4], "AT_???");
}
return 0;
 }
diff --git a/xlat/name_to_handle_at_flags.in b/xlat/name_to_handle_at_flags.in
new file mode 100644
index 000..4522a80
--- /dev/null
+++ b/xlat/name_to_handle_at_flags.in
@@ -0,0 +1,2 @@
+AT_SYMLINK_FOLLOW  0x400
+AT_EMPTY_PATH  0x1000
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 21/26] tests: Add kexec checks

2016-10-23 Thread Eugene Syromyatnikov
* tests/.gitignore: Add kexec_file_load, kexec_load.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add kexec_file_load.test, kexec_load.test.
* tests/kexec_file_load.c: New file.
* tests/kexec_file_load.test: Likewise.
* tests/kexec_load.c: Likewise.
* tests/kexec_load.test: Likewise.
---
 tests/.gitignore   |2 +
 tests/Makefile.am  |4 +
 tests/kexec_file_load.c|  129 
 tests/kexec_file_load.test |6 ++
 tests/kexec_load.c |  178 
 tests/kexec_load.test  |6 ++
 6 files changed, 325 insertions(+)
 create mode 100644 tests/kexec_file_load.c
 create mode 100755 tests/kexec_file_load.test
 create mode 100644 tests/kexec_load.c
 create mode 100755 tests/kexec_load.test

diff --git a/tests/.gitignore b/tests/.gitignore
index e1c1be6..35a072f 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -129,6 +129,8 @@ ipc_msgbuf
 ipc_sem
 ipc_shm
 kcmp
+kexec_file_load
+kexec_load
 keyctl
 kill
 ksysent
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0c799b3..e90b18a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -189,6 +189,8 @@ check_PROGRAMS = \
ipc_sem \
ipc_shm \
kcmp \
+   kexec_file_load \
+   kexec_load \
keyctl \
kill \
ksysent \
@@ -555,6 +557,8 @@ DECODER_TESTS = \
ipc_sem.test \
ipc_shm.test \
kcmp.test \
+   kexec_file_load.test \
+   kexec_load.test \
keyctl.test \
kill.test \
lchown.test \
diff --git a/tests/kexec_file_load.c b/tests/kexec_file_load.c
new file mode 100644
index 000..5846c6a
--- /dev/null
+++ b/tests/kexec_file_load.c
@@ -0,0 +1,129 @@
+/*
+ * Check decoding of kexec_file_load syscall.
+ *
+ * Copyright (c) 2016 Eugene Syromyatnikov <evg...@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+
+#include 
+
+#ifdef __NR_kexec_file_load
+
+# include 
+# include 
+# include 
+
+# include "kernel_types.h"
+
+struct strval {
+   kernel_ulong_t val;
+   const char *str64;
+   const char *str32;
+   const char *str;
+};
+
+#define CMDLINE_STR "deadcodebaddatadefaced";
+
+int
+main(void)
+{
+   static const kernel_ulong_t bogus_kernel_fd =
+   (kernel_ulong_t) 0xdeadca57badda7a1ULL;
+   static const kernel_ulong_t bogus_initrd_fd =
+   (kernel_ulong_t) 0xdec0ded1defaced2ULL;
+   static const char cmdline_str[] = CMDLINE_STR;
+   static const char cmdline_short_str[] = "abcdef";
+
+   static const kernel_ulong_t cmdline_lens[] = {
+   0,
+   (kernel_ulong_t) 0xcaffeeeddeadbeefULL,
+   sizeof(cmdline_str),
+   sizeof(cmdline_str) - 1,
+   sizeof(cmdline_short_str),
+   sizeof(cmdline_short_str) - 1,
+   sizeof(cmdline_short_str) + 1,
+   };
+   static const struct strval flags[] = {
+   { (kernel_ulong_t) 0xbadc0dedda7a1058ULL,
+   "0xbadc0ded", "0x",
+   "da7a1058 /* KEXEC_FILE_??? */", },
+   { 0, "", "", "0" },
+   { 0xdeadbeef, "", "", "KEXEC_FILE_UNLOAD|KEXEC_FILE_ON_CRASH|"
+   "KEXEC_FILE_NO_INITRAMFS|0xdeadbee8" },
+   };
+
+
+   long rc;
+   char *cmdline = tail_memdup(cmdline_str, sizeof(cmdline_str));
+

[PATCH 18/26] kexec: Fix zeroing of higher bits of flags parameter in kexec_load

2016-10-23 Thread Eugene Syromyatnikov
* kexec.c (SYS_FUNC(kexec_load)): Perform type conversion before
negation in order to properly negate higher bits of KEXEC_ARCH_MASK.
---
 kexec.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec.c b/kexec.c
index 9ced015..d27bfe1 100644
--- a/kexec.c
+++ b/kexec.c
@@ -91,7 +91,7 @@ SYS_FUNC(kexec_load)
/* flags */
unsigned long n = tcp->u_arg[3];
printxval_long(kexec_arch_values, n & KEXEC_ARCH_MASK, 
"KEXEC_ARCH_???");
-   n &= ~KEXEC_ARCH_MASK;
+   n &= ~(unsigned long) KEXEC_ARCH_MASK;
if (n) {
tprints("|");
printflags_long(kexec_load_flags, n, "KEXEC_???");
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 19/26] defs: Add widen_to_ulong macro

2016-10-23 Thread Eugene Syromyatnikov
This is similar to widen_to_long, but for unsigned values.

* defs.h (widen_to_ulong): New macro.
---
 defs.h |8 
 1 file changed, 8 insertions(+)

diff --git a/defs.h b/defs.h
index 6566488..8f34679 100644
--- a/defs.h
+++ b/defs.h
@@ -760,6 +760,14 @@ extern unsigned current_wordsize;
 # define widen_to_long(v) ((long)(v))
 #endif
 
+#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
+# define widen_to_ulong(v) \
+   (current_wordsize == 4 ? (unsigned long) (uint32_t) (v) : \
+   (unsigned long) (v))
+#else
+# define widen_to_ulong(v) ((long)(v))
+#endif
+
 /*
  * Zero-extend a signed integer type to unsigned long long.
  */
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 16/26] tests: Add unshare syscall decoding check

2016-10-23 Thread Eugene Syromyatnikov
* tests/unshare.c: New file.
* tests/unshare.test: New test.
* tests/.gitignore: Add unshare.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unshare.test.
---
 tests/.gitignore   |1 +
 tests/Makefile.am  |2 ++
 tests/unshare.c|   82 
 tests/unshare.test |6 
 4 files changed, 91 insertions(+)
 create mode 100644 tests/unshare.c
 create mode 100755 tests/unshare.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 11df7e3..e1c1be6 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -323,6 +323,7 @@ unix-pair-send-recv
 unix-pair-sendto-recvfrom
 unlink
 unlinkat
+unshare
 userfaultfd
 utime
 utimensat
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b79f755..0c799b3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -381,6 +381,7 @@ check_PROGRAMS = \
unix-pair-sendto-recvfrom \
unlink \
unlinkat \
+   unshare \
userfaultfd \
utime \
utimensat \
@@ -736,6 +737,7 @@ DECODER_TESTS = \
unix-pair-sendto-recvfrom.test \
unlink.test \
unlinkat.test \
+   unshare.test \
userfaultfd.test \
utime.test \
utimensat.test \
diff --git a/tests/unshare.c b/tests/unshare.c
new file mode 100644
index 000..7b702dc
--- /dev/null
+++ b/tests/unshare.c
@@ -0,0 +1,82 @@
+/*
+ * Check decoding of unshare syscall.
+ *
+ * Copyright (c) 2016 Eugene Syromyatnikov <evg...@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+
+#include 
+
+#ifdef __NR_unshare
+
+# include 
+# include 
+
+# include "kernel_types.h"
+
+int
+main(void)
+{
+   static const kernel_ulong_t bogus_flags =
+   (kernel_ulong_t) 0xbadc0ded000fULL;
+
+   static struct {
+   kernel_ulong_t val;
+   const char *str;
+   } unshare_flags[] = {
+   { ARG_STR(0) },
+   { 0xdeadca75,
+   "CLONE_THREAD|CLONE_FS|CLONE_SIGHAND|CLONE_SYSVSEM|"
+   "CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET|CLONE_NEWUSER|"
+   "CLONE_NEWCGROUP|0x80a8c075" },
+   { 0x200, "CLONE_NEWCGROUP" },
+   { ARG_STR(0x81f8f0ff) " /* CLONE_??? */" },
+   };
+
+   long rc;
+   unsigned int i;
+
+   rc = syscall(__NR_unshare, bogus_flags);
+   printf("unshare(%#llx /* CLONE_??? */) = %s\n",
+  (unsigned long long) bogus_flags, sprintrc(rc));
+
+   for (i = 0; i < ARRAY_SIZE(unshare_flags); i++) {
+   rc = syscall(__NR_unshare, unshare_flags[i].val);
+   printf("unshare(%s) = %s\n",
+  unshare_flags[i].str, sprintrc(rc));
+   }
+
+   puts("+++ exited with 0 +++");
+
+   return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_unshare");
+
+#endif
diff --git a/tests/unshare.test b/tests/unshare.test
new file mode 100755
index 000..ccb9575
--- /dev/null
+++ b/tests/unshare.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check decoding of setns syscall.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a11
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 13/26] tests: Add old*stat checks

2016-10-23 Thread Eugene Syromyatnikov
* tests/.gitignore: Add oldfstat, oldlstat, oldstat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add oldfstat.test, oldlstat.test, oldstat.test.
* tests/oldfstat.c: New file.
* tests/oldfstat.test: Likewise.
* tests/oldlstat.c: Likewise.
* tests/oldlstat.test: Likewise.
* tests/oldstat.c: Likewise.
* tests/oldstat.test: Likewise.
* tests/xstatx.c [!OLD_STAT]: define OLD_STAT to 0.
(print_stat) [OLD_STAT]: Print predefined values for
st_blksize/st_blocks.
(print_stat): check for !OLD_STAT in nanosecond precision checks.
(main) [OLD_STAT]: Ignore EOVERFLOW.
(main): Add check for successful rc in returned size value check;
print address only on non-successful rc.
---
 tests/.gitignore|3 +++
 tests/Makefile.am   |6 ++
 tests/oldfstat.c|   47 +++
 tests/oldfstat.test |   19 +++
 tests/oldlstat.c|   47 +++
 tests/oldlstat.test |5 +
 tests/oldstat.c |   47 +++
 tests/oldstat.test  |5 +
 tests/xstatx.c  |   34 ++
 9 files changed, 205 insertions(+), 8 deletions(-)
 create mode 100644 tests/oldfstat.c
 create mode 100755 tests/oldfstat.test
 create mode 100644 tests/oldlstat.c
 create mode 100755 tests/oldlstat.test
 create mode 100644 tests/oldstat.c
 create mode 100755 tests/oldstat.test

diff --git a/tests/.gitignore b/tests/.gitignore
index a71a0f4..11df7e3 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -183,7 +183,10 @@ netlink_unix_diag
 newfstatat
 nsyscalls
 old_mmap
+oldfstat
+oldlstat
 oldselect
+oldstat
 open
 openat
 pause
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 88a1f9a..b79f755 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -241,7 +241,10 @@ check_PROGRAMS = \
newfstatat \
nsyscalls \
old_mmap \
+   oldfstat \
+   oldlstat \
oldselect \
+   oldstat \
open \
openat \
pause \
@@ -599,7 +602,10 @@ DECODER_TESTS = \
newfstatat.test \
nsyscalls.test \
old_mmap.test \
+   oldfstat.test \
+   oldlstat.test \
oldselect.test \
+   oldstat.test \
open.test \
openat.test \
pause.test \
diff --git a/tests/oldfstat.c b/tests/oldfstat.c
new file mode 100644
index 000..5278599
--- /dev/null
+++ b/tests/oldfstat.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015-2016 Dmitry V. Levin <l...@altlinux.org>
+ * Copyright (c) 2016 Eugene Syromyatnikov <evg...@gmail.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include 
+
+#if defined __NR_oldfstat && HAVE_STRUCT___OLD_KERNEL_STAT
+
+# define OLD_STAT 1
+# define TEST_SYSCALL_NR __NR_oldfstat
+# define TEST_SYSCALL_STR "oldfstat"
+# define STRUCT_STAT struct __old_kernel_stat
+# define STRUCT_STAT_STR "struct __old_kernel_stat"
+# define STRUCT_STAT_IS_STAT64 0
+# define SAMPLE_SIZE ((kernel_ulong_t) 23147718418U)
+# include "fstatx.c"
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_oldfstat && HAVE_STRUCT___OLD_KERNEL_STAT")
+
+#endif
diff --git a/tests/oldfstat.test b/tests/oldfstat.test
new file mode 100755
index 000..66a1056
--- /dev/null
+++ b/tests/oldfstat.test
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Check oldfstat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+# strace -P is implemented using /proc/self/fd
+[ -d /proc/self/fd/ ] ||
+   framework_skip_ '/proc/s

[PATCH 12/26] tests: Additional tests for stat decoder

2016-10-23 Thread Eugene Syromyatnikov
PRINT_SYSCALL_HEADER/PRINT_SYSCALL_FOOTER now contain open/close brace
pair in order to save errno. PRINT_SYSCALL_FOOTER now uses sprintrc for
printing rc/errno.

* xstatx.c (main): Add check for non-available pointer, for block device
file. Update PRINT_SYSCALL_FOOTER call convention.
* fstatat.c (PRINT_SYSCALL_HEADER): Add errno saving.
(PRINT_SYSCALL_FOOTER): Restore errno.
* fstatx.c (PRINT_SYSCALL_HEADER): Add errno saving.
(PRINT_SYSCALL_FOOTER): Restore errno.
* lstatx.c (PRINT_SYSCALL_HEADER): Add errno saving.
(PRINT_SYSCALL_FOOTER): Restore errno.
* statx.sh: Add tracing of /dev/full file, specify alignment.
* fstat.test: Specify alignment.
---
 tests/fstat.test |2 +-
 tests/fstatat.c  |   10 +++---
 tests/fstatx.c   |   11 ---
 tests/lstatx.c   |   10 +++---
 tests/statx.sh   |2 +-
 tests/xstatx.c   |   33 ++---
 6 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/tests/fstat.test b/tests/fstat.test
index 506b440..2ba0fba 100755
--- a/tests/fstat.test
+++ b/tests/fstat.test
@@ -12,7 +12,7 @@ syscall=$NAME
 run_prog > /dev/null
 sample=$syscall.sample
 > "$sample"
-run_strace -ve$syscall -P$sample $args > "$OUT"
+run_strace -ve$syscall -P$sample -a21 $args > "$OUT"
 match_diff "$LOG" "$OUT"
 rm -f "$OUT"
 
diff --git a/tests/fstatat.c b/tests/fstatat.c
index ff47601..ec55ca0 100644
--- a/tests/fstatat.c
+++ b/tests/fstatat.c
@@ -30,9 +30,13 @@
 # define TEST_SYSCALL_INVOKE(sample, pst) \
fstatat(AT_FDCWD, sample, pst, AT_SYMLINK_NOFOLLOW)
 # define PRINT_SYSCALL_HEADER(sample) \
-   printf("%s(AT_FDCWD, \"%s\", ", TEST_SYSCALL_STR, sample)
-# define PRINT_SYSCALL_FOOTER \
-   puts(", AT_SYMLINK_NOFOLLOW) = 0")
+   do { \
+   int saved_errno = errno; \
+   printf("%s(AT_FDCWD, \"%s\", ", TEST_SYSCALL_STR, sample)
+# define PRINT_SYSCALL_FOOTER(rc) \
+   errno = saved_errno; \
+   printf(", AT_SYMLINK_NOFOLLOW) = %s\n", sprintrc(rc)); \
+   } while (0)
 
 # include "xstatx.c"
 
diff --git a/tests/fstatx.c b/tests/fstatx.c
index 890e30d..174f29f 100644
--- a/tests/fstatx.c
+++ b/tests/fstatx.c
@@ -25,12 +25,17 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define IS_FSTAT 1
 #define TEST_SYSCALL_INVOKE(sample, pst) \
syscall(TEST_SYSCALL_NR, 0, pst)
 #define PRINT_SYSCALL_HEADER(sample) \
-   printf("%s(0, ", TEST_SYSCALL_STR)
-#define PRINT_SYSCALL_FOOTER \
-   puts(") = 0")
+   do { \
+   int saved_errno = errno; \
+   printf("%s(0, ", TEST_SYSCALL_STR)
+#define PRINT_SYSCALL_FOOTER(rc) \
+   errno = saved_errno; \
+   printf(") = %s\n", sprintrc(rc)); \
+   } while (0)
 
 #define USE_ASM_STAT
 
diff --git a/tests/lstatx.c b/tests/lstatx.c
index 2bd4e9f..a3ff843 100644
--- a/tests/lstatx.c
+++ b/tests/lstatx.c
@@ -28,9 +28,13 @@
 #define TEST_SYSCALL_INVOKE(sample, pst) \
syscall(TEST_SYSCALL_NR, sample, pst)
 #define PRINT_SYSCALL_HEADER(sample) \
-   printf("%s(\"%s\", ", TEST_SYSCALL_STR, sample)
-#define PRINT_SYSCALL_FOOTER \
-   puts(") = 0")
+   do { \
+   int saved_errno = errno; \
+   printf("%s(\"%s\", ", TEST_SYSCALL_STR, sample)
+#define PRINT_SYSCALL_FOOTER(rc) \
+   errno = saved_errno; \
+   printf(") = %s\n", sprintrc(rc)); \
+   } while (0)
 
 #define USE_ASM_STAT
 
diff --git a/tests/statx.sh b/tests/statx.sh
index 830e5fc..a630193 100755
--- a/tests/statx.sh
+++ b/tests/statx.sh
@@ -3,4 +3,4 @@
 # Check decoding of stat family syscalls.
 
 . "${srcdir=.}/init.sh"
-run_strace_match_diff -v -P $NAME.sample
+run_strace_match_diff -v -P $NAME.sample -P /dev/full -a32
diff --git a/tests/xstatx.c b/tests/xstatx.c
index 2d0dac3..d1ad52d 100644
--- a/tests/xstatx.c
+++ b/tests/xstatx.c
@@ -40,6 +40,7 @@
 #  error PRINT_SYSCALL_FOOTER must be defined
 # endif
 
+# include 
 # include 
 # include 
 # include 
@@ -132,6 +133,10 @@ typedef off_t libc_off_t;
 #  endif /* HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC */
 # endif
 
+# ifndef IS_FSTAT
+#  define IS_STAT 0
+# endif
+
 static void
 print_ftype(const unsigned int mode)
 {
@@ -227,16 +232,38 @@ create_sample(const char *fname, const libc_off_t size)
 int
 main(void)
 {
+# if !IS_FSTAT
+   static const char full[] = "/dev/full";
+# endif
static const char sample[] = TEST_SYSCALL_STR ".sample";
STRUCT_STAT st[2];
 
-   int rc = create_sample(sample, SAMPLE_SIZE);
+   STRUCT_STAT *st_cut = tail_alloc(sizeof(*st_cut) - 4);
+
+   int rc;
+
+   rc = create_sample(sample, SAMPLE_SIZE);
if (rc) {
(void) unlink(sample);
return rc;
}
 
-   if (TEST_SYSCALL_INVOKE(sample, st)) {
+   rc = TEST_SYSCALL_INVOKE(sample, st_cut);
+   PRINT_SYSCALL_HEADER(sample);
+   printf("%p", st_cut);
+   PRINT_SYSCALL_FOOTER(rc);
+
+# if !IS_FSTAT
+   rc = 

[PATCH 15/26] clone: Use kernel_ulong_t as type of flags parameter of unshare call

2016-10-23 Thread Eugene Syromyatnikov
Kernel declares flags parameter as long and looks like x32 and n32
implement no compat for this call.

* clone.c (SYS_FUNC(unshare)): Use getarg_ull and printflags64 for
obtaining and parsing flags parameter.
---
 clone.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clone.c b/clone.c
index c2832c1..0f2d32c 100644
--- a/clone.c
+++ b/clone.c
@@ -153,7 +153,7 @@ SYS_FUNC(setns)
 
 SYS_FUNC(unshare)
 {
-   printflags_long(unshare_flags, tcp->u_arg[0], "CLONE_???");
+   printflags64(unshare_flags, getarg_ull(tcp, 0), "CLONE_???");
return RVAL_DECODED;
 }
 
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 02/26] xlat: Add values for MODULE_INIT_* constants

2016-10-23 Thread Eugene Syromyatnikov
* bjm.c (MODULE_INIT_IGNORE_MODVERSIONS, MODULE_INIT_IGNORE_VERMAGIC):
Remove.
* xlat/module_init_flags.in: Add values for
MODULE_INIT_IGNORE_MODVERSIONS and MODULE_INIT_IGNORE_VERMAGIC records.
---
 bjm.c |3 ---
 xlat/module_init_flags.in |4 ++--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/bjm.c b/bjm.c
index d7e241e..e77b73d 100644
--- a/bjm.c
+++ b/bjm.c
@@ -51,9 +51,6 @@ SYS_FUNC(init_module)
return RVAL_DECODED;
 }
 
-#define MODULE_INIT_IGNORE_MODVERSIONS  1
-#define MODULE_INIT_IGNORE_VERMAGIC 2
-
 #include "xlat/module_init_flags.h"
 
 SYS_FUNC(finit_module)
diff --git a/xlat/module_init_flags.in b/xlat/module_init_flags.in
index e672a59..1547189 100644
--- a/xlat/module_init_flags.in
+++ b/xlat/module_init_flags.in
@@ -1,2 +1,2 @@
-MODULE_INIT_IGNORE_MODVERSIONS
-MODULE_INIT_IGNORE_VERMAGIC
+MODULE_INIT_IGNORE_MODVERSIONS (1 << 0)
+MODULE_INIT_IGNORE_VERMAGIC(1 << 1)
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 06/26] tests: Some additional checks for fanotify_mark

2016-10-23 Thread Eugene Syromyatnikov
* tests/fanotify_mark.c (do_call): New function.
(main): Use it.
---
 tests/fanotify_mark.c|  137 +-
 tests/fanotify_mark.test |2 +-
 2 files changed, 135 insertions(+), 4 deletions(-)

diff --git a/tests/fanotify_mark.c b/tests/fanotify_mark.c
index a994c15..a4cb26d 100644
--- a/tests/fanotify_mark.c
+++ b/tests/fanotify_mark.c
@@ -1,24 +1,155 @@
 #include "tests.h"
 
-#if defined HAVE_SYS_FANOTIFY_H && defined HAVE_FANOTIFY_MARK
+#include 
 
+#if defined HAVE_SYS_FANOTIFY_H && defined HAVE_FANOTIFY_MARK && \
+   defined __NR_fanotify_mark
+
+# include 
 # include 
+# include 
+
 # include 
 
+# include "kernel_types.h"
+
+/* Performs fanotify_mark call via the syscall interface. */
+static void
+do_call(kernel_ulong_t fd, kernel_ulong_t flags, const char *flags_str,
+   uint64_t mask, const char *mask_str, kernel_ulong_t dirfd,
+   const char *dirfd_str, kernel_ulong_t path, const char *path_str)
+{
+   long rc;
+
+   rc = syscall(__NR_fanotify_mark, fd, flags,
+# if (LONG_MAX > INT_MAX) \
+  || (defined __x86_64__ && defined __ILP32__) \
+  || defined LINUX_MIPSN32
+   mask,
+# else
+/* arch/parisc/kernel/sys_parisc32.c, commit ab8a261b */
+#  ifdef HPPA
+   LL_VAL_TO_PAIR((mask << 32) | (mask >> 32)),
+#  else
+   LL_VAL_TO_PAIR(mask),
+#  endif
+# endif
+   dirfd, path);
+
+   printf("fanotify_mark(%d, %s, %s, %s, %s) = %s\n",
+  (int) fd, flags_str, mask_str, dirfd_str, path_str,
+  sprintrc(rc));
+}
+
+struct strval {
+   kernel_ulong_t val;
+   const char *str;
+};
+
+struct strval64 {
+   uint64_t val;
+   const char *str;
+};
+
+#define STR16 "0123456789abcdef"
+#define STR64 STR16 STR16 STR16 STR16
+
 int
 main(void)
 {
-   int rc = fanotify_mark(-1, FAN_MARK_ADD, FAN_MODIFY | FAN_ONDIR,
+   enum {
+   PATH1_SIZE = 64,
+   };
+
+   static const kernel_ulong_t fds[] = {
+   (kernel_ulong_t) 0xdeadfeed12345678ULL,
+   (kernel_ulong_t) 0xULL,
+   (kernel_ulong_t) 0xdeb0d1edULL,
+   };
+   static const struct strval flags[] = {
+   { (kernel_ulong_t) 0xULL, "0" },
+   { (kernel_ulong_t) 0xdec0deddefaced00ULL,
+   "0xefaced00 /* FAN_MARK_??? */" },
+   { (kernel_ulong_t) 0xda7a10570040ULL,
+   "FAN_MARK_IGNORED_SURV_MODIFY" },
+   { (kernel_ulong_t) 0xbadc0deddeadfeedULL,
+   "FAN_MARK_ADD|FAN_MARK_DONT_FOLLOW|FAN_MARK_ONLYDIR|"
+   "FAN_MARK_IGNORED_MASK|FAN_MARK_IGNORED_SURV_MODIFY|"
+   "FAN_MARK_FLUSH|0xdeadfe00" },
+   };
+   static const struct strval64 masks[] = {
+   { ARG_ULL_STR(0) },
+   { 0xdeadfeedfacebeefULL,
+   "FAN_ACCESS|FAN_MODIFY|FAN_CLOSE_WRITE|FAN_OPEN|"
+   "FAN_ACCESS_PERM|FAN_ONDIR|FAN_EVENT_ON_CHILD|"
+   "0xdeadfeedb2ccbec4" },
+   { ARG_ULL_STR(0xb7fcbfc4) " /* FAN_??? */" },
+   };
+   static const struct strval dirfds[] = {
+   { (kernel_ulong_t) 0xfacefeed0001ULL, "1" },
+   { (kernel_ulong_t) 0xdec0ded0ULL, "FAN_NOFD" },
+   { (kernel_ulong_t) 0xbadfacedff9cULL, "AT_FDCWD" },
+   { (kernel_ulong_t) 0xdefaced1beeff00dULL, "-1091571699" },
+   };
+   static const char str64[] = STR64;
+
+   static char bogus_path1_addr[sizeof("0x") + sizeof(void *) * 2];
+   static char bogus_path1_after_addr[sizeof("0x") + sizeof(void *) * 2];
+
+   char *bogus_path1 = tail_memdup(str64, PATH1_SIZE);
+   char *bogus_path2 = tail_memdup(str64, sizeof(str64));
+
+   struct strval paths[] = {
+   { (kernel_ulong_t) 0, "NULL" },
+   { (kernel_ulong_t) (uintptr_t) (bogus_path1 + PATH1_SIZE),
+   bogus_path1_after_addr },
+   { (kernel_ulong_t) (uintptr_t) bogus_path1, bogus_path1_addr },
+   { (kernel_ulong_t) (uintptr_t) bogus_path2, "\"" STR64 "\"" },
+   };
+
+   unsigned int i;
+   unsigned int j;
+   unsigned int k;
+   unsigned int l;
+   unsigned int m;
+   int rc;
+
+
+   snprintf(bogus_path1_addr, sizeof(bogus_path1_addr), "%p", bogus_path1);
+   snprintf(bogus_path1_after_addr, sizeof(bogus_path1_after_addr), "%p",
+   bogus_path1 + PATH1_SIZE);
+
+   rc = fanotify_mark(-1, FAN_MARK_ADD, FAN_MODIFY | FAN_ONDIR,
   -100, ".");
printf("fanotify_mark(-1, FAN_MARK_ADD, FAN_MODIFY|FAN_ONDIR"
   ", AT_FDCWD, \".\") = %s\n", sprintrc(rc));
 
+   for (i = 0; i < ARRAY_SIZE(fds); i++) {
+   for (j = 0; j < ARRAY_SIZE(flags); j++) {
+   for (k = 0; k < 

[PATCH 10/26] clone: Use separate xlat for nstype parameter of setns syscall

2016-10-23 Thread Eugene Syromyatnikov
nstype is not flag set but specific type value against which it is
compared in kernel (see kernel/nsproxy.c, SYSCALL_DEFINE2(setns, ...)).

* xlat/setns_types.in: New file.
* clone.c: Use printxval and setns_types for nstype parameter.
---
 clone.c |3 ++-
 xlat/setns_types.in |8 
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 xlat/setns_types.in

diff --git a/clone.c b/clone.c
index 604a695..0dd4fc9 100644
--- a/clone.c
+++ b/clone.c
@@ -38,6 +38,7 @@
 #endif
 
 #include "xlat/clone_flags.h"
+#include "xlat/setns_types.h"
 
 #if defined IA64
 # define ARG_FLAGS 0
@@ -144,7 +145,7 @@ SYS_FUNC(setns)
 {
printfd(tcp, tcp->u_arg[0]);
tprints(", ");
-   printflags(clone_flags, tcp->u_arg[1], "CLONE_???");
+   printxval(setns_types, tcp->u_arg[1], "CLONE_NEW???");
 
return RVAL_DECODED;
 }
diff --git a/xlat/setns_types.in b/xlat/setns_types.in
new file mode 100644
index 000..09186f2
--- /dev/null
+++ b/xlat/setns_types.in
@@ -0,0 +1,8 @@
+0
+CLONE_NEWNS0x0002
+CLONE_NEWCGROUP0x0200
+CLONE_NEWUTS   0x0400
+CLONE_NEWIPC   0x0800
+CLONE_NEWUSER  0x1000
+CLONE_NEWPID   0x2000
+CLONE_NEWNET   0x4000
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 14/26] clone: Use separate flag list for unshare

2016-10-23 Thread Eugene Syromyatnikov
Not all clone flags could be passed to unshare (see check_unshare_flags
function in kernel/fork.c).

* xlat/unshare_flags.in: New file.
* clone.c (SYS_FUNC(unshare)): Use unshare_flags for printing flags
parameter.
---
 clone.c   |3 ++-
 xlat/unshare_flags.in |   13 +
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 xlat/unshare_flags.in

diff --git a/clone.c b/clone.c
index 0dd4fc9..c2832c1 100644
--- a/clone.c
+++ b/clone.c
@@ -39,6 +39,7 @@
 
 #include "xlat/clone_flags.h"
 #include "xlat/setns_types.h"
+#include "xlat/unshare_flags.h"
 
 #if defined IA64
 # define ARG_FLAGS 0
@@ -152,7 +153,7 @@ SYS_FUNC(setns)
 
 SYS_FUNC(unshare)
 {
-   printflags_long(clone_flags, tcp->u_arg[0], "CLONE_???");
+   printflags_long(unshare_flags, tcp->u_arg[0], "CLONE_???");
return RVAL_DECODED;
 }
 
diff --git a/xlat/unshare_flags.in b/xlat/unshare_flags.in
new file mode 100644
index 000..4b289a7
--- /dev/null
+++ b/xlat/unshare_flags.in
@@ -0,0 +1,13 @@
+CLONE_THREAD
+CLONE_FS
+CLONE_NEWNS
+CLONE_SIGHAND
+CLONE_VM
+CLONE_FILES
+CLONE_SYSVSEM
+CLONE_NEWUTS
+CLONE_NEWIPC
+CLONE_NEWNET
+CLONE_NEWUSER
+CLONE_NEWPID
+CLONE_NEWCGROUP
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 09/26] tests: Check non-verbose capget/capset output

2016-10-23 Thread Eugene Syromyatnikov
* tests/caps-abbrev.awk: New file.
* tests/caps-abbrev.c: Likewise.
* tests/caps-abbrev.test: New test.
* tests/.gitignore: Add caps-abbrev.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add caps-abbrev.test.
(EXTRA_DIST): Add caps-abbrev.awk.
---
 tests/.gitignore   |1 +
 tests/Makefile.am  |3 +++
 tests/caps-abbrev.awk  |   52 
 tests/caps-abbrev.c|1 +
 tests/caps-abbrev.test |   11 ++
 5 files changed, 68 insertions(+)
 create mode 100644 tests/caps-abbrev.awk
 create mode 100644 tests/caps-abbrev.c
 create mode 100755 tests/caps-abbrev.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 826df34..7b1f5ed 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -21,6 +21,7 @@ bpf
 brk
 btrfs
 caps
+caps-abbrev
 chmod
 chown
 chown32
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a25df97..000b2db 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -81,6 +81,7 @@ check_PROGRAMS = \
brk \
btrfs \
caps \
+   caps-abbrev \
chmod \
chown \
chown32 \
@@ -444,6 +445,7 @@ DECODER_TESTS = \
btrfs-w.test \
btrfs-vw.test \
caps.test \
+   caps-abbrev.test \
chmod.test \
chown.test \
chown32.test \
@@ -788,6 +790,7 @@ AM_TEST_LOG_FLAGS = STRACE_ARCH=$(ARCH) 
MIPS_ABI=$(MIPS_ABI) $(srcdir)/run.sh
 
 EXTRA_DIST = init.sh run.sh match.awk \
 caps.awk \
+caps-abbrev.awk \
 count-f.expected \
 eventfd.expected \
 fadvise.h \
diff --git a/tests/caps-abbrev.awk b/tests/caps-abbrev.awk
new file mode 100644
index 000..86de7f2
--- /dev/null
+++ b/tests/caps-abbrev.awk
@@ -0,0 +1,52 @@
+#!/bin/gawk
+#
+# This file is part of caps strace test.
+#
+# Copyright (c) 2014-2016 Dmitry V. Levin 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+#derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+BEGIN {
+   cap = 
"(0|1<

[PATCH 05/26] tests: use sprintrc in tests/fanotify_mark.c

2016-10-23 Thread Eugene Syromyatnikov
* tests/fanotify.c (main): Use sprintrc.
---
 tests/fanotify_mark.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fanotify_mark.c b/tests/fanotify_mark.c
index 9cac5ef..a994c15 100644
--- a/tests/fanotify_mark.c
+++ b/tests/fanotify_mark.c
@@ -11,7 +11,7 @@ main(void)
int rc = fanotify_mark(-1, FAN_MARK_ADD, FAN_MODIFY | FAN_ONDIR,
   -100, ".");
printf("fanotify_mark(-1, FAN_MARK_ADD, FAN_MODIFY|FAN_ONDIR"
-  ", AT_FDCWD, \".\") = %d %s (%m)\n", rc, errno2name());
+  ", AT_FDCWD, \".\") = %s\n", sprintrc(rc));
 
puts("+++ exited with 0 +++");
return 0;
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 01/26] Remove parser of create_module syscall

2016-10-23 Thread Eugene Syromyatnikov
Since create_module syscall is present only in kernels before Linux 2.6
and strace does not support those kernels, there is no use to keep this
parser any longer.

* bjm.c (SYS_FUNC(create_module)): Remove.
* linux/dummy.h (sys_create_module): Add stub alias.
---
 bjm.c |8 
 linux/dummy.h |1 +
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/bjm.c b/bjm.c
index 7a72809..d7e241e 100644
--- a/bjm.c
+++ b/bjm.c
@@ -33,14 +33,6 @@
 
 #include "xlat/delete_module_flags.h"
 
-SYS_FUNC(create_module)
-{
-   printpath(tcp, tcp->u_arg[0]);
-   tprintf(", %lu", tcp->u_arg[1]);
-
-   return RVAL_DECODED | RVAL_HEX;
-}
-
 SYS_FUNC(delete_module)
 {
printstr(tcp, tcp->u_arg[0], -1);
diff --git a/linux/dummy.h b/linux/dummy.h
index 87d2127..49dcf16 100644
--- a/linux/dummy.h
+++ b/linux/dummy.h
@@ -134,6 +134,7 @@
 /* unimplemented */
 #definesys_afs_syscall printargs
 #definesys_break   printargs
+#definesys_create_module   printargs
 #definesys_ftime   printargs
 #definesys_get_kernel_syms printargs
 #definesys_getpmsg printargs
-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[PATCH 00/26] Various misc tests and additional checks

2016-10-23 Thread Eugene Syromyatnikov
Hello.

This patchset adds some minor decoder tests, amend existing decoder
tests with additional checks and provides some minor fixes.
 * New tests: init_module, finit_module, delete_module, fanotify_init,
   setns, unshare, oldfstat, oldlstat, oldstat, kexec_load,
   kexec_file_load.
 * Additional checks: fonotify_mark, capset, capget, stat family,
   name_to_handle_at, open_by_handle_at.
 * Another changes: create_module decoder removed; keyctl test build
   warning fix; minor fixes in decoders.

Eugene Syromyatnikov (26):
  Remove parser of create_module syscall
  xlat: Add values for MODULE_INIT_* constants
  bjm: Use getarg_ull for retrieving len parameter of init_module
syscall
  tests: Add checks for {init,finit,delete}_module syscall decoders
  tests: use sprintrc in tests/fanotify_mark.c
  tests: Some additional checks for fanotify_mark
  tests: Add fanotify_init syscall decoding check
  tests: Additional capset decoder checks
  tests: Check non-verbose capget/capset output
  clone: Use separate xlat for nstype parameter of setns syscall
  tests: Add setns syscall decoding check
  tests: Additional tests for stat decoder
  tests: Add old*stat checks
  clone: Use separate flag list for unshare
  clone: Use kernel_ulong_t as type of flags parameter of unshare call
  tests: Add unshare syscall decoding check
  kexec: Add printing of struct kexec_segment field names
  kexec: Fix zeroing of higher bits of flags parameter in kexec_load
  defs: Add widen_to_ulong macro
  kexec: Use widen_to_ulong since kexec_load has compat on x32/n32
  tests: Add kexec checks
  bjm: Parse parameters of init_module as of kernel_ulong_t type
  file_handle: Use separate xlat for name_ta_handle_at flags
  tests: Proper type conversion in keyctl test
  tests: Require only presence of __NR_* macros for file_handle test
  tests: Additional name_to_handle_at/open_by_handle_at checks

 bjm.c   |   17 +--
 clone.c |6 +-
 defs.h  |   15 +-
 file_handle.c   |7 +-
 kexec.c |   17 +--
 linux/dummy.h   |1 +
 tests/.gitignore|   12 ++
 tests/Makefile.am   |   26 
 tests/caps-abbrev.awk   |   52 +++
 tests/caps-abbrev.c |1 +
 tests/caps-abbrev.test  |   11 ++
 tests/caps.awk  |   16 ++-
 tests/caps.c|   28 +++-
 tests/delete_module.c   |  118 
 tests/delete_module.test|6 +
 tests/fanotify_init.c   |   68 +
 tests/fanotify_init.test|6 +
 tests/fanotify_mark.c   |  139 ++-
 tests/fanotify_mark.test|2 +-
 tests/file_handle.c |  293 +--
 tests/finit_module.c|  124 +
 tests/finit_module.test |6 +
 tests/fstat.test|2 +-
 tests/fstatat.c |   10 +-
 tests/fstatx.c  |   11 +-
 tests/init_delete_module.h  |   37 +
 tests/init_module.c |  113 +++
 tests/init_module.test  |6 +
 tests/kexec_file_load.c |  129 +
 tests/kexec_file_load.test  |6 +
 tests/kexec_load.c  |  178 
 tests/kexec_load.test   |6 +
 tests/keyctl.c  |3 +-
 tests/lstatx.c  |   10 +-
 tests/oldfstat.c|   47 +++
 tests/oldfstat.test |   19 +++
 tests/oldlstat.c|   47 +++
 tests/oldlstat.test |5 +
 tests/oldstat.c |   47 +++
 tests/oldstat.test  |5 +
 tests/setns.c   |   75 ++
 tests/setns.test|6 +
 tests/statx.sh  |2 +-
 tests/unshare.c |   82 +++
 tests/unshare.test  |6 +
 tests/xstatx.c  |   67 +++--
 util.c  |   11 +-
 xlat/module_init_flags.in   |4 +-
 xlat/name_to_handle_at_flags.in |2 +
 xlat/setns_types.in |8 ++
 xlat/unshare_flags.in   |   13 ++
 51 files changed, 1849 insertions(+), 79 deletions(-)
 create mode 100644 tests/caps-abbrev.awk
 create mode 100644 tests/caps-abbrev.c
 create mode 100755 tests/caps-abbrev.test
 create mode 100644 tests/delete_module.c
 create mode 100755 tests/delete_module.test
 create mode 100644 tests/fanotify_init.c
 create mode 100755 tests/fanotify_init.test
 create mode 100644 tests/finit_module.c
 create mode 100755 tests/finit_module.test
 create mode 100644 tests/init_delete_module.h
 create mode 100644 tests/init_module.c
 create mode 100755 tests/init_module.test
 create mode 100644 tests/kexec_file_load.c
 create mode 100755 tests/kexec_file_load.test
 create mode 100644 tests/kexec_load.c
 create mode 100755

[PATCH 6/6] tests: Add tests for perf_event_attr structure decoding in perf_event_open

2016-10-15 Thread Eugene Syromyatnikov
* configure.ac: Add checks for presence of various fields of struct
perf_event_attr defined in kernel headers.
* tests/.gitignore: Add Add perf_event_open_verbose,
perf_event_open_verbose_unabbrev..
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS):  Add perf_event_open_verbose.test,
perf_event_open_verbose_unabbrev.test.
* tests/perf_event_open_verbose.c: New file.
* tests/perf_event_open_verbose.test: Likewise.
* tests/perf_event_open_verbose_unabbrev.c: Likewise.
* tests/perf_event_open_verbose_unabbrev.test: Likewise.
---
 configure.ac|   24 +
 tests/.gitignore|2 +
 tests/Makefile.am   |4 +
 tests/perf_event_open_verbose.c |  790 +++
 tests/perf_event_open_verbose.test  |7 +
 tests/perf_event_open_verbose_unabbrev.c|2 +
 tests/perf_event_open_verbose_unabbrev.test |7 +
 7 files changed, 836 insertions(+)
 create mode 100644 tests/perf_event_open_verbose.c
 create mode 100755 tests/perf_event_open_verbose.test
 create mode 100644 tests/perf_event_open_verbose_unabbrev.c
 create mode 100755 tests/perf_event_open_verbose_unabbrev.test

diff --git a/configure.ac b/configure.ac
index 404dfb9..3102a9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -347,6 +347,30 @@ AC_CHECK_MEMBERS(m4_normalize([
siginfo_t.si_overrun
 ]),,, [#include ])
 
+AC_CHECK_MEMBERS(m4_normalize([
+   struct perf_event_attr.precise_ip,
+   struct perf_event_attr.mmap_data,
+   struct perf_event_attr.sample_id_all,
+   struct perf_event_attr.exclude_host,
+   struct perf_event_attr.exclude_guest,
+   struct perf_event_attr.exclude_callchain_kernel,
+   struct perf_event_attr.exclude_callchain_user,
+   struct perf_event_attr.mmap2,
+   struct perf_event_attr.comm_exec,
+   struct perf_event_attr.use_clockid,
+   struct perf_event_attr.context_switch,
+   struct perf_event_attr.write_backward,
+   struct perf_event_attr.bp_type,
+   struct perf_event_attr.config1,
+   struct perf_event_attr.config2,
+   struct perf_event_attr.branch_sample_type,
+   struct perf_event_attr.sample_regs_user,
+   struct perf_event_attr.sample_stack_user,
+   struct perf_event_attr.sample_regs_intr,
+   struct perf_event_attr.aux_watermark,
+   struct perf_event_attr.sample_max_stack
+]),,, [#include ])
+
 AC_CHECK_HEADERS(m4_normalize([
asm/cachectl.h
asm/sysmips.h
diff --git a/tests/.gitignore b/tests/.gitignore
index 5b33416..92cca67 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -177,6 +177,8 @@ openat
 pause
 pc
 perf_event_open
+perf_event_open_verbose
+perf_event_open_verbose_unabbrev
 personality
 pipe
 poll
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6138199..1305c96 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -235,6 +235,8 @@ check_PROGRAMS = \
pause \
pc \
perf_event_open \
+   perf_event_open_verbose \
+   perf_event_open_verbose_unabbrev \
personality \
pipe \
poll \
@@ -575,6 +577,8 @@ DECODER_TESTS = \
openat.test \
pause.test \
perf_event_open.test \
+   perf_event_open_verbose.test \
+   perf_event_open_verbose_unabbrev.test \
personality.test \
pipe.test \
poll.test \
diff --git a/tests/perf_event_open_verbose.c b/tests/perf_event_open_verbose.c
new file mode 100644
index 000..3517b5f
--- /dev/null
+++ b/tests/perf_event_open_verbose.c
@@ -0,0 +1,790 @@
+#include "tests.h"
+#include 
+
+#if defined(__NR_perf_event_open) && defined(HAVE_LINUX_PERF_EVENT_H)
+
+# include 
+# include 
+# include 
+# include 
+# include 
+# include 
+# include 
+# include 
+
+# include 
+
+# include "xlat.h"
+# include "xlat/perf_event_open_flags.h"
+# include "xlat/perf_attr_size.h"
+
+# if ULONG_MAX > UINT_MAX /* Poor man's "whether long is 8 bytes?" */
+#  define LONG_STR_PREFIX ""
+# else /* !(ULONG_MAX > UINT_MAX) */
+#  define LONG_STR_PREFIX ""
+# endif /* ULONG_MAX > UINT_MAX */
+
+# if !defined(ABBREV)
+#  define ABBREV 1
+# endif /* !defined(ABBREV) */
+
+# define PERF_TYPE_BREAKPOINT 5
+
+
+struct s32_val_str {
+   int32_t val;
+   const char *str;
+};
+
+struct u32_val_str {
+   uint32_t val;
+   const char *str;
+};
+
+struct u64_val_str {
+   uint64_t val;
+   const char *str;
+};
+
+/* In order to avoid endianess-specific hackery */
+struct pea_flags {
+   uint64_t disabled :1,
+inherit  :1,
+pinned   :1,
+exclusive:1,
+exclude_user :1,
+exclude_kernel   :1,
+exclude_hv   :1,
+exclude_idle :1,
+mmap :1,
+comm 

[PATCH 0/6] Decoding of perf_event_attr structure

2016-10-15 Thread Eugene Syromyatnikov
Hello.

The following patch implements decoding of the perf_event_attr structure
used in perf_event_open syscall.

Eugene Syromyatnikov (6):
  defs.h: Add offsetofend macro
  Implement decoding of perf_event_attr structure in perf_event_open
syscall
  tests: Add period parameter to fill_memory_ex
  tests: Move fill_memory{,_ex} into a separate file
  xlat: Add values for clockname definitions
  tests: Add tests for perf_event_attr structure decoding in
perf_event_open

 Makefile.am |1 +
 configure.ac|   24 +
 defs.h  |5 +
 perf.c  |  409 +-
 perf_event_struct.h |   73 +++
 tests/.gitignore|2 +
 tests/Makefile.am   |5 +
 tests/fill_memory.c |   18 +
 tests/perf_event_open.test  |2 +-
 tests/perf_event_open_verbose.c |  790 +++
 tests/perf_event_open_verbose.test  |7 +
 tests/perf_event_open_verbose_unabbrev.c|2 +
 tests/perf_event_open_verbose_unabbrev.test |7 +
 tests/quotactl-xfs.c|2 +-
 tests/quotactl.h|   16 -
 tests/tests.h   |   10 +
 xlat/clocknames.in  |   24 +-
 xlat/hw_breakpoint_len.in   |4 +
 xlat/hw_breakpoint_type.in  |6 +
 xlat/perf_attr_size.in  |6 +
 xlat/perf_branch_sample_type.in |   16 +
 xlat/perf_event_read_format.in  |4 +
 xlat/perf_event_sample_format.in|   19 +
 xlat/perf_hw_cache_id.in|8 +
 xlat/perf_hw_cache_op_id.in |4 +
 xlat/perf_hw_cache_op_result_id.in  |3 +
 xlat/perf_hw_id.in  |   11 +
 xlat/perf_sw_ids.in |   12 +
 xlat/perf_type_id.in|7 +
 29 files changed, 1460 insertions(+), 37 deletions(-)
 create mode 100644 perf_event_struct.h
 create mode 100644 tests/fill_memory.c
 create mode 100644 tests/perf_event_open_verbose.c
 create mode 100755 tests/perf_event_open_verbose.test
 create mode 100644 tests/perf_event_open_verbose_unabbrev.c
 create mode 100755 tests/perf_event_open_verbose_unabbrev.test
 create mode 100644 xlat/hw_breakpoint_len.in
 create mode 100644 xlat/hw_breakpoint_type.in
 create mode 100644 xlat/perf_attr_size.in
 create mode 100644 xlat/perf_branch_sample_type.in
 create mode 100644 xlat/perf_event_read_format.in
 create mode 100644 xlat/perf_event_sample_format.in
 create mode 100644 xlat/perf_hw_cache_id.in
 create mode 100644 xlat/perf_hw_cache_op_id.in
 create mode 100644 xlat/perf_hw_cache_op_result_id.in
 create mode 100644 xlat/perf_hw_id.in
 create mode 100644 xlat/perf_sw_ids.in
 create mode 100644 xlat/perf_type_id.in

-- 
1.7.10.4


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


  1   2   3   >