2 /*--------------------------------------------------------------------*/
3 /*--- Misc client state info pub_core_clientstate.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2017 Julian Seward
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.
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.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __PUB_CORE_CLIENTSTATE_H
30 #define __PUB_CORE_CLIENTSTATE_H
32 //--------------------------------------------------------------------
33 // PURPOSE: This module holds various bits of client state which don't
34 // live comfortably anywhere else. Note that the ThreadStates for the
35 // client don't live here; they instead live in m_threadstate.h. Most
36 // of these values are set once at startup and not changed later.
37 //--------------------------------------------------------------------
39 #include "pub_tool_clientstate.h"
41 // Address space globals
44 extern Addr
VG_(clstk_start_base
); // *Initial* lowest byte address
45 extern Addr
VG_(clstk_end
); // Highest byte address
46 extern UWord
VG_(clstk_id
); // client stack id
47 extern SizeT
VG_(clstk_max_size
); // max size of the main threads's client stack
49 /* Linux and Solaris only: where is the client auxv? */
50 /* This is setup as part of setup_client_stack in initimg-linux.c
51 or initimg-solaris.c, respectively. */
52 extern UWord
* VG_(client_auxv
);
54 extern Addr
VG_(brk_base
); // start of brk
55 extern Addr
VG_(brk_limit
); // current brk
57 /* A fd which refers to the client executable. */
58 extern Int
VG_(cl_exec_fd
);
60 /* A fd which refers to the fake /proc/<pid>/cmdline in /tmp. The
61 idea is: make up the /proc/<pid>/cmdline file the client would
62 expect to see if it was running natively. Copy into a file in
63 /tmp. When the client then does an open of /proc/<pid>/cmdline or
64 /proc/self/cmdline, instead give it a file handle to the file in
65 /tmp. The problem of deleting said file when Valgrind exits is
66 neatly sidestepped by unlinking it as soon as it has been created,
67 but holding on to the file handle. That causes the kernel to keep
68 the file contents alive exactly until the process exits. */
69 extern Int
VG_(cl_cmdline_fd
);
71 /* Same as above, but for /proc/<pid>/auxv. */
72 extern Int
VG_(cl_auxv_fd
);
74 #if defined(VGO_solaris)
75 /* Same as above, but for /proc/<pid>/psinfo. */
76 extern Int
VG_(cl_psinfo_fd
);
77 #endif /* VGO_solaris */
79 // Client's original rlimit data and rlimit stack
80 extern struct vki_rlimit
VG_(client_rlimit_data
);
81 extern struct vki_rlimit
VG_(client_rlimit_stack
);
83 // Name of the launcher, as extracted from VALGRIND_LAUNCHER at
85 extern HChar
* VG_(name_of_launcher
);
87 /* Application-visible file descriptor limits */
88 extern Int
VG_(fd_soft_limit
);
89 extern Int
VG_(fd_hard_limit
);
91 /* Useful addresses extracted from the client. */
92 /* Where is the freeres_wrapper routine we made? */
93 extern Addr
VG_(client_freeres_wrapper
);
95 /* x86-linux only: where is ld.so's _dl_sysinfo_int80 function?
96 Finding it isn't essential, but knowing where it is does sometimes
97 help produce better back traces. See big comment in
98 VG_(get_StackTrace) in m_stacktrace.c for further info. */
99 extern Addr
VG_(client__dl_sysinfo_int80
);
101 /* Obtains the initial client stack pointer from the finalised image info. */
102 extern Addr
VG_(get_initial_client_SP
)(void);
104 /* glibc nptl pthread systems only, when no-nptl-pthread-stackcache
105 was given in --sim-hints.
106 Used for a (kludgy) way to disable the cache of stacks as implemented in
108 Based on internal knowledge of the pthread glibc nptl/allocatestack.c code:
109 a huge value in stack_cache_actsize (bigger than the constant
110 stack_cache_maxsize) makes glibc believes the cache is full
111 and so stacks are always released when a pthread terminates.
112 Several ugliness in this kludge:
113 * hardcodes private glibc var name "stack_cache_maxsize"
114 * based on knowledge of the code of the functions
115 queue_stack and __free_stacks
116 * static symbol for "stack_cache_maxsize" must be in
118 It would be much cleaner to have a documented and supported
119 way to disable the pthread stack cache. */
120 extern SizeT
* VG_(client__stack_cache_actsize__addr
);
122 #if defined(VGO_solaris)
123 /* Address of variable vg_vfork_fildes in vgpreload_core.so.0
125 extern Int
* VG_(vfork_fildes_addr
);
128 #endif // __PUB_CORE_CLIENTSTATE_H
130 /*--------------------------------------------------------------------*/
132 /*--------------------------------------------------------------------*/