If your call stack seems to be missing routines, you may be seeing the result of a compiler optimization known as tail calls. When a function calls another function, typically it saves the return address and the caller's registers on the stack before making a call, so that the callee can know where to return to once it is done. A new stack frame is also created for the callee. If the caller's last operation is to call the callee, and the callee's return value is used as the return value for the caller, the compiler may convert the call to a branch or jump to the callee. This is a tail call optimization and allows the callee to directly return results to the caller. In this case, the stack does not change and the caller function's stack frame is reused, which saves time and stack space. However, since no new frames are added, stack frames can be missing from the stack trace, which can ultimately adversely affect debugging.
Copyright © 2001-2011, Intel Corporation. All rights reserved.