blob: 73bd4e8936f092d92f405a1ec71c455af1dc5bb9 [file] [log] [blame]
sewardj45f4e7c2005-09-27 19:20:21 +00001
2/*--------------------------------------------------------------------*/
3/*--- Misc client state info pub_core_clientstate.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
Elliott Hughesed398002017-06-21 14:41:24 -070010 Copyright (C) 2000-2017 Julian Seward
sewardj45f4e7c2005-09-27 19:20:21 +000011 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_CORE_CLIENTSTATE_H
32#define __PUB_CORE_CLIENTSTATE_H
33
34//--------------------------------------------------------------------
35// PURPOSE: This module holds various bits of client state which don't
36// live comfortably anywhere else. Note that the ThreadStates for the
sewardjfdf91b42005-09-28 00:53:09 +000037// client don't live here; they instead live in m_threadstate.h. Most
38// of these values are set once at startup and not changed later.
sewardj45f4e7c2005-09-27 19:20:21 +000039//--------------------------------------------------------------------
40
41#include "pub_tool_clientstate.h"
42
43// Address space globals
44
philippe38a74d22014-08-29 22:53:19 +000045// client stack range
46extern Addr VG_(clstk_start_base); // *Initial* lowest byte address
47extern Addr VG_(clstk_end); // Highest byte address
sewardj45f4e7c2005-09-27 19:20:21 +000048extern UWord VG_(clstk_id); // client stack id
sewardj8eb8bab2015-07-21 14:44:28 +000049extern SizeT VG_(clstk_max_size); // max size of the main threads's client stack
sewardj45f4e7c2005-09-27 19:20:21 +000050
sewardj8eb8bab2015-07-21 14:44:28 +000051/* Linux and Solaris only: where is the client auxv? */
52/* This is setup as part of setup_client_stack in initimg-linux.c
53 or initimg-solaris.c, respectively. */
sewardj2a312392011-06-26 09:26:48 +000054extern UWord* VG_(client_auxv);
55
sewardj45f4e7c2005-09-27 19:20:21 +000056extern Addr VG_(brk_base); // start of brk
57extern Addr VG_(brk_limit); // current brk
58
59/* A fd which refers to the client executable. */
60extern Int VG_(cl_exec_fd);
61
62/* A fd which refers to the fake /proc/<pid>/cmdline in /tmp. The
63 idea is: make up the /proc/<pid>/cmdline file the client would
64 expect to see if it was running natively. Copy into a file in
65 /tmp. When the client then does an open of /proc/<pid>/cmdline or
66 /proc/self/cmdline, instead give it a file handle to the file in
67 /tmp. The problem of deleting said file when Valgrind exits is
68 neatly sidestepped by unlinking it as soon as it has been created,
69 but holding on to the file handle. That causes the kernel to keep
70 the file contents alive exactly until the process exits. */
71extern Int VG_(cl_cmdline_fd);
72
tom41ad7e72012-10-04 20:27:38 +000073/* Same as above, but for /proc/<pid>/auxv. */
74extern Int VG_(cl_auxv_fd);
75
sewardj8eb8bab2015-07-21 14:44:28 +000076#if defined(VGO_solaris)
77/* Same as above, but for /proc/<pid>/psinfo. */
78extern Int VG_(cl_psinfo_fd);
79#endif /* VGO_solaris */
80
sewardj45f4e7c2005-09-27 19:20:21 +000081// Client's original rlimit data and rlimit stack
82extern struct vki_rlimit VG_(client_rlimit_data);
83extern struct vki_rlimit VG_(client_rlimit_stack);
84
85// Name of the launcher, as extracted from VALGRIND_LAUNCHER at
86// startup.
87extern HChar* VG_(name_of_launcher);
88
sewardjfdf91b42005-09-28 00:53:09 +000089/* Application-visible file descriptor limits */
90extern Int VG_(fd_soft_limit);
91extern Int VG_(fd_hard_limit);
92
Elliott Hughesa0664b92017-04-18 17:46:52 -070093/* Useful addresses extracted from the client. */
94/* Where is the freeres_wrapper routine we made? */
95extern Addr VG_(client_freeres_wrapper);
sewardj45f4e7c2005-09-27 19:20:21 +000096
sewardja672ea32006-04-29 18:03:14 +000097/* x86-linux only: where is ld.so's _dl_sysinfo_int80 function?
98 Finding it isn't essential, but knowing where it is does sometimes
99 help produce better back traces. See big comment in
100 VG_(get_StackTrace) in m_stacktrace.c for further info. */
101extern Addr VG_(client__dl_sysinfo_int80);
102
sewardj8eb8bab2015-07-21 14:44:28 +0000103/* Obtains the initial client stack pointer from the finalised image info. */
104extern Addr VG_(get_initial_client_SP)(void);
sewardja672ea32006-04-29 18:03:14 +0000105
philippe98486902014-08-19 22:46:44 +0000106/* glibc nptl pthread systems only, when no-nptl-pthread-stackcache
107 was given in --sim-hints.
108 Used for a (kludgy) way to disable the cache of stacks as implemented in
109 nptl glibc.
110 Based on internal knowledge of the pthread glibc nptl/allocatestack.c code:
111 a huge value in stack_cache_actsize (bigger than the constant
112 stack_cache_maxsize) makes glibc believes the cache is full
113 and so stacks are always released when a pthread terminates.
114 Several ugliness in this kludge:
115 * hardcodes private glibc var name "stack_cache_maxsize"
116 * based on knowledge of the code of the functions
117 queue_stack and __free_stacks
118 * static symbol for "stack_cache_maxsize" must be in
119 the debug info.
120 It would be much cleaner to have a documented and supported
121 way to disable the pthread stack cache. */
122extern SizeT* VG_(client__stack_cache_actsize__addr);
123
sewardj8eb8bab2015-07-21 14:44:28 +0000124#if defined(VGO_solaris)
125/* Address of variable vg_vfork_fildes in vgpreload_core.so.0
126 (vg_preloaded.c). */
127extern Int* VG_(vfork_fildes_addr);
128#endif
129
sewardj45f4e7c2005-09-27 19:20:21 +0000130#endif // __PUB_CORE_CLIENTSTATE_H
131
132/*--------------------------------------------------------------------*/
133/*--- end ---*/
134/*--------------------------------------------------------------------*/