Blame SOURCES/0041-tests-add-strace-k-p-test.patch

86f512
From 8e515c744935fe67e6a1b941f4c5414472c163b7 Mon Sep 17 00:00:00 2001
86f512
From: Eugene Syromyatnikov <evgsyr@gmail.com>
86f512
Date: Mon, 20 Jan 2020 16:19:40 +0100
86f512
Subject: [PATCH] tests: add strace-k-p test
86f512
86f512
Add a check of the stack unwinding for attached processes.
86f512
86f512
* tests/stack-fcall-attach.c: New file.
86f512
* tests/strace-k-p.expected: Likewise.
86f512
* tests/strace-k-p.test: New test.
86f512
* tests/Makefile.am (EXTRA_DIST): Add strace-k-p.expected and strace-k-p.test.
86f512
(STACKTRACE_TESTS): Add strace-k-p.test
86f512
(check_PROGRAMS): Add stack-fcall-attach.
86f512
(stack_fcall_attach_SOURCES): New variable.
86f512
* tests/stack-fcall.c: Include "tests.h" and <unistd.h>.
86f512
[!ATTACH_MODE] (ATTACH_MODE): Define to 0.
86f512
(main) [ATTACH_MODE]: Wait a bit.
86f512
* tests/strace-k.test: Add attach mode.
86f512
86f512
Complements: v5.4-18-g69b2c33 "unwind-libdw: fix initialization of libdwfl cache"
86f512
---
86f512
Backport changes:
86f512
 * "SIGURG" line has been removed from tests/strace-k-p.expected, as it requires
86f512
   v4.25~22 "Print stack traces on signals" and v4.25~21 "tests: check stack
86f512
   unwinding for signals".
86f512
 * "chdir" usage in tests/strace-k-p.expected has been replaced with "getpid",
86f512
    as it is the syscall that was used in the stack-fcall.c at the time.
86f512
 * Added the respective changes to tests/Makefile.in file.
86f512
 * The changes to tests/stack-fcall-attach.c, tests/strace-k-p.expected,
86f512
   tests/strace-k-p.test, tests/Makefile.am, tests/stack-fcall.c,
86f512
   and tests/strace-k.test have been copied over to tests-m32 and tests-mx32
86f512
   directories.
86f512
86f512
---
86f512
 tests/Makefile.am          |  8 +++++++-
86f512
 tests/stack-fcall-attach.c |  2 ++
86f512
 tests/stack-fcall.c        | 11 +++++++++++
86f512
 tests/strace-k-p.expected  |  2 ++
86f512
 tests/strace-k-p.test      | 13 +++++++++++++
86f512
 tests/strace-k.test        | 17 ++++++++++++++++-
86f512
 6 files changed, 51 insertions(+), 2 deletions(-)
86f512
 create mode 100644 tests/stack-fcall-attach.c
86f512
 create mode 100644 tests/strace-k-p.expected
86f512
 create mode 100755 tests/strace-k-p.test
86f512
86f512
Index: strace-5.1/tests/Makefile.am
86f512
===================================================================
86f512
--- strace-5.1.orig/tests/Makefile.am	2020-01-23 16:56:22.081268798 +0100
86f512
+++ strace-5.1/tests/Makefile.am	2020-01-23 17:03:50.786051167 +0100
86f512
@@ -156,6 +156,7 @@
86f512
 	signal_receive \
86f512
 	sleep \
86f512
 	stack-fcall \
86f512
+	stack-fcall-attach \
86f512
 	stack-fcall-mangled \
86f512
 	threads-execve \
86f512
 	unblock_reset_raise \
86f512
@@ -198,6 +199,9 @@
86f512
 stack_fcall_SOURCES = stack-fcall.c \
86f512
 	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
 
86f512
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
86f512
+	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
+
86f512
 stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
86f512
 	stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
86f512
 	stack-fcall-mangled-2.c stack-fcall-mangled-3.c
86f512
@@ -205,7 +209,7 @@
86f512
 include gen_tests.am
86f512
 
86f512
 if ENABLE_STACKTRACE
86f512
-STACKTRACE_TESTS = strace-k.test
86f512
+STACKTRACE_TESTS = strace-k.test strace-k-p.test
86f512
 if USE_DEMANGLE
86f512
 STACKTRACE_TESTS += strace-k-demangle.test
86f512
 endif
86f512
@@ -428,6 +432,8 @@
86f512
 	strace-ff.expected \
86f512
 	strace-k-demangle.expected \
86f512
 	strace-k-demangle.test \
86f512
+	strace-k-p.expected \
86f512
+	strace-k-p.test \
86f512
 	strace-k.expected \
86f512
 	strace-k.test \
86f512
 	strace-r.expected \
86f512
Index: strace-5.1/tests/stack-fcall-attach.c
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests/stack-fcall-attach.c	2020-01-23 17:03:50.786051167 +0100
86f512
@@ -0,0 +1,2 @@
86f512
+#define ATTACH_MODE 1
86f512
+#include "stack-fcall.c"
86f512
Index: strace-5.1/tests/stack-fcall.c
86f512
===================================================================
86f512
--- strace-5.1.orig/tests/stack-fcall.c	2020-01-23 17:03:50.787051163 +0100
86f512
+++ strace-5.1/tests/stack-fcall.c	2020-01-23 17:04:34.525868669 +0100
86f512
@@ -5,10 +5,21 @@
86f512
  * SPDX-License-Identifier: GPL-2.0-or-later
