Undocumented Silverlight Feature – ETW Tracing
Event Tracing for Windows is tracing mechanism built into windows kernel. It is like log file for windows, but way cool and can log thousands events per second, with very less CPU utilization. From windows vista onwards, we can have windows ETW combined with our application tracing. It would be one trace file which would contain information about windows as well as our application, so it is easy to diagnose and figure what is happening in the OS combined with our application. Today I am not going be discussing about how to do this. I will write about in another post. This post is going to be about how to have ETW tracing from Silverlight, which is not documented. I am using Silverlight 4.0 and I haven’t checked in another vesion.
I was looking to in to coreclr.dll inside the Windbg. FYI coreclr.dll is the runtime for Silverlight. And I happened to notice ETW. I used the command
x coreclr!etw*
0:026> x coreclr!etw*
6574af13 coreclr!ETW::MethodLog::MethodJitting = <no type information>
657434e5 coreclr!ETW::MethodLog::MethodJitted = <no type information>
6588810e coreclr!ETW::LoaderLog::CollectibleLoaderAllocatorUnload = <no type information>
65886240 coreclr!ETW::MethodLog::SendHelperEvent = <no type information>
6588327f coreclr!ETW::SamplingLog::SaveCurrentStack = <no type information>
6588752d coreclr!ETW::EnumerationLog::StartRundown = <no type information>
65887f30 coreclr!EtwCallback = <no type information>
65886e10 coreclr!ETW::EnumerationLog::IterateAssembly = <no type information>
6578ad0c coreclr!ETW::MethodLog::MethodRestored = <no type information>
65886450 coreclr!ETW::MethodLog::StubInitialized = <no type information>
65886729 coreclr!ETW::LoaderLog::SendModuleEvent = <no type information>
65884d0a coreclr!ETW::EnumerationLog::SendThreadRundownEvent = <no type information>
65884960 coreclr!ETW::LoaderLog::SendDomainEvent = <no type information>
65737ac1 coreclr!ETW::ExceptionLog::ExceptionThrown = <no type information>
658862e6 coreclr!ETW::MethodLog::SendEventsForNgenMethods = <no type information>
658837b0 coreclr!etwStackSupportedEvents = <no type information>
65887a60 coreclr!ETW::EnumerationLog::EndRundown = <no type information>
657a7b57 coreclr!ETW::MethodLog::StubsInitialized = <no type information>
657bb514 coreclr!ETW::CEtwTracer::Register = <no type information>
6588363e coreclr!EtwCallout = <no type information>
656de72b coreclr!ETWTraceStartup::ETWTraceStartup = <no type information>
658865c2 coreclr!ETW::MethodLog::DynamicMethodDestroyed = <no type information>
658853e8 coreclr!ETW::MethodLog::SendMethodEvent = <no type information>
65808659 coreclr!ETW::EnumerationLog::ProcessShutdown = <no type information>
657a67b0 coreclr!ETW::InfoLog::RuntimeInformation = <no type information>
65884e23 coreclr!ETW::LoaderLog::SendAssemblyEvent = <no type information>
65885198 coreclr!ETW::MethodLog::SendMethodJitStartEvent = <no type information>
658872ff coreclr!ETW::EnumerationLog::IterateCollectibleLoaderAllocator = <no type information>
658831d5 coreclr!ETW::SamplingLog::Append = <no type information>
6588840d coreclr!ETW::LoaderLog::ModuleLoad = <no type information>
656de705 coreclr!ETWTraceStartup::StartupTraceEvent = <no type information>
6588744b coreclr!ETW::EnumerationLog::EnumerationHelper = <no type information>
656fa2f8 coreclr!ETW::MethodLog::MethodTableRestored = <no type information>
65886f78 coreclr!ETW::EnumerationLog::IterateModule = <no type information>
656d11a4 coreclr!ETW::SecurityLog::StrongNameVerificationStart = <no type information>
658847f3 coreclr!ETW::GCLog::GCSettingsEvent = <no type information>
So this is cool we can get ETW tracing from Silverlight regarding loader, GC, threading, ThreadPool. But one thing I couldn’t find was a “.man” file like “CLR-ETW.man” for CLR 4.0. This was disappointing. The next thing to do was fired up .NET 4.0, attached to the debugger and issues the command x clr!ETW*.And it was same as the coreclr.dll output above.So the API’s being the same I guessed I could use the clr-etw.man for tracing Silverlight. Then the next thing to do is try tracing Silverlight using CLR-ETW.man. FYI I am using Windows 7 and this will work only from Windows Vista onwards. Make sure the CLR-ETW is registered. To register issue the command (clr-etw.man would be .NET 4.0 directory)
wevtutil im CLR-ETW.man
And to check if the provider is installed issue the command
xperf -providers I | Findstr ".NET"
And the output should be something like this
C:\>xperf -providers I | Findstr “.NET”
a669021c-c450-4609-a035-5af59af4df18 : Microsoft-Windows-DotNETRuntimeRundown
aff081fe-0247-4275-9c4e-021f3dc1da35 : ASP.NET Events
e13c0d23-ccbc-4e12-931b-d9cc2eee27e4 : .NETCommon Language Runtime
e13c0d23-ccbc-4e12-931b-d9cc2eee27e4 : Microsoft-Windows-DotNETRuntime
Try and close all .NET applications like VS2010, so that you don’t get traces from VS2010. From the command line issue the command
xperf -start usersession -on ".NET Common Language Runtime" -f usersession.etl
Start IE and browse a Silverlight site and then stop the trace
xperf -stop usersession
And to view the output of the etl file, issue the command
xperf usersession.etl
There we go now, we are able to see coreclr ETW tracing. From the above picture we can see information like assembly load, module load. This can be used for GC, Exception, threading etc. So the next time someone tells the Silverlight site is slow on their box, you can ask them to run an etw trace and you would be able to see what is happening on their system.

Undocumented Silverlight Feature – ETW Tracing « Naveen’s Blog…
Thank you for submitting this cool story – Trackback from DotNetShoutout…
DotNetShoutout
March 15, 2010 at 9:09 pm
Undocumented Silverlight Feature ? ETW Tracing…
Thank you for submitting this cool story – Trackback from iAwaaz-News-by-People…
iAwaaz-News-by-People
March 15, 2010 at 10:02 pm
Interesting.. Thanks.
Michael Sync
March 17, 2010 at 2:52 am
Thanks Michael.
Naveen
March 17, 2010 at 9:04 am
[...] on March 17, 2010 At last CLR 4.0 has started showing some love towards ETW. Like I mentioned before ETW is very useful in understanding what is happening on the entire system, along with your [...]
Using CLR 4.0 Event Tracing for Windows (ETW) along with application ETW « Naveen's Blog
March 17, 2010 at 5:19 pm
[...] stripped down clr) is a black box with respect to diagnostics information, until we had ETW. The only way was to get internal diagnostics information was using Windbg. But the idea is to get [...]
Get GC Information in Silverlight using ETW « Naveen's Blog
March 21, 2010 at 3:47 pm
Naveen, thanks for the detailed walkthrough. I’m trying to track down a stackoverflow exception in the JIT of CoreCLR. Any particular providers I should be watching? Nothing in the log seems to stand out here.
Chui Tey
November 27, 2012 at 4:00 pm