mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
Converted fork(), and added a separate regtest for it.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2961
This commit is contained in:
parent
9f628720a2
commit
f49d300804
@ -2111,10 +2111,15 @@ POST(fstat)
|
||||
|
||||
static vki_sigset_t fork_saved_mask;
|
||||
|
||||
PRE(fork)
|
||||
// In Linux, the sys_fork() function varies across architectures, but we
|
||||
// ignore the various args it gets, and so it looks arch-neutral. Hmm.
|
||||
PREx(sys_fork, 0)
|
||||
{
|
||||
vki_sigset_t mask;
|
||||
|
||||
PRINT("sys_fork ( )");
|
||||
PRE_REG_READ0(long, "fork");
|
||||
|
||||
vg_assert(VG_(gettid)() == VG_(main_pid));
|
||||
|
||||
/* Block all signals during fork, so that we can fix things up in
|
||||
@ -2122,13 +2127,10 @@ PRE(fork)
|
||||
VG_(sigfillset)(&mask);
|
||||
VG_(sigprocmask)(VKI_SIG_SETMASK, &mask, &fork_saved_mask);
|
||||
|
||||
/* pid_t fork(void); */
|
||||
PRINT("fork ()");
|
||||
|
||||
do_atfork_pre(tid);
|
||||
}
|
||||
|
||||
POST(fork)
|
||||
POST(sys_fork)
|
||||
{
|
||||
if (res == 0) {
|
||||
do_atfork_child(tid);
|
||||
@ -2160,9 +2162,9 @@ PRE(clone)
|
||||
(arg1 == (VKI_CLONE_CHILD_CLEARTID|VKI_CLONE_CHILD_SETTID|VKI_SIGCHLD)
|
||||
|| arg1 == (VKI_CLONE_PARENT_SETTID|VKI_SIGCHLD)))
|
||||
{
|
||||
before_fork(tid, tst);
|
||||
before_sys_fork(tid, tst);
|
||||
set_result( VG_(do_syscall)(SYSNO, arg1, arg2, arg3, arg4, arg5) );
|
||||
after_fork(tid, tst);
|
||||
after_sys_fork(tid, tst);
|
||||
} else {
|
||||
VG_(unimplemented)
|
||||
("clone(): not supported by Valgrind.\n "
|
||||
@ -5806,7 +5808,7 @@ static const struct sys_info bad_sys = { Special, NULL, bad_before, NULL };
|
||||
static const struct sys_info sys_info[] = {
|
||||
// 0 is restart_syscall
|
||||
SYSX_(__NR_exit, sys_exit), // 1 * P
|
||||
SYSBA(fork, 0), // 2 sys_fork P
|
||||
SYSXY(__NR_fork, sys_fork), // 2 (quasi-generic...) P
|
||||
SYSXY(__NR_read, sys_read), // 3 * P
|
||||
SYSX_(__NR_write, sys_write), // 4 * P
|
||||
|
||||
|
||||
@ -3,6 +3,8 @@ SUBDIRS = ${VG_ARCH} .
|
||||
noinst_SCRIPTS = filter_allocs filter_leak_check_size \
|
||||
filter_stderr filter_stderr_backtrace
|
||||
|
||||
noinst_HEADERS = scalar.h
|
||||
|
||||
EXTRA_DIST = $(noinst_SCRIPTS) \
|
||||
badaddrvalue.stderr.exp \
|
||||
badaddrvalue.stdout.exp badaddrvalue.vgtest \
|
||||
@ -52,7 +54,8 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
|
||||
realloc2.stderr.exp realloc2.vgtest \
|
||||
realloc3.stderr.exp realloc3.vgtest \
|
||||
scalar.stderr.exp scalar.vgtest scalar.supp \
|
||||
scalar_supp.stderr.exp scalar_supp.vgtest scalar_supp.c \
|
||||
scalar_fork.stderr.exp scalar_fork.vgtest \
|
||||
scalar_supp.stderr.exp scalar_supp.vgtest \
|
||||
sigaltstack.stderr.exp sigaltstack.vgtest \
|
||||
signal2.stderr.exp \
|
||||
signal2.stdout.exp signal2.vgtest \
|
||||
@ -81,7 +84,8 @@ check_PROGRAMS = \
|
||||
memalign_test memalign2 memcmptest mempool mmaptest \
|
||||
nanoleak new_nothrow \
|
||||
null_socket overlap \
|
||||
realloc1 realloc2 realloc3 scalar scalar_supp sigaltstack signal2 \
|
||||
realloc1 realloc2 realloc3 scalar scalar_fork \
|
||||
scalar_supp sigaltstack signal2 \
|
||||
str_tester supp1 supp2 suppfree \
|
||||
trivialleak weirdioctl \
|
||||
mismatches new_override metadata threadederrno \
|
||||
@ -134,6 +138,7 @@ realloc1_SOURCES = realloc1.c
|
||||
realloc2_SOURCES = realloc2.c
|
||||
realloc3_SOURCES = realloc3.c
|
||||
scalar_SOURCES = scalar.c
|
||||
scalar_fork_SOURCES = scalar_fork.c
|
||||
scalar_supp_SOURCES = scalar_supp.c
|
||||
signal2_SOURCES = signal2.c
|
||||
supp1_SOURCES = supp.c
|
||||
|
||||
@ -1,23 +1,4 @@
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// Thorough syscall scalar arg checking. Also serves as thorough checking
|
||||
// for (very) basic syscall use. Generally not trying to do anything
|
||||
// meaningful with the syscalls.
|
||||
|
||||
#define GO(__NR_xxx, s) \
|
||||
fprintf(stderr, "-----------------------------------------------------\n" \
|
||||
"%3d:%20s %s\n" \
|
||||
"-----------------------------------------------------\n", \
|
||||
__NR_xxx, #__NR_xxx, s);
|
||||
|
||||
#define SY syscall
|
||||
#include "scalar.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
22
memcheck/tests/scalar.h
Normal file
22
memcheck/tests/scalar.h
Normal file
@ -0,0 +1,22 @@
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// Thorough syscall scalar arg checking. Also serves as thorough checking
|
||||
// for (very) basic syscall use. Generally not trying to do anything
|
||||
// meaningful with the syscalls.
|
||||
|
||||
#define GO(__NR_xxx, s) \
|
||||
fprintf(stderr, "-----------------------------------------------------\n" \
|
||||
"%3d:%20s %s\n" \
|
||||
"-----------------------------------------------------\n", \
|
||||
__NR_xxx, #__NR_xxx, s);
|
||||
|
||||
#define SY syscall
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user