| 1 | const std = @import("../std.zig"); |
| 2 | const valgrind = std.valgrind; |
| 3 | |
| 4 | pub const ClientRequest = enum(usize) { |
| 5 | StartInstrumentation = valgrind.ToolBase("CG".*), |
| 6 | StopInstrumentation, |
| 7 | }; |
| 8 | |
| 9 | fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { |
| 10 | return valgrind.doClientRequest(default, @as(usize, @intCast(@backingInt(request))), a1, a2, a3, a4, a5); |
| 11 | } |
| 12 | |
| 13 | fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void { |
| 14 | _ = doClientRequestExpr(0, request, a1, a2, a3, a4, a5); |
| 15 | } |
| 16 | |
| 17 | /// Start Cachegrind instrumentation if not already enabled. Use this in |
| 18 | /// combination with `std.valgrind.cachegrind.stopInstrumentation` and |
| 19 | /// `--instr-at-start` to measure only part of a client program's execution. |
| 20 | pub fn startInstrumentation() void { |
| 21 | doClientRequestStmt(.StartInstrumentation, 0, 0, 0, 0, 0); |
| 22 | } |
| 23 | |
| 24 | /// Stop Cachegrind instrumentation if not already disabled. Use this in |
| 25 | /// combination with `std.valgrind.cachegrind.startInstrumentation` and |
| 26 | /// `--instr-at-start` to measure only part of a client program's execution. |
| 27 | pub fn stopInstrumentation() void { |
| 28 | doClientRequestStmt(.StopInstrumentation, 0, 0, 0, 0, 0); |
| 29 | } |