86f512
  */
86f512
 
86f512
+#include "tests.h"
86f512
+#include <unistd.h>
86f512
 #include "stack-fcall.h"
86f512
 
86f512
+#ifndef ATTACH_MODE
86f512
+# define ATTACH_MODE 0
86f512
+#endif
86f512
+
86f512
 int main(void)
86f512
 {
86f512
+#if ATTACH_MODE
86f512
+	/* sleep a bit to let the tracer time to catch up */
86f512
+	sleep(1);
86f512
+#endif
86f512
+
86f512
 	f0(0);
86f512
 	f0(1);
86f512
 	return 0;
86f512
Index: strace-5.1/tests/strace-k-p.expected
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests/strace-k-p.expected	2020-01-23 17:14:13.570831178 +0100
86f512
@@ -0,0 +1,2 @@
86f512
+^chdir .*(__kernel_vsyscaln )?(__)?chdir f3 f2 f1 f0 main
86f512
+^SIGURG .*(__kernel_vsyscaln )?(__)?kill f3 f2 f1 f0 main
86f512
Index: strace-5.1/tests/strace-k-p.test
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests/strace-k-p.test	2020-01-23 17:03:50.787051163 +0100
86f512
@@ -0,0 +1,13 @@
86f512
+#!/bin/sh
86f512
+#
86f512
+# Check strace -k for attached tracees.
86f512
+#
86f512
+# Copyright (c) 2020 The strace developers.
86f512
+# All rights reserved.
86f512
+#
86f512
+# SPDX-License-Identifier: GPL-2.0-or-later
86f512
+
86f512
+ATTACH_MODE=1
86f512
+test_prog=../stack-fcall-attach
86f512
+
86f512
+. "${srcdir=.}"/strace-k.test
86f512
Index: strace-5.1/tests/strace-k.test
86f512
===================================================================
86f512
--- strace-5.1.orig/tests/strace-k.test	2020-01-23 16:56:22.081268798 +0100
86f512
+++ strace-5.1/tests/strace-k.test	2020-01-23 17:05:26.569651525 +0100
86f512
@@ -11,6 +11,8 @@
86f512
 
86f512
 . "${srcdir=.}/init.sh"
86f512
 
86f512
+: "${ATTACH_MODE=0}"
86f512
+
86f512
 # strace -k is implemented using /proc/$pid/maps
86f512
 [ -f /proc/self/maps ] ||
86f512
 	framework_skip_ '/proc/self/maps is not available'
86f512
@@ -20,7 +22,19 @@
86f512
 check_prog tr
86f512
 
86f512
 run_prog "${test_prog=../stack-fcall}"
86f512
-run_strace -e chdir -k $args
86f512
+if [ "x${ATTACH_MODE}" = "x1" ]; then
86f512
+	../set_ptracer_any "${test_prog}" >> "$EXP" &
86f512
+	tracee_pid=$!
86f512
+
86f512
+	while ! [ -s "$EXP" ]; do
86f512
+		kill -0 "$tracee_pid" 2> /dev/null ||
86f512
+			fail_ 'set_ptracer_any failed'
86f512
+	done
86f512
+
86f512
+	run_strace -e chdir -k -p "$tracee_pid"
86f512
+else
86f512
+	run_strace -e chdir -k $args
86f512
+fi
86f512
 
86f512
 expected="$srcdir/$NAME.expected"
86f512
 awk '
86f512
Index: strace-5.1/tests/Makefile.in
86f512
===================================================================
86f512
--- strace-5.1.orig/tests/Makefile.in	2020-01-23 16:56:22.086268802 +0100
86f512
+++ strace-5.1/tests/Makefile.in	2020-01-23 17:07:45.456135366 +0100
86f512
@@ -144,9 +144,9 @@
86f512
 	seccomp-strict$(EXEEXT) select-P$(EXEEXT) \
86f512
 	set_ptracer_any$(EXEEXT) set_sigblock$(EXEEXT) \
86f512
 	set_sigign$(EXEEXT) signal_receive$(EXEEXT) sleep$(EXEEXT) \
86f512
-	stack-fcall$(EXEEXT) stack-fcall-mangled$(EXEEXT) \
86f512
-	threads-execve$(EXEEXT) unblock_reset_raise$(EXEEXT) \
86f512
-	unix-pair-send-recv$(EXEEXT) \
86f512
+	stack-fcall$(EXEEXT) stack-fcall-attach$(EXEEXT) \
86f512
+	stack-fcall-mangled$(EXEEXT) threads-execve$(EXEEXT) \
86f512
+	unblock_reset_raise$(EXEEXT) unix-pair-send-recv$(EXEEXT) \
86f512
 	unix-pair-sendto-recvfrom$(EXEEXT) vfork-f$(EXEEXT) \
86f512
 	wait4-v$(EXEEXT) waitid-v$(EXEEXT) zeroargc$(EXEEXT)
86f512
 @ENABLE_STACKTRACE_TRUE@@USE_DEMANGLE_TRUE@am__append_1 = strace-k-demangle.test
86f512
@@ -2604,6 +2604,12 @@
86f512
 stack_fcall_OBJECTS = $(am_stack_fcall_OBJECTS)
86f512
 stack_fcall_LDADD = $(LDADD)
86f512
 stack_fcall_DEPENDENCIES = libtests.a
86f512
+am_stack_fcall_attach_OBJECTS = stack-fcall-attach.$(OBJEXT) \
86f512
+	stack-fcall-0.$(OBJEXT) stack-fcall-1.$(OBJEXT) \
86f512
+	stack-fcall-2.$(OBJEXT) stack-fcall-3.$(OBJEXT)
86f512
+stack_fcall_attach_OBJECTS = $(am_stack_fcall_attach_OBJECTS)
86f512
+stack_fcall_attach_LDADD = $(LDADD)
86f512
+stack_fcall_attach_DEPENDENCIES = libtests.a
86f512
 am_stack_fcall_mangled_OBJECTS = stack-fcall-mangled.$(OBJEXT) \
86f512
 	stack-fcall-mangled-0.$(OBJEXT) \
86f512
 	stack-fcall-mangled-1.$(OBJEXT) \
86f512
@@ -3453,7 +3459,7 @@
86f512
 	sock_filter-v-Xverbose.c sockaddr_xlat-Xabbrev.c \
86f512
 	sockaddr_xlat-Xraw.c sockaddr_xlat-Xverbose.c socketcall.c \
86f512
 	sockopt-sol_netlink.c sockopt-timestamp.c splice.c \
86f512
-	$(stack_fcall_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
+	$(stack_fcall_SOURCES) $(stack_fcall_attach_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
 	stat64.c statfs.c statfs64.c statx.c swap.c sxetmask.c \
86f512
 	symlink.c symlinkat.c sync.c sync_file_range.c \
86f512
 	sync_file_range2.c sysinfo.c syslog.c tee.c threads-execve.c \
86f512
@@ -3620,7 +3626,7 @@
86f512
 	sock_filter-v-Xverbose.c sockaddr_xlat-Xabbrev.c \
86f512
 	sockaddr_xlat-Xraw.c sockaddr_xlat-Xverbose.c socketcall.c \
86f512
 	sockopt-sol_netlink.c sockopt-timestamp.c splice.c \
86f512
-	$(stack_fcall_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
+	$(stack_fcall_SOURCES) $(stack_fcall_attach_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
 	stat64.c statfs.c statfs64.c statx.c swap.c sxetmask.c \
86f512
 	symlink.c symlinkat.c sync.c sync_file_range.c \
86f512
 	sync_file_range2.c sysinfo.c syslog.c tee.c threads-execve.c \
86f512
@@ -3848,7 +3854,8 @@
86f512
   bases=`echo $$bases`
86f512
 RECHECK_LOGS = $(TEST_LOGS)
86f512
 AM_RECURSIVE_TARGETS = check recheck
86f512
-@ENABLE_STACKTRACE_TRUE@am__EXEEXT_2 = strace-k.test $(am__append_1)
86f512
+@ENABLE_STACKTRACE_TRUE@am__EXEEXT_2 = strace-k.test strace-k-p.test \
86f512
+@ENABLE_STACKTRACE_TRUE@	$(am__append_1)
86f512
 TEST_SUITE_LOG = test-suite.log
86f512
 TEST_EXTENSIONS = @EXEEXT@ .test
86f512
 am__test_logs1 = $(TESTS:=.log)
86f512
@@ -4634,6 +4641,9 @@
86f512
 stack_fcall_SOURCES = stack-fcall.c \
86f512
 	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
 
86f512
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
86f512
+	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
+
86f512
 stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
86f512
 	stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
86f512
 	stack-fcall-mangled-2.c stack-fcall-mangled-3.c
86f512
@@ -4863,7 +4873,7 @@
86f512
 	xettimeofday.gen.test
86f512
 @ENABLE_STACKTRACE_FALSE@STACKTRACE_TESTS = 
86f512
 @ENABLE_STACKTRACE_TRUE@STACKTRACE_TESTS = strace-k.test \
86f512
-@ENABLE_STACKTRACE_TRUE@	$(am__append_1)
86f512
+@ENABLE_STACKTRACE_TRUE@	strace-k-p.test $(am__append_1)
86f512
 DECODER_TESTS = \
86f512
 	bpf-success-v.test \
86f512
 	bpf-success.test \
86f512
@@ -5074,6 +5084,8 @@
86f512
 	strace-ff.expected \
86f512
 	strace-k-demangle.expected \
86f512
 	strace-k-demangle.test \
86f512
+	strace-k-p.expected \
86f512
+	strace-k-p.test \
86f512
 	strace-k.expected \
86f512
 	strace-k.test \
86f512
 	strace-r.expected \
86f512
@@ -7345,6 +7357,10 @@
86f512
 	@rm -f stack-fcall$(EXEEXT)
86f512
 	$(AM_V_CCLD)$(LINK) $(stack_fcall_OBJECTS) $(stack_fcall_LDADD) $(LIBS)
86f512
 
86f512
+stack-fcall-attach$(EXEEXT): $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_DEPENDENCIES) $(EXTRA_stack_fcall_attach_DEPENDENCIES) 
86f512
+	@rm -f stack-fcall-attach$(EXEEXT)
86f512
+	$(AM_V_CCLD)$(LINK) $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_LDADD) $(LIBS)
86f512
+
86f512
 stack-fcall-mangled$(EXEEXT): $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_DEPENDENCIES) $(EXTRA_stack_fcall_mangled_DEPENDENCIES) 
86f512
 	@rm -f stack-fcall-mangled$(EXEEXT)
86f512
 	$(AM_V_CCLD)$(LINK) $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_LDADD) $(LIBS)
86f512
@@ -8193,6 +8209,7 @@
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-1.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-2.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-3.Po@am__quote@ # am--include-marker
86f512
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-attach.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-0.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-1.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-2.Po@am__quote@ # am--include-marker
86f512
Index: strace-5.1/tests-m32/Makefile.am
86f512
===================================================================
86f512
--- strace-5.1.orig/tests-m32/Makefile.am	2020-01-23 16:56:22.087268803 +0100
86f512
+++ strace-5.1/tests-m32/Makefile.am	2020-01-23 17:03:50.790051150 +0100
86f512
@@ -156,6 +156,7 @@
86f512
 	signal_receive \
86f512
 	sleep \
86f512
 	stack-fcall \
86f512
+	stack-fcall-attach \
86f512
 	stack-fcall-mangled \
86f512
 	threads-execve \
86f512
 	unblock_reset_raise \
86f512
@@ -198,6 +199,9 @@
86f512
 stack_fcall_SOURCES = stack-fcall.c \
86f512
 	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
 
86f512
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
86f512
+	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
+
86f512
 stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
86f512
 	stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
86f512
 	stack-fcall-mangled-2.c stack-fcall-mangled-3.c
86f512
@@ -205,7 +209,7 @@
86f512
 include gen_tests.am
86f512
 
86f512
 if ENABLE_STACKTRACE
86f512
-STACKTRACE_TESTS = strace-k.test
86f512
+STACKTRACE_TESTS = strace-k.test strace-k-p.test
86f512
 if USE_DEMANGLE
86f512
 STACKTRACE_TESTS += strace-k-demangle.test
86f512
 endif
86f512
@@ -428,6 +432,8 @@
86f512
 	strace-ff.expected \
86f512
 	strace-k-demangle.expected \
86f512
 	strace-k-demangle.test \
86f512
+	strace-k-p.expected \
86f512
+	strace-k-p.test \
86f512
 	strace-k.expected \
86f512
 	strace-k.test \
86f512
 	strace-r.expected \
86f512
Index: strace-5.1/tests-m32/Makefile.in
86f512
===================================================================
86f512
--- strace-5.1.orig/tests-m32/Makefile.in	2020-01-23 16:56:22.089268805 +0100
86f512
+++ strace-5.1/tests-m32/Makefile.in	2020-01-23 18:24:15.534972421 +0100
86f512
@@ -144,9 +144,9 @@
86f512
 	seccomp-strict$(EXEEXT) select-P$(EXEEXT) \
86f512
 	set_ptracer_any$(EXEEXT) set_sigblock$(EXEEXT) \
86f512
 	set_sigign$(EXEEXT) signal_receive$(EXEEXT) sleep$(EXEEXT) \
86f512
-	stack-fcall$(EXEEXT) stack-fcall-mangled$(EXEEXT) \
86f512
-	threads-execve$(EXEEXT) unblock_reset_raise$(EXEEXT) \
86f512
-	unix-pair-send-recv$(EXEEXT) \
86f512
+	stack-fcall$(EXEEXT) stack-fcall-attach$(EXEEXT) \
86f512
+	stack-fcall-mangled$(EXEEXT) threads-execve$(EXEEXT) \
86f512
+	unblock_reset_raise$(EXEEXT) unix-pair-send-recv$(EXEEXT) \
86f512
 	unix-pair-sendto-recvfrom$(EXEEXT) vfork-f$(EXEEXT) \
86f512
 	wait4-v$(EXEEXT) waitid-v$(EXEEXT) zeroargc$(EXEEXT)
86f512
 @ENABLE_STACKTRACE_TRUE@@USE_DEMANGLE_TRUE@am__append_1 = strace-k-demangle.test
86f512
@@ -2604,6 +2604,12 @@
86f512
 stack_fcall_OBJECTS = $(am_stack_fcall_OBJECTS)
86f512
 stack_fcall_LDADD = $(LDADD)
86f512
 stack_fcall_DEPENDENCIES = libtests.a
86f512
+am_stack_fcall_attach_OBJECTS = stack-fcall-attach.$(OBJEXT) \
86f512
+	stack-fcall-0.$(OBJEXT) stack-fcall-1.$(OBJEXT) \
86f512
+	stack-fcall-2.$(OBJEXT) stack-fcall-3.$(OBJEXT)
86f512
+stack_fcall_attach_OBJECTS = $(am_stack_fcall_attach_OBJECTS)
86f512
+stack_fcall_attach_LDADD = $(LDADD)
86f512
+stack_fcall_attach_DEPENDENCIES = libtests.a
86f512
 am_stack_fcall_mangled_OBJECTS = stack-fcall-mangled.$(OBJEXT) \
86f512
 	stack-fcall-mangled-0.$(OBJEXT) \
86f512
 	stack-fcall-mangled-1.$(OBJEXT) \
86f512
@@ -3453,7 +3459,7 @@
86f512
 	sock_filter-v-Xverbose.c sockaddr_xlat-Xabbrev.c \
86f512
 	sockaddr_xlat-Xraw.c sockaddr_xlat-Xverbose.c socketcall.c \
86f512
 	sockopt-sol_netlink.c sockopt-timestamp.c splice.c \
86f512
-	$(stack_fcall_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
+	$(stack_fcall_SOURCES)  $(stack_fcall_attach_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
 	stat64.c statfs.c statfs64.c statx.c swap.c sxetmask.c \
86f512
 	symlink.c symlinkat.c sync.c sync_file_range.c \
86f512
 	sync_file_range2.c sysinfo.c syslog.c tee.c threads-execve.c \
86f512
@@ -3620,7 +3626,7 @@
86f512
 	sock_filter-v-Xverbose.c sockaddr_xlat-Xabbrev.c \
86f512
 	sockaddr_xlat-Xraw.c sockaddr_xlat-Xverbose.c socketcall.c \
86f512
 	sockopt-sol_netlink.c sockopt-timestamp.c splice.c \
86f512
-	$(stack_fcall_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
+	$(stack_fcall_SOURCES)  $(stack_fcall_attach_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
 	stat64.c statfs.c statfs64.c statx.c swap.c sxetmask.c \
86f512
 	symlink.c symlinkat.c sync.c sync_file_range.c \
86f512
 	sync_file_range2.c sysinfo.c syslog.c tee.c threads-execve.c \
86f512
@@ -3848,7 +3854,8 @@
86f512
   bases=`echo $$bases`
86f512
 RECHECK_LOGS = $(TEST_LOGS)
86f512
 AM_RECURSIVE_TARGETS = check recheck
86f512
-@ENABLE_STACKTRACE_TRUE@am__EXEEXT_2 = strace-k.test $(am__append_1)
86f512
+@ENABLE_STACKTRACE_TRUE@am__EXEEXT_2 = strace-k.test strace-k-p.test \
86f512
+@ENABLE_STACKTRACE_TRUE@	$(am__append_1)
86f512
 TEST_SUITE_LOG = test-suite.log
86f512
 TEST_EXTENSIONS = @EXEEXT@ .test
86f512
 am__test_logs1 = $(TESTS:=.log)
86f512
@@ -4634,6 +4641,9 @@
86f512
 stack_fcall_SOURCES = stack-fcall.c \
86f512
 	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
 
86f512
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
86f512
+	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
+
86f512
 stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
86f512
 	stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
86f512
 	stack-fcall-mangled-2.c stack-fcall-mangled-3.c
86f512
@@ -4863,7 +4873,7 @@
86f512
 	xettimeofday.gen.test
86f512
 @ENABLE_STACKTRACE_FALSE@STACKTRACE_TESTS = 
86f512
 @ENABLE_STACKTRACE_TRUE@STACKTRACE_TESTS = strace-k.test \
86f512
-@ENABLE_STACKTRACE_TRUE@	$(am__append_1)
86f512
+@ENABLE_STACKTRACE_TRUE@	strace-k-p.test $(am__append_1)
86f512
 DECODER_TESTS = \
86f512
 	bpf-success-v.test \
86f512
 	bpf-success.test \
86f512
@@ -5074,6 +5084,8 @@
86f512
 	strace-ff.expected \
86f512
 	strace-k-demangle.expected \
86f512
 	strace-k-demangle.test \
86f512
+	strace-k-p.expected \
86f512
+	strace-k-p.test \
86f512
 	strace-k.expected \
86f512
 	strace-k.test \
86f512
 	strace-r.expected \
86f512
@@ -7345,6 +7357,10 @@
86f512
 	@rm -f stack-fcall$(EXEEXT)
86f512
 	$(AM_V_CCLD)$(LINK) $(stack_fcall_OBJECTS) $(stack_fcall_LDADD) $(LIBS)
86f512
 
86f512
+stack-fcall-attach$(EXEEXT): $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_DEPENDENCIES) $(EXTRA_stack_fcall_attach_DEPENDENCIES) 
86f512
+	@rm -f stack-fcall-attach$(EXEEXT)
86f512
+	$(AM_V_CCLD)$(LINK) $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_LDADD) $(LIBS)
86f512
+
86f512
 stack-fcall-mangled$(EXEEXT): $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_DEPENDENCIES) $(EXTRA_stack_fcall_mangled_DEPENDENCIES) 
86f512
 	@rm -f stack-fcall-mangled$(EXEEXT)
86f512
 	$(AM_V_CCLD)$(LINK) $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_LDADD) $(LIBS)
86f512
@@ -8193,6 +8209,7 @@
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-1.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-2.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-3.Po@am__quote@ # am--include-marker
86f512
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-attach.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-0.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-1.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-2.Po@am__quote@ # am--include-marker
86f512
@@ -9777,6 +9794,7 @@
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-1.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-2.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-3.Po
86f512
+	-rm -f ./$(DEPDIR)/stack-fcall-attach.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-0.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-1.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-2.Po
86f512
@@ -10468,6 +10486,7 @@
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-1.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-2.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-3.Po
86f512
+	-rm -f ./$(DEPDIR)/stack-fcall-attach.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-0.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-1.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-2.Po
86f512
Index: strace-5.1/tests-mx32/Makefile.am
86f512
===================================================================
86f512
--- strace-5.1.orig/tests-mx32/Makefile.am	2020-01-23 16:56:22.090268805 +0100
86f512
+++ strace-5.1/tests-mx32/Makefile.am	2020-01-23 17:03:50.793051138 +0100
86f512
@@ -156,6 +156,7 @@
86f512
 	signal_receive \
86f512
 	sleep \
86f512
 	stack-fcall \
86f512
+	stack-fcall-attach \
86f512
 	stack-fcall-mangled \
86f512
 	threads-execve \
86f512
 	unblock_reset_raise \
86f512
@@ -198,6 +199,9 @@
86f512
 stack_fcall_SOURCES = stack-fcall.c \
86f512
 	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
 
86f512
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
86f512
+	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
+
86f512
 stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
86f512
 	stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
86f512
 	stack-fcall-mangled-2.c stack-fcall-mangled-3.c
86f512
@@ -205,7 +209,7 @@
86f512
 include gen_tests.am
86f512
 
86f512
 if ENABLE_STACKTRACE
86f512
-STACKTRACE_TESTS = strace-k.test
86f512
+STACKTRACE_TESTS = strace-k.test strace-k-p.test
86f512
 if USE_DEMANGLE
86f512
 STACKTRACE_TESTS += strace-k-demangle.test
86f512
 endif
86f512
@@ -428,6 +432,8 @@
86f512
 	strace-ff.expected \
86f512
 	strace-k-demangle.expected \
86f512
 	strace-k-demangle.test \
86f512
+	strace-k-p.expected \
86f512
+	strace-k-p.test \
86f512
 	strace-k.expected \
86f512
 	strace-k.test \
86f512
 	strace-r.expected \
86f512
Index: strace-5.1/tests-mx32/Makefile.in
86f512
===================================================================
86f512
--- strace-5.1.orig/tests-mx32/Makefile.in	2020-01-23 16:56:22.092268807 +0100
86f512
+++ strace-5.1/tests-mx32/Makefile.in	2020-01-23 17:13:00.583709367 +0100
86f512
@@ -144,9 +144,9 @@
86f512
 	seccomp-strict$(EXEEXT) select-P$(EXEEXT) \
86f512
 	set_ptracer_any$(EXEEXT) set_sigblock$(EXEEXT) \
86f512
 	set_sigign$(EXEEXT) signal_receive$(EXEEXT) sleep$(EXEEXT) \
86f512
-	stack-fcall$(EXEEXT) stack-fcall-mangled$(EXEEXT) \
86f512
-	threads-execve$(EXEEXT) unblock_reset_raise$(EXEEXT) \
86f512
-	unix-pair-send-recv$(EXEEXT) \
86f512
+	stack-fcall$(EXEEXT) stack-fcall-attach$(EXEEXT) \
86f512
+	stack-fcall-mangled$(EXEEXT) threads-execve$(EXEEXT) \
86f512
+	unblock_reset_raise$(EXEEXT) unix-pair-send-recv$(EXEEXT) \
86f512
 	unix-pair-sendto-recvfrom$(EXEEXT) vfork-f$(EXEEXT) \
86f512
 	wait4-v$(EXEEXT) waitid-v$(EXEEXT) zeroargc$(EXEEXT)
86f512
 @ENABLE_STACKTRACE_TRUE@@USE_DEMANGLE_TRUE@am__append_1 = strace-k-demangle.test
86f512
@@ -2604,6 +2604,12 @@
86f512
 stack_fcall_OBJECTS = $(am_stack_fcall_OBJECTS)
86f512
 stack_fcall_LDADD = $(LDADD)
86f512
 stack_fcall_DEPENDENCIES = libtests.a
86f512
+am_stack_fcall_attach_OBJECTS = stack-fcall-attach.$(OBJEXT) \
86f512
+	stack-fcall-0.$(OBJEXT) stack-fcall-1.$(OBJEXT) \
86f512
+	stack-fcall-2.$(OBJEXT) stack-fcall-3.$(OBJEXT)
86f512
+stack_fcall_attach_OBJECTS = $(am_stack_fcall_attach_OBJECTS)
86f512
+stack_fcall_attach_LDADD = $(LDADD)
86f512
+stack_fcall_attach_DEPENDENCIES = libtests.a
86f512
 am_stack_fcall_mangled_OBJECTS = stack-fcall-mangled.$(OBJEXT) \
86f512
 	stack-fcall-mangled-0.$(OBJEXT) \
86f512
 	stack-fcall-mangled-1.$(OBJEXT) \
86f512
@@ -3453,7 +3459,7 @@
86f512
 	sock_filter-v-Xverbose.c sockaddr_xlat-Xabbrev.c \
86f512
 	sockaddr_xlat-Xraw.c sockaddr_xlat-Xverbose.c socketcall.c \
86f512
 	sockopt-sol_netlink.c sockopt-timestamp.c splice.c \
86f512
-	$(stack_fcall_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
+	$(stack_fcall_SOURCES)  $(stack_fcall_attach_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
 	stat64.c statfs.c statfs64.c statx.c swap.c sxetmask.c \
86f512
 	symlink.c symlinkat.c sync.c sync_file_range.c \
86f512
 	sync_file_range2.c sysinfo.c syslog.c tee.c threads-execve.c \
86f512
@@ -3620,7 +3626,7 @@
86f512
 	sock_filter-v-Xverbose.c sockaddr_xlat-Xabbrev.c \
86f512
 	sockaddr_xlat-Xraw.c sockaddr_xlat-Xverbose.c socketcall.c \
86f512
 	sockopt-sol_netlink.c sockopt-timestamp.c splice.c \
86f512
-	$(stack_fcall_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
+	$(stack_fcall_SOURCES)  $(stack_fcall_attach_SOURCES) $(stack_fcall_mangled_SOURCES) stat.c \
86f512
 	stat64.c statfs.c statfs64.c statx.c swap.c sxetmask.c \
86f512
 	symlink.c symlinkat.c sync.c sync_file_range.c \
86f512
 	sync_file_range2.c sysinfo.c syslog.c tee.c threads-execve.c \
86f512
@@ -4634,6 +4640,10 @@
86f512
 stack_fcall_SOURCES = stack-fcall.c \
86f512
 	stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
86f512
 
86f512
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
86f512
+	stack-fcall-0.c stack-fcall-1.c \
86f512
+	stack-fcall-2.c stack-fcall-3.c
86f512
+
86f512
 stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
86f512
 	stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
86f512
 	stack-fcall-mangled-2.c stack-fcall-mangled-3.c
86f512
@@ -7345,6 +7355,10 @@
86f512
 	@rm -f stack-fcall$(EXEEXT)
86f512
 	$(AM_V_CCLD)$(LINK) $(stack_fcall_OBJECTS) $(stack_fcall_LDADD) $(LIBS)
86f512
 
86f512
+stack-fcall-attach$(EXEEXT): $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_DEPENDENCIES) $(EXTRA_stack_fcall_attach_DEPENDENCIES) 
86f512
+	@rm -f stack-fcall$(EXEEXT)
86f512
+	$(AM_V_CCLD)$(LINK) $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_LDADD) $(LIBS)
86f512
+
86f512
 stack-fcall-mangled$(EXEEXT): $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_DEPENDENCIES) $(EXTRA_stack_fcall_mangled_DEPENDENCIES) 
86f512
 	@rm -f stack-fcall-mangled$(EXEEXT)
86f512
 	$(AM_V_CCLD)$(LINK) $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_LDADD) $(LIBS)
