njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Process-related libc stuff pub_tool_libcproc.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
Elliott Hughes | ed39800 | 2017-06-21 14:41:24 -0700 | [diff] [blame^] | 10 | Copyright (C) 2000-2017 Julian Seward |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __PUB_TOOL_LIBCPROC_H |
| 32 | #define __PUB_TOOL_LIBCPROC_H |
| 33 | |
florian | 535fb1b | 2013-09-15 13:54:34 +0000 | [diff] [blame] | 34 | #include "pub_tool_basics.h" // VG_ macro |
| 35 | #include "pub_tool_vki.h" // vki_rlimit |
| 36 | |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 37 | /* --------------------------------------------------------------------- |
| 38 | Command-line and environment stuff |
| 39 | ------------------------------------------------------------------ */ |
| 40 | |
njn | 08ce7b3 | 2009-02-27 03:38:28 +0000 | [diff] [blame] | 41 | /* Client environment. */ |
florian | 19f91bb | 2012-11-10 22:29:54 +0000 | [diff] [blame] | 42 | extern HChar** VG_(client_envp); |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 43 | |
| 44 | /* Looks up VG_(client_envp) */ |
florian | 19f91bb | 2012-11-10 22:29:54 +0000 | [diff] [blame] | 45 | extern HChar* VG_(getenv) ( const HChar* name ); |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 46 | |
njn | 8d9965c | 2005-06-12 17:47:24 +0000 | [diff] [blame] | 47 | /* Path to all our library/aux files */ |
florian | 19f91bb | 2012-11-10 22:29:54 +0000 | [diff] [blame] | 48 | extern const HChar *VG_(libdir); |
njn | 8d9965c | 2005-06-12 17:47:24 +0000 | [diff] [blame] | 49 | |
njn | e323a6b | 2010-07-01 02:35:03 +0000 | [diff] [blame] | 50 | // The name of the LD_PRELOAD-equivalent variable. It varies across |
| 51 | // platforms. |
florian | 19f91bb | 2012-11-10 22:29:54 +0000 | [diff] [blame] | 52 | extern const HChar* VG_(LD_PRELOAD_var_name); |
njn | e323a6b | 2010-07-01 02:35:03 +0000 | [diff] [blame] | 53 | |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 54 | /* Resolves filename of VG_(cl_exec_fd) and copies it to the buffer. |
| 55 | Buffer must not be NULL and buf_size must be at least 1. |
| 56 | If buffer is not large enough it is terminated with '\0' only |
| 57 | when 'terminate_with_NUL == True'. */ |
| 58 | extern void VG_(client_fname)(HChar *buffer, SizeT buf_size, |
| 59 | Bool terminate_with_NUL); |
| 60 | |
| 61 | /* Concatenates client exename and command line arguments into |
| 62 | the buffer. Buffer must not be NULL and buf_size must be |
| 63 | at least 1. Buffer is always terminated with '\0'. */ |
| 64 | extern void VG_(client_cmd_and_args)(HChar *buffer, SizeT buf_size); |
| 65 | |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 66 | /* --------------------------------------------------------------------- |
| 67 | Important syscalls |
| 68 | ------------------------------------------------------------------ */ |
| 69 | |
njn | e9ba34a | 2008-10-13 04:19:15 +0000 | [diff] [blame] | 70 | extern Int VG_(waitpid)( Int pid, Int *status, Int options ); |
florian | 19f91bb | 2012-11-10 22:29:54 +0000 | [diff] [blame] | 71 | extern Int VG_(system) ( const HChar* cmd ); |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 72 | extern Int VG_(spawn) ( const HChar *filename, const HChar **argv ); |
njn | e9ba34a | 2008-10-13 04:19:15 +0000 | [diff] [blame] | 73 | extern Int VG_(fork) ( void); |
sewardj | 8eb8bab | 2015-07-21 14:44:28 +0000 | [diff] [blame] | 74 | extern void VG_(execv) ( const HChar* filename, const HChar** argv ); |
rhyskidd | 05be8f5 | 2015-04-01 12:15:49 +0000 | [diff] [blame] | 75 | extern Int VG_(sysctl) ( Int *name, UInt namelen, void *oldp, SizeT *oldlenp, void *newp, SizeT newlen ); |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 76 | |
| 77 | /* --------------------------------------------------------------------- |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 78 | Resource limits and capabilities |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 79 | ------------------------------------------------------------------ */ |
| 80 | |
| 81 | extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim ); |
| 82 | extern Int VG_(setrlimit) ( Int resource, const struct vki_rlimit *rlim ); |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 83 | extern Int VG_(prctl) (Int option, |
| 84 | ULong arg2, ULong arg3, ULong arg4, ULong arg5); |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 85 | |
| 86 | /* --------------------------------------------------------------------- |
| 87 | pids, etc |
| 88 | ------------------------------------------------------------------ */ |
| 89 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 90 | extern Int VG_(gettid) ( void ); |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 91 | extern Int VG_(getpid) ( void ); |
| 92 | extern Int VG_(getppid) ( void ); |
| 93 | extern Int VG_(getpgrp) ( void ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 94 | extern Int VG_(geteuid) ( void ); |
| 95 | extern Int VG_(getegid) ( void ); |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 96 | |
| 97 | /* --------------------------------------------------------------------- |
| 98 | Timing |
| 99 | ------------------------------------------------------------------ */ |
| 100 | |
njn | b63ca16 | 2007-03-28 12:16:55 +0000 | [diff] [blame] | 101 | // Returns the number of milliseconds passed since the progam started |
| 102 | // (roughly; it gets initialised partway through Valgrind's initialisation |
| 103 | // steps). |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 104 | extern UInt VG_(read_millisecond_timer) ( void ); |
florian | 82b9285 | 2015-01-08 14:43:29 +0000 | [diff] [blame] | 105 | extern Int VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz); |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 106 | |
njn | e9ba34a | 2008-10-13 04:19:15 +0000 | [diff] [blame] | 107 | /* --------------------------------------------------------------------- |
| 108 | atfork |
| 109 | ------------------------------------------------------------------ */ |
| 110 | |
| 111 | typedef void (*vg_atfork_t)(ThreadId); |
| 112 | extern void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t child); |
| 113 | |
| 114 | |
njn | f39e9a3 | 2005-06-12 02:43:17 +0000 | [diff] [blame] | 115 | #endif // __PUB_TOOL_LIBCPROC_H |
| 116 | |
| 117 | /*--------------------------------------------------------------------*/ |
| 118 | /*--- end ---*/ |
| 119 | /*--------------------------------------------------------------------*/ |