gdb: Environment

 
 4.4 Your Program's Environment
 ==============================
 
 The "environment" consists of a set of environment variables and their
 values.  Environment variables conventionally record such things as your
 user name, your home directory, your terminal type, and your search path
 for programs to run.  Usually you set up environment variables with the
 shell and they are inherited by all the other programs you run.  When
 debugging, it can be useful to try running your program with a modified
 environment without having to start GDB over again.
 
 'path DIRECTORY'
      Add DIRECTORY to the front of the 'PATH' environment variable (the
      search path for executables) that will be passed to your program.
      The value of 'PATH' used by GDB does not change.  You may specify
      several directory names, separated by whitespace or by a
      system-dependent separator character (':' on Unix, ';' on MS-DOS
      and MS-Windows).  If DIRECTORY is already in the path, it is moved
      to the front, so it is searched sooner.
 
      You can use the string '$cwd' to refer to whatever is the current
      working directory at the time GDB searches the path.  If you use
      '.' instead, it refers to the directory where you executed the
      'path' command.  GDB replaces '.' in the DIRECTORY argument (with
      the current path) before adding DIRECTORY to the search path.
 
 'show paths'
      Display the list of search paths for executables (the 'PATH'
      environment variable).
 
 'show environment [VARNAME]'
      Print the value of environment variable VARNAME to be given to your
      program when it starts.  If you do not supply VARNAME, print the
      names and values of all environment variables to be given to your
      program.  You can abbreviate 'environment' as 'env'.
 
 'set environment VARNAME [=VALUE]'
      Set environment variable VARNAME to VALUE.  The value changes for
      your program (and the shell GDB uses to launch it), not for GDB
      itself.  The VALUE may be any string; the values of environment
      variables are just strings, and any interpretation is supplied by
      your program itself.  The VALUE parameter is optional; if it is
      eliminated, the variable is set to a null value.
 
      For example, this command:
 
           set env USER = foo
 
      tells the debugged program, when subsequently run, that its user is
      named 'foo'.  (The spaces around '=' are used for clarity here;
      they are not actually required.)
 
      Note that on Unix systems, GDB runs your program via a shell, which
      also inherits the environment set with 'set environment'.  If
      necessary, you can avoid that by using the 'env' program as a
      wrapper instead of using 'set environment'.  Seeset
      exec-wrapper, for an example doing just that.
 
      Environment variables that are set by the user are also transmitted
      to 'gdbserver' to be used when starting the remote inferior.  See
      QEnvironmentHexEncoded.
 
 'unset environment VARNAME'
      Remove variable VARNAME from the environment to be passed to your
      program.  This is different from 'set env VARNAME ='; 'unset
      environment' removes the variable from the environment, rather than
      assigning it an empty value.
 
      Environment variables that are unset by the user are also unset on
      'gdbserver' when starting the remote inferior.  See
      QEnvironmentUnset.
 
    _Warning:_ On Unix systems, GDB runs your program using the shell
 indicated by your 'SHELL' environment variable if it exists (or
 '/bin/sh' if not).  If your 'SHELL' variable names a shell that runs an
 initialization file when started non-interactively--such as '.cshrc' for
 C-shell, $'.zshenv' for the Z shell, or the file specified in the
 'BASH_ENV' environment variable for BASH--any variables you set in that
 file affect your program.  You may wish to move setting of environment
 variables to files that are only run when you sign on, such as '.login'
 or '.profile'.