]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Finished the modularisation of vg_mylibc.c, which meant it could be removed.
authorNicholas Nethercote <njn@valgrind.org>
Sun, 12 Jun 2005 02:43:17 +0000 (02:43 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sun, 12 Jun 2005 02:43:17 +0000 (02:43 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3894

32 files changed:
cachegrind/cg-amd64.c
cachegrind/cg-x86.c
cachegrind/cg_main.c
coregrind/Makefile.am
coregrind/core.h
coregrind/linux/core_os.c
coregrind/m_aspacemgr/aspacemgr.c
coregrind/m_errormgr.c
coregrind/m_libcassert.c
coregrind/m_libcmman.c
coregrind/m_libcprint.c
coregrind/m_libcproc.c [moved from coregrind/vg_mylibc.c with 93% similarity]
coregrind/m_main.c
coregrind/m_scheduler/scheduler.c
coregrind/m_scheduler/sema.c
coregrind/m_signals.c
coregrind/m_syscalls/syscalls-amd64-linux.c
coregrind/m_syscalls/syscalls-generic.c
coregrind/m_syscalls/syscalls-main.c
coregrind/m_syscalls/syscalls-x86-linux.c
coregrind/m_tooliface.c
coregrind/pub_core_libcproc.h [new file with mode: 0644]
coregrind/pub_core_main.h
coregrind/pub_core_options.h
coregrind/stage1.c
helgrind/hg_main.c
include/Makefile.am
include/pub_tool_libcassert.h
include/pub_tool_libcproc.h [new file with mode: 0644]
include/tool.h
lackey/lk_main.c
massif/ms_main.c

index 6aa35a717d2a8740211cca087831241a70eb9dfe..824a4f81edceda59601d537e41bb1b250b2b1ef3 100644 (file)
@@ -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"
 
 // All CPUID info taken from sandpile.org/a32/cpuid.htm */
index 6ce7b603049da13ffd7cf878532e86f50b19b110..b7bce81e42d970a00456a3df3f5867c59f16e014 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "tool.h"
 #include "pub_tool_libcbase.h"
+#include "pub_tool_libcassert.h"
 #include "pub_tool_libcprint.h"
 #include "cg_arch.h"
 
index 5c7fd8bfae838ceac4876247e900dbc5a3ed33d1..d7c817d760d6f7820c8189cb45bf509e8705bab2 100644 (file)
@@ -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"
index 26a769f4ee058ebda2a1625a7cfd349202615815..2711a13fbb57a4e90d7400d1d7fe75d3ecc3b37b 100644 (file)
@@ -51,6 +51,7 @@ noinst_HEADERS = \
        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 @@ stage2_SOURCES = \
        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 @@ stage2_SOURCES = \
        m_translate.c \
        m_transtab.c \
        \
-       ume.c \
-       vg_mylibc.c
+       ume.c
 
 ## Nb: libscheduler.a must precede libdispatch.a in this list.
 stage2_extra= \
index 4111d08f5b401ddead60ac1ef94ce4de3852e4b8..bae70e1bc931167c62da83ffee0597e67da17a3e 100644 (file)
 
 #include "pub_core_scheduler.h"   // for types 'ThreadArchState'
 
-/* ---------------------------------------------------------------------
-   Environment variables
-   ------------------------------------------------------------------ */
-
-/* The directory we look for all our auxillary files in */
-#define VALGRINDLIB    "VALGRINDLIB"
-
 /* ---------------------------------------------------------------------
    Exports of vg_intercept.c
    ------------------------------------------------------------------ */
    ------------------------------------------------------------------ */
 
 extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
-extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout);
-
-/* 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 ); 
-
-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, 
-                                         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
index d32455e1da4a159fa9b0f55f39b4e24adbf55fc6..5d5c2d61969f5cc5cc0645cf48e6bd6dccc22a37 100644 (file)
@@ -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"
index de54b62449bfdf60ce6a53a64a68a8ed6d6e35d6..bfe926cd5e6324583b7d4c054ec1f0ca722e97a2 100644 (file)
@@ -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"
index de40eebfec42fae2e3eee0f241b9af70a1a12bb7..7ac1394fc6e88b8330526a3acdbe562d6f25b055 100644 (file)
@@ -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"
index b5c5373575b569acfc96e32b56eeb84c3b1c4241..dea4f053f92ad59fafac58902b031096672b577b 100644 (file)
 #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"
 
 /* ---------------------------------------------------------------------
    Assertery.
 #  error Unknown platform
 #endif
 
+/* 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 = 'x';
+   vg_assert(2+2 == 5);
+}
+
 __attribute__ ((noreturn))
 static void report_and_quit ( const Char* report, Addr ip, Addr sp, Addr fp )
 {
index c8536a8f70b81601cb07efaa59a439c2b6e18966..fc5e44f24d4f8cff9d50e23b158fc6306029aecf 100644 (file)
@@ -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"
 
 SysRes VG_(mmap_native)(void *start, SizeT length, UInt prot, UInt flags,
index f4ca698d2350b4bc6ed7ba73d9a228bbbb490146..b4bdda391eecafffa98eb5b8d950361467e8f4df 100644 (file)
@@ -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
 
similarity index 93%
rename from coregrind/vg_mylibc.c
rename to coregrind/m_libcproc.c
index 967b8659642b12a362925f22fc6c31ad721a4657..69d9b057e3761a7e1793484f257b9acf4218b38a 100644 (file)
@@ -1,8 +1,6 @@
 
 /*--------------------------------------------------------------------*/
-/*--- Reimplementation of some C library stuff, to avoid depending ---*/
-/*--- on libc.so.                                                  ---*/
-/*---                                                  vg_mylibc.c ---*/
+/*--- Process-related libc stuff.                     m_libcproc.c ---*/
 /*--------------------------------------------------------------------*/
  
 /*
 */
 
 #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_libcproc.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 = VG_(do_syscall4)(__NR_wait4, pid, (UWord)status, options, 0);
-   return res.isError ? -1 : res.val;
-}
-
-Int VG_(gettid)(void)
-{
-   SysRes res = VG_(do_syscall0)(__NR_gettid);
-
-   if (res.isError && res.val == VKI_ENOSYS) {
-      Char pid[16];      
-      /*
-       * 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 kernel
-       * where getpid has been changed to return the ID of the thread group
-       * 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 = VG_(do_syscall3)(__NR_readlink, (UWord)"/proc/self",
-                             (UWord)pid, sizeof(pid));
-      if (!res.isError && res.val > 0) {
-         pid[res.val] = '\0';
-         res.val = VG_(atoll)(pid);
-      }
-   }
-
-   return res.val;
-}
-
-
-
 /* ---------------------------------------------------------------------
-   exit, fcntl
+   Command line and environment stuff
    ------------------------------------------------------------------ */
 
-/* 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 = 'x';
-   vg_assert(2+2 == 5);
-}
-
-/* Returns -1 on error. */
-Int VG_(fcntl) ( Int fd, Int cmd, Int arg )
-{
-   SysRes res = 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 = VG_(do_syscall3)(__NR_poll, (UWord)ufds, nfds, timeout);
-   /* ASSUMES SYSCALL ALWAYS SUCCEEDS */
-   return res.val;
-}
+/* 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);
 
-
-/* ---------------------------------------------------------------------
-   Misc functions looking for a proper home.
-   ------------------------------------------------------------------ */
-
-/* clone the environment */
-static Char **env_clone ( Char **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)
 {
-   Char **oldenvp;
-   Char **newenvp;
-   Char **newenv;
-   Int  envlen;
-
-   for (oldenvp = oldenv; oldenvp && *oldenvp; oldenvp++);
-
-   envlen = oldenvp - oldenv + 1;
-   
-   newenv = VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Char **));
-
-   oldenvp = oldenv;
-   newenvp = newenv;
-   
-   while (oldenvp && *oldenvp) {
-      *newenvp++ = *oldenvp++;
+   Int i, n;
+   n = VG_(strlen)(varname);
+   for (i = 0; VG_(client_envp)[i] != NULL; i++) {
+      Char* s = VG_(client_envp)[i];
+      if (VG_(strncmp)(varname, s, n) == 0 && s[n] == '=') {
+         return & s[n+1];
+      }
    }
-   
-   *newenvp = *oldenvp;
-
-   return newenv;
+   return NULL;
 }
 
 void  VG_(env_unsetenv) ( Char **env, const Char *varname )
@@ -202,69 +118,6 @@ Char **VG_(env_setenv) ( Char ***envp, const Char* varname, const Char *val )
    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 = VG_(strlen)(varname);
-   for (i = 0; VG_(client_envp)[i] != NULL; i++) {
-      Char* s = VG_(client_envp)[i];
-      if (VG_(strncmp)(varname, s, n) == 0 && s[n] == '=') {
-         return & s[n+1];
-      }
-   }
-   return NULL;
-}
-
-/* Support for getrlimit. */
-Int VG_(getrlimit) (Int resource, struct vki_rlimit *rlim)
-{
-   SysRes res = VG_(mk_SysRes_Error)(VKI_ENOSYS);
-   /* res = getrlimit( resource, rlim ); */
-#  ifdef __NR_ugetrlimit
-   res = VG_(do_syscall2)(__NR_ugetrlimit, resource, (UWord)rlim);
-#  endif
-   if (res.isError && res.val == VKI_ENOSYS)
-      res = 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 = setrlimit( resource, rlim ); */
-   res = 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
@@ -361,6 +214,56 @@ void VG_(env_remove_valgrind_env_stuff)(Char** envp)
    VG_(arena_free)(VG_AR_CORE, buf);
 }
 
