views:

161

answers:

3

I've inherited a rather large WPF application, and I need to generate application traces for a significant portion of it. Because of the complexity of the project, I'd like to do this without making any changes to the code base, if possible. I mostly need to know the stack deltas, ie when a function call or return takes place. Is there a tool or methodology that will get me this trace with (preferably) no code changes? Is this even possible to do without writing a tool to add Trace calls to the code?

If it were limited to specific function calls, i think i could live with that. I have a tool that can do that for win32 api calls, via import table rewriting to redirect the dll function call to a custom stub that logs the call stack at that point. If there is no such tool that works 'out of the box' on .NET, does anyone know of a FAQ or something that explains how .NET DLL linkage works (export table, thunks, etc)?

+1  A: 

You could inject method calls (to Trace or whatever suits your fancy) using PostSharp Core, though it's not an out-of-the-box solution.

Pavel Minaev
+1  A: 

To give you an answer that would be useful, it really is important to know why you need an application trace.

I can think, one of:

  1. For analysis purposes (understanding things at an architectural level). In this case, what would be appropriate is a static code analysis tool such as NDepend;

  2. For logging purposes (once again, why specifically would you need to know method entrance and exits?). In this case, since you don't want to have to change the source, an aspect orientation framework that injects aspects just before execution is probably what you're looking for, e.g., PostSharp.

  3. For performance analysis purposes. In this case, use the tool that comes with Visual Studio, or a commercial tool such as ANTS Profiler.

Other AOP solutions exist that would be suited to intercepting method calls (e.g., Spring.NET) but these require changes to the source (albeit relatively small ones) which you've already said that you're not interested in.

Eric Smith
Due to the large size of the application, I'm looking for an architectural analysis, as you say. I'll look into NDepend, thanks for the suggestions :)
Jeff Shattock
+1  A: 

Runtime Flow provides automatic tracing of .NET applications without any changes to the code base.

Sergey Vlasov