Hi, This patch to do_fork_clone() supports specifying the child stack pointer. An app may do this when it believes that address space is constrained. Most callers specify a child stack pointer of 0; the Linux kernel then uses the actual stack pointer of the caller, thus equivalent to fork(). Patch is against a recent SVN version.
--- ./coregrind/m_syswrap/syswrap-ppc64-linux.c.orig 2007-11-01 12:16:36.000000000 -0700 +++ ./coregrind/m_syswrap/syswrap-ppc64-linux.c 2007-11-05 07:45:32.000000000 -0800 @@ -973,6 +973,7 @@ SET_STATUS_from_SysRes( ML_(do_fork_clone)(tid, cloneflags, /* flags */ + (Addr)ARG2, /* child SP */ (Int *)ARG3, /* parent_tidptr */ (Int *)ARG5)); /* child_tidptr */ break; --- ./coregrind/m_syswrap/syswrap-amd64-linux.c.orig 2007-11-01 12:16:36.000000000 -0700 +++ ./coregrind/m_syswrap/syswrap-amd64-linux.c 2007-11-05 07:45:32.000000000 -0800 @@ -422,6 +422,7 @@ SET_STATUS_from_SysRes( ML_(do_fork_clone)(tid, cloneflags, /* flags */ + (Addr)ARG2, /* child ESP */ (Int *)ARG3, /* parent_tidptr */ (Int *)ARG4)); /* child_tidptr */ break; --- ./coregrind/m_syswrap/syswrap-linux.c.orig 2007-11-01 12:16:36.000000000 -0700 +++ ./coregrind/m_syswrap/syswrap-linux.c 2007-11-05 07:46:41.000000000 -0800 @@ -294,7 +294,7 @@ /* Do a clone which is really a fork() */ -SysRes ML_(do_fork_clone) ( ThreadId tid, UInt flags, +SysRes ML_(do_fork_clone) ( ThreadId tid, UInt flags, Addr child_esp, Int* parent_tidptr, Int* child_tidptr ) { vki_sigset_t fork_saved_mask; @@ -328,6 +328,11 @@ if (!res.isError && res.res == 0) { /* child */ + if (child_esp != 0) { + ThreadState *const ctst = VG_(get_ThreadState)(tid); + ctst->arch.vex.guest_ESP = child_esp; + } + VG_(do_atfork_child)(tid); /* restore signal mask */ --- ./coregrind/m_syswrap/syswrap-x86-linux.c.orig 2007-11-01 12:16:36.000000000 -0700 +++ ./coregrind/m_syswrap/syswrap-x86-linux.c 2007-11-05 07:45:32.000000000 -0800 @@ -903,6 +903,7 @@ SET_STATUS_from_SysRes( ML_(do_fork_clone)(tid, cloneflags, /* flags */ + (Addr)ARG2, /* child ESP */ (Int *)ARG3, /* parent_tidptr */ (Int *)ARG5)); /* child_tidptr */ break; --- ./coregrind/m_syswrap/syswrap-ppc32-linux.c.orig 2007-11-01 12:16:36.000000000 -0700 +++ ./coregrind/m_syswrap/syswrap-ppc32-linux.c 2007-11-05 07:45:32.000000000 -0800 @@ -995,6 +995,7 @@ SET_STATUS_from_SysRes( ML_(do_fork_clone)(tid, cloneflags, /* flags */ + (Addr)ARG2, /* child SP */ (Int *)ARG3, /* parent_tidptr */ (Int *)ARG5)); /* child_tidptr */ break; --- ./coregrind/m_syswrap/priv_syswrap-linux.h.orig 2007-11-01 12:16:36.000000000 -0700 +++ ./coregrind/m_syswrap/priv_syswrap-linux.h 2007-11-05 07:45:32.000000000 -0800 @@ -38,7 +38,7 @@ extern Addr ML_(allocstack) ( ThreadId tid ); extern void ML_(call_on_new_stack_0_1) ( Addr stack, Addr retaddr, void (*f)(Word), Word arg1 ); -extern SysRes ML_(do_fork_clone) ( ThreadId tid, UInt flags, +extern SysRes ML_(do_fork_clone) ( ThreadId tid, UInt flags, Addr child_esp, Int* parent_tidptr, Int* child_tidptr ); -- John Reiser, [EMAIL PROTECTED] ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Valgrind-developers mailing list Valgrind-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-developers