Skip to content
Standard libraryZig 0.17.0Official documentation
Sourcestd/valgrind/callgrind.zig

Source line 1

std.valgrind.callgrind.ClientRequest

container

Source line 4

Fields

DumpStats = valgrind.ToolBase("CT".*)
ZeroStats
ToggleCollect
DumpStatsAt
StartInstrumentation
StopInstrumentation

std.valgrind.callgrind.doClientRequestExpr

function

Source line 13

fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize

Parameters

default: usize
request: ClientRequest
a1: usize
a2: usize
a3: usize
a4: usize
a5: usize

std.valgrind.callgrind.doClientRequestStmt

function

Source line 17

fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void

Parameters

request: ClientRequest
a1: usize
a2: usize
a3: usize
a4: usize
a5: usize

std.valgrind.callgrind.dumpStats

function

Source line 22

Dump current state of cost centers, and zero them afterwards

pub fn dumpStats() void

std.valgrind.callgrind.dumpStatsAt

function

Source line 30

Dump current state of cost centers, and zero them afterwards. The argument is appended to a string stating the reason which triggered the dump. This string is written as a description field into the profile data dump.

pub fn dumpStatsAt(pos_str: [*:0]const u8) void

Parameters

pos_str: [*:0]const u8

std.valgrind.callgrind.startInstrumentation

function

Source line 51

Start full callgrind instrumentation if not already switched on. When cache simulation is done, it will flush the simulated cache; this will lead to an artificial cache warmup phase afterwards with cache misses which would not have happened in reality.

pub fn startInstrumentation() void

std.valgrind.callgrind.std

alias

Source line 1

Alias of std

std.valgrind.callgrind.stopInstrumentation

function

Source line 62

Stop full callgrind instrumentation if not already switched off. This flushes Valgrinds translation cache, and does no additional instrumentation afterwards, which effectively will run at the same speed as the "none" tool (ie. at minimal slowdown). Use this to bypass Callgrind aggregation for uninteresting code parts. To start Callgrind in this mode to ignore the setup phase, use the option "--instr-atstart=no".

pub fn stopInstrumentation() void

std.valgrind.callgrind.toggleCollect

function

Source line 43

Toggles collection state. The collection state specifies whether the happening of events should be noted or if they are to be ignored. Events are noted by increment of counters in a cost center

pub fn toggleCollect() void

std.valgrind.callgrind.valgrind

alias

Source line 2

Alias of std.valgrind

std.valgrind.callgrind.zeroStats

function

Source line 35

Zero cost centers

pub fn zeroStats() void
Source code

std/valgrind/callgrind.zig

const std = @import("../std.zig");
const valgrind = std.valgrind;

pub const ClientRequest = enum(usize) {
    DumpStats = valgrind.ToolBase("CT".*),
    ZeroStats,
    ToggleCollect,
    DumpStatsAt,
    StartInstrumentation,
    StopInstrumentation,
};

fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
    return valgrind.doClientRequest(default, @as(usize, @intCast(@backingInt(request))), a1, a2, a3, a4, a5);
}

fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void {
    _ = doClientRequestExpr(0, request, a1, a2, a3, a4, a5);
}

/// Dump current state of cost centers, and zero them afterwards
pub fn dumpStats() void {
    doClientRequestStmt(.DumpStats, 0, 0, 0, 0, 0);
}

/// Dump current state of cost centers, and zero them afterwards.
/// The argument is appended to a string stating the reason which triggered
/// the dump. This string is written as a description field into the
/// profile data dump.
pub fn dumpStatsAt(pos_str: [*:0]const u8) void {
    doClientRequestStmt(.DumpStatsAt, @intFromPtr(pos_str), 0, 0, 0, 0);
}

/// Zero cost centers
pub fn zeroStats() void {
    doClientRequestStmt(.ZeroStats, 0, 0, 0, 0, 0);
}

/// Toggles collection state.
/// The collection state specifies whether the happening of events
/// should be noted or if they are to be ignored. Events are noted
/// by increment of counters in a cost center
pub fn toggleCollect() void {
    doClientRequestStmt(.ToggleCollect, 0, 0, 0, 0, 0);
}

/// Start full callgrind instrumentation if not already switched on.
/// When cache simulation is done, it will flush the simulated cache;
/// this will lead to an artificial cache warmup phase afterwards with
/// cache misses which would not have happened in reality.
pub fn startInstrumentation() void {
    doClientRequestStmt(.StartInstrumentation, 0, 0, 0, 0, 0);
}

/// Stop full callgrind instrumentation if not already switched off.
/// This flushes Valgrinds translation cache, and does no additional
/// instrumentation afterwards, which effectively will run at the same
/// speed as the "none" tool (ie. at minimal slowdown).
/// Use this to bypass Callgrind aggregation for uninteresting code parts.
/// To start Callgrind in this mode to ignore the setup phase, use
/// the option "--instr-atstart=no".
pub fn stopInstrumentation() void {
    doClientRequestStmt(.StopInstrumentation, 0, 0, 0, 0, 0);
}