|
From: Jeremy F. <je...@go...> - 2005-02-09 20:16:24
|
CVS commit by fitzhardinge:
Report the proper filename when complaining about execve failures. Also, just
print a message and exit rather than panicing, since the execve failure is likely
to be something the user can fix.
M +13 -8 vg_syscalls.c 1.243
--- valgrind/coregrind/vg_syscalls.c #1.242:1.243
@@ -1676,4 +1676,6 @@ void pre_argv_envp(Addr a, ThreadId tid,
PRE(sys_execve, Special)
{
+ Char *path; /* path to executable */
+
PRINT("sys_execve ( %p(%s), %p, %p )", arg1, arg1, arg2, arg3);
PRE_REG_READ3(vki_off_t, "execve",
@@ -1685,4 +1687,6 @@ PRE(sys_execve, Special)
pre_argv_envp( arg3, tid, "execve(envp)", "execve(envp[i])" );
+ path = (const Char *)arg1;
+
/* Erk. If the exec fails, then the following will have made a
mess of things which makes it hard for us to continue. The
@@ -1693,5 +1697,5 @@ PRE(sys_execve, Special)
{
struct vki_stat st;
- Int ret = VG_(stat)((Char *)arg1, &st);
+ Int ret = VG_(stat)(path, &st);
if (ret < 0) {
@@ -1735,5 +1739,5 @@ PRE(sys_execve, Special)
if (VG_(clo_trace_children)) {
- Char* optvar = VG_(build_child_VALGRINDCLO)( (Char*)arg1 );
+ Char* optvar = VG_(build_child_VALGRINDCLO)( path );
// Set VALGRINDCLO and VALGRINDLIB in arg3 (the environment)
@@ -1741,6 +1745,6 @@ PRE(sys_execve, Special)
VG_(env_setenv)( (Char***)&arg3, VALGRINDLIB, VG_(libdir));
- // Create executable name: "/proc/self/fd/<vgexecfd>", update arg1
- arg1 = (Addr)VG_(build_child_exename)();
+ // Create executable name: "/proc/self/fd/<vgexecfd>", update path
+ path = (Addr)VG_(build_child_exename)();
}
@@ -1748,5 +1752,5 @@ PRE(sys_execve, Special)
Char **cpp;
- VG_(printf)("exec: %s\n", (Char *)arg1);
+ VG_(printf)("exec: %s\n", path);
for(cpp = (Char **)arg2; cpp && *cpp; cpp++)
VG_(printf)("argv: %s\n", *cpp);
@@ -1799,5 +1803,5 @@ PRE(sys_execve, Special)
}
- set_result( VG_(do_syscall)(__NR_execve, arg1, arg2, arg3) );
+ set_result( VG_(do_syscall)(__NR_execve, path, arg2, arg3) );
/* If we got here, then the execve failed. We've already made too much of a mess
@@ -1805,6 +1809,7 @@ PRE(sys_execve, Special)
VG_(message)(Vg_UserMsg, "execve(%p(%s), %p, %p) failed, errno %d",
arg1, arg1, arg2, arg3, -SYSRES);
- VG_(core_panic)("EXEC FAILED: I can't recover from execve() failing, so I'm dying.\n"
- "Add more stringent tests in PRE(execve), or work out how to recover.");
+ VG_(message)(Vg_UserMsg, "EXEC FAILED: I can't recover from execve() failing, so I'm dying.");
+ VG_(message)(Vg_UserMsg, "Add more stringent tests in PRE(execve), or work out how to recover.");
+ VG_(exit)(101);
}
|