5

Is there a way to quickly search for the complete list of code paths to one particular function in my project, in order to find out whether some certain upper-lever function calls it, either directly or indirectly? For example, some possible output to determine whether MyLowLevelFunction is reachable from TargetFunction:

Code path 1

ModuleA2.TopLevelFunction
|--ModuleA1.SomeFunction
|----Utility.MyLowLevelFunction

Code path 2

ModuleB2.TopLevelFunction
|--TargetModule.TargetFunction <-- This calls MyLowLevelFunction indirectly
|----ModuleB1.SomeFunction
|------Utility.MyLowLevelFunction
Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
Jim
  • 53
  • 4
  • possible duplicate of [Display the call stack in a Delphi Win32 application](http://stackoverflow.com/questions/258727/display-the-call-stack-in-a-delphi-win32-application) or [Need a way to periodically log the call stack/stack trace](http://stackoverflow.com/questions/2326980/need-a-way-to-periodically-log-the-call-stack-stack-trace-for-every-method-proced) – Robert Love Jun 30 '11 at 01:19
  • 1
    I might be wrong on the dupe. Are you looking for a static analysis of the code or are you looking for something at runtime? – Robert Love Jun 30 '11 at 01:29
  • I don't think this is a dupe. This is about a reverse call tree report (not a call stack), usually done via static analysis although I suppose you could do it with a sampling profiler. – Warren P Jun 30 '11 at 01:37
  • This question is totally unclear to me. Perhaps if you used examples that were more distinctly separate (eg., something more differential than `ModuleA` and `ModuleD`) it would be more clear. (A single final letter difference makes it hard to tell them apart, especially when cluttered with `---------------------------`) – Ken White Jun 30 '11 at 01:55
  • The difference between a stack value (a single call tree) and a reverse call tree, is that a reverse call tree is like a matrix product of all possible forward call trees. – Warren P Jun 30 '11 at 02:07
  • Hi Robert Love, thanks for providing the dups. And yes, I am looking for a static-code-analysis. – Jim Jun 30 '11 at 05:20
  • Hi Ken White, thanks for the advice. I have refined it to make it clearer. – Jim Jun 30 '11 at 05:27

1 Answers1

6

Pascal analyzer by Peganza has a Reverse call tree report. I am a customer and very happy with it, although I have never used that particular type of report, preferring a simple cross-ref report instead, which it also has.

As an interesting side-note static analysis tools will fail to find calls that are indirect, such as via an event callback.

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • Hi Warren, it is so lucky to get the answer from a user of Pascal Analyzer like you:) I have downloaded the evaluation edition of Pascal Analyzer. However the evaluation edition does not contain the feature "Reverse call tree report" nor "cross-ref report". I was wondering whether it can limit the reporting to the particular function? The reason that I ask so is that the generated "call tree report" is a text file around hundreds of MB which makes hard to search. Thank you~ – Jim Jun 30 '11 at 05:35
  • 1
    Jim: That's the basic problem with most of the reports. I wrote a simple utility in Delphi to filter the output of the reports to contain what I want, because most of the reports don't contain what I want. Further, if your project uses runtime packages, it seems necessary to build a monolithic (no packages) project, even if you never build it, to get all the units of a package-based solution to be included in a single analysis. There are workarounds for these limitations. – Warren P Jun 30 '11 at 12:28
  • Warren: Thanks for the answer! It makes clear now that what the limitation this software has. I guess I will finally purchase it and write a helper program then. Accepted your solution~ – Jim Jul 01 '11 at 01:57
  • I am unable to generate the build dependency tree by the evaluation version :( – The Bitman Jul 28 '16 at 15:02