86f512
@@ -8193,6 +8207,7 @@
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-1.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-2.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-3.Po@am__quote@ # am--include-marker
86f512
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-attach.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-0.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-1.Po@am__quote@ # am--include-marker
86f512
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-2.Po@am__quote@ # am--include-marker
86f512
@@ -9777,6 +9792,7 @@
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-1.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-2.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-3.Po
86f512
+	-rm -f ./$(DEPDIR)/stack-fcall-attach.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-0.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-1.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-2.Po
86f512
@@ -10468,6 +10484,7 @@
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-1.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-2.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-3.Po
86f512
+	-rm -f ./$(DEPDIR)/stack-fcall-attach.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-0.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-1.Po
86f512
 	-rm -f ./$(DEPDIR)/stack-fcall-mangled-2.Po
86f512
Index: strace-5.1/tests-m32/stack-fcall-attach.c
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests-m32/stack-fcall-attach.c	2020-01-23 17:03:50.796051125 +0100
86f512
@@ -0,0 +1,2 @@
86f512
+#define ATTACH_MODE 1
86f512
+#include "stack-fcall.c"
86f512
Index: strace-5.1/tests-m32/stack-fcall.c
86f512
===================================================================
86f512
--- strace-5.1.orig/tests-m32/stack-fcall.c	2020-01-23 17:03:50.796051125 +0100
86f512
+++ strace-5.1/tests-m32/stack-fcall.c	2020-01-23 17:08:04.027080020 +0100
86f512
@@ -5,10 +5,21 @@
86f512
  * SPDX-License-Identifier: GPL-2.0-or-later
