1<html lang="en"> 2<head> 3<title>Finish Breakpoints in 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="Python-API.html#Python-API" title="Python API"> 9<link rel="prev" href="Breakpoints-In-Python.html#Breakpoints-In-Python" title="Breakpoints In Python"> 10<link rel="next" href="Lazy-Strings-In-Python.html#Lazy-Strings-In-Python" title="Lazy Strings In Python"> 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="Finish-Breakpoints-in-Python"></a> 43<p> 44Next: <a rel="next" accesskey="n" href="Lazy-Strings-In-Python.html#Lazy-Strings-In-Python">Lazy Strings In Python</a>, 45Previous: <a rel="previous" accesskey="p" href="Breakpoints-In-Python.html#Breakpoints-In-Python">Breakpoints In Python</a>, 46Up: <a rel="up" accesskey="u" href="Python-API.html#Python-API">Python API</a> 47<hr> 48</div> 49 50<h5 class="subsubsection">23.2.2.25 Finish Breakpoints</h5> 51 52<p><a name="index-python-finish-breakpoints-2181"></a><a name="index-gdb_002eFinishBreakpoint-2182"></a> 53A finish breakpoint is a temporary breakpoint set at the return address of 54a frame, based on the <code>finish</code> command. <code>gdb.FinishBreakpoint</code> 55extends <code>gdb.Breakpoint</code>. The underlying breakpoint will be disabled 56and deleted when the execution will run out of the breakpoint scope (i.e. 57<code>Breakpoint.stop</code> or <code>FinishBreakpoint.out_of_scope</code> triggered). 58Finish breakpoints are thread specific and must be create with the right 59thread selected. 60 61<div class="defun"> 62— Function: <b>FinishBreakpoint.__init__</b> (<span class="roman">[</span><var>frame</var><span class="roman">]</span> <span class="roman">[</span><var>, internal</var><span class="roman">]</span>)<var><a name="index-FinishBreakpoint_002e_005f_005finit_005f_005f-2183"></a></var><br> 63<blockquote><p>Create a finish breakpoint at the return address of the <code>gdb.Frame</code> 64object <var>frame</var>. If <var>frame</var> is not provided, this defaults to the 65newest frame. The optional <var>internal</var> argument allows the breakpoint to 66become invisible to the user. See <a href="Breakpoints-In-Python.html#Breakpoints-In-Python">Breakpoints In Python</a>, for further 67details about this argument. 68</p></blockquote></div> 69 70<div class="defun"> 71— Function: <b>FinishBreakpoint.out_of_scope</b> (<var>self</var>)<var><a name="index-FinishBreakpoint_002eout_005fof_005fscope-2184"></a></var><br> 72<blockquote><p>In some circumstances (e.g. <code>longjmp</code>, C<tt>++</tt> exceptions, <span class="sc">gdb</span> 73<code>return</code> command, <small class="dots">...</small>), a function may not properly terminate, and 74thus never hit the finish breakpoint. When <span class="sc">gdb</span> notices such a 75situation, the <code>out_of_scope</code> callback will be triggered. 76 77 <p>You may want to sub-class <code>gdb.FinishBreakpoint</code> and override this 78method: 79 80 <pre class="smallexample"> class MyFinishBreakpoint (gdb.FinishBreakpoint) 81 def stop (self): 82 print "normal finish" 83 return True 84 85 def out_of_scope (): 86 print "abnormal finish" 87</pre> 88 </blockquote></div> 89 90<div class="defun"> 91— Variable: <b>FinishBreakpoint.return_value</b><var><a name="index-FinishBreakpoint_002ereturn_005fvalue-2185"></a></var><br> 92<blockquote><p>When <span class="sc">gdb</span> is stopped at a finish breakpoint and the frame 93used to build the <code>gdb.FinishBreakpoint</code> object had debug symbols, this 94attribute will contain a <code>gdb.Value</code> object corresponding to the return 95value of the function. The value will be <code>None</code> if the function return 96type is <code>void</code> or if the return value was not computable. This attribute 97is not writable. 98</p></blockquote></div> 99 100 </body></html> 101 102