Recording a call stack in Visual Studio

I am trying to debug a really big C ++ / c program in Visual Studio. Changing the value of one parameter dramatically changes the result. I want to record call stacks for both runs and distinguish between them.

Does anyone know how to drop call stack to file in VS without setting breakpoints and use Select ALL / Copy in the window?

Thanks.

+3
source share
2 answers

Take a look at this codeproject example that uses the StackWalk64 API.

+2
source

System.Diagnostics.StackTrace, . :

private static writeStack(string file)
{
    StackTrace trace = new StackTrace(true); // the "true" param here allows you to get the file name, etc.
    using (StreamWriter writer = new StreamWriter(file))
    {
    for (int i = 0; i < trace.FrameCount; i++)
        {
            StackFrame frame = trace.GetFrame(i);
            writer.WriteLine("{0}\t{1}\t{2}", frame.GetFileName(), frame.GetFileLineNumber(), frame.GetMethod());
        }
    }
}

, , writeStack(somePath).

+2

Source: https://habr.com/ru/post/1720018/


All Articles