开发者

Weird difference in callstack between release and debug

开发者 https://www.devze.com 2023-04-13 01:05 出处:网络
I\'m trying to walk the stack of this sample program: #include <windows.h> void Func1() { Sleep(1000);

I'm trying to walk the stack of this sample program:

#include <windows.h>

void Func1()
{
    Sleep(1000);
}

void开发者_JS百科 Func2()
{
    Sleep(1000);
    Func1();
}

void Func3()
{
    Sleep(1000);
    Func2();
}

void main()
{
    for (int i = 0; i < 100; i++)
    {
        Func3();
    }
}

In debug mode I get what you'd expect. Something like:

Sleep

Func3

main

In release mode (with frame pointer optimization enabled) I get the stack:

Sleep

main

Where did the function between "main" and "sleep" go in the release run?


The function was inlined.
I simply change the "Inline Function Expansion" to Only_inline (in VS2008) and the missing function appears. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号