+/* ---------------------------------------------------------------------
+   Various important syscall wrappers
+   ------------------------------------------------------------------ */
+
+Int VG_(waitpid)(Int pid, Int *status, Int options)
+{
+   SysRes res = VG_(do_syscall4)(__NR_wait4, pid, (UWord)status, options, 0);
+   return res.isError ? -1 : res.val;
+}
+
+/* Returns -1 on error. */
+Int VG_(fcntl) ( Int fd, Int cmd, Int arg )
+{
+   SysRes res = 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 = 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 = oldenv; oldenvp && *oldenvp; oldenvp++);
+
+   envlen = oldenvp - oldenv + 1;
+   
+   newenv = VG_(arena_malloc)(VG_AR_CORE, envlen * sizeof(Char **));
+
+   oldenvp = oldenv;
+   newenvp = newenv;
+   
+   while (oldenvp && *oldenvp) {
+      *newenvp++ = *oldenvp++;
+   }
+   
+   *newenvp = *oldenvp;
+
+   return newenv;
+}
+
 /* Return -1 if error, else 0.  NOTE does not indicate return code of
    child! */
 Int VG_(system) ( Char* cmd )
@@ -401,9 +304,98 @@ Int VG_(system) ( Char* cmd )
    }
 }
 
+/* ---------------------------------------------------------------------
+   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 = VG_(mk_SysRes_Error)(VKI_ENOSYS);
+   /* res = getrlimit( resource, rlim ); */
+#  ifdef __NR_ugetrlimit
+   res = VG_(do_syscall2)(__NR_ugetrlimit, resource, (UWord)rlim);
+#  endif
+   if (res.isError && res.val == VKI_ENOSYS)
+      res = 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 = setrlimit( resource, rlim ); */
+   res = VG_(do_syscall2)(__NR_setrlimit, resource, (UWord)rlim);
+   return res.isError ? -1 : res.val;
+}
 
 /* ---------------------------------------------------------------------
-   Support for a millisecond-granularity timer.
+   pids, etc
+   ------------------------------------------------------------------ */
+
+Int VG_(gettid)(void)
+{
+   SysRes res = VG_(do_syscall0)(__NR_gettid);
+
+   if (res.isError && res.val == VKI_ENOSYS) {
+      Char pid[16];      
+      /*
+       * 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 kernel
+       * where getpid has been changed to return the ID of the thread group
+       * 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 = VG_(do_syscall3)(__NR_readlink, (UWord)"/proc/self",
+                             (UWord)pid, sizeof(pid));
+      if (!res.isError && res.val > 0) {
+         pid[res.val] = '\0';
+         res.val = 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 )
@@ -429,10 +421,6 @@ 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
    ------------------------------------------------------------------ */
@@ -497,8 +485,6 @@ void VG_(do_atfork_child)(ThreadId tid)
         (*atforks[i].child)(tid);
 }
 
-
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
 /*--------------------------------------------------------------------*/
-
index e7d10ed7ebdd2483be507b6e86cc51fdb8d37d65..000e388adcbd9e089ffe35b15666219d0c9e9635 100644 (file)
@@ -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"
    Startup stuff                            
    ------------------------------------------------------------------ */
 
-struct vki_rlimit VG_(client_rlimit_data);
-struct vki_rlimit VG_(client_rlimit_stack);
-
 /* stage1 (main) executable */
 static Int vgexecfd = -1;
 
@@ -127,12 +125,6 @@ const Char *VG_(libdir) = VG_LIBDIR;
 static Int  vg_argc;
 static Char **vg_argv;
 
-/* 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);
-
 
 /* ---------------------------------------------------------------------
    Running stuff                            
index ff54a0b9c0f89bceb72457e08d76a62cc20ae400..3b63cd2078dacbd682e5cd9cffcc3af3a1adebda 100644 (file)
@@ -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"
index dd1ba1b1915b1948b34e2bbefcd6c096f17107c7..a01aed787a660d0f7a41c4eed2625de9cd7ec480 100644 (file)
@@ -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"
 
 /* 
index eba5ddd5aa6e3f1c4d39477f754611d44e653c52..29edb5334d5fe5f0a8dbca41a69bfbcdd886af06 100644 (file)
@@ -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"
index 3ddfb8d7abed32074d6cfe886fbded54946a4660..c8392bb8b0994aa64877cdc6f03e55de02e7b5d4 100644 (file)
@@ -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"
index caa6ddc2637cbe45042e2d97463bb61435f48b05..250d7bcca974698d1d8c669d95b908b594de7768 100644 (file)
@@ -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"
index bae018d80149e014a31cbc0c22749f8e655b2472..619a8d678d9be42f57538db33754d86d932c439d 100644 (file)
@@ -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"
index 9806c8999d761a854401c59af8e18dd361238269..624ac73d8b4f60b422cb5e490a7abdf42fc956c1 100644 (file)
@@ -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"
index e65126a35c0986aa131c612b58cfe983da0b8e32..fa0fedac6ee55ff82fd359a0dd9287c7dffa44e4 100644 (file)
@@ -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"
diff --git a/coregrind/pub_core_libcproc.h b/coregrind/pub_core_libcproc.h
new file mode 100644 (file)
index 0000000..2079ed5
--- /dev/null
@@ -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
+      jseward@acm.org
+
+   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=yes.  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 ); 
+
+// 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                                                          ---*/
+/*--------------------------------------------------------------------*/
index e0bcfc59ec0db58e8f7dd51f03407b6ba6a53bc0..a06450090e3bbf0077e10b4e2e1b8c5224fabc57 100644 (file)
@@ -41,9 +41,6 @@
 /* Sanity checks which may be done at any time.  The scheduler decides when. */
 extern void VG_(sanity_check_general) ( Bool force_expensive );
 
-extern struct vki_rlimit VG_(client_rlimit_data); /* client's original rlimit data */
-extern struct vki_rlimit VG_(client_rlimit_stack); /* client's original rlimit stack */
-
 /* client executable file descriptor */
 extern Int  VG_(clexecfd);
 
index 4fb00d87372167c478049aaa4e409c0c04af9ddd..bcdb0e42a8600247d42c81926d0b5d75dc809676 100644 (file)
 
 #include "pub_tool_options.h"
 
-/* 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=yes.  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
index 56673d47de44fab0f618a6f836240e7db3e8c571..7a3fb7713836b1f4dbd4d066abfe0a7fc6a0e9a1 100644 (file)
@@ -45,6 +45,7 @@
 #include "ume.h"
 #include "memcheck/memcheck.h"
 #include "pub_core_debuglog.h"
+#include "pub_core_libcproc.h"
 
 
 static int stack[SIGSTKSZ*4];
index 3b852441571b8833adf827ce4a2826b16011d94a..66da1f44a57c66f184303cd4a8bee6b488fd6dbd 100644 (file)
@@ -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"
index 1a2c7340820d1dcaaae9af5850c9d4bf45290587..9ece13dfaaaf574526bbcc7d439a188fd0bc8275 100644 (file)
@@ -14,6 +14,7 @@ incinc_HEADERS = \
        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              \
index 22a46e08a2889cc0d54c66534c75121cbfee2098..079485f2aea2953b5d820955bedaae76da75542a 100644 (file)
                               format, ##args),                          \
                               0)))
 
+__attribute__ ((__noreturn__))
+extern void VG_(exit)( Int status );
+
+/* Prints a panic message, appends newline and bug reporting info, aborts. */
+__attribute__ ((__noreturn__))
+extern void  VG_(tool_panic) ( Char* str );
+
 __attribute__ ((__noreturn__))
 extern void VG_(assert_fail) ( Bool isCore, const Char* expr, const Char* file, 
                                Int line, const Char* fn, 
diff --git a/include/pub_tool_libcproc.h b/include/pub_tool_libcproc.h
new file mode 100644 (file)
index 0000000..6776b2b
--- /dev/null
@@ -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
+      jseward@acm.org
+
+   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                                                          ---*/
+/*--------------------------------------------------------------------*/
index 60fa4133104bafffaf411de822783bfad1635279..d837f3c9e544b179780b5313a8d9aa255caf501f 100644 (file)
 /* Path to all our library/aux files */
 extern const Char *VG_(libdir);
 
-/* 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);
-
-
 /*====================================================================*/
 /*=== Useful stuff to call from generated code                     ===*/
 /*====================================================================*/
@@ -104,38 +96,6 @@ extern Addr VG_(get_IP) ( ThreadId tid );
 /*=== Valgrind's version of libc                                   ===*/
 /*====================================================================*/
 
-/* ------------------------------------------------------------------ */
-/* 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 the glibc system() call. */
-extern Int   VG_(system) ( Char* cmd );
-
-/* ------------------------------------------------------------------ */
-/* unistd.h, fcntl.h, sys/stat.h */
-extern Int  VG_(getpid)  ( void );
-extern Int  VG_(getppid) ( void );
-extern Int  VG_(getpgrp) ( void );
-extern Int  VG_(gettid)         ( void );
-extern Int  VG_(setpgid) ( Int pid, Int pgrp );
-
 /* ------------------------------------------------------------------ */
 /* Register an interest in apparently internal faults; used code which
    wanders around dangerous memory (ie, leakcheck).  The catcher is
@@ -145,12 +105,8 @@ extern void VG_(set_fault_catcher)(void (*catcher)(Int sig, Addr addr));
 /* Calls "mark_addr" with register values (which may or may not be pointers) */
 extern void VG_(mark_from_registers)(void (*mark_addr)(Addr addr));
 
-extern Int VG_(waitpid)            ( Int pid, Int *status, Int options );
-
 /* ------------------------------------------------------------------ */
 /* other, randomly useful functions */
-extern UInt VG_(read_millisecond_timer) ( void );
-
 extern Bool VG_(has_cpuid) ( void );
 
 extern void VG_(cpuid) ( UInt eax,
index af5f5aaa0178df48811d063c6c314c3867982660..db39de39ef2107bd83adaa5fd5a2803b826f7e14 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "tool.h"
 #include "pub_tool_tooliface.h"
+#include "pub_tool_libcassert.h"
 #include "pub_tool_libcprint.h"
 
 /* Nb: use ULongs because the numbers can get very big */
index 57201a0083e65c67feca74486bcfc41ae6ae7582..2a65bbda33807d6080b8981ab6eb3db0bd92f122 100644 (file)
@@ -42,6 +42,7 @@
 #include "pub_tool_libcfile.h"
 #include "pub_tool_libcmman.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"