📄 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.6"><!--Copyright © 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. <p>Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being "GNU General Public License" and "FundingFree Software", the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below). A copy of the license isincluded 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.--><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 }--></style></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 afunction.<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 ofone of its callers. The <var>level</var> argument is number of frames toscan up the call stack. A value of <code>0</code> yields the return addressof the current function, a value of <code>1</code> yields the return addressof the caller of the current function, and so forth. When inliningthe expected behavior is that the function will return the address ofthe function that will be returned to. To work around this behavior usethe <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 ofany function other than the current one; in such cases, or when the topof the stack has been reached, this function will return <code>0</code> or arandom value. In addition, <code>__builtin_frame_address</code> may be usedto determine if the top of the stack has been reached. <p>This function should only be used with a nonzero argument for debuggingpurposes. </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 itreturns the address of the function frame rather than the return addressof 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 savedregisters. The frame address is normally the address of the first wordpushed on to the stack by the function. However, the exact definitiondepends upon the processor and the calling convention. If the processorhas a dedicated frame pointer register, and the function has a frame,then <code>__builtin_frame_address</code> will return the value of the framepointer register. <p>On some machines it may be impossible to determine the frame address ofany function other than the current one; in such cases, or when the topof the stack has been reached, this function will return <code>0</code> ifthe first frame pointer is properly initialized by the startup code. <p>This function should only be used with a nonzero argument for debuggingpurposes. </td></tr></table> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -