Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing line-level profiling

The last week or so I've been playing with the CLR Profiling API, as a pet project for the summer.

I started thinking about how ANTS and DotTrace implement line-level profiling. I can't see anything related to this in the Profiling API, so I assume they've got something proprietary.

I'm looking for pointers or thoughts on how this is implemented by them.

Do they inject MSIL code when the code is being JIT'ed?

like image 540
trydis Avatar asked May 20 '26 08:05

trydis


1 Answers

CLR Profiling API support out of the box only tracing on Enter & Leave level. This can be done using ICorProfilerInfo::SetEnterLeaveFunctionHooks

In order to trace at finer level weaving of IL is required. You can use these open source profilers code as references:

  • OpenCover
  • PartCover

Both weave code during JITCompilationStarted callback.

like image 179
Elisha Avatar answered May 22 '26 21:05

Elisha