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.

Auto_002dloading.html 14KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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>Auto-loading (Debugging with GDB)</title>
  17. <meta name="description" content="Auto-loading (Debugging with GDB)">
  18. <meta name="keywords" content="Auto-loading (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="Controlling-GDB.html#Controlling-GDB" rel="up" title="Controlling GDB">
  26. <link href="Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory" rel="next" title="Init File in the Current Directory">
  27. <link href="ABI.html#ABI" rel="prev" title="ABI">
  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="Auto_002dloading"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Messages_002fWarnings.html#Messages_002fWarnings" accesskey="n" rel="next">Messages/Warnings</a>, Previous: <a href="ABI.html#ABI" accesskey="p" rel="prev">ABI</a>, Up: <a href="Controlling-GDB.html#Controlling-GDB" accesskey="u" rel="up">Controlling 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>
  61. </div>
  62. <hr>
  63. <a name="Automatically-loading-associated-files"></a>
  64. <h3 class="section">22.8 Automatically loading associated files</h3>
  65. <a name="index-auto_002dloading"></a>
  66. <p><small>GDB</small> sometimes reads files with commands and settings automatically,
  67. without being explicitly told so by the user. We call this feature
  68. <em>auto-loading</em>. While auto-loading is useful for automatically adapting
  69. <small>GDB</small> to the needs of your project, it can sometimes produce unexpected
  70. results or introduce security risks (e.g., if the file comes from untrusted
  71. sources).
  72. </p>
  73. <table class="menu" border="0" cellspacing="0">
  74. <tr><td align="left" valign="top">&bull; <a href="Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory" accesskey="1">Init File in the Current Directory</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>set/show/info auto-load local-gdbinit</samp>&rsquo;
  75. </td></tr>
  76. <tr><td align="left" valign="top">&bull; <a href="libthread_005fdb_002eso_002e1-file.html#libthread_005fdb_002eso_002e1-file" accesskey="2">libthread_db.so.1 file</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>set/show/info auto-load libthread-db</samp>&rsquo;
  77. </td></tr>
  78. <tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
  79. </pre></th></tr><tr><td align="left" valign="top">&bull; <a href="Auto_002dloading-safe-path.html#Auto_002dloading-safe-path" accesskey="3">Auto-loading safe path</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>set/show/info auto-load safe-path</samp>&rsquo;
  80. </td></tr>
  81. <tr><td align="left" valign="top">&bull; <a href="Auto_002dloading-verbose-mode.html#Auto_002dloading-verbose-mode" accesskey="4">Auto-loading verbose mode</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>set/show debug auto-load</samp>&rsquo;
  82. </td></tr>
  83. </table>
  84. <p>There are various kinds of files <small>GDB</small> can automatically load.
  85. In addition to these files, <small>GDB</small> supports auto-loading code written
  86. in various extension languages. See <a href="Auto_002dloading-extensions.html#Auto_002dloading-extensions">Auto-loading extensions</a>.
  87. </p>
  88. <p>Note that loading of these associated files (including the local <samp>.gdbinit</samp>
  89. file) requires accordingly configured <code>auto-load safe-path</code>
  90. (see <a href="Auto_002dloading-safe-path.html#Auto_002dloading-safe-path">Auto-loading safe path</a>).
  91. </p>
  92. <p>For these reasons, <small>GDB</small> includes commands and options to let you
  93. control when to auto-load files and which files should be auto-loaded.
  94. </p>
  95. <dl compact="compact">
  96. <dd><a name="set-auto_002dload-off"></a><a name="index-set-auto_002dload-off"></a>
  97. </dd>
  98. <dt><code>set auto-load off</code></dt>
  99. <dd><p>Globally disable loading of all auto-loaded files.
  100. You may want to use this command with the &lsquo;<samp>-iex</samp>&rsquo; option
  101. (see <a href="Startup.html#Option-_002dinit_002deval_002dcommand">Option -init-eval-command</a>) such as:
  102. </p><div class="smallexample">
  103. <pre class="smallexample">$ <kbd>gdb -iex &quot;set auto-load off&quot; untrusted-executable corefile</kbd>
  104. </pre></div>
  105. <p>Be aware that system init file (see <a href="System_002dwide-configuration.html#System_002dwide-configuration">System-wide configuration</a>)
  106. and init files from your home directory (see <a href="Startup.html#Home-Directory-Init-File">Home Directory Init File</a>)
  107. still get read (as they come from generally trusted directories).
  108. To prevent <small>GDB</small> from auto-loading even those init files, use the
  109. <samp>-nx</samp> option (see <a href="Mode-Options.html#Mode-Options">Mode Options</a>), in addition to
  110. <code>set auto-load no</code>.
  111. </p>
  112. <a name="show-auto_002dload"></a><a name="index-show-auto_002dload"></a>
  113. </dd>
  114. <dt><code>show auto-load</code></dt>
  115. <dd><p>Show whether auto-loading of each specific &lsquo;<samp>auto-load</samp>&rsquo; file(s) is enabled
  116. or disabled.
  117. </p>
  118. <div class="smallexample">
  119. <pre class="smallexample">(gdb) show auto-load
  120. gdb-scripts: Auto-loading of canned sequences of commands scripts is on.
  121. libthread-db: Auto-loading of inferior specific libthread_db is on.
  122. local-gdbinit: Auto-loading of .gdbinit script from current directory
  123. is on.
  124. python-scripts: Auto-loading of Python scripts is on.
  125. safe-path: List of directories from which it is safe to auto-load files
  126. is $debugdir:$datadir/auto-load.
  127. scripts-directory: List of directories from which to load auto-loaded scripts
  128. is $debugdir:$datadir/auto-load.
  129. </pre></div>
  130. <a name="info-auto_002dload"></a><a name="index-info-auto_002dload"></a>
  131. </dd>
  132. <dt><code>info auto-load</code></dt>
  133. <dd><p>Print whether each specific &lsquo;<samp>auto-load</samp>&rsquo; file(s) have been auto-loaded or
  134. not.
  135. </p>
  136. <div class="smallexample">
  137. <pre class="smallexample">(gdb) info auto-load
  138. gdb-scripts:
  139. Loaded Script
  140. Yes /home/user/gdb/gdb-gdb.gdb
  141. libthread-db: No auto-loaded libthread-db.
  142. local-gdbinit: Local .gdbinit file &quot;/home/user/gdb/.gdbinit&quot; has been
  143. loaded.
  144. python-scripts:
  145. Loaded Script
  146. Yes /home/user/gdb/gdb-gdb.py
  147. </pre></div>
  148. </dd>
  149. </dl>
  150. <p>These are <small>GDB</small> control commands for the auto-loading:
  151. </p>
  152. <table>
  153. <tr><td width="50%">See <a href="#set-auto_002dload-off">set auto-load off</a>.</td><td width="50%">Disable auto-loading globally.</td></tr>
  154. <tr><td width="50%">See <a href="#show-auto_002dload">show auto-load</a>.</td><td width="50%">Show setting of all kinds of files.</td></tr>
  155. <tr><td width="50%">See <a href="#info-auto_002dload">info auto-load</a>.</td><td width="50%">Show state of all kinds of files.</td></tr>
  156. <tr><td width="50%">See <a href="Auto_002dloading-sequences.html#set-auto_002dload-gdb_002dscripts">set auto-load gdb-scripts</a>.</td><td width="50%">Control for <small>GDB</small> command scripts.</td></tr>
  157. <tr><td width="50%">See <a href="Auto_002dloading-sequences.html#show-auto_002dload-gdb_002dscripts">show auto-load gdb-scripts</a>.</td><td width="50%">Show setting of <small>GDB</small> command scripts.</td></tr>
  158. <tr><td width="50%">See <a href="Auto_002dloading-sequences.html#info-auto_002dload-gdb_002dscripts">info auto-load gdb-scripts</a>.</td><td width="50%">Show state of <small>GDB</small> command scripts.</td></tr>
  159. <tr><td width="50%">See <a href="Python-Auto_002dloading.html#set-auto_002dload-python_002dscripts">set auto-load python-scripts</a>.</td><td width="50%">Control for <small>GDB</small> Python scripts.</td></tr>
  160. <tr><td width="50%">See <a href="Python-Auto_002dloading.html#show-auto_002dload-python_002dscripts">show auto-load python-scripts</a>.</td><td width="50%">Show setting of <small>GDB</small> Python scripts.</td></tr>
  161. <tr><td width="50%">See <a href="Python-Auto_002dloading.html#info-auto_002dload-python_002dscripts">info auto-load python-scripts</a>.</td><td width="50%">Show state of <small>GDB</small> Python scripts.</td></tr>
  162. <tr><td width="50%">See <a href="Guile-Auto_002dloading.html#set-auto_002dload-guile_002dscripts">set auto-load guile-scripts</a>.</td><td width="50%">Control for <small>GDB</small> Guile scripts.</td></tr>
  163. <tr><td width="50%">See <a href="Guile-Auto_002dloading.html#show-auto_002dload-guile_002dscripts">show auto-load guile-scripts</a>.</td><td width="50%">Show setting of <small>GDB</small> Guile scripts.</td></tr>
  164. <tr><td width="50%">See <a href="Guile-Auto_002dloading.html#info-auto_002dload-guile_002dscripts">info auto-load guile-scripts</a>.</td><td width="50%">Show state of <small>GDB</small> Guile scripts.</td></tr>
  165. <tr><td width="50%">See <a href="objfile_002dgdbdotext-file.html#set-auto_002dload-scripts_002ddirectory">set auto-load scripts-directory</a>.</td><td width="50%">Control for <small>GDB</small> auto-loaded scripts location.</td></tr>
  166. <tr><td width="50%">See <a href="objfile_002dgdbdotext-file.html#show-auto_002dload-scripts_002ddirectory">show auto-load scripts-directory</a>.</td><td width="50%">Show <small>GDB</small> auto-loaded scripts location.</td></tr>
  167. <tr><td width="50%">See <a href="objfile_002dgdbdotext-file.html#add_002dauto_002dload_002dscripts_002ddirectory">add-auto-load-scripts-directory</a>.</td><td width="50%">Add directory for auto-loaded scripts location list.</td></tr>
  168. <tr><td width="50%">See <a href="Init-File-in-the-Current-Directory.html#set-auto_002dload-local_002dgdbinit">set auto-load local-gdbinit</a>.</td><td width="50%">Control for init file in the current directory.</td></tr>
  169. <tr><td width="50%">See <a href="Init-File-in-the-Current-Directory.html#show-auto_002dload-local_002dgdbinit">show auto-load local-gdbinit</a>.</td><td width="50%">Show setting of init file in the current directory.</td></tr>
  170. <tr><td width="50%">See <a href="Init-File-in-the-Current-Directory.html#info-auto_002dload-local_002dgdbinit">info auto-load local-gdbinit</a>.</td><td width="50%">Show state of init file in the current directory.</td></tr>
  171. <tr><td width="50%">See <a href="libthread_005fdb_002eso_002e1-file.html#set-auto_002dload-libthread_002ddb">set auto-load libthread-db</a>.</td><td width="50%">Control for thread debugging library.</td></tr>
  172. <tr><td width="50%">See <a href="libthread_005fdb_002eso_002e1-file.html#show-auto_002dload-libthread_002ddb">show auto-load libthread-db</a>.</td><td width="50%">Show setting of thread debugging library.</td></tr>
  173. <tr><td width="50%">See <a href="libthread_005fdb_002eso_002e1-file.html#info-auto_002dload-libthread_002ddb">info auto-load libthread-db</a>.</td><td width="50%">Show state of thread debugging library.</td></tr>
  174. <tr><td width="50%">See <a href="Auto_002dloading-safe-path.html#set-auto_002dload-safe_002dpath">set auto-load safe-path</a>.</td><td width="50%">Control directories trusted for automatic loading.</td></tr>
  175. <tr><td width="50%">See <a href="Auto_002dloading-safe-path.html#show-auto_002dload-safe_002dpath">show auto-load safe-path</a>.</td><td width="50%">Show directories trusted for automatic loading.</td></tr>
  176. <tr><td width="50%">See <a href="Auto_002dloading-safe-path.html#add_002dauto_002dload_002dsafe_002dpath">add-auto-load-safe-path</a>.</td><td width="50%">Add directory trusted for automatic loading.</td></tr>
  177. </table>
  178. <hr>
  179. <div class="header">
  180. <p>
  181. Next: <a href="Messages_002fWarnings.html#Messages_002fWarnings" accesskey="n" rel="next">Messages/Warnings</a>, Previous: <a href="ABI.html#ABI" accesskey="p" rel="prev">ABI</a>, Up: <a href="Controlling-GDB.html#Controlling-GDB" accesskey="u" rel="up">Controlling 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>
  182. </div>
  183. </body>
  184. </html>