c++visual-studiodebugging

What is Inline Frame in c++/VS?


I'm debugging some c++ code. In call stack I have calls with [Inline Frame] before them, what is that and how it's different from normal calls? I'm using Visual Studio 2022 (if you down voting then say why, if it's so trivial then answer, I couldn't find answer anywhere on the internet)


Solution

  • I consider it should be inline function frame.

    The document also mentions:

    The GetStackTraceEx method provides inline frame support. For more information about working with inline functions, see Debugging Optimized Code and Inline Functions.

    Sample: https://developercommunity.visualstudio.com/t/Inconsistent-debug-information-for-inlin/10582059

    #include <cassert>
    #include <iostream>
    #include <set>
    
    using namespace std;
    
    __forceinline void test3(size_t len, set<double>& s) {
        s.insert(0.0);
        while (s.size() < len) {
            auto it = s.rbegin();
            double last = *it;
            s.insert(last + 1.0);
        }
    }
    
    __forceinline void test2(size_t len) {
        set <double> s;
        for (int i = 0; i < 100000000; i++) {
            test3(len, s);
        }
        cout << "last: " << *(s.rbegin()) << " size: " << s.size() << endl;
    }
    
    __declspec(noinline) void test(size_t len) {
        test2(len);
    }
    
    #pragma optimize("", off)
    
    int main(int argc, char** args)
    {
        test(1000000);
        return 0;
    }
    
    #pragma optimize("", on)
    

    Compile the code: cl source.cpp /Zi /O2 /GL

    [inline frame] appears to the left of functions test2 and test3.