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

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