Welcome to MSDN Blogs Sign in | Join | Help

How to Disable a Specific MDA

How to Disable a Specific MDA

As Mike Stall has noted in his post, the PInvokeStackImbalance MDA can be very slow, depending on the number of pinvoke calls in an application.  Recently, we have had a few customers running into this issue, but MSDN does not give much information regarding disabling MDAs except for setting COMPLUS_MDA to 0 or setting the registry key to 0.  The problem with these options is that they disable all MDAs.  Moreover, if you set the registry key, it has machine-wide impact.

 

There is actually a more fine-grained approach to do this.  You can actually disable an MDA using an MDA configuration file.  However, as mentioned on MSDN and in Stephen Toub’s article, the CLR will not look for the MDA configuration file unless either the environment variable or the registry key is set 1.  Doing so has no effect if an application has no MDA configuration file.

 

For example, to disable the PInvokeStackImbalance MDA, you can do this:

 

1)      Set the COMPLUS_MDA environment variable to 1 (or equivalently, set HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\MDA to “1”)

 

2)      Assuming your application is called hello.exe, create hello.exe.mda.config in the same directory and put the following XML in it:

 

<?xml version="1.0" encoding="UTF-8" ?>

 

<mdaConfig>

  <assistants>

    <pInvokeStackImbalance enable="false"/>

  </assistants>

</mdaConfig>

 

 

Note that MDA configuration files have precedence over MDAs activated by default for the managed debugger and the unmanaged debugger.  This means that an MDA configuration file can disable an MDA which is enabled automatically because a debugger is attached.  (In fact, it is the only way.)

 

Due to an oversight, the PInvokeStackImbalance MDA is not even defined on 64-bit (both X64 and IA64) platforms.  So if you try to use the MDA configuration file above on 64-bit platforms, you will get an error.  But then again, since we only have one calling convention on X64 and one on IA64, why would you need this MDA on 64-bit platforms anyway?  ;)  

Posted by tlai | 4 Comments
Filed under:

Introduction

Introduction

Hi everyone, my name is Thomas Lai.  I am a developer on the Common Language Runtime (CLR) team at Microsoft.  More specifically, I am on the Developer Services Team, which includes both the Profiling Services Team and the Debugging Services Team.  Prior to Whidbey RTM, I worked on the CLR Port Team, porting the CLR to both X64 and IA64.  Needless to say, I’m biased against the x86 platform.  So don’t be surprised when you hear me bash the “legacy” x86 platform from time to time.  :)

 

I am a late comer to the blogging world.  Quite a few of my current and former colleagues already have their own blogs: Mike Stall, Rick Byers, David Broman, Josh Williams, etc.  Since there is already a good coverage of various CLR topics, I have not found any specific hole I can fill with my blog yet.  I will write about anything I find interesting/obscure/ridiculous.  Of course, my entries will be mostly related to my daily work, i.e. managed debugging, 64-bit, etc.

 

One area I have picked up recently is the infrastructure for the Managed Debugging Assistants (MDAs).  My first blog will be on how to disable a specific MDA.  Stay tuned if you are interested.

 

Posted by tlai | 1 Comments
Filed under:
 
Page view tracker