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: Finish Breakpoints in Python</title>
18
19<meta name="description" content="Debugging with GDB: Finish Breakpoints in Python">
20<meta name="keywords" content="Debugging with GDB: Finish Breakpoints in Python">
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="Python-API.html#Python-API" rel="up" title="Python API">
29<link href="Lazy-Strings-In-Python.html#Lazy-Strings-In-Python" rel="next" title="Lazy Strings In Python">
30<link href="Breakpoints-In-Python.html#Breakpoints-In-Python" rel="previous" title="Breakpoints In Python">
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="Finish-Breakpoints-in-Python"></a>
65<div class="header">
66<p>
67Next: <a href="Lazy-Strings-In-Python.html#Lazy-Strings-In-Python" accesskey="n" rel="next">Lazy Strings In Python</a>, Previous: <a href="Breakpoints-In-Python.html#Breakpoints-In-Python" accesskey="p" rel="previous">Breakpoints In Python</a>, Up: <a href="Python-API.html#Python-API" accesskey="u" rel="up">Python API</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>
68</div>
69<hr>
70<a name="Finish-Breakpoints"></a>
71<h4 class="subsubsection">23.2.2.31 Finish Breakpoints</h4>
72
73<a name="index-python-finish-breakpoints"></a>
74<a name="index-gdb_002eFinishBreakpoint"></a>
75
76<p>A finish breakpoint is a temporary breakpoint set at the return address of
77a frame, based on the <code>finish</code> command.  <code>gdb.FinishBreakpoint</code>
78extends <code>gdb.Breakpoint</code>.  The underlying breakpoint will be disabled
79and deleted when the execution will run out of the breakpoint scope (i.e.
80<code>Breakpoint.stop</code> or <code>FinishBreakpoint.out_of_scope</code> triggered).
81Finish breakpoints are thread specific and must be create with the right
82thread selected.
83</p>
84<dl>
85<dt><a name="index-FinishBreakpoint_002e_005f_005finit_005f_005f"></a>Function: <strong>FinishBreakpoint.__init__</strong> <em>(<span class="roman">[</span>frame<span class="roman">]</span> <span class="roman">[</span>, internal<span class="roman">]</span>)</em></dt>
86<dd><p>Create a finish breakpoint at the return address of the <code>gdb.Frame</code>
87object <var>frame</var>.  If <var>frame</var> is not provided, this defaults to the
88newest frame.  The optional <var>internal</var> argument allows the breakpoint to
89become invisible to the user.  See <a href="Breakpoints-In-Python.html#Breakpoints-In-Python">Breakpoints In Python</a>, for further
90details about this argument.
91</p></dd></dl>
92
93<dl>
94<dt><a name="index-FinishBreakpoint_002eout_005fof_005fscope"></a>Function: <strong>FinishBreakpoint.out_of_scope</strong> <em>(self)</em></dt>
95<dd><p>In some circumstances (e.g. <code>longjmp</code>, C<tt>++</tt> exceptions, <small>GDB</small>
96<code>return</code> command, &hellip;), a function may not properly terminate, and
97thus never hit the finish breakpoint.  When <small>GDB</small> notices such a
98situation, the <code>out_of_scope</code> callback will be triggered.
99</p>
100<p>You may want to sub-class <code>gdb.FinishBreakpoint</code> and override this
101method:
102</p>
103<div class="smallexample">
104<pre class="smallexample">class MyFinishBreakpoint (gdb.FinishBreakpoint)
105    def stop (self):
106        print &quot;normal finish&quot;
107        return True
108
109    def out_of_scope ():
110        print &quot;abnormal finish&quot;
111</pre></div>
112</dd></dl>
113
114<dl>
115<dt><a name="index-FinishBreakpoint_002ereturn_005fvalue"></a>Variable: <strong>FinishBreakpoint.return_value</strong></dt>
116<dd><p>When <small>GDB</small> is stopped at a finish breakpoint and the frame
117used to build the <code>gdb.FinishBreakpoint</code> object had debug symbols, this
118attribute will contain a <code>gdb.Value</code> object corresponding to the return
119value of the function.  The value will be <code>None</code> if the function return
120type is <code>void</code> or if the return value was not computable.  This attribute
121is not writable.
122</p></dd></dl>
123
124<hr>
125<div class="header">
126<p>
127Next: <a href="Lazy-Strings-In-Python.html#Lazy-Strings-In-Python" accesskey="n" rel="next">Lazy Strings In Python</a>, Previous: <a href="Breakpoints-In-Python.html#Breakpoints-In-Python" accesskey="p" rel="previous">Breakpoints In Python</a>, Up: <a href="Python-API.html#Python-API" accesskey="u" rel="up">Python API</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>
128</div>
129
130
131
132</body>
133</html>
134