signal2.stderr.exp signal2.stdout.exp signal2.vgtest \
sigprocmask.stderr.exp sigprocmask.stderr.exp2 sigprocmask.vgtest \
stack_changes.stderr.exp stack_changes.stdout.exp stack_changes.vgtest \
+ stack_switch.stderr.exp stack_switch.vgtest \
strchr.stderr.exp strchr.stderr.exp2 strchr.vgtest \
str_tester.stderr.exp str_tester.vgtest \
supp_unknown.stderr.exp supp_unknown.vgtest supp_unknown.supp \
post-syscall \
realloc1 realloc2 realloc3 \
sigaltstack signal2 sigprocmask sigkill \
- stack_changes strchr str_tester supp_unknown supp1 supp2 suppfree \
+ stack_changes stack_switch strchr str_tester \
+ supp_unknown supp1 supp2 suppfree \
trivialleak \
mismatches new_override metadata \
xml1 \
oset_test_CFLAGS = -DVGA_$(VG_ARCH) -DVGO_$(VG_OS) -DVGP_$(VG_PLATFORM)
# Don't allow GCC to inline memcpy(), because then we can't intercept it
overlap_CFLAGS = $(AM_CFLAGS) -fno-builtin-memcpy
+stack_switch_LDADD = -lpthread
str_tester_CFLAGS = $(AM_CFLAGS) -Wno-shadow
supp_unknown_SOURCES = badjump.c
supp1_SOURCES = supp.c
--- /dev/null
+#define _XOPEN_SOURCE 600
+#define _BSD_SOURCE
+
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include "valgrind.h"
+
+#define STACK_SIZE 8192
+
+static int thread_main(void *arg)
+{
+ char buffer[1024];
+
+ memset( buffer, 1, sizeof( buffer ) );
+
+ return memchr( buffer, 1, sizeof( buffer ) ) == NULL;
+}
+
+int main(int argc, char **argv)
+{
+ void *stack;
+ int stackid;
+ pid_t pid;
+
+ if ( ( stack = mmap( NULL, STACK_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 ) ) == MAP_FAILED )
+ {
+ perror( "mmap" );
+ exit( 1 );
+ }
+
+ stackid = VALGRIND_STACK_REGISTER( stack, stack + STACK_SIZE );
+
+ if ( ( pid = clone( thread_main, stack + STACK_SIZE, CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|SIGCHLD, NULL ) ) == -1 )
+ {
+ perror( "clone" );
+ exit( 1 );
+ }
+
+ sleep( 1 );
+
+ exit( 0 );
+}