168 lines
8.3 KiB
HTML
168 lines
8.3 KiB
HTML
<html lang="en">
|
|
<head>
|
|
<title>Inferiors In Python - Debugging with GDB</title>
|
|
<meta http-equiv="Content-Type" content="text/html">
|
|
<meta name="description" content="Debugging with GDB">
|
|
<meta name="generator" content="makeinfo 4.13">
|
|
<link title="Top" rel="start" href="index.html#Top">
|
|
<link rel="up" href="Python-API.html#Python-API" title="Python API">
|
|
<link rel="prev" href="Writing-an-Xmethod.html#Writing-an-Xmethod" title="Writing an Xmethod">
|
|
<link rel="next" href="Events-In-Python.html#Events-In-Python" title="Events In Python">
|
|
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
|
|
<!--
|
|
Copyright (C) 1988-2019 Free Software Foundation, Inc.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with the
|
|
Invariant Sections being ``Free Software'' and ``Free Software Needs
|
|
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
|
|
and with the Back-Cover Texts as in (a) below.
|
|
|
|
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
|
|
this GNU Manual. Buying copies from GNU Press supports the FSF in
|
|
developing GNU and promoting software freedom.''
|
|
-->
|
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
<style type="text/css"><!--
|
|
pre.display { font-family:inherit }
|
|
pre.format { font-family:inherit }
|
|
pre.smalldisplay { font-family:inherit; font-size:smaller }
|
|
pre.smallformat { font-family:inherit; font-size:smaller }
|
|
pre.smallexample { font-size:smaller }
|
|
pre.smalllisp { font-size:smaller }
|
|
span.sc { font-variant:small-caps }
|
|
span.roman { font-family:serif; font-weight:normal; }
|
|
span.sansserif { font-family:sans-serif; font-weight:normal; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
<div class="node">
|
|
<a name="Inferiors-In-Python"></a>
|
|
<p>
|
|
Next: <a rel="next" accesskey="n" href="Events-In-Python.html#Events-In-Python">Events In Python</a>,
|
|
Previous: <a rel="previous" accesskey="p" href="Writing-an-Xmethod.html#Writing-an-Xmethod">Writing an Xmethod</a>,
|
|
Up: <a rel="up" accesskey="u" href="Python-API.html#Python-API">Python API</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h5 class="subsubsection">23.2.2.16 Inferiors In Python</h5>
|
|
|
|
<p><a name="index-inferiors-in-Python-2052"></a>
|
|
<a name="index-gdb_002eInferior-2053"></a>Programs which are being run under <span class="sc">gdb</span> are called inferiors
|
|
(see <a href="Inferiors-and-Programs.html#Inferiors-and-Programs">Inferiors and Programs</a>). Python scripts can access
|
|
information about and manipulate inferiors controlled by <span class="sc">gdb</span>
|
|
via objects of the <code>gdb.Inferior</code> class.
|
|
|
|
<p>The following inferior-related functions are available in the <code>gdb</code>
|
|
module:
|
|
|
|
<div class="defun">
|
|
— Function: <b>gdb.inferiors</b> ()<var><a name="index-gdb_002einferiors-2054"></a></var><br>
|
|
<blockquote><p>Return a tuple containing all inferior objects.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Function: <b>gdb.selected_inferior</b> ()<var><a name="index-gdb_002eselected_005finferior-2055"></a></var><br>
|
|
<blockquote><p>Return an object representing the current inferior.
|
|
</p></blockquote></div>
|
|
|
|
<p>A <code>gdb.Inferior</code> object has the following attributes:
|
|
|
|
<div class="defun">
|
|
— Variable: <b>Inferior.num</b><var><a name="index-Inferior_002enum-2056"></a></var><br>
|
|
<blockquote><p>ID of inferior, as assigned by GDB.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Variable: <b>Inferior.pid</b><var><a name="index-Inferior_002epid-2057"></a></var><br>
|
|
<blockquote><p>Process ID of the inferior, as assigned by the underlying operating
|
|
system.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Variable: <b>Inferior.was_attached</b><var><a name="index-Inferior_002ewas_005fattached-2058"></a></var><br>
|
|
<blockquote><p>Boolean signaling whether the inferior was created using `attach', or
|
|
started by <span class="sc">gdb</span> itself.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Variable: <b>Inferior.progspace</b><var><a name="index-Inferior_002eprogspace-2059"></a></var><br>
|
|
<blockquote><p>The inferior's program space. See <a href="Progspaces-In-Python.html#Progspaces-In-Python">Progspaces In Python</a>.
|
|
</p></blockquote></div>
|
|
|
|
<p>A <code>gdb.Inferior</code> object has the following methods:
|
|
|
|
<div class="defun">
|
|
— Function: <b>Inferior.is_valid</b> ()<var><a name="index-Inferior_002eis_005fvalid-2060"></a></var><br>
|
|
<blockquote><p>Returns <code>True</code> if the <code>gdb.Inferior</code> object is valid,
|
|
<code>False</code> if not. A <code>gdb.Inferior</code> object will become invalid
|
|
if the inferior no longer exists within <span class="sc">gdb</span>. All other
|
|
<code>gdb.Inferior</code> methods will throw an exception if it is invalid
|
|
at the time the method is called.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Function: <b>Inferior.threads</b> ()<var><a name="index-Inferior_002ethreads-2061"></a></var><br>
|
|
<blockquote><p>This method returns a tuple holding all the threads which are valid
|
|
when it is called. If there are no valid threads, the method will
|
|
return an empty tuple.
|
|
</p></blockquote></div>
|
|
|
|
<div class="defun">
|
|
— Function: <b>Inferior.architecture</b> ()<var><a name="index-Inferior_002earchitecture-2062"></a></var><br>
|
|
<blockquote><p>Return the <code>gdb.Architecture</code> (see <a href="Architectures-In-Python.html#Architectures-In-Python">Architectures In Python</a>)
|
|
for this inferior. This represents the architecture of the inferior
|
|
as a whole. Some platforms can have multiple architectures in a
|
|
single address space, so this may not match the architecture of a
|
|
particular frame (see <a href="Frames-In-Python.html#Frames-In-Python">Frames In Python</a>).
|
|
</p></blockquote></div>
|
|
|
|
<p><a name="index-Inferior_002eread_005fmemory-2063"></a>
|
|
|
|
<div class="defun">
|
|
— Function: <b>Inferior.read_memory</b> (<var>address, length</var>)<var><a name="index-Inferior_002eread_005fmemory-2064"></a></var><br>
|
|
<blockquote><p>Read <var>length</var> addressable memory units from the inferior, starting at
|
|
<var>address</var>. Returns a buffer object, which behaves much like an array
|
|
or a string. It can be modified and given to the
|
|
<code>Inferior.write_memory</code> function. In Python 3, the return
|
|
value is a <code>memoryview</code> object.
|
|
</p></blockquote></div>
|
|
|
|
<p><a name="index-Inferior_002ewrite_005fmemory-2065"></a>
|
|
|
|
<div class="defun">
|
|
— Function: <b>Inferior.write_memory</b> (<var>address, buffer </var><span class="roman">[</span><var>, length</var><span class="roman">]</span>)<var><a name="index-Inferior_002ewrite_005fmemory-2066"></a></var><br>
|
|
<blockquote><p>Write the contents of <var>buffer</var> to the inferior, starting at
|
|
<var>address</var>. The <var>buffer</var> parameter must be a Python object
|
|
which supports the buffer protocol, i.e., a string, an array or the
|
|
object returned from <code>Inferior.read_memory</code>. If given, <var>length</var>
|
|
determines the number of addressable memory units from <var>buffer</var> to be
|
|
written.
|
|
</p></blockquote></div>
|
|
|
|
<p><a name="index-gdb_002esearch_005fmemory-2067"></a>
|
|
|
|
<div class="defun">
|
|
— Function: <b>Inferior.search_memory</b> (<var>address, length, pattern</var>)<var><a name="index-Inferior_002esearch_005fmemory-2068"></a></var><br>
|
|
<blockquote><p>Search a region of the inferior memory starting at <var>address</var> with
|
|
the given <var>length</var> using the search pattern supplied in
|
|
<var>pattern</var>. The <var>pattern</var> parameter must be a Python object
|
|
which supports the buffer protocol, i.e., a string, an array or the
|
|
object returned from <code>gdb.read_memory</code>. Returns a Python <code>Long</code>
|
|
containing the address where the pattern was found, or <code>None</code> if
|
|
the pattern could not be found.
|
|
</p></blockquote></div>
|
|
|
|
<p><a name="index-Inferior_002ethread_005ffrom_005fthread_005fhandle-2069"></a>
|
|
|
|
<div class="defun">
|
|
— Function: <b>Inferior.thread_from_thread_handle</b> (<var>thread_handle</var>)<var><a name="index-Inferior_002ethread_005ffrom_005fthread_005fhandle-2070"></a></var><br>
|
|
<blockquote><p>Return the thread object corresponding to <var>thread_handle</var>, a thread
|
|
library specific data structure such as <code>pthread_t</code> for pthreads
|
|
library implementations.
|
|
</p></blockquote></div>
|
|
|
|
</body></html>
|
|
|