Using a Profiler for inspection

I’ve gotten some questions about using a profiler to do inspection a managed process. The best blogs to look for on this would be and  

The inspection problem obviously intersects between debugging and profiling; here’s some key trivia:

1. In V2, ICorDebug and ICorProfiler are now totally disjoint interfaces. We had a concept called “Inproc-Debugging” in V1.0 and V1.1 where you could get an ICorDebug inspection object from the ICorProfiler interfaces (via BeginInprocDebugging). This was removed in V2 and replaced with a profiler-centric inspection API. The MSDN article describes more of the details:

2. You can’t debug yourself. So you can’t try to instantiate ICorDebug on your own process from within a profiler callback.  In fact, profiler callbacks are generally very restricted, so don’t do anything goofy in them.

Also, here’s a comparison of debugger versus profiler services in the CLR. I would personally like to see these interfaces come closer together, but since we’ve shipped V2, that’s a story for the future.

Comments (0)