86f512
  */
86f512
 
86f512
+#include "tests.h"
86f512
+#include <unistd.h>
86f512
 #include "stack-fcall.h"
86f512
 
86f512
+#ifndef ATTACH_MODE
86f512
+# define ATTACH_MODE 0
86f512
+#endif
86f512
+
86f512
 int main(void)
86f512
 {
86f512
+#if ATTACH_MODE
86f512
+	/* sleep a bit to let the tracer time to catch up */
86f512
+	sleep(1);
86f512
+#endif
86f512
+
86f512
 	f0(0);
86f512
 	f0(1);
86f512
 	return 0;
86f512
Index: strace-5.1/tests-m32/strace-k-p.expected
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests-m32/strace-k-p.expected	2020-01-23 17:14:16.083835372 +0100
86f512
@@ -0,0 +1,2 @@
86f512
+^chdir .*(__kernel_vsyscaln )?(__)?chdir f3 f2 f1 f0 main
86f512
+^SIGURG .*(__kernel_vsyscaln )?(__)?kill f3 f2 f1 f0 main
86f512
Index: strace-5.1/tests-m32/strace-k-p.test
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests-m32/strace-k-p.test	2020-01-23 17:03:50.796051125 +0100
86f512
@@ -0,0 +1,13 @@
86f512
+#!/bin/sh
86f512
+#
86f512
+# Check strace -k for attached tracees.
86f512
+#
86f512
+# Copyright (c) 2020 The strace developers.
86f512
+# All rights reserved.
86f512
+#
86f512
+# SPDX-License-Identifier: GPL-2.0-or-later
86f512
+
86f512
+ATTACH_MODE=1
86f512
+test_prog=../stack-fcall-attach
86f512
+
86f512
+. "${srcdir=.}"/strace-k.test
86f512
Index: strace-5.1/tests-m32/strace-k.test
86f512
===================================================================
86f512
--- strace-5.1.orig/tests-m32/strace-k.test	2020-01-23 17:03:50.797051121 +0100
86f512
+++ strace-5.1/tests-m32/strace-k.test	2020-01-23 17:13:44.509782677 +0100
86f512
@@ -11,6 +11,8 @@
86f512
 
86f512
 . "${srcdir=.}/init.sh"
86f512
 
86f512
+: "${ATTACH_MODE=0}"
86f512
+
86f512
 # strace -k is implemented using /proc/$pid/maps
86f512
 [ -f /proc/self/maps ] ||
86f512
 	framework_skip_ '/proc/self/maps is not available'
86f512
@@ -20,7 +22,19 @@
86f512
 check_prog tr
86f512
 
86f512
 run_prog "${test_prog=../stack-fcall}"
86f512
-run_strace -e chdir -k $args
86f512
+if [ "x${ATTACH_MODE}" = "x1" ]; then
86f512
+	../set_ptracer_any "${test_prog}" >> "$EXP" &
86f512
+	tracee_pid=$!
86f512
+
86f512
+	while ! [ -s "$EXP" ]; do
86f512
+		kill -0 "$tracee_pid" 2> /dev/null ||
86f512
+			fail_ 'set_ptracer_any failed'
86f512
+	done
86f512
+
86f512
+	run_strace -e chdir -k -p "$tracee_pid"
86f512
+else
86f512
+	run_strace -e chdir -k $args
86f512
+fi
86f512
 
86f512
 expected="$srcdir/$NAME.expected"
86f512
 awk '
86f512
Index: strace-5.1/tests-mx32/stack-fcall-attach.c
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests-mx32/stack-fcall-attach.c	2020-01-23 17:03:50.797051121 +0100
86f512
@@ -0,0 +1,2 @@
86f512
+#define ATTACH_MODE 1
86f512
+#include "stack-fcall.c"
86f512
Index: strace-5.1/tests-mx32/stack-fcall.c
86f512
===================================================================
86f512
--- strace-5.1.orig/tests-mx32/stack-fcall.c	2020-01-23 17:03:50.797051121 +0100
86f512
+++ strace-5.1/tests-mx32/stack-fcall.c	2020-01-23 17:08:06.451072796 +0100
86f512
@@ -5,10 +5,21 @@
86f512
  * SPDX-License-Identifier: GPL-2.0-or-later
86f512
  */
86f512
 
86f512
+#include "tests.h"
86f512
+#include <unistd.h>
86f512
 #include "stack-fcall.h"
86f512
 
86f512
+#ifndef ATTACH_MODE
86f512
+# define ATTACH_MODE 0
86f512
+#endif
86f512
+
86f512
 int main(void)
86f512
 {
86f512
+#if ATTACH_MODE
86f512
+	/* sleep a bit to let the tracer time to catch up */
86f512
+	sleep(1);
86f512
+#endif
86f512
+
86f512
 	f0(0);
86f512
 	f0(1);
86f512
 	return 0;
86f512
Index: strace-5.1/tests-mx32/strace-k-p.expected
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests-mx32/strace-k-p.expected	2020-01-23 17:14:17.786838214 +0100
86f512
@@ -0,0 +1,2 @@
86f512
+^chdir .*(__kernel_vsyscaln )?(__)?chdir f3 f2 f1 f0 main
86f512
+^SIGURG .*(__kernel_vsyscaln )?(__)?kill f3 f2 f1 f0 main
86f512
Index: strace-5.1/tests-mx32/strace-k-p.test
86f512
===================================================================
86f512
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
86f512
+++ strace-5.1/tests-mx32/strace-k-p.test	2020-01-23 17:03:50.797051121 +0100
86f512
@@ -0,0 +1,13 @@
86f512
+#!/bin/sh
86f512
+#
86f512
+# Check strace -k for attached tracees.
86f512
+#
86f512
+# Copyright (c) 2020 The strace developers.
86f512
+# All rights reserved.
86f512
+#
86f512
+# SPDX-License-Identifier: GPL-2.0-or-later
86f512
+
86f512
+ATTACH_MODE=1
86f512
+test_prog=../stack-fcall-attach
86f512
+
86f512
+. "${srcdir=.}"/strace-k.test
86f512
Index: strace-5.1/tests-mx32/strace-k.test
86f512
===================================================================
86f512
--- strace-5.1.orig/tests-mx32/strace-k.test	2020-01-23 17:03:50.797051121 +0100
86f512
+++ strace-5.1/tests-mx32/strace-k.test	2020-01-23 17:13:41.793778144 +0100
86f512
@@ -11,6 +11,8 @@
86f512
 
86f512
 . "${srcdir=.}/init.sh"
86f512
 
86f512
+: "${ATTACH_MODE=0}"
86f512
+
86f512
 # strace -k is implemented using /proc/$pid/maps
86f512
 [ -f /proc/self/maps ] ||
86f512
 	framework_skip_ '/proc/self/maps is not available'
86f512
@@ -20,7 +22,19 @@
86f512
 check_prog tr
86f512
 
86f512
 run_prog "${test_prog=../stack-fcall}"
86f512
-run_strace -e chdir -k $args
86f512
+if [ "x${ATTACH_MODE}" = "x1" ]; then
86f512
+	../set_ptracer_any "${test_prog}" >> "$EXP" &
86f512
+	tracee_pid=$!
86f512
+
86f512
+	while ! [ -s "$EXP" ]; do
86f512
+		kill -0 "$tracee_pid" 2> /dev/null ||
86f512
+			fail_ 'set_ptracer_any failed'
86f512
+	done
86f512
+
86f512
+	run_strace -e chdir -k -p "$tracee_pid"
86f512
+else
86f512
+	run_strace -e chdir -k $args
86f512
+fi
86f512
 
86f512
 expected="$srcdir/$NAME.expected"
86f512
 awk '