Author: njn Date: 2005-06-12 03:43:17 +0100 (Sun, 12 Jun 2005) New Revision: 3894 Log: Finished the modularisation of vg_mylibc.c, which meant it could be remov= ed. Added: trunk/coregrind/m_libcproc.c trunk/coregrind/pub_core_libcproc.h trunk/include/pub_tool_libcproc.h Removed: trunk/coregrind/vg_mylibc.c Modified: trunk/cachegrind/cg-amd64.c trunk/cachegrind/cg-x86.c trunk/cachegrind/cg_main.c trunk/coregrind/Makefile.am trunk/coregrind/core.h trunk/coregrind/linux/core_os.c trunk/coregrind/m_aspacemgr/aspacemgr.c trunk/coregrind/m_errormgr.c trunk/coregrind/m_libcassert.c trunk/coregrind/m_libcmman.c trunk/coregrind/m_libcprint.c trunk/coregrind/m_main.c trunk/coregrind/m_scheduler/scheduler.c trunk/coregrind/m_scheduler/sema.c trunk/coregrind/m_signals.c trunk/coregrind/m_syscalls/syscalls-amd64-linux.c trunk/coregrind/m_syscalls/syscalls-generic.c trunk/coregrind/m_syscalls/syscalls-main.c trunk/coregrind/m_syscalls/syscalls-x86-linux.c trunk/coregrind/m_tooliface.c trunk/coregrind/pub_core_main.h trunk/coregrind/pub_core_options.h trunk/coregrind/stage1.c trunk/helgrind/hg_main.c trunk/include/Makefile.am trunk/include/pub_tool_libcassert.h trunk/include/tool.h trunk/lackey/lk_main.c trunk/massif/ms_main.c Modified: trunk/cachegrind/cg-amd64.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cachegrind/cg-amd64.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/cachegrind/cg-amd64.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -31,6 +31,7 @@ #include "tool.h" #include "cg_arch.h" #include "pub_tool_libcbase.h" +#include "pub_tool_libcassert.h" #include "pub_tool_libcprint.h" =20 // All CPUID info taken from sandpile.org/a32/cpuid.htm */ Modified: trunk/cachegrind/cg-x86.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cachegrind/cg-x86.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/cachegrind/cg-x86.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -30,6 +30,7 @@ =20 #include "tool.h" #include "pub_tool_libcbase.h" +#include "pub_tool_libcassert.h" #include "pub_tool_libcprint.h" #include "cg_arch.h" =20 Modified: trunk/cachegrind/cg_main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/cachegrind/cg_main.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/cachegrind/cg_main.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -36,6 +36,7 @@ #include "pub_tool_libcassert.h" #include "pub_tool_libcfile.h" #include "pub_tool_libcprint.h" +#include "pub_tool_libcproc.h" #include "pub_tool_mallocfree.h" #include "pub_tool_options.h" #include "pub_tool_profile.h" Modified: trunk/coregrind/Makefile.am =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/Makefile.am 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/Makefile.am 2005-06-12 02:43:17 UTC (rev 3894) @@ -51,6 +51,7 @@ pub_core_libcfile.h \ pub_core_libcmman.h \ pub_core_libcprint.h \ + pub_core_libcproc.h \ pub_core_libcsignal.h \ pub_core_main.h \ pub_core_mallocfree.h \ @@ -100,6 +101,7 @@ m_libcfile.c \ m_libcmman.c \ m_libcprint.c \ + m_libcproc.c \ m_libcsignal.c \ m_main.c \ m_mallocfree.c \ @@ -115,8 +117,7 @@ m_translate.c \ m_transtab.c \ \ - ume.c \ - vg_mylibc.c + ume.c =20 ## Nb: libscheduler.a must precede libdispatch.a in this list. stage2_extra=3D \ Modified: trunk/coregrind/core.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/core.h 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/core.h 2005-06-12 02:43:17 UTC (rev 3894) @@ -82,13 +82,6 @@ #include "pub_core_scheduler.h" // for types 'ThreadArchState' =20 /* --------------------------------------------------------------------- - Environment variables - ------------------------------------------------------------------ */ - -/* The directory we look for all our auxillary files in */ -#define VALGRINDLIB "VALGRINDLIB" - -/* --------------------------------------------------------------------- Exports of vg_intercept.c ------------------------------------------------------------------ */ =20 @@ -124,26 +117,7 @@ ------------------------------------------------------------------ */ =20 extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg ); -extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout); =20 -/* Environment manipulations */ -extern Char **VG_(env_setenv) ( Char ***envp, const Char* varname, - const Char *val ); -extern void VG_(env_unsetenv) ( Char **env, const Char *varname ); -extern void VG_(env_remove_valgrind_env_stuff) ( Char** env );=20 - -extern void VG_(nanosleep)(struct vki_timespec *); - -/* Simple Valgrind-internal atfork mechanism */ -/* Internal atfork handlers */ -typedef void (*vg_atfork_t)(ThreadId); -extern void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent,=20 - vg_atfork_t child); -extern void VG_(do_atfork_pre) (ThreadId tid); -extern void VG_(do_atfork_parent)(ThreadId tid); -extern void VG_(do_atfork_child) (ThreadId tid); - - /* --------------------------------------------------------------------- Exports of vg_syscall.S ------------------------------------------------------------------ */ Modified: trunk/coregrind/linux/core_os.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/linux/core_os.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/linux/core_os.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -33,6 +33,7 @@ #include "pub_core_debuglog.h" #include "pub_core_libcassert.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_options.h" #include "pub_core_signals.h" Modified: trunk/coregrind/m_aspacemgr/aspacemgr.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-06-12 00:06:24 UTC (rev = 3893) +++ trunk/coregrind/m_aspacemgr/aspacemgr.c 2005-06-12 02:43:17 UTC (rev = 3894) @@ -37,6 +37,7 @@ #include "pub_core_libcfile.h" // For VG_(fstat)() #include "pub_core_libcmman.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_mallocfree.h" #include "pub_core_options.h" #include "pub_core_syscalls.h" Modified: trunk/coregrind/m_errormgr.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_errormgr.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_errormgr.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -36,6 +36,7 @@ #include "pub_core_libcassert.h" #include "pub_core_libcfile.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_main.h" // for VG_(start_debugger)() #include "pub_core_mallocfree.h" #include "pub_core_options.h" Modified: trunk/coregrind/m_libcassert.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_libcassert.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_libcassert.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -32,9 +32,11 @@ #include "pub_core_libcbase.h" #include "pub_core_libcassert.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_main.h" #include "pub_core_stacktrace.h" #include "pub_core_tooliface.h" +#include "vki_unistd.h" =20 /* --------------------------------------------------------------------- Assertery. @@ -56,6 +58,17 @@ # error Unknown platform #endif =20 +/* Pull down the entire world */ +void VG_(exit)( Int status ) +{ + (void)VG_(do_syscall1)(__NR_exit_group, status ); + (void)VG_(do_syscall1)(__NR_exit, status ); + /* Why are we still alive here? */ + /*NOTREACHED*/ + *(volatile Int *)0 =3D 'x'; + vg_assert(2+2 =3D=3D 5); +} + __attribute__ ((noreturn)) static void report_and_quit ( const Char* report, Addr ip, Addr sp, Addr= fp ) { Modified: trunk/coregrind/m_libcmman.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_libcmman.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_libcmman.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -34,6 +34,7 @@ #include "pub_core_libcassert.h" #include "pub_core_libcmman.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "vki_unistd.h" =20 SysRes VG_(mmap_native)(void *start, SizeT length, UInt prot, UInt flags= , Modified: trunk/coregrind/m_libcprint.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_libcprint.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_libcprint.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -34,6 +34,7 @@ #include "pub_core_libcassert.h" #include "pub_core_libcfile.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_options.h" #include "valgrind.h" // for RUNNING_ON_VALGRIND =20 Added: trunk/coregrind/m_libcproc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_libcproc.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_libcproc.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -0,0 +1,490 @@ + +/*--------------------------------------------------------------------*/ +/*--- Process-related libc stuff. m_libcproc.c ---*/ +/*--------------------------------------------------------------------*/ +=20 +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2005 Julian Seward=20 + js...@ac... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307, USA. + + The GNU General Public License is contained in the file COPYING. +*/ + +#include "core.h" +#include "pub_core_libcbase.h" +#include "pub_core_libcassert.h" +#include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" +#include "pub_core_mallocfree.h" +#include "vki_unistd.h" + +/* --------------------------------------------------------------------- + Command line and environment stuff + ------------------------------------------------------------------ */ + +/* As deduced from sp_at_startup, the client's argc, argv[] and + envp[] as extracted from the client's stack at startup-time. */ +Int VG_(client_argc); +Char** VG_(client_argv); +Char** VG_(client_envp); + +/* We do getenv without libc's help by snooping around in + VG_(client_envp) as determined at startup time. */ +Char *VG_(getenv)(Char *varname) +{ + Int i, n; + n =3D VG_(strlen)(varname); + for (i =3D 0; VG_(client_envp)[i] !=3D NULL; i++) { + Char* s =3D VG_(client_envp)[i]; + if (VG_(strncmp)(varname, s, n) =3D=3D 0 && s[n] =3D=3D '=3D') { + return & s[n+1]; + } + } + return NULL; +} + +void VG_(env_unsetenv) ( Char **env, const Char *varname ) +{ + Char **from; + Char **to =3D NULL; + Int len =3D VG_(strlen)(varname); + + for(from =3D to =3D env; from && *from; from++) { + if (!(VG_(strncmp)(varname, *from, len) =3D=3D 0 && (*from)[len] =3D= =3D '=3D')) { + *to =3D *from; + to++; + } + } + *to =3D *from; +} + +/* set the environment; returns the old env if a new one was allocated *= / +Char **VG_(env_setenv) ( Char ***envp, const Char* varname, const Char *= val ) +{ + Char **env =3D (*envp); + Char **cpp; + Int len =3D VG_(strlen)(varname); + Char *valstr =3D VG_(arena_malloc)(VG_AR_CORE, len + VG_(strlen)(val)= + 2); + Char **oldenv =3D NULL; + + VG_(sprintf)(valstr, "%s=3D%s", varname, val); + + for(cpp =3D env; cpp && *cpp; cpp++) { + if (VG_(strncmp)(varname, *cpp, len) =3D=3D 0 && (*cpp)[len] =3D=3D= '=3D') { + *cpp =3D valstr; + return oldenv; + } + } + + if (env =3D=3D NULL) { + env =3D VG_(arena_malloc)(VG_AR_CORE, sizeof(Char **) * 2); + env[0] =3D valstr; + env[1] =3D NULL; + + *envp =3D env; + + } else { + Int envlen =3D (cpp-env) + 2; + Char **newenv =3D VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Ch= ar **)); + + for(cpp =3D newenv; *env; ) + *cpp++ =3D *env++; + *cpp++ =3D valstr; + *cpp++ =3D NULL; + + oldenv =3D *envp; + + *envp =3D newenv; + } + + return oldenv; +} + +/* Walk through a colon-separated environment variable, and remove the + entries which match remove_pattern. It slides everything down over + the removed entries, and pads the remaining space with '\0'. It + modifies the entries in place (in the client address space), but it + shouldn't matter too much, since we only do this just before an + execve(). + + This is also careful to mop up any excess ':'s, since empty strings + delimited by ':' are considered to be '.' in a path. +*/ +static void mash_colon_env(Char *varp, const Char *remove_pattern) +{ + Char *const start =3D varp; + Char *entry_start =3D varp; + Char *output =3D varp; + + if (varp =3D=3D NULL) + return; + + while(*varp) { + if (*varp =3D=3D ':') { + Char prev; + Bool match; + + /* This is a bit subtle: we want to match against the entry + we just copied, because it may have overlapped with + itself, junking the original. */ + + prev =3D *output; + *output =3D '\0'; + + match =3D VG_(string_match)(remove_pattern, entry_start); + + *output =3D prev; + =20 + if (match) { + output =3D entry_start; + varp++; /* skip ':' after removed entry */ + } else + entry_start =3D output+1; /* entry starts after ':' */ + } + + *output++ =3D *varp++; + } + + /* match against the last entry */ + if (VG_(string_match)(remove_pattern, entry_start)) { + output =3D entry_start; + if (output > start) { + /* remove trailing ':' */ + output--; + vg_assert(*output =3D=3D ':'); + } + } =20 + + /* pad out the left-overs with '\0' */ + while(output < varp) + *output++ =3D '\0'; +} + + +// Removes all the Valgrind-added stuff from the passed environment. Us= ed +// when starting child processes, so they don't see that added stuff. +void VG_(env_remove_valgrind_env_stuff)(Char** envp) +{ + Int i; + Char* ld_preload_str =3D NULL; + Char* ld_library_path_str =3D NULL; + Char* buf; + + // Find LD_* variables + for (i =3D 0; envp[i] !=3D NULL; i++) { + if (VG_(strncmp)(envp[i], "LD_PRELOAD=3D", 11) =3D=3D 0) + ld_preload_str =3D &envp[i][11]; + if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=3D", 16) =3D=3D 0) + ld_library_path_str =3D &envp[i][16]; + } + + buf =3D VG_(arena_malloc)(VG_AR_CORE, VG_(strlen)(VG_(libdir)) + 20); + + // Remove Valgrind-specific entries from LD_*. + VG_(sprintf)(buf, "%s*/vg_inject.so", VG_(libdir)); + mash_colon_env(ld_preload_str, buf); + VG_(sprintf)(buf, "%s*/vgpreload_*.so", VG_(libdir)); + mash_colon_env(ld_preload_str, buf); + VG_(sprintf)(buf, "%s*", VG_(libdir)); + mash_colon_env(ld_library_path_str, buf); + + // Remove VALGRIND_CLO variable. + VG_(env_unsetenv)(envp, VALGRINDCLO); + + // XXX if variable becomes empty, remove it completely? + + VG_(arena_free)(VG_AR_CORE, buf); +} + +/* --------------------------------------------------------------------- + Various important syscall wrappers + ------------------------------------------------------------------ */ + +Int VG_(waitpid)(Int pid, Int *status, Int options) +{ + SysRes res =3D VG_(do_syscall4)(__NR_wait4, pid, (UWord)status, optio= ns, 0); + return res.isError ? -1 : res.val; +} + +/* Returns -1 on error. */ +Int VG_(fcntl) ( Int fd, Int cmd, Int arg ) +{ + SysRes res =3D VG_(do_syscall3)(__NR_fcntl, fd, cmd, arg); + return res.isError ? -1 : res.val; +} + +Int VG_(poll)( struct vki_pollfd *ufds, UInt nfds, Int timeout) +{ + SysRes res =3D VG_(do_syscall3)(__NR_poll, (UWord)ufds, nfds, timeout= ); + /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ + return res.val; +} + +/* clone the environment */ +static Char **env_clone ( Char **oldenv ) +{ + Char **oldenvp; + Char **newenvp; + Char **newenv; + Int envlen; + + for (oldenvp =3D oldenv; oldenvp && *oldenvp; oldenvp++); + + envlen =3D oldenvp - oldenv + 1; + =20 + newenv =3D VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Char **)); + + oldenvp =3D oldenv; + newenvp =3D newenv; + =20 + while (oldenvp && *oldenvp) { + *newenvp++ =3D *oldenvp++; + } + =20 + *newenvp =3D *oldenvp; + + return newenv; +} + +/* Return -1 if error, else 0. NOTE does not indicate return code of + child! */ +Int VG_(system) ( Char* cmd ) +{ + Int pid; + SysRes res; + if (cmd =3D=3D NULL) + return 1; + res =3D VG_(do_syscall0)(__NR_fork); + if (res.isError) + return -1; + pid =3D res.val; + if (pid =3D=3D 0) { + /* child */ + static Char** envp =3D NULL; + Char* argv[4]; + + /* restore the DATA rlimit for the child */ + VG_(setrlimit)(VKI_RLIMIT_DATA, &VG_(client_rlimit_data)); + + envp =3D env_clone(VG_(client_envp)); + VG_(env_remove_valgrind_env_stuff)( envp );=20 + + argv[0] =3D "/bin/sh"; + argv[1] =3D "-c"; + argv[2] =3D cmd; + argv[3] =3D 0; + + (void)VG_(do_syscall3)(__NR_execve,=20 + (UWord)"/bin/sh", (UWord)argv, (UWord)envp)= ; + + /* If we're still alive here, execve failed. */ + VG_(exit)(1); + } else { + /* parent */ + Int zzz =3D VG_(waitpid)(pid, NULL, 0); + return zzz =3D=3D -1 ? -1 : 0; + } +} + +/* --------------------------------------------------------------------- + Resource limits + ------------------------------------------------------------------ */ + +struct vki_rlimit VG_(client_rlimit_data); +struct vki_rlimit VG_(client_rlimit_stack); + +/* Support for getrlimit. */ +Int VG_(getrlimit) (Int resource, struct vki_rlimit *rlim) +{ + SysRes res =3D VG_(mk_SysRes_Error)(VKI_ENOSYS); + /* res =3D getrlimit( resource, rlim ); */ +# ifdef __NR_ugetrlimit + res =3D VG_(do_syscall2)(__NR_ugetrlimit, resource, (UWord)rlim); +# endif + if (res.isError && res.val =3D=3D VKI_ENOSYS) + res =3D VG_(do_syscall2)(__NR_getrlimit, resource, (UWord)rlim); + return res.isError ? -1 : res.val; +} + + +/* Support for setrlimit. */ +Int VG_(setrlimit) (Int resource, const struct vki_rlimit *rlim) +{ + SysRes res; + /* res =3D setrlimit( resource, rlim ); */ + res =3D VG_(do_syscall2)(__NR_setrlimit, resource, (UWord)rlim); + return res.isError ? -1 : res.val; +} + +/* --------------------------------------------------------------------- + pids, etc + ------------------------------------------------------------------ */ + +Int VG_(gettid)(void) +{ + SysRes res =3D VG_(do_syscall0)(__NR_gettid); + + if (res.isError && res.val =3D=3D VKI_ENOSYS) { + Char pid[16]; =20 + /* + * The gettid system call does not exist. The obvious assumption + * to make at this point would be that we are running on an older + * system where the getpid system call actually returns the ID of + * the current thread. + * + * Unfortunately it seems that there are some systems with a kerne= l + * where getpid has been changed to return the ID of the thread gr= oup + * leader but where the gettid system call has not yet been added. + * + * So instead of calling getpid here we use readlink to see where + * the /proc/self link is pointing... + */ + + res =3D VG_(do_syscall3)(__NR_readlink, (UWord)"/proc/self", + (UWord)pid, sizeof(pid)); + if (!res.isError && res.val > 0) { + pid[res.val] =3D '\0'; + res.val =3D VG_(atoll)(pid); + } + } + + return res.val; +} + +/* You'd be amazed how many places need to know the current pid. */ +Int VG_(getpid) ( void ) +{ + /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ + return VG_(do_syscall0)(__NR_getpid) . val; +} + +Int VG_(getpgrp) ( void ) +{ + /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ + return VG_(do_syscall0)(__NR_getpgrp) . val; +} + +Int VG_(getppid) ( void ) +{ + /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ + return VG_(do_syscall0)(__NR_getppid) . val; +} + +Int VG_(setpgid) ( Int pid, Int pgrp ) +{ + /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ + return VG_(do_syscall2)(__NR_setpgid, pid, pgrp) . val; +} + +/* --------------------------------------------------------------------- + Timing stuff + ------------------------------------------------------------------ */ + +UInt VG_(read_millisecond_timer) ( void ) +{ + static ULong base =3D 0; + struct vki_timeval tv_now; + ULong now; + SysRes res; + + res =3D VG_(do_syscall2)(__NR_gettimeofday, (UWord)&tv_now, (UWord)NU= LL); + =20 + now =3D tv_now.tv_sec * 1000000ULL + tv_now.tv_usec; + =20 + if (base =3D=3D 0) + base =3D now; + + return (now - base) / 1000; +} + + +void VG_(nanosleep)(struct vki_timespec *ts) +{ + (void)VG_(do_syscall2)(__NR_nanosleep, (UWord)ts, (UWord)NULL); +} + +/* --------------------------------------------------------------------- + A simple atfork() facility for Valgrind's internal use + ------------------------------------------------------------------ */ + +struct atfork { + vg_atfork_t pre; + vg_atfork_t parent; + vg_atfork_t child; +}; + +#define VG_MAX_ATFORK 10 + +static struct atfork atforks[VG_MAX_ATFORK]; +static Int n_atfork; + +void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t child) +{ + Int i; + + for(i =3D 0; i < n_atfork; i++) { + if (atforks[i].pre =3D=3D pre && + atforks[i].parent =3D=3D parent && + atforks[i].child =3D=3D child) + return; + } + + if (n_atfork >=3D VG_MAX_ATFORK) + VG_(core_panic)("Too many VG_(atfork) handlers requested: " + "raise VG_MAX_ATFORK"); + + atforks[n_atfork].pre =3D pre; + atforks[n_atfork].parent =3D parent; + atforks[n_atfork].child =3D child; + + n_atfork++; +} + +void VG_(do_atfork_pre)(ThreadId tid) +{ + Int i; + + for(i =3D 0; i < n_atfork; i++) + if (atforks[i].pre !=3D NULL) + (*atforks[i].pre)(tid); +} + +void VG_(do_atfork_parent)(ThreadId tid) +{ + Int i; + + for(i =3D 0; i < n_atfork; i++) + if (atforks[i].parent !=3D NULL) + (*atforks[i].parent)(tid); +} + +void VG_(do_atfork_child)(ThreadId tid) +{ + Int i; + + for(i =3D 0; i < n_atfork; i++) + if (atforks[i].child !=3D NULL) + (*atforks[i].child)(tid); +} + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ Modified: trunk/coregrind/m_main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_main.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_main.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -41,6 +41,7 @@ #include "pub_core_libcfile.h" #include "pub_core_libcmman.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_main.h" #include "pub_core_mallocfree.h" @@ -111,9 +112,6 @@ Startup stuff =20 ------------------------------------------------------------------ */ =20 -struct vki_rlimit VG_(client_rlimit_data); -struct vki_rlimit VG_(client_rlimit_stack); - /* stage1 (main) executable */ static Int vgexecfd =3D -1; =20 @@ -127,13 +125,7 @@ static Int vg_argc; static Char **vg_argv; =20 -/* As deduced from sp_at_startup, the client's argc, argv[] and - envp[] as extracted from the client's stack at startup-time. */ -Int VG_(client_argc); -Char** VG_(client_argv); -Char** VG_(client_envp); =20 - /* --------------------------------------------------------------------- Running stuff =20 ------------------------------------------------------------------ */ Modified: trunk/coregrind/m_scheduler/scheduler.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_scheduler/scheduler.c 2005-06-12 00:06:24 UTC (rev = 3893) +++ trunk/coregrind/m_scheduler/scheduler.c 2005-06-12 02:43:17 UTC (rev = 3894) @@ -66,6 +66,7 @@ #include "pub_core_libcbase.h" #include "pub_core_libcassert.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_main.h" #include "pub_core_mallocfree.h" Modified: trunk/coregrind/m_scheduler/sema.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_scheduler/sema.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_scheduler/sema.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -31,6 +31,7 @@ #include "core.h" #include "pub_core_libcassert.h" #include "pub_core_libcfile.h" +#include "pub_core_libcproc.h" #include "priv_sema.h" =20 /*=20 Modified: trunk/coregrind/m_signals.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_signals.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_signals.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -87,6 +87,7 @@ #include "pub_core_libcassert.h" #include "pub_core_libcmman.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_main.h" #include "pub_core_mallocfree.h" Modified: trunk/coregrind/m_syscalls/syscalls-amd64-linux.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_syscalls/syscalls-amd64-linux.c 2005-06-12 00:06:24= UTC (rev 3893) +++ trunk/coregrind/m_syscalls/syscalls-amd64-linux.c 2005-06-12 02:43:17= UTC (rev 3894) @@ -37,6 +37,7 @@ #include "pub_core_libcassert.h" #include "pub_core_libcmman.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_sigframe.h" #include "pub_core_signals.h" Modified: trunk/coregrind/m_syscalls/syscalls-generic.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_syscalls/syscalls-generic.c 2005-06-12 00:06:24 UTC= (rev 3893) +++ trunk/coregrind/m_syscalls/syscalls-generic.c 2005-06-12 02:43:17 UTC= (rev 3894) @@ -36,6 +36,7 @@ #include "pub_core_libcfile.h" #include "pub_core_libcmman.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_main.h" #include "pub_core_mallocfree.h" Modified: trunk/coregrind/m_syscalls/syscalls-main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_syscalls/syscalls-main.c 2005-06-12 00:06:24 UTC (r= ev 3893) +++ trunk/coregrind/m_syscalls/syscalls-main.c 2005-06-12 02:43:17 UTC (r= ev 3894) @@ -33,6 +33,7 @@ #include "pub_core_libcbase.h" #include "pub_core_libcassert.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_stacktrace.h" #include "pub_core_tooliface.h" Modified: trunk/coregrind/m_syscalls/syscalls-x86-linux.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_syscalls/syscalls-x86-linux.c 2005-06-12 00:06:24 U= TC (rev 3893) +++ trunk/coregrind/m_syscalls/syscalls-x86-linux.c 2005-06-12 02:43:17 U= TC (rev 3894) @@ -42,6 +42,7 @@ #include "pub_core_libcassert.h" #include "pub_core_libcmman.h" #include "pub_core_libcprint.h" +#include "pub_core_libcproc.h" #include "pub_core_libcsignal.h" #include "pub_core_mallocfree.h" #include "pub_core_sigframe.h" Modified: trunk/coregrind/m_tooliface.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/m_tooliface.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/m_tooliface.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -32,6 +32,7 @@ #include "core.h" #include "pub_core_aspacemgr.h" #include "pub_core_libcbase.h" +#include "pub_core_libcassert.h" #include "pub_core_libcprint.h" #include "pub_core_mallocfree.h" #include "pub_core_tooliface.h" Added: trunk/coregrind/pub_core_libcproc.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/pub_core_libcproc.h 2005-06-12 00:06:24 UTC (rev 3893= ) +++ trunk/coregrind/pub_core_libcproc.h 2005-06-12 02:43:17 UTC (rev 3894= ) @@ -0,0 +1,85 @@ + +/*--------------------------------------------------------------------*/ +/*--- Process-related libc stuff. pub_core_libcproc.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2005 Julian Seward + js...@ac... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307, USA. + + The GNU General Public License is contained in the file COPYING. +*/ + +#ifndef __PUB_CORE_LIBCPROC_H +#define __PUB_CORE_LIBCPROC_H + +//-------------------------------------------------------------------- +// PURPOSE: This module contains libc code related to the process. +// It's a bit of a mixed bag. +//-------------------------------------------------------------------- + +#include "pub_tool_libcproc.h" + +/* The directory we look for all our auxillary files in */ +#define VALGRINDLIB "VALGRINDLIB" + +/* Additional command-line arguments; they are overridden by actual + command-line option. Each argument is separated by spaces. There + is no quoting mechanism. */ +#define VALGRINDOPTS "VALGRIND_OPTS" + +/* If this variable is present in the environment, then valgrind will + not parse the command line for options at all; all options come + from this variable. Arguments are terminated by ^A (\001). There + is no quoting mechanism. + + This variable is not expected to be set by anything other than + Valgrind itself, as part of its handling of execve with + --trace-children=3Dyes. This variable should not be present in the + client environment. */ +#define VALGRINDCLO "_VALGRIND_CLO" + +// Client's original rlimit data and rlimit stack +extern struct vki_rlimit VG_(client_rlimit_data); +extern struct vki_rlimit VG_(client_rlimit_stack); + +// Environment manipulations +extern Char **VG_(env_setenv) ( Char ***envp, const Char* varname, + const Char *val ); +extern void VG_(env_unsetenv) ( Char **env, const Char *varname ); +extern void VG_(env_remove_valgrind_env_stuff) ( Char** env );=20 + +// misc +extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout); +extern void VG_(nanosleep) ( struct vki_timespec * ); + +// atfork +typedef void (*vg_atfork_t)(ThreadId); +extern void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t= child); +extern void VG_(do_atfork_pre) ( ThreadId tid ); +extern void VG_(do_atfork_parent) ( ThreadId tid ); +extern void VG_(do_atfork_child) ( ThreadId tid ); + +#endif // __PUB_CORE_LIBCPROC_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ Modified: trunk/coregrind/pub_core_main.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/pub_core_main.h 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/pub_core_main.h 2005-06-12 02:43:17 UTC (rev 3894) @@ -41,9 +41,6 @@ /* Sanity checks which may be done at any time. The scheduler decides w= hen. */ extern void VG_(sanity_check_general) ( Bool force_expensive ); =20 -extern struct vki_rlimit VG_(client_rlimit_data); /* client's original r= limit data */ -extern struct vki_rlimit VG_(client_rlimit_stack); /* client's original = rlimit stack */ - /* client executable file descriptor */ extern Int VG_(clexecfd); =20 Modified: trunk/coregrind/pub_core_options.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/pub_core_options.h 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/pub_core_options.h 2005-06-12 02:43:17 UTC (rev 3894) @@ -39,22 +39,6 @@ =20 #include "pub_tool_options.h" =20 -/* Additional command-line arguments; they are overridden by actual - command-line option. Each argument is separated by spaces. There - is no quoting mechanism. */ -#define VALGRINDOPTS "VALGRIND_OPTS" - -/* If this variable is present in the environment, then valgrind will - not parse the command line for options at all; all options come - from this variable. Arguments are terminated by ^A (\001). There - is no quoting mechanism. - - This variable is not expected to be set by anything other than - Valgrind itself, as part of its handling of execve with - --trace-children=3Dyes. This variable should not be present in the - client environment. */ -#define VALGRINDCLO "_VALGRIND_CLO" - /* Default destination port to be used in logging over a network, if none specified. */ #define VG_CLO_DEFAULT_LOGPORT 1500 Modified: trunk/coregrind/stage1.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/stage1.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/stage1.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -45,6 +45,7 @@ #include "ume.h" #include "memcheck/memcheck.h" #include "pub_core_debuglog.h" +#include "pub_core_libcproc.h" =20 =20 static int stack[SIGSTKSZ*4]; Deleted: trunk/coregrind/vg_mylibc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/coregrind/vg_mylibc.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/coregrind/vg_mylibc.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -1,504 +0,0 @@ - -/*--------------------------------------------------------------------*/ -/*--- Reimplementation of some C library stuff, to avoid depending ---*/ -/*--- on libc.so. ---*/ -/*--- vg_mylibc.c ---*/ -/*--------------------------------------------------------------------*/ -=20 -/* - This file is part of Valgrind, a dynamic binary instrumentation - framework. - - Copyright (C) 2000-2005 Julian Seward=20 - js...@ac... - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307, USA. - - The GNU General Public License is contained in the file COPYING. -*/ - -#include "core.h" -#include "pub_core_aspacemgr.h" -#include "pub_core_debuglog.h" /* VG_(debugLog_vprintf) */ -#include "pub_core_libcbase.h" -#include "pub_core_libcassert.h" -#include "pub_core_libcprint.h" -#include "pub_core_libcfile.h" -#include "pub_core_main.h" -#include "pub_core_mallocfree.h" -#include "pub_core_options.h" -#include "pub_core_stacktrace.h" -#include "pub_core_syscalls.h" -#include "pub_core_tooliface.h" -#include "vki_unistd.h" - - -Int VG_(waitpid)(Int pid, Int *status, Int options) -{ - SysRes res =3D VG_(do_syscall4)(__NR_wait4, pid, (UWord)status, optio= ns, 0); - return res.isError ? -1 : res.val; -} - -Int VG_(gettid)(void) -{ - SysRes res =3D VG_(do_syscall0)(__NR_gettid); - - if (res.isError && res.val =3D=3D VKI_ENOSYS) { - Char pid[16]; =20 - /* - * The gettid system call does not exist. The obvious assumption - * to make at this point would be that we are running on an older - * system where the getpid system call actually returns the ID of - * the current thread. - * - * Unfortunately it seems that there are some systems with a kerne= l - * where getpid has been changed to return the ID of the thread gr= oup - * leader but where the gettid system call has not yet been added. - * - * So instead of calling getpid here we use readlink to see where - * the /proc/self link is pointing... - */ - - res =3D VG_(do_syscall3)(__NR_readlink, (UWord)"/proc/self", - (UWord)pid, sizeof(pid)); - if (!res.isError && res.val > 0) { - pid[res.val] =3D '\0'; - res.val =3D VG_(atoll)(pid); - } - } - - return res.val; -} - - - -/* --------------------------------------------------------------------- - exit, fcntl - ------------------------------------------------------------------ */ - -/* Pull down the entire world */ -void VG_(exit)( Int status ) -{ - (void)VG_(do_syscall1)(__NR_exit_group, status ); - (void)VG_(do_syscall1)(__NR_exit, status ); - /* Why are we still alive here? */ - /*NOTREACHED*/ - *(volatile Int *)0 =3D 'x'; - vg_assert(2+2 =3D=3D 5); -} - -/* Returns -1 on error. */ -Int VG_(fcntl) ( Int fd, Int cmd, Int arg ) -{ - SysRes res =3D VG_(do_syscall3)(__NR_fcntl, fd, cmd, arg); - return res.isError ? -1 : res.val; -} - -Int VG_(poll)( struct vki_pollfd *ufds, UInt nfds, Int timeout) -{ - SysRes res =3D VG_(do_syscall3)(__NR_poll, (UWord)ufds, nfds, timeout= ); - /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ - return res.val; -} - - -/* --------------------------------------------------------------------- - Misc functions looking for a proper home. - ------------------------------------------------------------------ */ - -/* clone the environment */ -static Char **env_clone ( Char **oldenv ) -{ - Char **oldenvp; - Char **newenvp; - Char **newenv; - Int envlen; - - for (oldenvp =3D oldenv; oldenvp && *oldenvp; oldenvp++); - - envlen =3D oldenvp - oldenv + 1; - =20 - newenv =3D VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Char **)); - - oldenvp =3D oldenv; - newenvp =3D newenv; - =20 - while (oldenvp && *oldenvp) { - *newenvp++ =3D *oldenvp++; - } - =20 - *newenvp =3D *oldenvp; - - return newenv; -} - -void VG_(env_unsetenv) ( Char **env, const Char *varname ) -{ - Char **from; - Char **to =3D NULL; - Int len =3D VG_(strlen)(varname); - - for(from =3D to =3D env; from && *from; from++) { - if (!(VG_(strncmp)(varname, *from, len) =3D=3D 0 && (*from)[len] =3D= =3D '=3D')) { - *to =3D *from; - to++; - } - } - *to =3D *from; -} - -/* set the environment; returns the old env if a new one was allocated *= / -Char **VG_(env_setenv) ( Char ***envp, const Char* varname, const Char *= val ) -{ - Char **env =3D (*envp); - Char **cpp; - Int len =3D VG_(strlen)(varname); - Char *valstr =3D VG_(arena_malloc)(VG_AR_CORE, len + VG_(strlen)(val)= + 2); - Char **oldenv =3D NULL; - - VG_(sprintf)(valstr, "%s=3D%s", varname, val); - - for(cpp =3D env; cpp && *cpp; cpp++) { - if (VG_(strncmp)(varname, *cpp, len) =3D=3D 0 && (*cpp)[len] =3D=3D= '=3D') { - *cpp =3D valstr; - return oldenv; - } - } - - if (env =3D=3D NULL) { - env =3D VG_(arena_malloc)(VG_AR_CORE, sizeof(Char **) * 2); - env[0] =3D valstr; - env[1] =3D NULL; - - *envp =3D env; - - } else { - Int envlen =3D (cpp-env) + 2; - Char **newenv =3D VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Ch= ar **)); - - for(cpp =3D newenv; *env; ) - *cpp++ =3D *env++; - *cpp++ =3D valstr; - *cpp++ =3D NULL; - - oldenv =3D *envp; - - *envp =3D newenv; - } - - return oldenv; -} - -/* We do getenv without libc's help by snooping around in - VG_(client_envp) as determined at startup time. */ -Char *VG_(getenv)(Char *varname) -{ - Int i, n; - n =3D VG_(strlen)(varname); - for (i =3D 0; VG_(client_envp)[i] !=3D NULL; i++) { - Char* s =3D VG_(client_envp)[i]; - if (VG_(strncmp)(varname, s, n) =3D=3D 0 && s[n] =3D=3D '=3D') { - return & s[n+1]; - } - } - return NULL; -} - -/* Support for getrlimit. */ -Int VG_(getrlimit) (Int resource, struct vki_rlimit *rlim) -{ - SysRes res =3D VG_(mk_SysRes_Error)(VKI_ENOSYS); - /* res =3D getrlimit( resource, rlim ); */ -# ifdef __NR_ugetrlimit - res =3D VG_(do_syscall2)(__NR_ugetrlimit, resource, (UWord)rlim); -# endif - if (res.isError && res.val =3D=3D VKI_ENOSYS) - res =3D VG_(do_syscall2)(__NR_getrlimit, resource, (UWord)rlim); - return res.isError ? -1 : res.val; -} - - -/* Support for setrlimit. */ -Int VG_(setrlimit) (Int resource, const struct vki_rlimit *rlim) -{ - SysRes res; - /* res =3D setrlimit( resource, rlim ); */ - res =3D VG_(do_syscall2)(__NR_setrlimit, resource, (UWord)rlim); - return res.isError ? -1 : res.val; -} - -/* You'd be amazed how many places need to know the current pid. */ -Int VG_(getpid) ( void ) -{ - /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ - return VG_(do_syscall0)(__NR_getpid) . val; -} - -Int VG_(getpgrp) ( void ) -{ - /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ - return VG_(do_syscall0)(__NR_getpgrp) . val; -} - -Int VG_(getppid) ( void ) -{ - /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ - return VG_(do_syscall0)(__NR_getppid) . val; -} - -Int VG_(setpgid) ( Int pid, Int pgrp ) -{ - /* ASSUMES SYSCALL ALWAYS SUCCEEDS */ - return VG_(do_syscall2)(__NR_setpgid, pid, pgrp) . val; -} - -/* Walk through a colon-separated environment variable, and remove the - entries which match remove_pattern. It slides everything down over - the removed entries, and pads the remaining space with '\0'. It - modifies the entries in place (in the client address space), but it - shouldn't matter too much, since we only do this just before an - execve(). - - This is also careful to mop up any excess ':'s, since empty strings - delimited by ':' are considered to be '.' in a path. -*/ -static void mash_colon_env(Char *varp, const Char *remove_pattern) -{ - Char *const start =3D varp; - Char *entry_start =3D varp; - Char *output =3D varp; - - if (varp =3D=3D NULL) - return; - - while(*varp) { - if (*varp =3D=3D ':') { - Char prev; - Bool match; - - /* This is a bit subtle: we want to match against the entry - we just copied, because it may have overlapped with - itself, junking the original. */ - - prev =3D *output; - *output =3D '\0'; - - match =3D VG_(string_match)(remove_pattern, entry_start); - - *output =3D prev; - =20 - if (match) { - output =3D entry_start; - varp++; /* skip ':' after removed entry */ - } else - entry_start =3D output+1; /* entry starts after ':' */ - } - - *output++ =3D *varp++; - } - - /* match against the last entry */ - if (VG_(string_match)(remove_pattern, entry_start)) { - output =3D entry_start; - if (output > start) { - /* remove trailing ':' */ - output--; - vg_assert(*output =3D=3D ':'); - } - } =20 - - /* pad out the left-overs with '\0' */ - while(output < varp) - *output++ =3D '\0'; -} - - -// Removes all the Valgrind-added stuff from the passed environment. Us= ed -// when starting child processes, so they don't see that added stuff. -void VG_(env_remove_valgrind_env_stuff)(Char** envp) -{ - Int i; - Char* ld_preload_str =3D NULL; - Char* ld_library_path_str =3D NULL; - Char* buf; - - // Find LD_* variables - for (i =3D 0; envp[i] !=3D NULL; i++) { - if (VG_(strncmp)(envp[i], "LD_PRELOAD=3D", 11) =3D=3D 0) - ld_preload_str =3D &envp[i][11]; - if (VG_(strncmp)(envp[i], "LD_LIBRARY_PATH=3D", 16) =3D=3D 0) - ld_library_path_str =3D &envp[i][16]; - } - - buf =3D VG_(arena_malloc)(VG_AR_CORE, VG_(strlen)(VG_(libdir)) + 20); - - // Remove Valgrind-specific entries from LD_*. - VG_(sprintf)(buf, "%s*/vg_inject.so", VG_(libdir)); - mash_colon_env(ld_preload_str, buf); - VG_(sprintf)(buf, "%s*/vgpreload_*.so", VG_(libdir)); - mash_colon_env(ld_preload_str, buf); - VG_(sprintf)(buf, "%s*", VG_(libdir)); - mash_colon_env(ld_library_path_str, buf); - - // Remove VALGRIND_CLO variable. - VG_(env_unsetenv)(envp, VALGRINDCLO); - - // XXX if variable becomes empty, remove it completely? - - VG_(arena_free)(VG_AR_CORE, buf); -} - -/* Return -1 if error, else 0. NOTE does not indicate return code of - child! */ -Int VG_(system) ( Char* cmd ) -{ - Int pid; - SysRes res; - if (cmd =3D=3D NULL) - return 1; - res =3D VG_(do_syscall0)(__NR_fork); - if (res.isError) - return -1; - pid =3D res.val; - if (pid =3D=3D 0) { - /* child */ - static Char** envp =3D NULL; - Char* argv[4]; - - /* restore the DATA rlimit for the child */ - VG_(setrlimit)(VKI_RLIMIT_DATA, &VG_(client_rlimit_data)); - - envp =3D env_clone(VG_(client_envp)); - VG_(env_remove_valgrind_env_stuff)( envp );=20 - - argv[0] =3D "/bin/sh"; - argv[1] =3D "-c"; - argv[2] =3D cmd; - argv[3] =3D 0; - - (void)VG_(do_syscall3)(__NR_execve,=20 - (UWord)"/bin/sh", (UWord)argv, (UWord)envp)= ; - - /* If we're still alive here, execve failed. */ - VG_(exit)(1); - } else { - /* parent */ - Int zzz =3D VG_(waitpid)(pid, NULL, 0); - return zzz =3D=3D -1 ? -1 : 0; - } -} - - -/* --------------------------------------------------------------------- - Support for a millisecond-granularity timer. - ------------------------------------------------------------------ */ - -UInt VG_(read_millisecond_timer) ( void ) -{ - static ULong base =3D 0; - struct vki_timeval tv_now; - ULong now; - SysRes res; - - res =3D VG_(do_syscall2)(__NR_gettimeofday, (UWord)&tv_now, (UWord)NU= LL); - =20 - now =3D tv_now.tv_sec * 1000000ULL + tv_now.tv_usec; - =20 - if (base =3D=3D 0) - base =3D now; - - return (now - base) / 1000; -} - - -void VG_(nanosleep)(struct vki_timespec *ts) -{ - (void)VG_(do_syscall2)(__NR_nanosleep, (UWord)ts, (UWord)NULL); -} - -/* --------------------------------------------------------------------- - Misc stuff looking for a proper home - ------------------------------------------------------------------ */ - -/* --------------------------------------------------------------------- - A simple atfork() facility for Valgrind's internal use - ------------------------------------------------------------------ */ - -struct atfork { - vg_atfork_t pre; - vg_atfork_t parent; - vg_atfork_t child; -}; - -#define VG_MAX_ATFORK 10 - -static struct atfork atforks[VG_MAX_ATFORK]; -static Int n_atfork; - -void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t child) -{ - Int i; - - for(i =3D 0; i < n_atfork; i++) { - if (atforks[i].pre =3D=3D pre && - atforks[i].parent =3D=3D parent && - atforks[i].child =3D=3D child) - return; - } - - if (n_atfork >=3D VG_MAX_ATFORK) - VG_(core_panic)("Too many VG_(atfork) handlers requested: " - "raise VG_MAX_ATFORK"); - - atforks[n_atfork].pre =3D pre; - atforks[n_atfork].parent =3D parent; - atforks[n_atfork].child =3D child; - - n_atfork++; -} - -void VG_(do_atfork_pre)(ThreadId tid) -{ - Int i; - - for(i =3D 0; i < n_atfork; i++) - if (atforks[i].pre !=3D NULL) - (*atforks[i].pre)(tid); -} - -void VG_(do_atfork_parent)(ThreadId tid) -{ - Int i; - - for(i =3D 0; i < n_atfork; i++) - if (atforks[i].parent !=3D NULL) - (*atforks[i].parent)(tid); -} - -void VG_(do_atfork_child)(ThreadId tid) -{ - Int i; - - for(i =3D 0; i < n_atfork; i++) - if (atforks[i].child !=3D NULL) - (*atforks[i].child)(tid); -} - - -/*--------------------------------------------------------------------*/ -/*--- end ---*/ -/*--------------------------------------------------------------------*/ - Modified: trunk/helgrind/hg_main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/helgrind/hg_main.c 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/helgrind/hg_main.c 2005-06-12 02:43:17 UTC (rev 3894) @@ -36,6 +36,7 @@ #include "pub_tool_libcbase.h" #include "pub_tool_libcassert.h" #include "pub_tool_libcprint.h" +#include "pub_tool_libcproc.h" #include "pub_tool_mallocfree.h" #include "pub_tool_options.h" #include "pub_tool_profile.h" Modified: trunk/include/Makefile.am =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/include/Makefile.am 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/include/Makefile.am 2005-06-12 02:43:17 UTC (rev 3894) @@ -14,6 +14,7 @@ pub_tool_libcfile.h \ pub_tool_libcmman.h \ pub_tool_libcprint.h \ + pub_tool_libcproc.h \ pub_tool_libcsignal.h \ pub_tool_mallocfree.h \ pub_tool_options.h \ Modified: trunk/include/pub_tool_libcassert.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/include/pub_tool_libcassert.h 2005-06-12 00:06:24 UTC (rev 3893= ) +++ trunk/include/pub_tool_libcassert.h 2005-06-12 02:43:17 UTC (rev 3894= ) @@ -46,6 +46,13 @@ 0))) =20 __attribute__ ((__noreturn__)) +extern void VG_(exit)( Int status ); + +/* Prints a panic message, appends newline and bug reporting info, abort= s. */ +__attribute__ ((__noreturn__)) +extern void VG_(tool_panic) ( Char* str ); + +__attribute__ ((__noreturn__)) extern void VG_(assert_fail) ( Bool isCore, const Char* expr, const Char= * file,=20 Int line, const Char* fn,=20 const HChar* format, ... ); Added: trunk/include/pub_tool_libcproc.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/include/pub_tool_libcproc.h 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/include/pub_tool_libcproc.h 2005-06-12 02:43:17 UTC (rev 3894) @@ -0,0 +1,80 @@ + +/*--------------------------------------------------------------------*/ +/*--- Process-related libc stuff pub_tool_libcproc.h ---*/ +/*--------------------------------------------------------------------*/ + +/* + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2005 Julian Seward + js...@ac... + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307, USA. + + The GNU General Public License is contained in the file COPYING. +*/ + +#ifndef __PUB_TOOL_LIBCPROC_H +#define __PUB_TOOL_LIBCPROC_H + +/* --------------------------------------------------------------------- + Command-line and environment stuff + ------------------------------------------------------------------ */ + +/* Client args and environment (which can be inspected with VG_(getenv)(= ). */ +extern Int VG_(client_argc); +extern Char** VG_(client_argv); +extern Char** VG_(client_envp); + +/* Looks up VG_(client_envp) */ +extern Char* VG_(getenv) ( Char* name ); + +/* --------------------------------------------------------------------- + Important syscalls + ------------------------------------------------------------------ */ + +extern Int VG_(waitpid)( Int pid, Int *status, Int options ); +extern Int VG_(system) ( Char* cmd ); + +/* --------------------------------------------------------------------- + Resource limits + ------------------------------------------------------------------ */ + +extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim ); +extern Int VG_(setrlimit) ( Int resource, const struct vki_rlimit *rlim = ); + +/* --------------------------------------------------------------------- + pids, etc + ------------------------------------------------------------------ */ + +extern Int VG_(gettid) ( void ); +extern Int VG_(getpid) ( void ); +extern Int VG_(getppid) ( void ); +extern Int VG_(getpgrp) ( void ); +extern Int VG_(setpgid) ( Int pid, Int pgrp ); + +/* --------------------------------------------------------------------- + Timing + ------------------------------------------------------------------ */ + +extern UInt VG_(read_millisecond_timer) ( void ); + +#endif // __PUB_TOOL_LIBCPROC_H + +/*--------------------------------------------------------------------*/ +/*--- end ---*/ +/*--------------------------------------------------------------------*/ Modified: trunk/include/tool.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/include/tool.h 2005-06-12 00:06:24 UTC (rev 3893) +++ trunk/include/tool.h 2005-06-12 02:43:17 UTC (rev 3894) @@ -66,14 +66,6 @@ /* Path to all our library/aux files */ extern const Char *VG_(libdir); =20 -/* Client args */ -extern Int VG_(client_argc); -extern Char** VG_(client_argv); - -/* Client environment. Can be inspected with VG_(getenv)() */ -extern Char** VG_(client_envp); - - /*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/ /*=3D=3D=3D Useful stuff to call from generated code = =3D=3D=3D*/ /*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/ @@ -105,38 +97,6 @@ /*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/ =20 /* ------------------------------------------------------------------ */ -/* stdlib.h */ - -/* terminate everything */ -extern void VG_(exit)( Int status ) - __attribute__ ((__noreturn__)); - -/* Prints a panic message (a constant string), appends newline and bug - reporting info, aborts. */ -__attribute__ ((__noreturn__)) -extern void VG_(tool_panic) ( Char* str ); - -/* Looks up VG_(client_envp) */ -extern Char* VG_(getenv) ( Char* name ); - -/* Get client resource limit*/ -extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim ); - -/* Set client resource limit*/ -extern Int VG_(setrlimit) ( Int resource, const struct vki_rlimit *rlim = ); - -/* Crude stand-in for ... [truncated message content] |