You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
6.9KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Working Directory (Debugging with GDB)</title>
  17. <meta name="description" content="Working Directory (Debugging with GDB)">
  18. <meta name="keywords" content="Working Directory (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Running.html#Running" rel="up" title="Running">
  26. <link href="Input_002fOutput.html#Input_002fOutput" rel="next" title="Input/Output">
  27. <link href="Environment.html#Environment" rel="prev" title="Environment">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style: oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Working-Directory"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Input_002fOutput.html#Input_002fOutput" accesskey="n" rel="next">Input/Output</a>, Previous: <a href="Environment.html#Environment" accesskey="p" rel="prev">Environment</a>, Up: <a href="Running.html#Running" accesskey="u" rel="up">Running</a> &nbsp; [<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>
  61. </div>
  62. <hr>
  63. <a name="Your-Program_0027s-Working-Directory"></a>
  64. <h3 class="section">4.5 Your Program&rsquo;s Working Directory</h3>
  65. <a name="index-working-directory-_0028of-your-program_0029"></a>
  66. <p>Each time you start your program with <code>run</code>, the inferior will be
  67. initialized with the current working directory specified by the
  68. <kbd>set cwd</kbd> command. If no directory has been specified by this
  69. command, then the inferior will inherit <small>GDB</small>&rsquo;s current working
  70. directory as its working directory if native debugging, or it will
  71. inherit the remote server&rsquo;s current working directory if remote
  72. debugging.
  73. </p>
  74. <dl compact="compact">
  75. <dd><a name="index-set-cwd"></a>
  76. <a name="index-change-inferior_0027s-working-directory"></a>
  77. <a name="set-cwd-command"></a></dd>
  78. <dt><code>set cwd <span class="roman">[</span><var>directory</var><span class="roman">]</span></code></dt>
  79. <dd><p>Set the inferior&rsquo;s working directory to <var>directory</var>, which will be
  80. <code>glob</code>-expanded in order to resolve tildes (<samp>~</samp>). If no
  81. argument has been specified, the command clears the setting and resets
  82. it to an empty state. This setting has no effect on <small>GDB</small>&rsquo;s
  83. working directory, and it only takes effect the next time you start
  84. the inferior. The <samp>~</samp> in <var>directory</var> is a short for the
  85. <em>home directory</em>, usually pointed to by the <code>HOME</code> environment
  86. variable. On MS-Windows, if <code>HOME</code> is not defined, <small>GDB</small>
  87. uses the concatenation of <code>HOMEDRIVE</code> and <code>HOMEPATH</code> as
  88. fallback.
  89. </p>
  90. <p>You can also change <small>GDB</small>&rsquo;s current working directory by using
  91. the <code>cd</code> command.
  92. See <a href="#cd-command">cd command</a>.
  93. </p>
  94. <a name="index-show-cwd"></a>
  95. <a name="index-show-inferior_0027s-working-directory"></a>
  96. </dd>
  97. <dt><code>show cwd</code></dt>
  98. <dd><p>Show the inferior&rsquo;s working directory. If no directory has been
  99. specified by <kbd>set cwd</kbd>, then the default inferior&rsquo;s working
  100. directory is the same as <small>GDB</small>&rsquo;s working directory.
  101. </p>
  102. <a name="index-cd"></a>
  103. <a name="index-change-GDB_0027s-working-directory"></a>
  104. <a name="cd-command"></a></dd>
  105. <dt><code>cd <span class="roman">[</span><var>directory</var><span class="roman">]</span></code></dt>
  106. <dd><p>Set the <small>GDB</small> working directory to <var>directory</var>. If not
  107. given, <var>directory</var> uses <samp>'~'</samp>.
  108. </p>
  109. <p>The <small>GDB</small> working directory serves as a default for the
  110. commands that specify files for <small>GDB</small> to operate on.
  111. See <a href="Files.html#Files">Commands to Specify Files</a>.
  112. See <a href="#set-cwd-command">set cwd command</a>.
  113. </p>
  114. <a name="index-pwd"></a>
  115. </dd>
  116. <dt><code>pwd</code></dt>
  117. <dd><p>Print the <small>GDB</small> working directory.
  118. </p></dd>
  119. </dl>
  120. <p>It is generally impossible to find the current working directory of
  121. the process being debugged (since a program can change its directory
  122. during its run). If you work on a system where <small>GDB</small> supports
  123. the <code>info proc</code> command (see <a href="Process-Information.html#Process-Information">Process Information</a>), you can
  124. use the <code>info proc</code> command to find out the
  125. current working directory of the debuggee.
  126. </p>
  127. <hr>
  128. <div class="header">
  129. <p>
  130. Next: <a href="Input_002fOutput.html#Input_002fOutput" accesskey="n" rel="next">Input/Output</a>, Previous: <a href="Environment.html#Environment" accesskey="p" rel="prev">Environment</a>, Up: <a href="Running.html#Running" accesskey="u" rel="up">Running</a> &nbsp; [<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>
  131. </div>
  132. </body>
  133. </html>