1 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 12 Copyright (C) 2000-2012 Julian Seward 13 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" 34#include "pub_core_vki.h" 35#include "pub_core_xarray.h" 36#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 47Addr VG_(client_base) = 0; /* client address space limits */ 48Addr VG_(client_end) = 0; 49 50Addr VG_(clstk_base) = 0; 51Addr VG_(clstk_end) = 0; 52UWord VG_(clstk_id) = 0; 53 54/* linux only: where is the client auxv ? */ 55/* This is set up as part of setup_client_stack in initimg-linux.c. */ 56UWord* VG_(client_auxv) = NULL; 57 58Addr VG_(brk_base) = 0; /* start of brk */ 59Addr VG_(brk_limit) = 0; /* current brk */ 60 61/* A fd which refers to the client executable. */ 62Int VG_(cl_exec_fd) = -1; 63 64/* A fd which refers to the fake /proc/<pid>/cmdline in /tmp. */ 65Int VG_(cl_cmdline_fd) = -1; 66 67// Command line pieces, after they have been extracted from argv in 68// m_main.main(). The payload vectors are allocated in VG_AR_TOOL 69// (the default arena). They are never freed. 70 71/* Args for the client. */ 72XArray* /* of HChar* */ VG_(args_for_client) = NULL; 73 74/* Args for V (augments, then those from the launcher). */ 75XArray* /* of HChar* */ VG_(args_for_valgrind) = NULL; 76 77/* How many of the above not to pass on at execve time? */ 78Int VG_(args_for_valgrind_noexecpass) = 0; 79 80/* The name of the client executable, as specified on the command 81 line. */ 82const HChar* VG_(args_the_exename) = NULL; 83 84// Client's original rlimit data and rlimit stack 85struct vki_rlimit VG_(client_rlimit_data); 86struct vki_rlimit VG_(client_rlimit_stack); 87 88// Name of the launcher, as extracted from VALGRIND_LAUNCHER at 89// startup. 90HChar* VG_(name_of_launcher) = NULL; 91 92/* Application-visible file descriptor limits */ 93Int VG_(fd_soft_limit) = -1; 94Int VG_(fd_hard_limit) = -1; 95 96/* Useful addresses extracted from the client */ 97/* Where is the __libc_freeres_wrapper routine we made? */ 98Addr VG_(client___libc_freeres_wrapper) = 0; 99 100/* x86-linux only: where is glibc's _dl_sysinfo_int80 function? 101 Finding it isn't essential, but knowing where it is does sometimes 102 help produce better back traces. See big comment in 103 VG_(get_StackTrace) in m_stacktrace.c for further info. */ 104Addr VG_(client__dl_sysinfo_int80) = 0; 105 106 107/*--------------------------------------------------------------------*/ 108/*--- end ---*/ 109/*--------------------------------------------------------------------*/ 110