blob: 7cbc7c741b4cf77cb71609f01eac6ece88216a1b [file] [log] [blame]
sewardj45f4e7c2005-09-27 19:20:21 +00001
2/*--------------------------------------------------------------------*/
3/*--- A home for miscellaneous bits of information which pertain ---*/
4/*--- to the client's state. ---*/
5/*--- m_clientstate.c ---*/
6/*--------------------------------------------------------------------*/
7
8/*
9 This file is part of Valgrind, a dynamic binary instrumentation
10 framework.
11
sewardjb3a1e4b2015-08-21 11:32:26 +000012 Copyright (C) 2000-2015 Julian Seward
sewardj45f4e7c2005-09-27 19:20:21 +000013 jseward@acm.org
14
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.
19
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.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 02111-1307, USA.
29
30 The GNU General Public License is contained in the file COPYING.
31*/
32
33#include "pub_core_basics.h"
sewardj4cfea4f2006-10-14 19:26:10 +000034#include "pub_core_vki.h"
sewardj14c7cc52007-02-25 15:08:24 +000035#include "pub_core_xarray.h"
sewardj45f4e7c2005-09-27 19:20:21 +000036#include "pub_core_clientstate.h"
37
38/*-----------------------------------------------------------------*/
39/*--- ---*/
40/*--- Basic globals about the address space. ---*/
41/*--- ---*/
42/*-----------------------------------------------------------------*/
43
44/* Client address space, lowest to highest (see top of ume.c) */
45// TODO: get rid of as many of these as possible.
46
philippe4fa3d372013-07-21 16:04:05 +000047/* ***Initial*** lowest address of the stack segment of the main thread.
philippe38a74d22014-08-29 22:53:19 +000048 The main stack will grow if needed but VG_(clstk_start_base) will
philippe4fa3d372013-07-21 16:04:05 +000049 not be changed according to the growth. */
philippe38a74d22014-08-29 22:53:19 +000050Addr VG_(clstk_start_base) = 0;
philippe4fa3d372013-07-21 16:04:05 +000051/* Initial highest address of the stack segment of the main thread. */
sewardj45f4e7c2005-09-27 19:20:21 +000052Addr VG_(clstk_end) = 0;
53UWord VG_(clstk_id) = 0;
sewardj8eb8bab2015-07-21 14:44:28 +000054/* Maximum size of the main thread's client stack. */
55SizeT VG_(clstk_max_size) = 0;
sewardj45f4e7c2005-09-27 19:20:21 +000056
sewardj8eb8bab2015-07-21 14:44:28 +000057/* Solaris and Linux only, specifies where the client auxv is.
58
59 This is set up as part of setup_client_stack() in
60 initimg-{linux,solaris}.c. */
sewardj2a312392011-06-26 09:26:48 +000061UWord* VG_(client_auxv) = NULL;
62
sewardj45f4e7c2005-09-27 19:20:21 +000063Addr VG_(brk_base) = 0; /* start of brk */
64Addr VG_(brk_limit) = 0; /* current brk */
65
66/* A fd which refers to the client executable. */
67Int VG_(cl_exec_fd) = -1;
68
69/* A fd which refers to the fake /proc/<pid>/cmdline in /tmp. */
70Int VG_(cl_cmdline_fd) = -1;
71
tom41ad7e72012-10-04 20:27:38 +000072/* A fd which refers to the fake /proc/<pid>/auxv in /tmp. */
73Int VG_(cl_auxv_fd) = -1;
74
sewardj8eb8bab2015-07-21 14:44:28 +000075#if defined(VGO_solaris)
76/* A fd which refers to the fake /proc/<pid>/psinfo in /tmp. */
77Int VG_(cl_psinfo_fd) = -1;
78#endif /* VGO_solaris */
79
sewardj45f4e7c2005-09-27 19:20:21 +000080// Command line pieces, after they have been extracted from argv in
floriana2968cc2013-09-20 21:34:40 +000081// m_main.main(). The payload vectors are allocated in VG_AR_CORE
sewardj45f4e7c2005-09-27 19:20:21 +000082// (the default arena). They are never freed.
83
84/* Args for the client. */
sewardj14c7cc52007-02-25 15:08:24 +000085XArray* /* of HChar* */ VG_(args_for_client) = NULL;
sewardj45f4e7c2005-09-27 19:20:21 +000086
87/* Args for V (augments, then those from the launcher). */
sewardj14c7cc52007-02-25 15:08:24 +000088XArray* /* of HChar* */ VG_(args_for_valgrind) = NULL;
sewardj45f4e7c2005-09-27 19:20:21 +000089
90/* How many of the above not to pass on at execve time? */
91Int VG_(args_for_valgrind_noexecpass) = 0;
92
93/* The name of the client executable, as specified on the command
94 line. */
barta3054f52010-06-14 18:12:56 +000095const HChar* VG_(args_the_exename) = NULL;
sewardj45f4e7c2005-09-27 19:20:21 +000096
97// Client's original rlimit data and rlimit stack
98struct vki_rlimit VG_(client_rlimit_data);
99struct vki_rlimit VG_(client_rlimit_stack);
100
101// Name of the launcher, as extracted from VALGRIND_LAUNCHER at
102// startup.
103HChar* VG_(name_of_launcher) = NULL;
104
sewardjfdf91b42005-09-28 00:53:09 +0000105/* Application-visible file descriptor limits */
106Int VG_(fd_soft_limit) = -1;
107Int VG_(fd_hard_limit) = -1;
108
sewardj0ec07f32006-01-12 12:32:32 +0000109/* Useful addresses extracted from the client */
110/* Where is the __libc_freeres_wrapper routine we made? */
111Addr VG_(client___libc_freeres_wrapper) = 0;
112
sewardja672ea32006-04-29 18:03:14 +0000113/* x86-linux only: where is glibc's _dl_sysinfo_int80 function?
114 Finding it isn't essential, but knowing where it is does sometimes
115 help produce better back traces. See big comment in
116 VG_(get_StackTrace) in m_stacktrace.c for further info. */
117Addr VG_(client__dl_sysinfo_int80) = 0;
118
philippe98486902014-08-19 22:46:44 +0000119/* Address of the (internal) glibc nptl pthread stack cache size,
120 declared as:
121 static size_t stack_cache_actsize;
122 in nptl/allocatestack.c */
123SizeT* VG_(client__stack_cache_actsize__addr) = 0;
sewardj45f4e7c2005-09-27 19:20:21 +0000124
sewardj8eb8bab2015-07-21 14:44:28 +0000125#if defined(VGO_solaris)
126/* Address of variable vg_vfork_fildes in vgpreload_core.so.0
127 (vg_preloaded.c). */
128Int* VG_(vfork_fildes_addr) = 0;
129#endif
130
sewardj45f4e7c2005-09-27 19:20:21 +0000131/*--------------------------------------------------------------------*/
132/*--- end ---*/
133/*--------------------------------------------------------------------*/