1<html lang="en"> 2<head> 3<title>Python Auto-loading - Debugging with GDB</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Debugging with GDB"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Python.html#Python" title="Python"> 9<link rel="prev" href="Python-API.html#Python-API" title="Python API"> 10<link rel="next" href="Python-modules.html#Python-modules" title="Python modules"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988-2013 Free Software Foundation, Inc. 14 15Permission is granted to copy, distribute and/or modify this document 16under the terms of the GNU Free Documentation License, Version 1.3 or 17any later version published by the Free Software Foundation; with the 18Invariant Sections being ``Free Software'' and ``Free Software Needs 19Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' 20and with the Back-Cover Texts as in (a) below. 21 22(a) The FSF's Back-Cover Text is: ``You are free to copy and modify 23this GNU Manual. Buying copies from GNU Press supports the FSF in 24developing GNU and promoting software freedom.'' 25--> 26<meta http-equiv="Content-Style-Type" content="text/css"> 27<style type="text/css"><!-- 28 pre.display { font-family:inherit } 29 pre.format { font-family:inherit } 30 pre.smalldisplay { font-family:inherit; font-size:smaller } 31 pre.smallformat { font-family:inherit; font-size:smaller } 32 pre.smallexample { font-size:smaller } 33 pre.smalllisp { font-size:smaller } 34 span.sc { font-variant:small-caps } 35 span.roman { font-family:serif; font-weight:normal; } 36 span.sansserif { font-family:sans-serif; font-weight:normal; } 37--></style> 38<link rel="stylesheet" type="text/css" href="../cs.css"> 39</head> 40<body> 41<div class="node"> 42<a name="Python-Auto-loading"></a> 43<a name="Python-Auto_002dloading"></a> 44<p> 45Next: <a rel="next" accesskey="n" href="Python-modules.html#Python-modules">Python modules</a>, 46Previous: <a rel="previous" accesskey="p" href="Python-API.html#Python-API">Python API</a>, 47Up: <a rel="up" accesskey="u" href="Python.html#Python">Python</a> 48<hr> 49</div> 50 51<h4 class="subsection">23.2.3 Python Auto-loading</h4> 52 53<p><a name="index-Python-auto_002dloading-2196"></a> 54When a new object file is read (for example, due to the <code>file</code> 55command, or because the inferior has loaded a shared library), 56<span class="sc">gdb</span> will look for Python support scripts in several ways: 57<samp><var>objfile</var><span class="file">-gdb.py</span></samp> (see <a href="objfile_002dgdb_002epy-file.html#objfile_002dgdb_002epy-file">objfile-gdb.py file</a>) 58and <code>.debug_gdb_scripts</code> section 59(see <a href="dotdebug_005fgdb_005fscripts-section.html#dotdebug_005fgdb_005fscripts-section">dotdebug_gdb_scripts section</a>). 60 61 <p>The auto-loading feature is useful for supplying application-specific 62debugging commands and scripts. 63 64 <p>Auto-loading can be enabled or disabled, 65and the list of auto-loaded scripts can be printed. 66 67 <dl> 68<a name="set-auto_002dload-python_002dscripts"></a><a name="index-set-auto_002dload-python_002dscripts-2197"></a><dt><code>set auto-load python-scripts [on|off]</code><dd>Enable or disable the auto-loading of Python scripts. 69 70 <p><a name="show-auto_002dload-python_002dscripts"></a><a name="index-show-auto_002dload-python_002dscripts-2198"></a><br><dt><code>show auto-load python-scripts</code><dd>Show whether auto-loading of Python scripts is enabled or disabled. 71 72 <p><a name="info-auto_002dload-python_002dscripts"></a><a name="index-info-auto_002dload-python_002dscripts-2199"></a><a name="index-print-list-of-auto_002dloaded-Python-scripts-2200"></a><br><dt><code>info auto-load python-scripts [</code><var>regexp</var><code>]</code><dd>Print the list of all Python scripts that <span class="sc">gdb</span> auto-loaded. 73 74 <p>Also printed is the list of Python scripts that were mentioned in 75the <code>.debug_gdb_scripts</code> section and were not found 76(see <a href="dotdebug_005fgdb_005fscripts-section.html#dotdebug_005fgdb_005fscripts-section">dotdebug_gdb_scripts section</a>). 77This is useful because their names are not printed when <span class="sc">gdb</span> 78tries to load them and fails. There may be many of them, and printing 79an error message for each one is problematic. 80 81 <p>If <var>regexp</var> is supplied only Python scripts with matching names are printed. 82 83 <p>Example: 84 85 <pre class="smallexample"> (gdb) info auto-load python-scripts 86 Loaded Script 87 Yes py-section-script.py 88 full name: /tmp/py-section-script.py 89 No my-foo-pretty-printers.py 90</pre> 91 </dl> 92 93 <p>When reading an auto-loaded file, <span class="sc">gdb</span> sets the 94<dfn>current objfile</dfn>. This is available via the <code>gdb.current_objfile</code> 95function (see <a href="Objfiles-In-Python.html#Objfiles-In-Python">Objfiles In Python</a>). This can be useful for 96registering objfile-specific pretty-printers and frame-filters. 97 98<ul class="menu"> 99<li><a accesskey="1" href="objfile_002dgdb_002epy-file.html#objfile_002dgdb_002epy-file">objfile-gdb.py file</a>: The <samp><var>objfile</var><span class="file">-gdb.py</span></samp> file 100<li><a accesskey="2" href="dotdebug_005fgdb_005fscripts-section.html#dotdebug_005fgdb_005fscripts-section">dotdebug_gdb_scripts section</a>: The <code>.debug_gdb_scripts</code> section 101<li><a accesskey="3" href="Which-flavor-to-choose_003f.html#Which-flavor-to-choose_003f">Which flavor to choose?</a> 102</ul> 103 104 </body></html> 105 106