开发者

Monitoring changes of a private field in an external assembly without source

I want to monitor (or place a breakpoint on) each c开发者_如何学运维hange of a static field which is member of an internal class which resides in an external assembly for which I don't have code:

Assembly: PresentationCore.dll
Class   : MS.Internal.MemoryPressure
Field   : private static long _totalMemory

Ideally I should be able to see the stacktraces which trigger the changes.

Is this possible with VS and if yes then how do I have to setup VS in order to do this? Or will I need some external profiling tool?


You cannot set a breakpoint on a field. You are in luck, there's only one method that modifies the value, called AddToTotal. Debug + New Breakpoint + Break At Function. Type "MS.Internal.MemoryPressure.AddToTotal" and untick the "Use IntelliSense" option. The debugger will break as soon as the method is called, typically when the code creates a bitmap. You will only have machine code to look at.

As soon as it breaks, you can add a watch for MS.Internal.MemoryPressure._totalMemory. Adjust the breakpoint in the disassembly so it breaks past the field assignment.


Since PresentationCore is part of .Net you can debug the framework source
Take a look at this question


what about this: http://ayende.com/blog/4106/nhibernate-inotifypropertychanged


Both RedGate Reflector as well as JetBrains Resharper can help you do it. They both decompile the assembly and generate the C# source code after which they allow you to work with it as if it were yours including placing breakpoints, watching the stack, etc.

I started with reflector, but now (starting from v.6) I switched to resharper it seems at this point to be more robust. Resharper has a 30 days trial, reflector used to be free I am not sure what it is now

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