Skip STL Code when debugging C++ Code in Visual Studio 2012?

五迷三道 提交于 2019-12-03 15:04:19

问题


Is it possible to skip STL Code when using the C++ debugger (native, x64) in Visual Studio 2012? Quite often when debugging C++ code I step into STL code. I expect that the STL code provided by Microsoft is correct - I am not interested in debugging it - I am only interested in debugging my own (self-written) code.

For instacne when setting a break point at this function:

foo(std::make_shared<int>(6));

where foo is defined as:

void foo(std::shared_ptr<int> x)
{
    // do something
}

I do not want to dive into the details of std::make_shared - what I want is to step directly into the function foo. But this seems not to be possible. If the breakpoint at foo(std::make_shared<int>(6)); is reached and I press the 'Step Into' button (or F11) it first steps into the 'memory' header file (STL):

So again I have to press the 'Step Out' button than again the 'Step Into' button to get into the foo function. What I want is to skip the STL related parameter initialization or a possibility to jump directly into the function.


回答1:


There's Step Into Specific available on the right-click menu:

Though for a single argument, I'll more often do Step Into + Step Out + Step Into from the keyboard instead of navigating the menus for Step Into Specific.

An unofficial registry key for always stepping over certain code is described in an MSDN blog post, How to Not Step Into Functions using the Visual C++ Debugger.




回答2:


With Visual Studio, whenever you are about to step into a function, you can actually right-click onto the statement and select in a cascaded menu called "Step Into Specific" the destination you want to reach. You can then bypass copy constructor/getter/etc. passed as argument to the function. See http://msdn.microsoft.com/en-us/library/7ad07721(v=vs.100).aspx for more information.




回答3:


There used to be a registry key to do that, but this has changed in VS2012:

Visual Studio 2012 (dev11) Everything has changed! Until the VC++ team put something on their blog (feel free to bug them to do this), take a peek at this file:

C:\Program Files[ (x86)]\Microsoft Visual Studio 11.0\Common7\Packages\Debugger\Visualizers\default.natstepfilter

For VS 2013 and 2015, the Just my code setting, known from .NET projects, was extended to work for native C++ too.




回答4:


Move the STL call (make_shared) outside of foo, and pass the result into foo. Then the breakpoint set on the call to foo should be beyond that STL code. Otherwise could you not put the breakpoint inside the foo definition itself?



来源:https://stackoverflow.com/questions/20352426/skip-stl-code-when-debugging-c-code-in-visual-studio-2012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!