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-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 or 7any later version published by the Free Software Foundation; with the 8Invariant Sections being "Free Software" and "Free Software Needs 9Free Documentation", with the Front-Cover Texts being "A GNU Manual," 10and with the Back-Cover Texts as in (a) below. 11 12(a) The FSF's Back-Cover Text is: "You are free to copy and modify 13this GNU Manual. Buying copies from GNU Press supports the FSF in 14developing GNU and promoting software freedom." --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>Debugging with GDB: Startup</title> 18 19<meta name="description" content="Debugging with GDB: Startup"> 20<meta name="keywords" content="Debugging with GDB: Startup"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="Invoking-GDB.html#Invoking-GDB" rel="up" title="Invoking GDB"> 29<link href="Quitting-GDB.html#Quitting-GDB" rel="next" title="Quitting GDB"> 30<link href="Mode-Options.html#Mode-Options" rel="previous" title="Mode Options"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="Startup"></a> 65<div class="header"> 66<p> 67Previous: <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> [<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> 68</div> 69<hr> 70<a name="What-GDB-Does-during-Startup"></a> 71<h4 class="subsection">2.1.3 What <small>GDB</small> Does during Startup</h4> 72<a name="index-GDB-startup"></a> 73 74<p>Here’s the description of what <small>GDB</small> does during session startup: 75</p> 76<ol> 77<li> Sets up the command interpreter as specified by the command line 78(see <a href="Mode-Options.html#Mode-Options">interpreter</a>). 79 80</li><li> <a name="index-init-file"></a> 81Reads the system-wide <em>init file</em> (if <samp>--with-system-gdbinit</samp> was 82used 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 83gdbinit directory (if <samp>--with-system-gdbinit-dir</samp> was used) and executes 84all the commands in those files. The files need to be named with a <samp>.gdb</samp> 85extension to be interpreted as <small>GDB</small> commands, or they can be written 86in a supported scripting language with an appropriate file extension. 87 88<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 89that file. 90 91<a name="Option-_002dinit_002deval_002dcommand"></a></li><li> Executes commands and command files specified by the ‘<samp>-iex</samp>’ and 92‘<samp>-ix</samp>’ options in their specified order. Usually you should use the 93‘<samp>-ex</samp>’ and ‘<samp>-x</samp>’ options instead, but this way you can apply 94settings before <small>GDB</small> init files get executed and before inferior 95gets loaded. 96 97</li><li> Processes command line options and operands. 98 99<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 100working directory as long as ‘<samp>set auto-load local-gdbinit</samp>’ is set to 101‘<samp>on</samp>’ (see <a href="Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory">Init File in the Current Directory</a>). 102This is only done if the current directory is 103different from your home directory. Thus, you can have more than one 104init file, one generic in your home directory, and another, specific 105to the program you are debugging, in the directory where you invoke 106<small>GDB</small>. 107 108</li><li> If the command line specified a program to debug, or a process to 109attach to, or a core file, <small>GDB</small> loads any auto-loaded 110scripts provided for the program or for its loaded shared libraries. 111See <a href="Auto_002dloading.html#Auto_002dloading">Auto-loading</a>. 112 113<p>If you wish to disable the auto-loading during startup, 114you must do something like the following: 115</p> 116<div class="smallexample"> 117<pre class="smallexample">$ gdb -iex "set auto-load python-scripts off" myprogram 118</pre></div> 119 120<p>Option ‘<samp>-ex</samp>’ does not work because the auto-loading is then turned 121off too late. 122</p> 123</li><li> Executes commands and command files specified by the ‘<samp>-ex</samp>’ and 124‘<samp>-x</samp>’ options in their specified order. See <a href="Command-Files.html#Command-Files">Command Files</a>, for 125more details about <small>GDB</small> command files. 126 127</li><li> Reads the command history recorded in the <em>history file</em>. 128See <a href="Command-History.html#Command-History">Command History</a>, for more details about the command history and the 129files where <small>GDB</small> records it. 130</li></ol> 131 132<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 133file in your home directory can set options (such as ‘<samp>set 134complaints</samp>’) that affect subsequent processing of command line options 135and operands. Init files are not executed if you use the ‘<samp>-nx</samp>’ 136option (see <a href="Mode-Options.html#Mode-Options">Choosing Modes</a>). 137</p> 138<p>To display the list of init files loaded by gdb at startup, you 139can use <kbd>gdb --help</kbd>. 140</p> 141<a name="index-init-file-name"></a> 142<a name="index-_002egdbinit"></a> 143<a name="index-gdb_002eini"></a> 144<p>The <small>GDB</small> init files are normally called <samp>.gdbinit</samp>. 145The DJGPP port of <small>GDB</small> uses the name <samp>gdb.ini</samp>, due to 146the limitations of file names imposed by DOS filesystems. The Windows 147port of <small>GDB</small> uses the standard name, but if it finds a 148<samp>gdb.ini</samp> file in your home directory, it warns you about that 149and suggests to rename the file to the standard name. 150</p> 151 152<div class="footnote"> 153<hr> 154<h4 class="footnotes-heading">Footnotes</h4> 155 156<h3><a name="FOOT1" href="#DOCF1">(1)</a></h3> 157<p>On 158DOS/Windows systems, the home directory is the one pointed to by the 159<code>HOME</code> environment variable.</p> 160</div> 161<hr> 162<div class="header"> 163<p> 164Previous: <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> [<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> 165</div> 166 167 168 169</body> 170</html> 171