📄 return-address.html
字号:
<html lang="en">
<head>
<title>Using the GNU Compiler Collection (GCC)</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using the GNU Compiler Collection (GCC)">
<meta name="generator" content="makeinfo 4.3">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
<!--
Copyright © 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
<p>Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "GNU General Public License" and "Funding
Free Software", the Front-Cover texts being (a) (see below), and with
the Back-Cover Texts being (b) (see below). A copy of the license is
included in the section entitled "GNU Free Documentation License".
<p>(a) The FSF's Front-Cover Text is:
<p>A GNU Manual
<p>(b) The FSF's Back-Cover Text is:
<p>You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.-->
</head>
<body>
<div class="node">
<p>
Node:<a name="Return%20Address">Return Address</a>,
Next:<a rel="next" accesskey="n" href="Vector-Extensions.html#Vector%20Extensions">Vector Extensions</a>,
Previous:<a rel="previous" accesskey="p" href="Function-Names.html#Function%20Names">Function Names</a>,
Up:<a rel="up" accesskey="u" href="C-Extensions.html#C%20Extensions">C Extensions</a>
<hr><br>
</div>
<h3 class="section">Getting the Return or Frame Address of a Function</h3>
<p>These functions may be used to get information about the callers of a
function.
<p>
<table width="100%">
<tr>
<td align="left">void * <b>__builtin_return_address</b><i> </i>(<i>unsigned int </i><var>level</var><i></i>)<i>
</i></td>
<td align="right">Built-in Function</td>
</tr>
</table>
<table width="95%" align="center">
<tr><td>
This function returns the return address of the current function, or of
one of its callers. The <var>level</var> argument is number of frames to
scan up the call stack. A value of <code>0</code> yields the return address
of the current function, a value of <code>1</code> yields the return address
of the caller of the current function, and so forth. When inlining
the expected behavior is that the function will return the address of
the function that will be returned to. To work around this behavior use
the <code>noinline</code> function attribute.
<p>The <var>level</var> argument must be a constant integer.
<p>On some machines it may be impossible to determine the return address of
any function other than the current one; in such cases, or when the top
of the stack has been reached, this function will return <code>0</code> or a
random value. In addition, <code>__builtin_frame_address</code> may be used
to determine if the top of the stack has been reached.
<p>This function should only be used with a nonzero argument for debugging
purposes.
</td></tr>
</table>
<p>
<table width="100%">
<tr>
<td align="left">void * <b>__builtin_frame_address</b><i> </i>(<i>unsigned int </i><var>level</var><i></i>)<i>
</i></td>
<td align="right">Built-in Function</td>
</tr>
</table>
<table width="95%" align="center">
<tr><td>
This function is similar to <code>__builtin_return_address</code>, but it
returns the address of the function frame rather than the return address
of the function. Calling <code>__builtin_frame_address</code> with a value of
<code>0</code> yields the frame address of the current function, a value of
<code>1</code> yields the frame address of the caller of the current function,
and so forth.
<p>The frame is the area on the stack which holds local variables and saved
registers. The frame address is normally the address of the first word
pushed on to the stack by the function. However, the exact definition
depends upon the processor and the calling convention. If the processor
has a dedicated frame pointer register, and the function has a frame,
then <code>__builtin_frame_address</code> will return the value of the frame
pointer register.
<p>On some machines it may be impossible to determine the frame address of
any function other than the current one; in such cases, or when the top
of the stack has been reached, this function will return <code>0</code> if
the first frame pointer is properly initialized by the startup code.
<p>This function should only be used with a nonzero argument for debugging
purposes.
</td></tr>
</table>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -