Chapter 3. Basic Concepts

This chapter explains some concepts of the KCachegrind, and introduces terms used in the interface.

The Data Model for Profile Data

Cost Entities

Cost counts of event types (like L2 Misses) are attributed to cost entities, which are items with relationship to source code or data structures of a given program. Cost entities not only can be simple code or data positions, but also position tuples. For example, a call has a source and a target, or a data address can have a data type and a code position where its allocation happened.

The cost entities known to KCachegrind are given in the following. Simple Positions:


An assembler instruction at a specified address.

Source Line of a Function

All instructions that the compiler (via debug information) maps to a given source line specified by source file name and line number, and which are executed in the context of some function. The latter is needed because a source line inside of an inlined function can appear in the context of multiple functions. Instructions without any mapping to an actual source line are mapped to line number 0 in file ???.


All source lines of a given function make up the function itself. A function is specified by its name and its location in some binary object if available. The latter is needed because binary objects of a single program each can hold functions with the same name (these can be accessed e.g. with dlopen or dlsym; the runtime linker resolves functions in a given search order of binary objects used). If a profiling tool cannot detect the symbol name of a function, e.g. because debug information is not available, either the address of the first executed instruction typically is used, or ???.

Binary Object

All functions whose code is inside the range of a given binary object, either the main executable or a shared library.

Source File

All functions whose first instruction is mapped to a line of the given source file.


Symbol names of functions typically are hierarchically ordered in name spaces, e.g. C++ namespaces, or classes of object-oriented languages; thus, a class can hold functions of the class or embedded classes itself.

Profile Part

Some time section of a profile run, with a given thread ID, process ID, and command line executed.

As can be seen from the list, a set of cost entities often defines another cost entity; thus, there is a inclusion hierarchy of cost entities.

Positions tuples:

  • Call from instruction address to target function.

  • Call from source line to target function.

  • Call from source function to target function.

  • (Un)conditional jump from source to target instruction.

  • (Un)conditional jump from source to target line.

Jumps between functions are not allowed, as this makes no sense in a call graph; thus, constructs like exception handling and long jumps in C have to be translated to popping the call stack as needed.

Event Types

Arbitrary event types can be specified in the profile data by giving them a name. Their cost related to a cost entity is a 64-bit integer.

Event types whose costs are specified in a profile data file are called real events. Additionally, one can specify formulas for event types calculated from real events, which are called inherited events.