strace/SOURCES/0041-tests-add-strace-k-p-test.patch
2021-09-10 04:55:58 +00:00

725 lines
29 KiB
Diff

From 8e515c744935fe67e6a1b941f4c5414472c163b7 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Mon, 20 Jan 2020 16:19:40 +0100
Subject: [PATCH] tests: add strace-k-p test
Add a check of the stack unwinding for attached processes.
* tests/stack-fcall-attach.c: New file.
* tests/strace-k-p.expected: Likewise.
* tests/strace-k-p.test: New test.
* tests/Makefile.am (EXTRA_DIST): Add strace-k-p.expected and strace-k-p.test.
(STACKTRACE_TESTS): Add strace-k-p.test
(check_PROGRAMS): Add stack-fcall-attach.
(stack_fcall_attach_SOURCES): New variable.
* tests/stack-fcall.c: Include "tests.h" and <unistd.h>.
[!ATTACH_MODE] (ATTACH_MODE): Define to 0.
(main) [ATTACH_MODE]: Wait a bit.
* tests/strace-k.test: Add attach mode.
Complements: v5.4-18-g69b2c33 "unwind-libdw: fix initialization of libdwfl cache"
---
Backport changes:
* "SIGURG" line has been removed from tests/strace-k-p.expected, as it requires
v4.25~22 "Print stack traces on signals" and v4.25~21 "tests: check stack
unwinding for signals".
* "chdir" usage in tests/strace-k-p.expected has been replaced with "getpid",
as it is the syscall that was used in the stack-fcall.c at the time.
* Added the respective changes to tests/Makefile.in file.
* The changes to tests/stack-fcall-attach.c, tests/strace-k-p.expected,
tests/strace-k-p.test, tests/Makefile.am, tests/stack-fcall.c,
and tests/strace-k.test have been copied over to tests-m32 and tests-mx32
directories.
---
tests/Makefile.am | 8 +++++++-
tests/stack-fcall-attach.c | 2 ++
tests/stack-fcall.c | 11 +++++++++++
tests/strace-k-p.expected | 2 ++
tests/strace-k-p.test | 13 +++++++++++++
tests/strace-k.test | 17 ++++++++++++++++-
6 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 tests/stack-fcall-attach.c
create mode 100644 tests/strace-k-p.expected
create mode 100755 tests/strace-k-p.test
Index: strace-4.24/tests/Makefile.am
===================================================================
--- strace-4.24.orig/tests/Makefile.am 2020-01-23 14:58:43.424959638 +0100
+++ strace-4.24/tests/Makefile.am 2020-01-23 14:58:43.440959144 +0100
@@ -156,6 +156,7 @@
signal_receive \
sleep \
stack-fcall \
+ stack-fcall-attach \
stack-fcall-mangled \
threads-execve \
unblock_reset_raise \
@@ -198,6 +199,9 @@
stack_fcall_SOURCES = stack-fcall.c \
stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
+ stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+
stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
stack-fcall-mangled-2.c stack-fcall-mangled-3.c
@@ -205,7 +209,7 @@
include gen_tests.am
if ENABLE_STACKTRACE
-STACKTRACE_TESTS = strace-k.test
+STACKTRACE_TESTS = strace-k.test strace-k-p.test
if USE_DEMANGLE
STACKTRACE_TESTS += strace-k-demangle.test
endif
@@ -423,6 +427,8 @@
strace-ff.expected \
strace-k-demangle.expected \
strace-k-demangle.test \
+ strace-k-p.expected \
+ strace-k-p.test \
strace-k.expected \
strace-k.test \
strace-r.expected \
Index: strace-4.24/tests/stack-fcall-attach.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests/stack-fcall-attach.c 2020-01-23 14:58:43.441959113 +0100
@@ -0,0 +1,2 @@
+#define ATTACH_MODE 1
+#include "stack-fcall.c"
Index: strace-4.24/tests/stack-fcall.c
===================================================================
--- strace-4.24.orig/tests/stack-fcall.c 2020-01-23 14:58:09.934993679 +0100
+++ strace-4.24/tests/stack-fcall.c 2020-01-23 14:58:43.441959113 +0100
@@ -1,7 +1,18 @@
+#include "tests.h"
+#include <unistd.h>
#include "stack-fcall.h"
+#ifndef ATTACH_MODE
+# define ATTACH_MODE 0
+#endif
+
int main(int argc, char **argv)
{
+#if ATTACH_MODE
+ /* sleep a bit to let the tracer time to catch up */
+ sleep(1);
+#endif
+
f0(argc);
return 0;
}
Index: strace-4.24/tests/strace-k-p.expected
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests/strace-k-p.expected 2020-01-23 16:23:03.932457826 +0100
@@ -0,0 +1 @@
+(__kernel_vsyscall )?(__)?getpid f3 f2 f1 f0 main
Index: strace-4.24/tests/strace-k-p.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests/strace-k-p.test 2020-01-23 14:58:43.441959113 +0100
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# Check strace -k for attached tracees.
+#
+# Copyright (c) 2020 The strace developers.
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+ATTACH_MODE=1
+test_prog=../stack-fcall-attach
+
+. "${srcdir=.}"/strace-k.test
Index: strace-4.24/tests/strace-k.test
===================================================================
--- strace-4.24.orig/tests/strace-k.test 2020-01-23 14:58:43.001972698 +0100
+++ strace-4.24/tests/strace-k.test 2020-01-23 14:58:43.441959113 +0100
@@ -11,6 +11,8 @@
. "${srcdir=.}/init.sh"
+: "${ATTACH_MODE=0}"
+
# strace -k is implemented using /proc/$pid/maps
[ -f /proc/self/maps ] ||
framework_skip_ '/proc/self/maps is not available'
@@ -20,7 +22,19 @@
check_prog tr
run_prog "${test_prog=../stack-fcall}"
-run_strace -e getpid -k $args
+if [ "x${ATTACH_MODE}" = "x1" ]; then
+ ../set_ptracer_any "${test_prog}" >> "$EXP" &
+ tracee_pid=$!
+
+ while ! [ -s "$EXP" ]; do
+ kill -0 "$tracee_pid" 2> /dev/null ||
+ fail_ 'set_ptracer_any failed'
+ done
+
+ run_strace -e getpid -k -p "$tracee_pid"
+else
+ run_strace -e getpid -k $args
+fi
expected="$srcdir/$NAME.expected"
sed -r -n '1,/\(main\+0x[a-f0-9]+\) .*/ s/^[^(]+\(([^+]+)\+0x[a-f0-9]+\) .*/\1/p' "$LOG" |
Index: strace-4.24/tests/Makefile.in
===================================================================
--- strace-4.24.orig/tests/Makefile.in 2020-01-23 14:58:43.425959607 +0100
+++ strace-4.24/tests/Makefile.in 2020-01-23 14:57:57.710371128 +0100
@@ -178,9 +178,9 @@
seccomp-strict$(EXEEXT) select-P$(EXEEXT) \
set_ptracer_any$(EXEEXT) set_sigblock$(EXEEXT) \
set_sigign$(EXEEXT) signal_receive$(EXEEXT) sleep$(EXEEXT) \
- stack-fcall$(EXEEXT) stack-fcall-mangled$(EXEEXT) \
- threads-execve$(EXEEXT) unblock_reset_raise$(EXEEXT) \
- unix-pair-send-recv$(EXEEXT) \
+ stack-fcall$(EXEEXT) stack-fcall-attach$(EXEEXT) \
+ stack-fcall-mangled$(EXEEXT) threads-execve$(EXEEXT) \
+ unblock_reset_raise$(EXEEXT) unix-pair-send-recv$(EXEEXT) \
unix-pair-sendto-recvfrom$(EXEEXT) vfork-f$(EXEEXT) \
wait4-v$(EXEEXT) waitid-v$(EXEEXT) zeroargc$(EXEEXT)
@ENABLE_STACKTRACE_TRUE@@USE_DEMANGLE_TRUE@am__append_1 = strace-k-demangle.test
@@ -2427,6 +2427,12 @@
stack_fcall_OBJECTS = $(am_stack_fcall_OBJECTS)
stack_fcall_LDADD = $(LDADD)
stack_fcall_DEPENDENCIES = libtests.a
+am_stack_fcall_attach_OBJECTS = stack-fcall-attach.$(OBJEXT) \
+ stack-fcall-0.$(OBJEXT) stack-fcall-1.$(OBJEXT) \
+ stack-fcall-2.$(OBJEXT) stack-fcall-3.$(OBJEXT)
+stack_fcall_attach_OBJECTS = $(am_stack_fcall_attach_OBJECTS)
+stack_fcall_attach_LDADD = $(LDADD)
+stack_fcall_attach_DEPENDENCIES = libtests.a
am_stack_fcall_mangled_OBJECTS = stack-fcall-mangled.$(OBJEXT) \
stack-fcall-mangled-0.$(OBJEXT) \
stack-fcall-mangled-1.$(OBJEXT) \
@@ -2851,7 +2857,7 @@
so_peercred.c so_peercred-Xabbrev.c so_peercred-Xraw.c \
so_peercred-Xverbose.c sock_filter-v.c sock_filter-v-Xabbrev.c \
sock_filter-v-Xraw.c sock_filter-v-Xverbose.c socketcall.c \
- sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) \
+ sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) $(stack_fcall_attach_SOURCES) \
$(stack_fcall_mangled_SOURCES) stat.c stat64.c statfs.c \
statfs64.c statx.c swap.c sxetmask.c symlink.c symlinkat.c \
sync.c sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
@@ -2999,7 +3005,7 @@
so_peercred.c so_peercred-Xabbrev.c so_peercred-Xraw.c \
so_peercred-Xverbose.c sock_filter-v.c sock_filter-v-Xabbrev.c \
sock_filter-v-Xraw.c sock_filter-v-Xverbose.c socketcall.c \
- sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) \
+ sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) $(stack_fcall_attach_SOURCES) \
$(stack_fcall_mangled_SOURCES) stat.c stat64.c statfs.c \
statfs64.c statx.c swap.c sxetmask.c symlink.c symlinkat.c \
sync.c sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
@@ -3226,7 +3232,8 @@
bases=`echo $$bases`
RECHECK_LOGS = $(TEST_LOGS)
AM_RECURSIVE_TARGETS = check recheck
-@ENABLE_STACKTRACE_TRUE@am__EXEEXT_2 = strace-k.test $(am__append_1)
+@ENABLE_STACKTRACE_TRUE@am__EXEEXT_2 = strace-k.test strace-k-p.test \
+@ENABLE_STACKTRACE_TRUE@ $(am__append_1)
TEST_SUITE_LOG = test-suite.log
TEST_EXTENSIONS = @EXEEXT@ .test
am__test_logs1 = $(TESTS:=.log)
@@ -3960,6 +3967,9 @@
stack_fcall_SOURCES = stack-fcall.c \
stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
+ stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+
stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
stack-fcall-mangled-2.c stack-fcall-mangled-3.c
@@ -4163,7 +4173,7 @@
xettimeofday.gen.test
@ENABLE_STACKTRACE_FALSE@STACKTRACE_TESTS =
@ENABLE_STACKTRACE_TRUE@STACKTRACE_TESTS = strace-k.test \
-@ENABLE_STACKTRACE_TRUE@ $(am__append_1)
+@ENABLE_STACKTRACE_TRUE@ strace-k-p.test $(am__append_1)
DECODER_TESTS = \
bpf-success-v.test \
bpf-success.test \
@@ -4366,6 +4376,8 @@
strace-ff.expected \
strace-k-demangle.expected \
strace-k-demangle.test \
+ strace-k-p.expected \
+ strace-k-p.test \
strace-k.expected \
strace-k.test \
strace-r.expected \
@@ -6454,6 +6466,10 @@
@rm -f stack-fcall$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(stack_fcall_OBJECTS) $(stack_fcall_LDADD) $(LIBS)
+stack-fcall-attach$(EXEEXT): $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_DEPENDENCIES) $(EXTRA_stack_fcall_attach_DEPENDENCIES)
+ @rm -f stack-fcall-attach$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_LDADD) $(LIBS)
+
stack-fcall-mangled$(EXEEXT): $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_DEPENDENCIES) $(EXTRA_stack_fcall_mangled_DEPENDENCIES)
@rm -f stack-fcall-mangled$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_LDADD) $(LIBS)
@@ -7244,6 +7260,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-3.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-attach.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-0.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-2.Po@am__quote@
Index: strace-4.24/tests-m32/Makefile.am
===================================================================
--- strace-4.24.orig/tests-m32/Makefile.am 2020-01-23 14:58:43.422959699 +0100
+++ strace-4.24/tests-m32/Makefile.am 2020-01-23 14:58:43.442959082 +0100
@@ -173,6 +173,7 @@
signal_receive \
sleep \
stack-fcall \
+ stack-fcall-attach \
stack-fcall-mangled \
threads-execve \
unblock_reset_raise \
@@ -214,6 +215,9 @@
stack_fcall_SOURCES = stack-fcall.c \
stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
+ stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+
stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
stack-fcall-mangled-2.c stack-fcall-mangled-3.c
@@ -221,7 +225,7 @@
include gen_tests.am
if ENABLE_STACKTRACE
-STACKTRACE_TESTS = strace-k.test
+STACKTRACE_TESTS = strace-k.test strace-k-p.test
if USE_DEMANGLE
STACKTRACE_TESTS += strace-k-demangle.test
endif
@@ -434,6 +438,8 @@
strace-ff.expected \
strace-k-demangle.expected \
strace-k-demangle.test \
+ strace-k-p.expected \
+ strace-k-p.test \
strace-k.expected \
strace-k.test \
strace-r.expected \
Index: strace-4.24/tests-m32/Makefile.in
===================================================================
--- strace-4.24.orig/tests-m32/Makefile.in 2020-01-23 14:58:43.424959638 +0100
+++ strace-4.24/tests-m32/Makefile.in 2020-01-23 17:52:08.510416337 +0100
@@ -177,9 +177,9 @@
seccomp-strict$(EXEEXT) select-P$(EXEEXT) \
set_ptracer_any$(EXEEXT) set_sigblock$(EXEEXT) \
set_sigign$(EXEEXT) signal_receive$(EXEEXT) sleep$(EXEEXT) \
- stack-fcall$(EXEEXT) stack-fcall-mangled$(EXEEXT) \
- threads-execve$(EXEEXT) unblock_reset_raise$(EXEEXT) \
- unix-pair-send-recv$(EXEEXT) \
+ stack-fcall$(EXEEXT) stack-fcall-attach$(EXEEXT) \
+ stack-fcall-mangled$(EXEEXT) threads-execve$(EXEEXT) \
+ unblock_reset_raise$(EXEEXT) unix-pair-send-recv$(EXEEXT) \
unix-pair-sendto-recvfrom$(EXEEXT) vfork-f$(EXEEXT) \
wait4-v$(EXEEXT) waitid-v$(EXEEXT) zeroargc$(EXEEXT)
@ENABLE_STACKTRACE_TRUE@@USE_DEMANGLE_TRUE@am__append_1 = strace-k-demangle.test
@@ -2418,6 +2418,12 @@
stack_fcall_OBJECTS = $(am_stack_fcall_OBJECTS)
stack_fcall_LDADD = $(LDADD)
stack_fcall_DEPENDENCIES = libtests.a
+am_stack_fcall_attach_OBJECTS = stack-fcall-attach.$(OBJEXT) \
+ stack-fcall-0.$(OBJEXT) stack-fcall-1.$(OBJEXT) \
+ stack-fcall-2.$(OBJEXT) stack-fcall-3.$(OBJEXT)
+stack_fcall_attach_OBJECTS = $(am_stack_fcall_attach_OBJECTS)
+stack_fcall_attach_LDADD = $(LDADD)
+stack_fcall_attach_DEPENDENCIES = libtests.a
am_stack_fcall_mangled_OBJECTS = stack-fcall-mangled.$(OBJEXT) \
stack-fcall-mangled-0.$(OBJEXT) \
stack-fcall-mangled-1.$(OBJEXT) \
@@ -2841,7 +2847,7 @@
so_peercred.c so_peercred-Xabbrev.c so_peercred-Xraw.c \
so_peercred-Xverbose.c sock_filter-v.c sock_filter-v-Xabbrev.c \
sock_filter-v-Xraw.c sock_filter-v-Xverbose.c socketcall.c \
- sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) \
+ sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) $(stack_fcall_attach_SOURCES) \
$(stack_fcall_mangled_SOURCES) stat.c stat64.c statfs.c \
statfs64.c statx.c swap.c sxetmask.c symlink.c symlinkat.c \
sync.c sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
@@ -2988,7 +2994,7 @@
so_peercred.c so_peercred-Xabbrev.c so_peercred-Xraw.c \
so_peercred-Xverbose.c sock_filter-v.c sock_filter-v-Xabbrev.c \
sock_filter-v-Xraw.c sock_filter-v-Xverbose.c socketcall.c \
- sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) \
+ sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) $(stack_fcall_attach_SOURCES) \
$(stack_fcall_mangled_SOURCES) stat.c stat64.c statfs.c \
statfs64.c statx.c swap.c sxetmask.c symlink.c symlinkat.c \
sync.c sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
@@ -3215,7 +3221,8 @@
bases=`echo $$bases`
RECHECK_LOGS = $(TEST_LOGS)
AM_RECURSIVE_TARGETS = check recheck
-@ENABLE_STACKTRACE_TRUE@am__EXEEXT_2 = strace-k.test $(am__append_1)
+@ENABLE_STACKTRACE_TRUE@am__EXEEXT_2 = strace-k.test strace-k-p.test \
+@ENABLE_STACKTRACE_TRUE@ $(am__append_1)
TEST_SUITE_LOG = test-suite.log
TEST_EXTENSIONS = @EXEEXT@ .test
am__test_logs1 = $(TESTS:=.log)
@@ -3949,6 +3956,9 @@
stack_fcall_SOURCES = stack-fcall.c \
stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
+ stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+
stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
stack-fcall-mangled-2.c stack-fcall-mangled-3.c
@@ -4152,7 +4162,7 @@
xettimeofday.gen.test
@ENABLE_STACKTRACE_FALSE@STACKTRACE_TESTS =
@ENABLE_STACKTRACE_TRUE@STACKTRACE_TESTS = strace-k.test \
-@ENABLE_STACKTRACE_TRUE@ $(am__append_1)
+@ENABLE_STACKTRACE_TRUE@ strace-k-p.test $(am__append_1)
DECODER_TESTS = \
bpf-success-v.test \
bpf-success.test \
@@ -4353,6 +4363,8 @@
strace-ff.expected \
strace-k-demangle.expected \
strace-k-demangle.test \
+ strace-k-p.expected \
+ strace-k-p.test \
strace-k.expected \
strace-k.test \
strace-r.expected \
@@ -6433,6 +6445,10 @@
@rm -f stack-fcall$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(stack_fcall_OBJECTS) $(stack_fcall_LDADD) $(LIBS)
+stack-fcall-attach$(EXEEXT): $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_DEPENDENCIES) $(EXTRA_stack_fcall_attach_DEPENDENCIES)
+ @rm -f stack-fcall-attach$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(stack_fcall_attach_OBJECTS) $(stack_fcall_attach_LDADD) $(LIBS)
+
stack-fcall-mangled$(EXEEXT): $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_DEPENDENCIES) $(EXTRA_stack_fcall_mangled_DEPENDENCIES)
@rm -f stack-fcall-mangled$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(stack_fcall_mangled_OBJECTS) $(stack_fcall_mangled_LDADD) $(LIBS)
@@ -7221,6 +7237,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-3.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-attach.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-0.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack-fcall-mangled-2.Po@am__quote@
Index: strace-4.24/tests-mx32/Makefile.am
===================================================================
--- strace-4.24.orig/tests-mx32/Makefile.am 2020-01-23 14:58:43.424959638 +0100
+++ strace-4.24/tests-mx32/Makefile.am 2020-01-23 14:58:43.443959051 +0100
@@ -173,6 +173,7 @@
signal_receive \
sleep \
stack-fcall \
+ stack-fcall-attach \
stack-fcall-mangled \
threads-execve \
unblock_reset_raise \
@@ -214,6 +215,9 @@
stack_fcall_SOURCES = stack-fcall.c \
stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+stack_fcall_attach_SOURCES = stack-fcall-attach.c \
+ stack-fcall-0.c stack-fcall-1.c stack-fcall-2.c stack-fcall-3.c
+
stack_fcall_mangled_SOURCES = stack-fcall-mangled.c \
stack-fcall-mangled-0.c stack-fcall-mangled-1.c \
stack-fcall-mangled-2.c stack-fcall-mangled-3.c
@@ -221,7 +225,7 @@
include gen_tests.am
if ENABLE_STACKTRACE
-STACKTRACE_TESTS = strace-k.test
+STACKTRACE_TESTS = strace-k.test strace-k-p.test
if USE_DEMANGLE
STACKTRACE_TESTS += strace-k-demangle.test
endif
@@ -434,6 +438,8 @@
strace-ff.expected \
strace-k-demangle.expected \
strace-k-demangle.test \
+ strace-k-p.expected \
+ strace-k-p.test \
strace-k.expected \
strace-k.test \
strace-r.expected \
Index: strace-4.24/tests-mx32/Makefile.in
===================================================================
--- strace-4.24.orig/tests-mx32/Makefile.in 2020-01-23 14:58:43.424959638 +0100
+++ strace-4.24/tests-mx32/Makefile.in 2020-01-23 14:58:08.177047958 +0100
@@ -177,9 +177,9 @@
seccomp-strict$(EXEEXT) select-P$(EXEEXT) \
set_ptracer_any$(EXEEXT) set_sigblock$(EXEEXT) \
set_sigign$(EXEEXT) signal_receive$(EXEEXT) sleep$(EXEEXT) \
- stack-fcall$(EXEEXT) stack-fcall-mangled$(EXEEXT) \
- threads-execve$(EXEEXT) unblock_reset_raise$(EXEEXT) \
- unix-pair-send-recv$(EXEEXT) \
+ stack-fcall$(EXEEXT) stack-fcall-attach$(EXEEXT) \
+ stack-fcall-mangled$(EXEEXT) threads-execve$(EXEEXT) \
+ unblock_reset_raise$(EXEEXT) unix-pair-send-recv$(EXEEXT) \
unix-pair-sendto-recvfrom$(EXEEXT) vfork-f$(EXEEXT) \
wait4-v$(EXEEXT) waitid-v$(EXEEXT) zeroargc$(EXEEXT)
@ENABLE_STACKTRACE_TRUE@@USE_DEMANGLE_TRUE@am__append_1 = strace-k-demangle.test
@@ -2841,7 +2841,7 @@
so_peercred.c so_peercred-Xabbrev.c so_peercred-Xraw.c \
so_peercred-Xverbose.c sock_filter-v.c sock_filter-v-Xabbrev.c \
sock_filter-v-Xraw.c sock_filter-v-Xverbose.c socketcall.c \
- sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) \
+ sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) $(stack_fcall_attach_SOURCES) \
$(stack_fcall_mangled_SOURCES) stat.c stat64.c statfs.c \
statfs64.c statx.c swap.c sxetmask.c symlink.c symlinkat.c \
sync.c sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
@@ -2988,7 +2988,7 @@
so_peercred.c so_peercred-Xabbrev.c so_peercred-Xraw.c \
so_peercred-Xverbose.c sock_filter-v.c sock_filter-v-Xabbrev.c \
sock_filter-v-Xraw.c sock_filter-v-Xverbose.c socketcall.c \
- sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) \
+ sockopt-sol_netlink.c splice.c $(stack_fcall_SOURCES) $(stack_fcall_attach_SOURCES) \
$(stack_fcall_mangled_SOURCES) stat.c stat64.c statfs.c \
statfs64.c statx.c swap.c sxetmask.c symlink.c symlinkat.c \
sync.c sync_file_range.c sync_file_range2.c sysinfo.c syslog.c \
Index: strace-4.24/tests-m32/stack-fcall-attach.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-m32/stack-fcall-attach.c 2020-01-23 15:42:03.377780293 +0100
@@ -0,0 +1,2 @@
+#define ATTACH_MODE 1
+#include "stack-fcall.c"
Index: strace-4.24/tests-m32/stack-fcall.c
===================================================================
--- strace-4.24.orig/tests-m32/stack-fcall.c 2017-12-29 16:20:21.000000000 +0100
+++ strace-4.24/tests-m32/stack-fcall.c 2020-01-23 15:42:03.381780261 +0100
@@ -1,7 +1,18 @@
+#include "tests.h"
+#include <unistd.h>
#include "stack-fcall.h"
+#ifndef ATTACH_MODE
+# define ATTACH_MODE 0
+#endif
+
int main(int argc, char **argv)
{
+#if ATTACH_MODE
+ /* sleep a bit to let the tracer time to catch up */
+ sleep(1);
+#endif
+
f0(argc);
return 0;
}
Index: strace-4.24/tests-m32/strace-k-p.expected
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-m32/strace-k-p.expected 2020-01-23 16:22:56.367298204 +0100
@@ -0,0 +1 @@
+(__kernel_vsyscall )?(__)?getpid f3 f2 f1 f0 main
Index: strace-4.24/tests-m32/strace-k-p.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-m32/strace-k-p.test 2020-01-23 15:42:03.383780246 +0100
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# Check strace -k for attached tracees.
+#
+# Copyright (c) 2020 The strace developers.
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+ATTACH_MODE=1
+test_prog=../stack-fcall-attach
+
+. "${srcdir=.}"/strace-k.test
Index: strace-4.24/tests-m32/strace-k.test
===================================================================
--- strace-4.24.orig/tests-m32/strace-k.test 2018-06-14 13:00:00.000000000 +0200
+++ strace-4.24/tests-m32/strace-k.test 2020-01-23 15:42:03.385780230 +0100
@@ -7,30 +7,12 @@
# Copyright (c) 2014-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.
+# SPDX-License-Identifier: GPL-2.0-or-later
. "${srcdir=.}/init.sh"
+: "${ATTACH_MODE=0}"
+
# strace -k is implemented using /proc/$pid/maps
[ -f /proc/self/maps ] ||
framework_skip_ '/proc/self/maps is not available'
@@ -40,7 +22,19 @@
check_prog tr
run_prog "${test_prog=../stack-fcall}"
-run_strace -e getpid -k $args
+if [ "x${ATTACH_MODE}" = "x1" ]; then
+ ../set_ptracer_any "${test_prog}" >> "$EXP" &
+ tracee_pid=$!
+
+ while ! [ -s "$EXP" ]; do
+ kill -0 "$tracee_pid" 2> /dev/null ||
+ fail_ 'set_ptracer_any failed'
+ done
+
+ run_strace -e getpid -k -p "$tracee_pid"
+else
+ run_strace -e getpid -k $args
+fi
expected="$srcdir/$NAME.expected"
sed -r -n '1,/\(main\+0x[a-f0-9]+\) .*/ s/^[^(]+\(([^+]+)\+0x[a-f0-9]+\) .*/\1/p' "$LOG" |
Index: strace-4.24/tests-mx32/stack-fcall-attach.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-mx32/stack-fcall-attach.c 2020-01-23 15:42:10.783722024 +0100
@@ -0,0 +1,2 @@
+#define ATTACH_MODE 1
+#include "stack-fcall.c"
Index: strace-4.24/tests-mx32/stack-fcall.c
===================================================================
--- strace-4.24.orig/tests-mx32/stack-fcall.c 2017-12-29 16:20:21.000000000 +0100
+++ strace-4.24/tests-mx32/stack-fcall.c 2020-01-23 15:42:10.797721914 +0100
@@ -1,7 +1,18 @@
+#include "tests.h"
+#include <unistd.h>
#include "stack-fcall.h"
+#ifndef ATTACH_MODE
+# define ATTACH_MODE 0
+#endif
+
int main(int argc, char **argv)
{
+#if ATTACH_MODE
+ /* sleep a bit to let the tracer time to catch up */
+ sleep(1);
+#endif
+
f0(argc);
return 0;
}
Index: strace-4.24/tests-mx32/strace-k-p.expected
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-mx32/strace-k-p.expected 2020-01-23 16:22:53.346234461 +0100
@@ -0,0 +1 @@
+(__kernel_vsyscall )?(__)?getpid f3 f2 f1 f0 main
Index: strace-4.24/tests-mx32/strace-k-p.test
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ strace-4.24/tests-mx32/strace-k-p.test 2020-01-23 15:42:10.803721866 +0100
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# Check strace -k for attached tracees.
+#
+# Copyright (c) 2020 The strace developers.
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+ATTACH_MODE=1
+test_prog=../stack-fcall-attach
+
+. "${srcdir=.}"/strace-k.test
Index: strace-4.24/tests-mx32/strace-k.test
===================================================================
--- strace-4.24.orig/tests-mx32/strace-k.test 2018-06-14 13:00:00.000000000 +0200
+++ strace-4.24/tests-mx32/strace-k.test 2020-01-23 15:42:10.810721811 +0100
@@ -7,30 +7,12 @@
# Copyright (c) 2014-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.
+# SPDX-License-Identifier: GPL-2.0-or-later
. "${srcdir=.}/init.sh"
+: "${ATTACH_MODE=0}"
+
# strace -k is implemented using /proc/$pid/maps
[ -f /proc/self/maps ] ||
framework_skip_ '/proc/self/maps is not available'
@@ -40,7 +22,19 @@
check_prog tr
run_prog "${test_prog=../stack-fcall}"
-run_strace -e getpid -k $args
+if [ "x${ATTACH_MODE}" = "x1" ]; then
+ ../set_ptracer_any "${test_prog}" >> "$EXP" &
+ tracee_pid=$!
+
+ while ! [ -s "$EXP" ]; do
+ kill -0 "$tracee_pid" 2> /dev/null ||
+ fail_ 'set_ptracer_any failed'
+ done
+
+ run_strace -e getpid -k -p "$tracee_pid"
+else
+ run_strace -e getpid -k $args
+fi
expected="$srcdir/$NAME.expected"
sed -r -n '1,/\(main\+0x[a-f0-9]+\) .*/ s/^[^(]+\(([^+]+)\+0x[a-f0-9]+\) .*/\1/p' "$LOG" |