If you are a .NET developer then you’ve probably heard or read about CLR metadata. In this blog post I will try to give you a pragmatic view of what CLR metadata is and how to work with it. You are going to learn how to use unmanaged metadata API from C# code. I will …
Category Archives: .NET
Analyzing crash dumps with ClrMD
Microsoft recently released the first beta version of Microsoft.Diagnostics.Runtime component. Lee Culver describes ClrMD as follows: ClrMD is a set of advanced APIs for programmatically inspecting a crash dump of a .NET program much in the same way as the SOS Debugging Extensions (SOS). It allows you to write automated crash analysis for your applications …
Parsing “Unsafe” Method Signatures
If you’ve ever used JustMock then you should be familiar with code fragments like this one: public interface IFoo { byte Bar(int i, string s, long l); } var foo = Mock.Create<IFoo>(); Mock.Arrange(() => foo.Bar(123, “test”, 321)).Returns(5); The interesting thing in this code is in the Arrange method. Its signature is as follows: public static …
JustMock Design Choices
JustMock is a small product. It is around 10,000 lines of code. Despite its small size there are a lot of decisions that were made and many others that have to be made. In this post I would like to shed some light on our decision making process and I’ll try to answer the question …
RVA Static Fields
In JustTrace Q1 2013 we added support for analyzing GC roots that are static fields. The implementation of this feature uses ICorProfilerInfo2::GetAppDomainStaticAddress, ICorProfilerInfo2::GetThreadStaticAddress and so on. Among all these methods, there is a very interesting one, namely ICorProfilerInfo2::GetRVAStaticAddress. In this post I am going to focus on a little known CLR feature that is closely …
Profiler types and their overhead
It is a common opinion that profiling tools are slow. Every time I stumble upon this statement I ask for the definition of slow. Most of the time I get the answer that a profiler is slow when it adds more than 100% overhead. At present there many commercial profilers that are fast (according to …
Preventing Stack Corruption
I recently investigated stack corruption issue related to P/Invoke. In this post I am going to share my experience. I will show you a simple and yet effective approach to avoid similar problems. The Bug A colleague of mine discovered the bug during debugging piece of code in JustTrace dealing with ETW. The issue was …
CLR Profilers and Windows Store apps
Last month Microsoft published a white paper about profiling Windows Store apps. The paper is very detailed and provides rich information how to build CLR profiler for Windows Store apps. I was very curious to read it because at the time when we released JustTrace Q3 2012 there was no documentation. After all, I was …
Profiling Tools and Standardization
Imagine you have the following job. You have to deal with different performance and memory issues in .NET applications. You often get questions from your clients “Why my application is slow and/or consumes so much memory?” along with trace/dump files produced by profiling tools from different software vendors. Yeah, you guess it right – your …
Enumerate managed processes
If you ever needed to enumerate managed (.NET) processes you probably found that this is a difficult task. There is no single API that is robust and guarantees correct result. Let’s see what the available options are: GetVersionFromProcess. This function has been deprecated in .NET 4 ICLRMetaHost::EnumerateLoadedRuntimes. The MetaHost API was introduced in .NET 4 …