6

Is there a tool out there for visualizing dynamic call graphs? I saw a reference to one for Visual Basic 6 but I'd like one for .NET.

If I had to build a visualizer myself should I bother with the .NET profiling API or should I do something with Mono.Cecil? I started writing a CLI runtime with Cecil, but I guess it'd be easier if I just injected call-graph recording calls in the assemblies, although since I don't know the execution route ahead of time and would have to instrument everything.

ire_and_curses
  • 68,372
  • 23
  • 116
  • 141
Mark Cidade
  • 98,437
  • 31
  • 224
  • 236

4 Answers4

3

Maybe this open source project on CodePlex could help as starting point:

SequenceViz

http://www.codeplex.com/sequenceviz

"SequenceViz is a tool to generate sequence diagrams by reverse engineering .NET Assemblies. Although it does a little more than that in the later versions."

There is a standalone version and an implementation as reflector-plugin.

alt text http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=sequenceviz&DownloadId=44432

splattne
  • 102,760
  • 52
  • 202
  • 249
  • I think marxidad in interested by the *dynamic* calling graph, which implies that the execution must be profiled. SequenceViz, as Reflector, performs a static analysis. – Romain Verdier Dec 08 '08 at 08:29
  • I'm aware of SequenceViz but the hard part would be getting the actual calls that were made during run-time. – Mark Cidade Dec 08 '08 at 08:30
  • I understand, but I thought you could look at the code and take it as a base (for the visualization part) and "adding" the profiling stuff – splattne Dec 08 '08 at 08:46
  • I tried SequenceVis on a couple of my projects, and it displayed diagrams of the 1st method I clicked on, but then went into an endless loop on the 2nd. Great idea, but not a viable tool in it's current state. – Tom Bushell Jun 04 '12 at 19:34
  • Corection to my previous comment - it does work, but just very slowly, with poor feedback on what it's doing. – Tom Bushell Jun 04 '12 at 19:53
1

Profiling CLR is the purpose of the .NET Profiling API, so it seems to be perfect for your need. Most part of profiler products are based on top of it. But you'll have to write unmanaged code, urk.

Using Cecil is possible too, and pretty straightforward if you just want to record enter/exit of methods.

EDIT:

Well, PostSharp is probably the best solution, as it allows you to handle such a requirement by relying on static weaving. AOP provides a better level of abstraction than directly rewrite IL with Cecil.

Marjan Venema
  • 19,136
  • 6
  • 65
  • 79
Romain Verdier
  • 12,833
  • 7
  • 57
  • 77
  • I updated the link as the old one was dead. The PostSharp at the new location seems much more focused on building code than on analyzing existing code, but I must say I only glanced at the site. – Marjan Venema Mar 16 '16 at 10:14
1

You coud use NProf, an open source project on Sourceforge. It allows you to extend the default GUI with new visualization tools.

"nprof is designed to be not only a fully-fledged profiler for .NET applications, but also a complete API that can be used to build other profiler front-ends, as well as extend the default GUI with new visualization tools."

Mark Cidade
  • 98,437
  • 31
  • 224
  • 236
splattne
  • 102,760
  • 52
  • 202
  • 249
1

I love the CLR Profiler. I won't waste space by reproducing the documentation here, but it sounds like it is exactly what you are looking for.

The CLR Profiler is now available on Microsoft's Archive GitHub

heavyd
  • 17,303
  • 5
  • 56
  • 74
Justin R.
  • 23,435
  • 23
  • 108
  • 157
  • Does the CLR Profiler include function arguments that are passed and within a sequence of function calls? – Mark Cidade Jan 08 '09 at 18:22
  • It does capture the sequence of function calls, which it can present in a very useful visual fashion, but no it does not capture the function arguments. – Justin R. Jan 09 '09 at 20:30