开发者

How do I build a custom debugger that attaches to a .NET process and listens up to events of a specific type?

I intend to make a very specific profiling tool that listens t开发者_高级运维o events of a specific type, that is, I have a type T that has it's events. I want to know every time any instance of T triggers events.

The user runs the profiling application, attaches to a process and the app starts generating the logs.

Is it possible? If true, how do I start?


Few years back I worked on something similar, but not exactly profiling. The way I started was by looking at source code of CLR Profiler which is available on MSDN, and then figure out how it attaches to a running application, there is a little unmanaged code you'd have to do, but it can be directly picked up from CLR Profiler ;)

Following are some places where you could start looking at.

ICorDebug - Provides methods that allow developers to debug applications in the CLR.

Additional Debugging Interfaces - All the ways you could hook into CLR for debugging and profiling.

ICorProfilerCallback - First interface to look at for profiling implementation.

Profiling interfaces - For any profiling events you want to implement.

CLR Profiler - I'd look at the source of this, it does everything you want to do.


Do you know dotnet performance counter? They have nothing to do with debugging but are good for catching and counting special events.

You can use them for examle to see how many customers are logged in to your web application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