| <html lang="en"> |
| <head> |
| <title>Calling - 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="Altering.html#Altering" title="Altering"> |
| <link rel="prev" href="Returning.html#Returning" title="Returning"> |
| <link rel="next" href="Patching.html#Patching" title="Patching"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, |
| 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
| 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> |
| <link rel="stylesheet" type="text/css" href="../cs.css"> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Calling"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="Patching.html#Patching">Patching</a>, |
| Previous: <a rel="previous" accesskey="p" href="Returning.html#Returning">Returning</a>, |
| Up: <a rel="up" accesskey="u" href="Altering.html#Altering">Altering</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">17.5 Calling Program Functions</h3> |
| |
| |
| <a name="index-calling-functions-933"></a> |
| <a name="index-inferior-functions_002c-calling-934"></a> |
| <dl><dt><code>print </code><var>expr</var><dd>Evaluate the expression <var>expr</var> and display the resulting value. |
| <var>expr</var> may include calls to functions in the program being |
| debugged. |
| |
| <p><a name="index-call-935"></a><br><dt><code>call </code><var>expr</var><dd>Evaluate the expression <var>expr</var> without displaying <code>void</code> |
| returned values. |
| |
| <p>You can use this variant of the <code>print</code> command if you want to |
| execute a function from your program that does not return anything |
| (a.k.a. <dfn>a void function</dfn>), but without cluttering the output |
| with <code>void</code> returned values that <span class="sc">gdb</span> will otherwise |
| print. If the result is not void, it is printed and saved in the |
| value history. |
| </dl> |
| |
| <p>It is possible for the function you call via the <code>print</code> or |
| <code>call</code> command to generate a signal (e.g., if there's a bug in |
| the function, or if you passed it incorrect arguments). What happens |
| in that case is controlled by the <code>set unwindonsignal</code> command. |
| |
| <p>Similarly, with a C<tt>++</tt> program it is possible for the function you |
| call via the <code>print</code> or <code>call</code> command to generate an |
| exception that is not handled due to the constraints of the dummy |
| frame. In this case, any exception that is raised in the frame, but has |
| an out-of-frame exception handler will not be found. GDB builds a |
| dummy-frame for the inferior function call, and the unwinder cannot |
| seek for exception handlers outside of this dummy-frame. What happens |
| in that case is controlled by the |
| <code>set unwind-on-terminating-exception</code> command. |
| |
| <dl> |
| <dt><code>set unwindonsignal</code><dd><a name="index-set-unwindonsignal-936"></a><a name="index-unwind-stack-in-called-functions-937"></a><a name="index-call-dummy-stack-unwinding-938"></a>Set unwinding of the stack if a signal is received while in a function |
| that <span class="sc">gdb</span> called in the program being debugged. If set to on, |
| <span class="sc">gdb</span> unwinds the stack it created for the call and restores |
| the context to what it was before the call. If set to off (the |
| default), <span class="sc">gdb</span> stops in the frame where the signal was |
| received. |
| |
| <br><dt><code>show unwindonsignal</code><dd><a name="index-show-unwindonsignal-939"></a>Show the current setting of stack unwinding in the functions called by |
| <span class="sc">gdb</span>. |
| |
| <br><dt><code>set unwind-on-terminating-exception</code><dd><a name="index-set-unwind_002don_002dterminating_002dexception-940"></a><a name="index-unwind-stack-in-called-functions-with-unhandled-exceptions-941"></a><a name="index-call-dummy-stack-unwinding-on-unhandled-exception_002e-942"></a>Set unwinding of the stack if a C<tt>++</tt> exception is raised, but left |
| unhandled while in a function that <span class="sc">gdb</span> called in the program being |
| debugged. If set to on (the default), <span class="sc">gdb</span> unwinds the stack |
| it created for the call and restores the context to what it was before |
| the call. If set to off, <span class="sc">gdb</span> the exception is delivered to |
| the default C<tt>++</tt> exception handler and the inferior terminated. |
| |
| <br><dt><code>show unwind-on-terminating-exception</code><dd><a name="index-show-unwind_002don_002dterminating_002dexception-943"></a>Show the current setting of stack unwinding in the functions called by |
| <span class="sc">gdb</span>. |
| |
| </dl> |
| |
| <p><a name="index-weak-alias-functions-944"></a>Sometimes, a function you wish to call is actually a <dfn>weak alias</dfn> |
| for another function. In such case, <span class="sc">gdb</span> might not pick up |
| the type information, including the types of the function arguments, |
| which causes <span class="sc">gdb</span> to call the inferior function incorrectly. |
| As a result, the called function will function erroneously and may |
| even crash. A solution to that is to use the name of the aliased |
| function instead. |
| |
| </body></html> |
| |