How Calltree works

1. Differences to GProf

1.1 Cost at call arcs

1.2 Distinguish cost of same function in different context

2. Instrumentation

2.1 Callback to setup handler at beginning of each basic block

Each instrumented basic block first calls the helper function setup_bbcc(). This function has two purposes:
  1. Tracing function calls and returns
  2. Set up the pointer to the BBCC struct which should get the events happening in the execution of the basic block

There can be multiple BBCCs of the same BB, depending on the options choosen for the calltree run. The following properties of the execution context of a BB can lead to different BBCCs that have to be used:

For this, item (2) above depends on (1).

For call tracing, we use the struct JCC. These structs or stored in a hash table by using a BBCC pair: The BBCC address of the last BB where the call happened and the BBCC of the BB the call is targeted to. Because of this, the actual sequence of actions is:

2.2 Callbacks to logging handlers at memory accesses

This is almost identical to the actions of the Cachegrind skin. The only difference is that the logging helpers only get offsets to CC structs in a BBCC struct, and not an absolute pointer. This is needed to allow for multiple BBCCs for the same BB.

3. Tracking the active state of functions

4. Shared Libraries and PLT sections

5. Signal handlers

6. Multithreading