Startup.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Startup</title>
  16. <meta name="description" content="Debugging with GDB: Startup">
  17. <meta name="keywords" content="Debugging with GDB: Startup">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="Invoking-GDB.html#Invoking-GDB" rel="up" title="Invoking GDB">
  26. <link href="Quitting-GDB.html#Quitting-GDB" rel="next" title="Quitting GDB">
  27. <link href="Mode-Options.html#Mode-Options" rel="previous" title="Mode Options">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Startup"></a>
  59. <div class="header">
  60. <p>
  61. Previous: <a href="Mode-Options.html#Mode-Options" accesskey="p" rel="previous">Mode Options</a>, Up: <a href="Invoking-GDB.html#Invoking-GDB" accesskey="u" rel="up">Invoking GDB</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>
  62. </div>
  63. <hr>
  64. <a name="What-GDB-Does-During-Startup"></a>
  65. <h4 class="subsection">2.1.3 What <small>GDB</small> Does During Startup</h4>
  66. <a name="index-GDB-startup"></a>
  67. <p>Here&rsquo;s the description of what <small>GDB</small> does during session startup:
  68. </p>
  69. <ol>
  70. <li> Sets up the command interpreter as specified by the command line
  71. (see <a href="Mode-Options.html#Mode-Options">interpreter</a>).
  72. </li><li> <a name="index-init-file"></a>
  73. Reads the system-wide <em>init file</em> (if <samp>--with-system-gdbinit</samp> was
  74. used when building <small>GDB</small>; see <a href="System_002dwide-configuration.html#System_002dwide-configuration">System-wide configuration and settings</a>) and the files in the system-wide
  75. gdbinit directory (if <samp>--with-system-gdbinit-dir</samp> was used) and executes
  76. all the commands in those files. The files need to be named with a <samp>.gdb</samp>
  77. extension to be interpreted as <small>GDB</small> commands, or they can be written
  78. in a supported scripting language with an appropriate file extension.
  79. <a name="Home-Directory-Init-File"></a></li><li> Reads the init file (if any) in your home directory<a name="DOCF1" href="#FOOT1"><sup>1</sup></a> and executes all the commands in
  80. that file.
  81. <a name="Option-_002dinit_002deval_002dcommand"></a></li><li> Executes commands and command files specified by the &lsquo;<samp>-iex</samp>&rsquo; and
  82. &lsquo;<samp>-ix</samp>&rsquo; options in their specified order. Usually you should use the
  83. &lsquo;<samp>-ex</samp>&rsquo; and &lsquo;<samp>-x</samp>&rsquo; options instead, but this way you can apply
  84. settings before <small>GDB</small> init files get executed and before inferior
  85. gets loaded.
  86. </li><li> Processes command line options and operands.
  87. <a name="Init-File-in-the-Current-Directory-during-Startup"></a></li><li> Reads and executes the commands from init file (if any) in the current
  88. working directory as long as &lsquo;<samp>set auto-load local-gdbinit</samp>&rsquo; is set to
  89. &lsquo;<samp>on</samp>&rsquo; (see <a href="Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory">Init File in the Current Directory</a>).
  90. This is only done if the current directory is
  91. different from your home directory. Thus, you can have more than one
  92. init file, one generic in your home directory, and another, specific
  93. to the program you are debugging, in the directory where you invoke
  94. <small>GDB</small>.
  95. </li><li> If the command line specified a program to debug, or a process to
  96. attach to, or a core file, <small>GDB</small> loads any auto-loaded
  97. scripts provided for the program or for its loaded shared libraries.
  98. See <a href="Auto_002dloading.html#Auto_002dloading">Auto-loading</a>.
  99. <p>If you wish to disable the auto-loading during startup,
  100. you must do something like the following:
  101. </p>
  102. <div class="smallexample">
  103. <pre class="smallexample">$ gdb -iex &quot;set auto-load python-scripts off&quot; myprogram
  104. </pre></div>
  105. <p>Option &lsquo;<samp>-ex</samp>&rsquo; does not work because the auto-loading is then turned
  106. off too late.
  107. </p>
  108. </li><li> Executes commands and command files specified by the &lsquo;<samp>-ex</samp>&rsquo; and
  109. &lsquo;<samp>-x</samp>&rsquo; options in their specified order. See <a href="Command-Files.html#Command-Files">Command Files</a>, for
  110. more details about <small>GDB</small> command files.
  111. </li><li> Reads the command history recorded in the <em>history file</em>.
  112. See <a href="Command-History.html#Command-History">Command History</a>, for more details about the command history and the
  113. files where <small>GDB</small> records it.
  114. </li></ol>
  115. <p>Init files use the same syntax as <em>command files</em> (see <a href="Command-Files.html#Command-Files">Command Files</a>) and are processed by <small>GDB</small> in the same way. The init
  116. file in your home directory can set options (such as &lsquo;<samp>set
  117. complaints</samp>&rsquo;) that affect subsequent processing of command line options
  118. and operands. Init files are not executed if you use the &lsquo;<samp>-nx</samp>&rsquo;
  119. option (see <a href="Mode-Options.html#Mode-Options">Choosing Modes</a>).
  120. </p>
  121. <p>To display the list of init files loaded by gdb at startup, you
  122. can use <kbd>gdb --help</kbd>.
  123. </p>
  124. <a name="index-init-file-name"></a>
  125. <a name="index-_002egdbinit"></a>
  126. <a name="index-gdb_002eini"></a>
  127. <p>The <small>GDB</small> init files are normally called <samp>.gdbinit</samp>.
  128. The DJGPP port of <small>GDB</small> uses the name <samp>gdb.ini</samp>, due to
  129. the limitations of file names imposed by DOS filesystems. The Windows
  130. port of <small>GDB</small> uses the standard name, but if it finds a
  131. <samp>gdb.ini</samp> file in your home directory, it warns you about that
  132. and suggests to rename the file to the standard name.
  133. </p>
  134. <div class="footnote">
  135. <hr>
  136. <h4 class="footnotes-heading">Footnotes</h4>
  137. <h3><a name="FOOT1" href="#DOCF1">(1)</a></h3>
  138. <p>On
  139. DOS/Windows systems, the home directory is the one pointed to by the
  140. <code>HOME</code> environment variable.</p>
  141. </div>
  142. <hr>
  143. <div class="header">
  144. <p>
  145. Previous: <a href="Mode-Options.html#Mode-Options" accesskey="p" rel="previous">Mode Options</a>, Up: <a href="Invoking-GDB.html#Invoking-GDB" accesskey="u" rel="up">Invoking GDB</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>
  146. </div>
  147. </body>
  148. </html>