2 /*--------------------------------------------------------------------*/
3 /*--- A home for miscellaneous bits of information which pertain ---*/
4 /*--- to the client's state. ---*/
5 /*--- m_clientstate.c ---*/
6 /*--------------------------------------------------------------------*/
9 This file is part of Valgrind, a dynamic binary instrumentation
12 Copyright (C) 2000-2017 Julian Seward
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation; either version 2 of the
18 License, or (at your option) any later version.
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, see <http://www.gnu.org/licenses/>.
28 The GNU General Public License is contained in the file COPYING.
31 #include "pub_core_basics.h"
32 #include "pub_core_threadstate.h"
33 #include "pub_core_vki.h"
34 #include "pub_core_xarray.h"
35 #include "pub_core_clientstate.h"
37 /*-----------------------------------------------------------------*/
39 /*--- Basic globals about the address space. ---*/
41 /*-----------------------------------------------------------------*/
43 /* Client address space, lowest to highest (see top of ume.c) */
44 // TODO: get rid of as many of these as possible.
46 /* ***Initial*** lowest address of the stack segment of the main thread.
47 The main stack will grow if needed but VG_(clstk_start_base) will
48 not be changed according to the growth. */
49 Addr
VG_(clstk_start_base
) = 0;
50 /* Initial highest address of the stack segment of the main thread. */
51 Addr
VG_(clstk_end
) = 0;
52 UWord
VG_(clstk_id
) = NULL_STK_ID
;
53 /* Maximum size of the main thread's client stack. */
54 SizeT
VG_(clstk_max_size
) = 0;
56 /* Solaris and Linux only, specifies where the client auxv is.
58 This is set up as part of setup_client_stack() in
59 initimg-{linux,solaris}.c. */
60 UWord
* VG_(client_auxv
) = NULL
;
62 Addr
VG_(brk_base
) = 0; /* start of brk */
63 Addr
VG_(brk_limit
) = 0; /* current brk */
65 /* A fd which refers to the client executable. */
66 Int
VG_(cl_exec_fd
) = -1;
68 /* A fd which refers to the fake /proc/<pid>/cmdline in /tmp. */
69 Int
VG_(cl_cmdline_fd
) = -1;
71 /* A fd which refers to the fake /proc/<pid>/auxv in /tmp. */
72 Int
VG_(cl_auxv_fd
) = -1;
74 #if defined(VGO_solaris)
75 /* A fd which refers to the fake /proc/<pid>/psinfo in /tmp. */
76 Int
VG_(cl_psinfo_fd
) = -1;
77 #endif /* VGO_solaris */
79 // Command line pieces, after they have been extracted from argv in
80 // m_main.main(). The payload vectors are allocated in VG_AR_CORE
81 // (the default arena). They are never freed.
83 /* Args for the client. */
84 XArray
* /* of HChar* */ VG_(args_for_client
) = NULL
;
86 /* Args for V (augments, then those from the launcher). */
87 XArray
* /* of HChar* */ VG_(args_for_valgrind
) = NULL
;
89 /* How many of the above not to pass on at execve time? */
90 Int
VG_(args_for_valgrind_noexecpass
) = 0;
92 /* The name of the client executable, as specified on the command
94 const HChar
* VG_(args_the_exename
) = NULL
;
96 /* The real name of the executable, with resolved
97 * relative paths and symlinks */
98 const HChar
* VG_(resolved_exename
) = NULL
;
100 // Client's original rlimit data and rlimit stack
101 struct vki_rlimit
VG_(client_rlimit_data
);
102 struct vki_rlimit
VG_(client_rlimit_stack
);
104 // Name of the launcher, as extracted from VALGRIND_LAUNCHER at
106 HChar
* VG_(name_of_launcher
) = NULL
;
108 /* Application-visible file descriptor limits */
109 Int
VG_(fd_soft_limit
) = -1;
110 Int
VG_(fd_hard_limit
) = -1;
112 /* Useful addresses extracted from the client. */
113 /* Where is the freeres_wrapper routine we made? */
114 Addr
VG_(client_freeres_wrapper
) = 0;
116 /* x86-linux only: where is glibc's _dl_sysinfo_int80 function?
117 Finding it isn't essential, but knowing where it is does sometimes
118 help produce better back traces. See big comment in
119 VG_(get_StackTrace) in m_stacktrace.c for further info. */
120 Addr
VG_(client__dl_sysinfo_int80
) = 0;
122 /* Address of the (internal) glibc nptl pthread stack cache size,
124 static size_t stack_cache_actsize;
125 in nptl/allocatestack.c */
126 SizeT
* VG_(client__stack_cache_actsize__addr
) = 0;
128 client__gnu_get_libc_version_type
VG_(client__gnu_get_libc_version_addr
) = 0;
130 #if defined(VGO_solaris)
131 /* Address of variable vg_vfork_fildes in vgpreload_core.so.0
133 Int
* VG_(vfork_fildes_addr
) = 0;
136 #if defined(VGO_freebsd)
137 Bool
VG_(have_slash_proc
) = False
;
140 /*--------------------------------------------------------------------*/
142 /*--------------------------------------------------------------------*/