MSVS Lifehacks, Part 1 - Debugger. Step by Step Management

    Many of us use the Visual Studio 2010 debugger, however, I can bet that most are not aware that it has additional undocumented settings that make debugging easier.

    In this article I will tell you how to get rid of the constant getting inside the library code during step-by-step Step-In execution. This is for seed. Later I will describe the mechanism for controlling the representation of types in debug windows like locals and watch (everyone saw how beautifully the vectors / maps are displayed there, etc.?).

    Please note that the main focus will be on debugging Native code.

    And so, let's get started.

    If you have already switched to C ++ 11, then you should be familiar with lines of code like the following:
    do_something (std :: move (some_obj));
    Well, or such:
    do_something (std :: forward <T1> (rr1), std :: forward <T2> (rr2), std :: forward <T3> (rr3));

    At least I see such things when debugging quite often. And this is what infuriates: you stand on such a call, you want to press F11 and get inside do_something, but no! first, we get inside all of these std :: move and std :: forward, and only then wherever we want.

    Take at least the second example (with three calls to std :: forward).
    To get inside do_something you need to press F10, F10, F10, F11. This is the fastest way. Only nobody uses it: it’s easy to make a mistake with the amount of F10 and “step through” the desired call. Therefore, click Step In, Step Out until we get to the right place. It turns out F11, Shift-F11, F11, Shift-F11, F11, Shift-F11, F11 - some kind of horror! And even so, personally I regularly miss the right call.

    And then one day I got tired of it. It would be nice if Step In ignored some functions, at least move and forward (what did I not see in them?), I thought. And he began to search.

    It quickly became clear that there is such an option for .NET - “Just my code”, “Step over properties and operators”, “Enable .NET framework source stepping”, and it can even be manually configured via attributes . For native code there are no such parameters ... or is there?

    It turned out that there is still. In the registry, unofficial.

    Step-by-step execution: undocumented functions of the native code debugger.


    We will be interested in the branch:
    HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ VisualStudio \ 10.0 \ NativeDE \ StepOver - for x86
    HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ VisualStudio \ 10.0 \ NativeDE \ StepOver - for x64

    This branch contains parameters like "string" which does not play any role, but the value determines the behavior of the debugger.

    The meaning syntax is as follows:
    <regular expression matching function name> [= NoStepInto]

    "= NoStepInto" means that the debugger should never go inside the specified function. You can safely omit "= NoStepInto", tk. this is the default behavior, and I don’t know the other "instructions" to the debugger.

    The regular expression syntax is the same as in the search , plus the following commands:
    "cid:" - C / C ++ name of the identifier
    "funct:" - Name of the C / C ++ function (it seems this is the same as cid :)
    "scope:" - A set of class /
                        namespace identifiers for the function (for example, ATL :: CFoo :: CBar: :)
                        "scope:" cannot match the empty string
    "anything:" - Any string, incl. and without the quotes
    "oper:" - C ++ operator (for example, "*")

    Examples:

    Do not enter std :: forward:
    std \: \: forward \ <. * \>
    Do not enter std :: move:
    std \: \: move \ <. * \>
    Do not enter the functions of the test namespace:
    test \: \: funct \:
    Do not enter overloaded operators:
    \ scope: operator \ oper:

    Additional notes:

    • Visual Studio reads the settings at startup, so in order for them to take effect, the studio will have to be restarted.
    • If you really want to get inside a function that has already been entered "into the registry", you can do this either by setting a breakpoint inside it, or by doing Step In in the disassembly window.

    Conclusion:

    Hallelujah! By editing the registry, we will never get into std :: forward again! Now, when you press F11, we get right where we wanted: inside our code.

    A spoon of tar.


    Let's say we want to not get inside stl and, at the same time, boost. Easy! Add the appropriate lines to the registry ... But what if you want to press F11 on this code:
    std :: sort (vec.begin (), vec.end (), my_pred ());
    did we get inside my_pred :: operator () if it is called?

    How to make it possible to control whether we want to get into the function at the source code level when debugging (in C # this is done through attributes)?

    Read in the next series.

    Also popular now: