1<html lang="en"> 2<head> 3<title>Python - 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="Extending-GDB.html#Extending-GDB" title="Extending GDB"> 9<link rel="prev" href="Sequences.html#Sequences" title="Sequences"> 10<link rel="next" href="Aliases.html#Aliases" title="Aliases"> 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"></a> 43<p> 44Next: <a rel="next" accesskey="n" href="Aliases.html#Aliases">Aliases</a>, 45Previous: <a rel="previous" accesskey="p" href="Sequences.html#Sequences">Sequences</a>, 46Up: <a rel="up" accesskey="u" href="Extending-GDB.html#Extending-GDB">Extending GDB</a> 47<hr> 48</div> 49 50<h3 class="section">23.2 Scripting <span class="sc">gdb</span> using Python</h3> 51 52<p><a name="index-python-scripting-1717"></a><a name="index-scripting-with-python-1718"></a> 53You can script <span class="sc">gdb</span> using the <a href="http://www.python.org/">Python programming language</a>. This feature is available only if 54<span class="sc">gdb</span> was configured using <samp><span class="option">--with-python</span></samp>. 55 56 <p><a name="index-python-directory-1719"></a>Python scripts used by <span class="sc">gdb</span> should be installed in 57<samp><var>data-directory</var><span class="file">/python</span></samp>, where <var>data-directory</var> is 58the data directory as determined at <span class="sc">gdb</span> startup (see <a href="Data-Files.html#Data-Files">Data Files</a>). 59This directory, known as the <dfn>python directory</dfn>, 60is automatically added to the Python Search Path in order to allow 61the Python interpreter to locate all scripts installed at this location. 62 63 <p>Additionally, <span class="sc">gdb</span> commands and convenience functions which 64are written in Python and are located in the 65<samp><var>data-directory</var><span class="file">/python/gdb/command</span></samp> or 66<samp><var>data-directory</var><span class="file">/python/gdb/function</span></samp> directories are 67automatically imported when <span class="sc">gdb</span> starts. 68 69<ul class="menu"> 70<li><a accesskey="1" href="Python-Commands.html#Python-Commands">Python Commands</a>: Accessing Python from <span class="sc">gdb</span>. 71<li><a accesskey="2" href="Python-API.html#Python-API">Python API</a>: Accessing <span class="sc">gdb</span> from Python. 72<li><a accesskey="3" href="Python-Auto_002dloading.html#Python-Auto_002dloading">Python Auto-loading</a>: Automatically loading Python code. 73<li><a accesskey="4" href="Python-modules.html#Python-modules">Python modules</a>: Python modules provided by <span class="sc">gdb</span>. 74</ul> 75 76 </body></html> 77 78