You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
6.4 KiB
HTML
134 lines
6.4 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- 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." -->
|
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Inline Functions (Debugging with GDB)</title>
|
|
|
|
<meta name="description" content="Inline Functions (Debugging with GDB)">
|
|
<meta name="keywords" content="Inline Functions (Debugging with GDB)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link href="index.html#Top" rel="start" title="Top">
|
|
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Optimized-Code.html#Optimized-Code" rel="up" title="Optimized Code">
|
|
<link href="Tail-Call-Frames.html#Tail-Call-Frames" rel="next" title="Tail Call Frames">
|
|
<link href="Optimized-Code.html#Optimized-Code" rel="prev" title="Optimized Code">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
div.smalllisp {margin-left: 3.2em}
|
|
kbd {font-style: oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
|
pre.smallexample {font-size: smaller}
|
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
|
pre.smalllisp {font-size: smaller}
|
|
span.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<a name="Inline-Functions"></a>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Tail-Call-Frames.html#Tail-Call-Frames" accesskey="n" rel="next">Tail Call Frames</a>, Up: <a href="Optimized-Code.html#Optimized-Code" accesskey="u" rel="up">Optimized Code</a> [<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>
|
|
</div>
|
|
<hr>
|
|
<a name="Inline-Functions-1"></a>
|
|
<h3 class="section">11.1 Inline Functions</h3>
|
|
<a name="index-inline-functions_002c-debugging"></a>
|
|
|
|
<p><em>Inlining</em> is an optimization that inserts a copy of the function
|
|
body directly at each call site, instead of jumping to a shared
|
|
routine. <small>GDB</small> displays inlined functions just like
|
|
non-inlined functions. They appear in backtraces. You can view their
|
|
arguments and local variables, step into them with <code>step</code>, skip
|
|
them with <code>next</code>, and escape from them with <code>finish</code>.
|
|
You can check whether a function was inlined by using the
|
|
<code>info frame</code> command.
|
|
</p>
|
|
<p>For <small>GDB</small> to support inlined functions, the compiler must
|
|
record information about inlining in the debug information —
|
|
<small>GCC</small> using the <small>DWARF 2</small> format does this, and several
|
|
other compilers do also. <small>GDB</small> only supports inlined functions
|
|
when using <small>DWARF 2</small>. Versions of <small>GCC</small> before 4.1
|
|
do not emit two required attributes (‘<samp>DW_AT_call_file</samp>’ and
|
|
‘<samp>DW_AT_call_line</samp>’); <small>GDB</small> does not display inlined
|
|
function calls with earlier versions of <small>GCC</small>. It instead
|
|
displays the arguments and local variables of inlined functions as
|
|
local variables in the caller.
|
|
</p>
|
|
<p>The body of an inlined function is directly included at its call site;
|
|
unlike a non-inlined function, there are no instructions devoted to
|
|
the call. <small>GDB</small> still pretends that the call site and the
|
|
start of the inlined function are different instructions. Stepping to
|
|
the call site shows the call site, and then stepping again shows
|
|
the first line of the inlined function, even though no additional
|
|
instructions are executed.
|
|
</p>
|
|
<p>This makes source-level debugging much clearer; you can see both the
|
|
context of the call and then the effect of the call. Only stepping by
|
|
a single instruction using <code>stepi</code> or <code>nexti</code> does not do
|
|
this; single instruction steps always show the inlined body.
|
|
</p>
|
|
<p>There are some ways that <small>GDB</small> does not pretend that inlined
|
|
function calls are the same as normal calls:
|
|
</p>
|
|
<ul>
|
|
<li> Setting breakpoints at the call site of an inlined function may not
|
|
work, because the call site does not contain any code. <small>GDB</small>
|
|
may incorrectly move the breakpoint to the next line of the enclosing
|
|
function, after the call. This limitation will be removed in a future
|
|
version of <small>GDB</small>; until then, set a breakpoint on an earlier line
|
|
or inside the inlined function instead.
|
|
|
|
</li><li> <small>GDB</small> cannot locate the return value of inlined calls after
|
|
using the <code>finish</code> command. This is a limitation of compiler-generated
|
|
debugging information; after <code>finish</code>, you can step to the next line
|
|
and print a variable where your program stored the return value.
|
|
|
|
</li></ul>
|
|
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
Next: <a href="Tail-Call-Frames.html#Tail-Call-Frames" accesskey="n" rel="next">Tail Call Frames</a>, Up: <a href="Optimized-Code.html#Optimized-Code" accesskey="u" rel="up">Optimized Code</a> [<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>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|