Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am looking for a recursion analysis tool [closed]

I ran into a problem this weekend where method 1 called method 2 which called method 3 which caught exception, and within the exception handling method 1 was called again...

M1 -> M2 -> M3 -> M1 ....

The problem became obvious and easy to fix, once the problem happened.

Does anyone know of a tool to detect problems like this in a .NET application?

like image 714
Sam Avatar asked Mar 21 '11 18:03

Sam


1 Answers

To do this right, you need a global call graph over the C# application, computed using C# semantics and what amounts to a points-to analysis, arguably including the libraries it calls. With such a call graph, you could enumerate the cycles in it, and those would be the candidates to check.

I don't know where you would get a tool that compute such a global call graph for C#, off the shelf.

You could approximate this using simple code scanning techniques. For each method M, extract the apparant set of calls it contains as identifiers I. Mostly they will appear as syntax that looks like identifier( After this step you have M_i -> I. You can build this as an (extermely conservative) basic call graph, and then compute the transitive closure. With that, you have an approximate call graph with cycles, and you can carry out your cycle analysis. This would mass methods passed by names, and other cases, but it might be good enough.

like image 193
Ira Baxter Avatar answered Sep 26 '22 04:09

Ira Baxter