Share via


How to: Step Into Just My Code

This topic applies to:

Edition

Visual Basic

C#

F#

C++

Web Developer

Express

Topic applies Topic applies

Topic applies

Managed Only

Topic applies

Pro, Premium, and Ultimate

Topic applies Topic applies

Topic applies

Managed Only

Topic applies

Sometimes, while you are debugging, you might want to look at only the code you have written and ignore other code, such as system calls. You can do this with Just My Code debugging. Just My Code hides non-user code so that it does not appear in the debugger windows. When you step, the debugger steps through any non-user code but does not stop in it.

To distinguish user code from non-user code, Just My Code looks at three things: DBG Files, PDB files, and optimization.

In a standard Debug build, optimization is turned off and debug symbols are created for all modules. When you run a debug build, those modules are considered to be user code. If I call a library function that is optimized and does not have debug symbols, however, it is not user code. Just My Code prevents execution from stopping at breakpoints in the library code, which is usually not code you are interested in debugging. In the Breakpoints window, those breakpoints will appear with the Disabled Breakpoint icon.

To see all code and stop at all breakpoints, you can turn Just My Code debugging off by using the Options dialog box.

Three attributes also affect what the debugger considers to be My Code: DebuggerNonUserCodeAttribute tells the debugger that the code it is applied to is not My Code. DebuggerHiddenAttribute hides the code from the debugger, even if Just My Code is turned off. DebuggerStepThroughAttribute tells the debugger to step through the code it is applied to, rather than step into the code.

When Just My Code is enabled, it is possible to choose Break on the Debug menu and stop execution at a location where there is no My Code to display. When that happens, no code is displayed. Additionally, if you choose a Step command, it will take you to the next line of My Code.

Programmatic break statements, such as Visual Basic Stop statements, are handled differently. The debugger always breaks on these statements, even when Just My Code is enabled. In this situation, non-user code is displayed rather than hidden, but stepping will still take you out of non-user code to the next line of My Code.

Note

Just My Code is not supported for device projects.

To enable or disable Just My Code debugging

  1. On the Tools menu, choose Options.

  2. In the Options dialog box, open the Debugging node and then choose General.

  3. Select or clear Enable Just My Code.

See Also

Reference

DebuggerNonUserCodeAttribute

DebuggerHiddenAttribute

DebuggerStepThroughAttribute

Concepts

Execution Control