| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <!-- Copyright (C) 1988-2015 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being "Free Software" and "Free Software Needs |
| Free Documentation", with the Front-Cover Texts being "A GNU Manual," |
| and with the Back-Cover Texts as in (a) below. |
| |
| (a) The FSF's Back-Cover Text is: "You are free to copy and modify |
| this GNU Manual. Buying copies from GNU Press supports the FSF in |
| developing GNU and promoting software freedom." --> |
| <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> |
| <head> |
| <title>Debugging with GDB: Environment</title> |
| |
| <meta name="description" content="Debugging with GDB: Environment"> |
| <meta name="keywords" content="Debugging with GDB: Environment"> |
| <meta name="resource-type" content="document"> |
| <meta name="distribution" content="global"> |
| <meta name="Generator" content="makeinfo"> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| <link href="index.html#Top" rel="start" title="Top"> |
| <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> |
| <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> |
| <link href="Running.html#Running" rel="up" title="Running"> |
| <link href="Working-Directory.html#Working-Directory" rel="next" title="Working Directory"> |
| <link href="Arguments.html#Arguments" rel="prev" title="Arguments"> |
| <style type="text/css"> |
| <!-- |
| a.summary-letter {text-decoration: none} |
| blockquote.smallquotation {font-size: smaller} |
| div.display {margin-left: 3.2em} |
| div.example {margin-left: 3.2em} |
| div.indentedblock {margin-left: 3.2em} |
| div.lisp {margin-left: 3.2em} |
| div.smalldisplay {margin-left: 3.2em} |
| div.smallexample {margin-left: 3.2em} |
| div.smallindentedblock {margin-left: 3.2em; font-size: smaller} |
| div.smalllisp {margin-left: 3.2em} |
| kbd {font-style:oblique} |
| pre.display {font-family: inherit} |
| pre.format {font-family: inherit} |
| pre.menu-comment {font-family: serif} |
| pre.menu-preformatted {font-family: serif} |
| pre.smalldisplay {font-family: inherit; font-size: smaller} |
| pre.smallexample {font-size: smaller} |
| pre.smallformat {font-family: inherit; font-size: smaller} |
| pre.smalllisp {font-size: smaller} |
| span.nocodebreak {white-space:nowrap} |
| span.nolinebreak {white-space:nowrap} |
| span.roman {font-family:serif; font-weight:normal} |
| span.sansserif {font-family:sans-serif; font-weight:normal} |
| ul.no-bullet {list-style: none} |
| --> |
| </style> |
| |
| |
| </head> |
| |
| <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> |
| <a name="Environment"></a> |
| <div class="header"> |
| <p> |
| Next: <a href="Working-Directory.html#Working-Directory" accesskey="n" rel="next">Working Directory</a>, Previous: <a href="Arguments.html#Arguments" accesskey="p" rel="prev">Arguments</a>, Up: <a href="Running.html#Running" accesskey="u" rel="up">Running</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> |
| </div> |
| <hr> |
| <a name="Your-Program_0027s-Environment"></a> |
| <h3 class="section">4.4 Your Program’s Environment</h3> |
| |
| <a name="index-environment-_0028of-your-program_0029"></a> |
| <p>The <em>environment</em> 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 <small>GDB</small> over again. |
| </p> |
| <dl compact="compact"> |
| <dd><a name="index-path"></a> |
| </dd> |
| <dt><code>path <var>directory</var></code></dt> |
| <dd><p>Add <var>directory</var> to the front of the <code>PATH</code> environment variable |
| (the search path for executables) that will be passed to your program. |
| The value of <code>PATH</code> used by <small>GDB</small> does not change. |
| You may specify several directory names, separated by whitespace or by a |
| system-dependent separator character (‘<samp>:</samp>’ on Unix, ‘<samp>;</samp>’ on |
| MS-DOS and MS-Windows). If <var>directory</var> is already in the path, it |
| is moved to the front, so it is searched sooner. |
| </p> |
| <p>You can use the string ‘<samp>$cwd</samp>’ to refer to whatever is the current |
| working directory at the time <small>GDB</small> searches the path. If you |
| use ‘<samp>.</samp>’ instead, it refers to the directory where you executed the |
| <code>path</code> command. <small>GDB</small> replaces ‘<samp>.</samp>’ in the |
| <var>directory</var> argument (with the current path) before adding |
| <var>directory</var> to the search path. |
| </p> |
| <a name="index-show-paths"></a> |
| </dd> |
| <dt><code>show paths</code></dt> |
| <dd><p>Display the list of search paths for executables (the <code>PATH</code> |
| environment variable). |
| </p> |
| <a name="index-show-environment"></a> |
| </dd> |
| <dt><code>show environment <span class="roman">[</span><var>varname</var><span class="roman">]</span></code></dt> |
| <dd><p>Print the value of environment variable <var>varname</var> to be given to |
| your program when it starts. If you do not supply <var>varname</var>, |
| print the names and values of all environment variables to be given to |
| your program. You can abbreviate <code>environment</code> as <code>env</code>. |
| </p> |
| <a name="index-set-environment"></a> |
| </dd> |
| <dt><code>set environment <var>varname</var> <span class="roman">[</span>=<var>value</var><span class="roman">]</span></code></dt> |
| <dd><p>Set environment variable <var>varname</var> to <var>value</var>. The value |
| changes for your program (and the shell <small>GDB</small> uses to launch |
| it), not for <small>GDB</small> itself. The <var>value</var> may be any string; the |
| values of environment variables are just strings, and any |
| interpretation is supplied by your program itself. The <var>value</var> |
| parameter is optional; if it is eliminated, the variable is set to a |
| null value. |
| </p> |
| <p>For example, this command: |
| </p> |
| <div class="smallexample"> |
| <pre class="smallexample">set env USER = foo |
| </pre></div> |
| |
| <p>tells the debugged program, when subsequently run, that its user is named |
| ‘<samp>foo</samp>’. (The spaces around ‘<samp>=</samp>’ are used for clarity here; they |
| are not actually required.) |
| </p> |
| <p>Note that on Unix systems, <small>GDB</small> runs your program via a shell, |
| which also inherits the environment set with <code>set environment</code>. |
| If necessary, you can avoid that by using the ‘<samp>env</samp>’ program as a |
| wrapper instead of using <code>set environment</code>. See <a href="Starting.html#set-exec_002dwrapper">set exec-wrapper</a>, for an example doing just that. |
| </p> |
| <a name="index-unset-environment"></a> |
| </dd> |
| <dt><code>unset environment <var>varname</var></code></dt> |
| <dd><p>Remove variable <var>varname</var> from the environment to be passed to your |
| program. This is different from ‘<samp>set env <var>varname</var> =</samp>’; |
| <code>unset environment</code> removes the variable from the environment, |
| rather than assigning it an empty value. |
| </p></dd> |
| </dl> |
| |
| <p><em>Warning:</em> On Unix systems, <small>GDB</small> runs your program using |
| the shell indicated by your <code>SHELL</code> environment variable if it |
| exists (or <code>/bin/sh</code> if not). If your <code>SHELL</code> variable |
| names a shell that runs an initialization file when started |
| non-interactively—such as <samp>.cshrc</samp> for C-shell, $<samp>.zshenv</samp> |
| for the Z shell, or the file specified in the ‘<samp>BASH_ENV</samp>’ |
| 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 |
| <samp>.login</samp> or <samp>.profile</samp>. |
| </p> |
| <hr> |
| <div class="header"> |
| <p> |
| Next: <a href="Working-Directory.html#Working-Directory" accesskey="n" rel="next">Working Directory</a>, Previous: <a href="Arguments.html#Arguments" accesskey="p" rel="prev">Arguments</a>, Up: <a href="Running.html#Running" accesskey="u" rel="up">Running</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> |
| </div> |
| |
| |
| |
| </body> |
| </html> |