scitools.com

← Graph catalog

Calls is one of the interactive graphs Understand can draw of your code — call trees, dependencies, control flow, and more.

Calls

Languages: Ada, Any, Assembly, Basic, C#, C++, Fortran, Java, Jovial, Pascal, Python, Rust, VHDL, Web
Targets: Functions, Subprograms
Variants: Classic, Cluster, Compare, Relationship, Simplified, With Global Objects (Classic)

Show what a selected function calls, directly or indirectly, including through function pointers, lambdas, and virtual dispatch.

For a selected function, this shows an edge to each function it calls, then recurses into each of those functions' own calls, building a multi-level call tree.

Whenever a call could have more than one target at runtime — like through virtual dispatch or a function pointer — the graph shows all possible targets. Some variants add extra edges showing how those targets were identified: an edge to a function used as a pointer (e.g. from functionPtrDemo to assignedToFunctionPtr), an edge from the variable to a function it's assigned to (e.g. from funcPtr to assignedToFunctionPtr), or an edge from a virtual function to each function that overrides it (e.g. from ComplexBase::virtualCall to ComplexDerive::virtualCall).

Rooted at callDemo below, the graph shows calls to directRecursive (which calls itself), indirectRecursiveA (which cycles with indirectRecursiveB), functionPtrDemo (which calls assignedToFunctionPtr through a function pointer), simpleOverridesDemo and complexOverridesDemo (each calling a virtual function through a base pointer), and lambdaDemo (which calls a lambda). The inverse graph, Called By, shows the reverse relationship — everything that calls the selected function.

See the following code and corresponding graph

class Base {
public:
  virtual void pureVirtualCall() = 0;
};

class DerivedA : public Base {
public:
  void pureVirtualCall() override {}
};

class DerivedB : public Base {
public:
  void pureVirtualCall() override {}
};

class DerivedC : public Base {
public:
  void pureVirtualCall() override {}
};

class ComplexBase {
public:
  virtual int virtualCall();
};

class ComplexDerive: public ComplexBase {
public:
  int virtualCall() override;
};

int calledByBase() { return 0; }
int calledByDerived() { return 0; }

int ComplexBase::virtualCall() { return calledByBase(); }

int ComplexDerive::virtualCall()
{
  auto val = ComplexBase::virtualCall();
  return val + calledByDerived();
}

int GlobalObject = 0;

int directRecursive(int n) { return directRecursive(n); }
int indirectRecursiveA(int n);
int indirectRecursiveB(int n) { return indirectRecursiveA(n); }
int indirectRecursiveA(int n) { return indirectRecursiveB(n); }

int assignedToFunctionPtr(int x) { return x; }
int functionPtrDemo(int n)
{
  if (GlobalObject > n)
    return n;
  int (*funcPtr)(int) = assignedToFunctionPtr;
  return funcPtr(n); // function pointer call
}

void simpleOverridesDemo()
{
  Base *base = new DerivedA;
  base->pureVirtualCall();
  GlobalObject ++;
}

void complexOverridesDemo()
{
  ComplexBase *complexBase = new ComplexDerive;
  complexBase->virtualCall();
  GlobalObject = 0;
}

void lambdaDemo(int n)
{
  auto lambdaVariable = [](int x) { return x * 3; };
  lambdaVariable(n);
}

void callDemo(int n)
{
  directRecursive(n);
  indirectRecursiveA(n);
  functionPtrDemo(n);
  simpleOverridesDemo();
  complexOverridesDemo();
  lambdaDemo(n);
}

Calls - Classic

The Classic variant is similar to the Simplified variant, showing all relationships in a simple tree, but it uses a custom layout algorithm instead of Graphviz.


Back to Calls

Calls - Cluster

The Cluster variant groups entities by their containing class/file/architecture.


Back to Calls

Calls - Compare

The Compare variant shows how the graph has changed relative to the project's comparison database.


Back to Calls

Calls - Relationship

The Relationship variant filters the graph to only paths connecting the two entities.


Back to Calls

Calls - Simplified

The Simplified variant shows all relationships in a simple tree (no clusters)


Back to Calls

Calls - With Global Objects (Classic)

This variant also adds an edge from each function to any global object it sets, uses, or modifies, colored the same way as the Object References graph: a set is green, a modify is orange, and a use (or anything else) is the default blue. Below, functionPtrDemo uses GlobalObject, simpleOverridesDemo modifies it, and complexOverridesDemo sets it.


This variant is a plugin. It can be enabled/disabled from the Plugin Manager.

Back to Calls