Hide Methods from debugger Using DebuggerHidden attribute

DubuggerHidden attribute tells the Visual Studio debugger that the method is hidden from the debugging process and while debugging. This is quite helpful when you don’t want to go to stepping inside of a method while debugging.

When you mark a method with DebuggerHidden() attributes, It’s explicitly tells the debugger not to step inside of that methods and no break point will be hit over that method. Now I am going to explain the same using a Example with Intellitrace debugging.

1

Let’s consider you have below code snippet

We have set two break points in each of the method ( Line 22, and Line 31 as shown ) . Now if you run this application and check the output intellitrace debugging window , you will get bellow out put

3

As per the above image, you can see the flow of the application from Main() > Method1() > Method2() . If you also check the current live event’s “Call Stack” , that also represent the call of method2() from method1(). This is as per our expected behavior.

Now, If you don’t need to go inside Method1() while debugging and debugger should not stop inside method1() for any of the breakpoint, you have to add “DebuggerHidden()” attributes with the method1(). If you try to debug the application with the same breakpoint, CallStack() and IntelliTrace debugger view will be something different.

4

If you check the above image, debugger reached to Method2() through Method1(), but breakpoint in method1() never hits, because of the “DebugerHidden” attribute.

If you move from “EventView” mode to “CallView” mode in Intellitrace window, you can find the actual flow of sequence of the program.

5







Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

3 Comments to “Hide Methods from debugger Using DebuggerHidden attribute”

  1. I loved as much as you will receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get got an nervousness over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly a lot often inside case you shield this hike. 5

Comments are closed.