| author | |
| committer | |
| log | cc76494c428599b769049eeb66fd7c877039068b |
| tree | f1faa95d8fd22d56553021ce4a2a1411e5083a15 |
| parent | 4a3bb557f1612bc9955b1bf97519afd027acff03 |
| signature |
3 files changed, 53 insertions(+), 53 deletions(-)
lib/std/valgrind.zig+29-29| ... | ... | @@ -96,48 +96,48 @@ fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, |
| 96 | 96 | /// running under Valgrind which is running under another Valgrind, |
| 97 | 97 | /// etc. |
| 98 | 98 | pub fn runningOnValgrind() usize { |
| 99 | return doClientRequestExpr(0, ClientRequest.RunningOnValgrind, 0, 0, 0, 0, 0); | |
| 99 | return doClientRequestExpr(0, .RunningOnValgrind, 0, 0, 0, 0, 0); | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /// Discard translation of code in the slice qzz. Useful if you are debugging |
| 103 | 103 | /// a JITter or some such, since it provides a way to make sure valgrind will |
| 104 | 104 | /// retranslate the invalidated area. Returns no value. |
| 105 | 105 | pub fn discardTranslations(qzz: []const u8) void { |
| 106 | doClientRequestStmt(ClientRequest.DiscardTranslations, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 106 | doClientRequestStmt(.DiscardTranslations, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | pub fn innerThreads(qzz: [*]u8) void { |
| 110 | doClientRequestStmt(ClientRequest.InnerThreads, qzz, 0, 0, 0, 0); | |
| 110 | doClientRequestStmt(.InnerThreads, qzz, 0, 0, 0, 0); | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | //pub fn printf(format: [*]const u8, args: ...) usize { |
| 114 | 114 | // return doClientRequestExpr(0, |
| 115 | // ClientRequest.PrintfValistByRef, | |
| 115 | // .PrintfValistByRef, | |
| 116 | 116 | // @ptrToInt(format), @ptrToInt(args), |
| 117 | 117 | // 0, 0, 0); |
| 118 | 118 | //} |
| 119 | 119 | |
| 120 | 120 | //pub fn printfBacktrace(format: [*]const u8, args: ...) usize { |
| 121 | 121 | // return doClientRequestExpr(0, |
| 122 | // ClientRequest.PrintfBacktraceValistByRef, | |
| 122 | // .PrintfBacktraceValistByRef, | |
| 123 | 123 | // @ptrToInt(format), @ptrToInt(args), |
| 124 | 124 | // 0, 0, 0); |
| 125 | 125 | //} |
| 126 | 126 | |
| 127 | 127 | pub fn nonSIMDCall0(func: fn (usize) usize) usize { |
| 128 | return doClientRequestExpr(0, ClientRequest.ClientCall0, @ptrToInt(func), 0, 0, 0, 0); | |
| 128 | return doClientRequestExpr(0, .ClientCall0, @ptrToInt(func), 0, 0, 0, 0); | |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | pub fn nonSIMDCall1(func: fn (usize, usize) usize, a1: usize) usize { |
| 132 | return doClientRequestExpr(0, ClientRequest.ClientCall1, @ptrToInt(func), a1, 0, 0, 0); | |
| 132 | return doClientRequestExpr(0, .ClientCall1, @ptrToInt(func), a1, 0, 0, 0); | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | pub fn nonSIMDCall2(func: fn (usize, usize, usize) usize, a1: usize, a2: usize) usize { |
| 136 | return doClientRequestExpr(0, ClientRequest.ClientCall2, @ptrToInt(func), a1, a2, 0, 0); | |
| 136 | return doClientRequestExpr(0, .ClientCall2, @ptrToInt(func), a1, a2, 0, 0); | |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | pub fn nonSIMDCall3(func: fn (usize, usize, usize, usize) usize, a1: usize, a2: usize, a3: usize) usize { |
| 140 | return doClientRequestExpr(0, ClientRequest.ClientCall3, @ptrToInt(func), a1, a2, a3, 0); | |
| 140 | return doClientRequestExpr(0, .ClientCall3, @ptrToInt(func), a1, a2, a3, 0); | |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /// Counts the number of errors that have been recorded by a tool. Nb: |
| ... | ... | @@ -145,19 +145,19 @@ pub fn nonSIMDCall3(func: fn (usize, usize, usize, usize) usize, a1: usize, a2: |
| 145 | 145 | /// VG_(unique_error)() for them to be counted. |
| 146 | 146 | pub fn countErrors() usize { |
| 147 | 147 | return doClientRequestExpr(0, // default return |
| 148 | ClientRequest.CountErrors, 0, 0, 0, 0, 0); | |
| 148 | .CountErrors, 0, 0, 0, 0, 0); | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | pub fn mallocLikeBlock(mem: []u8, rzB: usize, is_zeroed: bool) void { |
| 152 | doClientRequestStmt(ClientRequest.MalloclikeBlock, @ptrToInt(mem.ptr), mem.len, rzB, @boolToInt(is_zeroed), 0); | |
| 152 | doClientRequestStmt(.MalloclikeBlock, @ptrToInt(mem.ptr), mem.len, rzB, @boolToInt(is_zeroed), 0); | |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | pub fn resizeInPlaceBlock(oldmem: []u8, newsize: usize, rzB: usize) void { |
| 156 | doClientRequestStmt(ClientRequest.ResizeinplaceBlock, @ptrToInt(oldmem.ptr), oldmem.len, newsize, rzB, 0); | |
| 156 | doClientRequestStmt(.ResizeinplaceBlock, @ptrToInt(oldmem.ptr), oldmem.len, newsize, rzB, 0); | |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | pub fn freeLikeBlock(addr: [*]u8, rzB: usize) void { |
| 160 | doClientRequestStmt(ClientRequest.FreelikeBlock, @ptrToInt(addr), rzB, 0, 0, 0); | |
| 160 | doClientRequestStmt(.FreelikeBlock, @ptrToInt(addr), rzB, 0, 0, 0); | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /// Create a memory pool. |
| ... | ... | @@ -166,66 +166,66 @@ pub const MempoolFlags = extern enum { |
| 166 | 166 | MetaPool = 2, |
| 167 | 167 | }; |
| 168 | 168 | pub fn createMempool(pool: [*]u8, rzB: usize, is_zeroed: bool, flags: usize) void { |
| 169 | doClientRequestStmt(ClientRequest.CreateMempool, @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags, 0); | |
| 169 | doClientRequestStmt(.CreateMempool, @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags, 0); | |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /// Destroy a memory pool. |
| 173 | 173 | pub fn destroyMempool(pool: [*]u8) void { |
| 174 | doClientRequestStmt(ClientRequest.DestroyMempool, pool, 0, 0, 0, 0); | |
| 174 | doClientRequestStmt(.DestroyMempool, pool, 0, 0, 0, 0); | |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /// Associate a piece of memory with a memory pool. |
| 178 | 178 | pub fn mempoolAlloc(pool: [*]u8, mem: []u8) void { |
| 179 | doClientRequestStmt(ClientRequest.MempoolAlloc, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0); | |
| 179 | doClientRequestStmt(.MempoolAlloc, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0); | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /// Disassociate a piece of memory from a memory pool. |
| 183 | 183 | pub fn mempoolFree(pool: [*]u8, addr: [*]u8) void { |
| 184 | doClientRequestStmt(ClientRequest.MempoolFree, @ptrToInt(pool), @ptrToInt(addr), 0, 0, 0); | |
| 184 | doClientRequestStmt(.MempoolFree, @ptrToInt(pool), @ptrToInt(addr), 0, 0, 0); | |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /// Disassociate any pieces outside a particular range. |
| 188 | 188 | pub fn mempoolTrim(pool: [*]u8, mem: []u8) void { |
| 189 | doClientRequestStmt(ClientRequest.MempoolTrim, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0); | |
| 189 | doClientRequestStmt(.MempoolTrim, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0); | |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /// Resize and/or move a piece associated with a memory pool. |
| 193 | 193 | pub fn moveMempool(poolA: [*]u8, poolB: [*]u8) void { |
| 194 | doClientRequestStmt(ClientRequest.MoveMempool, @ptrToInt(poolA), @ptrToInt(poolB), 0, 0, 0); | |
| 194 | doClientRequestStmt(.MoveMempool, @ptrToInt(poolA), @ptrToInt(poolB), 0, 0, 0); | |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /// Resize and/or move a piece associated with a memory pool. |
| 198 | 198 | pub fn mempoolChange(pool: [*]u8, addrA: [*]u8, mem: []u8) void { |
| 199 | doClientRequestStmt(ClientRequest.MempoolChange, @ptrToInt(pool), @ptrToInt(addrA), @ptrToInt(mem.ptr), mem.len, 0); | |
| 199 | doClientRequestStmt(.MempoolChange, @ptrToInt(pool), @ptrToInt(addrA), @ptrToInt(mem.ptr), mem.len, 0); | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /// Return if a mempool exists. |
| 203 | 203 | pub fn mempoolExists(pool: [*]u8) bool { |
| 204 | return doClientRequestExpr(0, ClientRequest.MempoolExists, @ptrToInt(pool), 0, 0, 0, 0) != 0; | |
| 204 | return doClientRequestExpr(0, .MempoolExists, @ptrToInt(pool), 0, 0, 0, 0) != 0; | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /// Mark a piece of memory as being a stack. Returns a stack id. |
| 208 | 208 | /// start is the lowest addressable stack byte, end is the highest |
| 209 | 209 | /// addressable stack byte. |
| 210 | 210 | pub fn stackRegister(stack: []u8) usize { |
| 211 | return doClientRequestExpr(0, ClientRequest.StackRegister, @ptrToInt(stack.ptr), @ptrToInt(stack.ptr) + stack.len, 0, 0, 0); | |
| 211 | return doClientRequestExpr(0, .StackRegister, @ptrToInt(stack.ptr), @ptrToInt(stack.ptr) + stack.len, 0, 0, 0); | |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /// Unmark the piece of memory associated with a stack id as being a stack. |
| 215 | 215 | pub fn stackDeregister(id: usize) void { |
| 216 | doClientRequestStmt(ClientRequest.StackDeregister, id, 0, 0, 0, 0); | |
| 216 | doClientRequestStmt(.StackDeregister, id, 0, 0, 0, 0); | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /// Change the start and end address of the stack id. |
| 220 | 220 | /// start is the new lowest addressable stack byte, end is the new highest |
| 221 | 221 | /// addressable stack byte. |
| 222 | 222 | pub fn stackChange(id: usize, newstack: []u8) void { |
| 223 | doClientRequestStmt(ClientRequest.StackChange, id, @ptrToInt(newstack.ptr), @ptrToInt(newstack.ptr) + newstack.len, 0, 0); | |
| 223 | doClientRequestStmt(.StackChange, id, @ptrToInt(newstack.ptr), @ptrToInt(newstack.ptr) + newstack.len, 0, 0); | |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | // Load PDB debug info for Wine PE image_map. |
| 227 | 227 | // pub fn loadPdbDebuginfo(fd, ptr, total_size, delta) void { |
| 228 | // doClientRequestStmt(ClientRequest.LoadPdbDebuginfo, | |
| 228 | // doClientRequestStmt(.LoadPdbDebuginfo, | |
| 229 | 229 | // fd, ptr, total_size, delta, |
| 230 | 230 | // 0); |
| 231 | 231 | // } |
| ... | ... | @@ -235,7 +235,7 @@ pub fn stackChange(id: usize, newstack: []u8) void { |
| 235 | 235 | /// result will be dumped in there and is guaranteed to be zero |
| 236 | 236 | /// terminated. If no info is found, the first byte is set to zero. |
| 237 | 237 | pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize { |
| 238 | return doClientRequestExpr(0, ClientRequest.MapIpToSrcloc, @ptrToInt(addr), @ptrToInt(&buf64[0]), 0, 0, 0); | |
| 238 | return doClientRequestExpr(0, .MapIpToSrcloc, @ptrToInt(addr), @ptrToInt(&buf64[0]), 0, 0, 0); | |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /// Disable error reporting for this thread. Behaves in a stack like |
| ... | ... | @@ -247,12 +247,12 @@ pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize { |
| 247 | 247 | /// reporting. Child threads do not inherit this setting from their |
| 248 | 248 | /// parents -- they are always created with reporting enabled. |
| 249 | 249 | pub fn disableErrorReporting() void { |
| 250 | doClientRequestStmt(ClientRequest.ChangeErrDisablement, 1, 0, 0, 0, 0); | |
| 250 | doClientRequestStmt(.ChangeErrDisablement, 1, 0, 0, 0, 0); | |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /// Re-enable error reporting, (see disableErrorReporting()) |
| 254 | 254 | pub fn enableErrorReporting() void { |
| 255 | doClientRequestStmt(ClientRequest.ChangeErrDisablement, math.maxInt(usize), 0, 0, 0, 0); | |
| 255 | doClientRequestStmt(.ChangeErrDisablement, math.maxInt(usize), 0, 0, 0, 0); | |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /// Execute a monitor command from the client program. |
| ... | ... | @@ -261,7 +261,7 @@ pub fn enableErrorReporting() void { |
| 261 | 261 | /// If no connection is opened, output will go to the log output. |
| 262 | 262 | /// Returns 1 if command not recognised, 0 otherwise. |
| 263 | 263 | pub fn monitorCommand(command: [*]u8) bool { |
| 264 | return doClientRequestExpr(0, ClientRequest.GdbMonitorCommand, @ptrToInt(command.ptr), 0, 0, 0, 0) != 0; | |
| 264 | return doClientRequestExpr(0, .GdbMonitorCommand, @ptrToInt(command.ptr), 0, 0, 0, 0) != 0; | |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | pub const memcheck = @import("valgrind/memcheck.zig"); |
lib/std/valgrind/callgrind.zig+6-6| ... | ... | @@ -20,7 +20,7 @@ fn doCallgrindClientRequestStmt(request: CallgrindClientRequest, a1: usize, a2: |
| 20 | 20 | |
| 21 | 21 | /// Dump current state of cost centers, and zero them afterwards |
| 22 | 22 | pub fn dumpStats() void { |
| 23 | doCallgrindClientRequestStmt(CallgrindClientRequest.DumpStats, 0, 0, 0, 0, 0); | |
| 23 | doCallgrindClientRequestStmt(.DumpStats, 0, 0, 0, 0, 0); | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /// Dump current state of cost centers, and zero them afterwards. |
| ... | ... | @@ -28,12 +28,12 @@ pub fn dumpStats() void { |
| 28 | 28 | /// the dump. This string is written as a description field into the |
| 29 | 29 | /// profile data dump. |
| 30 | 30 | pub fn dumpStatsAt(pos_str: [*]u8) void { |
| 31 | doCallgrindClientRequestStmt(CallgrindClientRequest.DumpStatsAt, @ptrToInt(pos_str), 0, 0, 0, 0); | |
| 31 | doCallgrindClientRequestStmt(.DumpStatsAt, @ptrToInt(pos_str), 0, 0, 0, 0); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /// Zero cost centers |
| 35 | 35 | pub fn zeroStats() void { |
| 36 | doCallgrindClientRequestStmt(CallgrindClientRequest.ZeroStats, 0, 0, 0, 0, 0); | |
| 36 | doCallgrindClientRequestStmt(.ZeroStats, 0, 0, 0, 0, 0); | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /// Toggles collection state. |
| ... | ... | @@ -41,7 +41,7 @@ pub fn zeroStats() void { |
| 41 | 41 | /// should be noted or if they are to be ignored. Events are noted |
| 42 | 42 | /// by increment of counters in a cost center |
| 43 | 43 | pub fn toggleCollect() void { |
| 44 | doCallgrindClientRequestStmt(CallgrindClientRequest.ToggleCollect, 0, 0, 0, 0, 0); | |
| 44 | doCallgrindClientRequestStmt(.ToggleCollect, 0, 0, 0, 0, 0); | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /// Start full callgrind instrumentation if not already switched on. |
| ... | ... | @@ -49,7 +49,7 @@ pub fn toggleCollect() void { |
| 49 | 49 | /// this will lead to an artificial cache warmup phase afterwards with |
| 50 | 50 | /// cache misses which would not have happened in reality. |
| 51 | 51 | pub fn startInstrumentation() void { |
| 52 | doCallgrindClientRequestStmt(CallgrindClientRequest.StartInstrumentation, 0, 0, 0, 0, 0); | |
| 52 | doCallgrindClientRequestStmt(.StartInstrumentation, 0, 0, 0, 0, 0); | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /// Stop full callgrind instrumentation if not already switched off. |
| ... | ... | @@ -60,5 +60,5 @@ pub fn startInstrumentation() void { |
| 60 | 60 | /// To start Callgrind in this mode to ignore the setup phase, use |
| 61 | 61 | /// the option "--instr-atstart=no". |
| 62 | 62 | pub fn stopInstrumentation() void { |
| 63 | doCallgrindClientRequestStmt(CallgrindClientRequest.StopInstrumentation, 0, 0, 0, 0, 0); | |
| 63 | doCallgrindClientRequestStmt(.StopInstrumentation, 0, 0, 0, 0, 0); | |
| 64 | 64 | } |
lib/std/valgrind/memcheck.zig+18-18| ... | ... | @@ -31,7 +31,7 @@ fn doMemCheckClientRequestStmt(request: MemCheckClientRequest, a1: usize, a2: us |
| 31 | 31 | /// This returns -1 when run on Valgrind and 0 otherwise. |
| 32 | 32 | pub fn makeMemNoAccess(qzz: []u8) i1 { |
| 33 | 33 | return @intCast(i1, doMemCheckClientRequestExpr(0, // default return |
| 34 | MemCheckClientRequest.MakeMemNoAccess, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); | |
| 34 | .MakeMemNoAccess, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /// Similarly, mark memory at qzz.ptr as addressable but undefined |
| ... | ... | @@ -39,7 +39,7 @@ pub fn makeMemNoAccess(qzz: []u8) i1 { |
| 39 | 39 | /// This returns -1 when run on Valgrind and 0 otherwise. |
| 40 | 40 | pub fn makeMemUndefined(qzz: []u8) i1 { |
| 41 | 41 | return @intCast(i1, doMemCheckClientRequestExpr(0, // default return |
| 42 | MemCheckClientRequest.MakeMemUndefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); | |
| 42 | .MakeMemUndefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /// Similarly, mark memory at qzz.ptr as addressable and defined |
| ... | ... | @@ -47,7 +47,7 @@ pub fn makeMemUndefined(qzz: []u8) i1 { |
| 47 | 47 | pub fn makeMemDefined(qzz: []u8) i1 { |
| 48 | 48 | // This returns -1 when run on Valgrind and 0 otherwise. |
| 49 | 49 | return @intCast(i1, doMemCheckClientRequestExpr(0, // default return |
| 50 | MemCheckClientRequest.MakeMemDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); | |
| 50 | .MakeMemDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /// Similar to makeMemDefined except that addressability is |
| ... | ... | @@ -56,7 +56,7 @@ pub fn makeMemDefined(qzz: []u8) i1 { |
| 56 | 56 | /// This returns -1 when run on Valgrind and 0 otherwise. |
| 57 | 57 | pub fn makeMemDefinedIfAddressable(qzz: []u8) i1 { |
| 58 | 58 | return @intCast(i1, doMemCheckClientRequestExpr(0, // default return |
| 59 | MemCheckClientRequest.MakeMemDefinedIfAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); | |
| 59 | .MakeMemDefinedIfAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0)); | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /// Create a block-description handle. The description is an ascii |
| ... | ... | @@ -65,14 +65,14 @@ pub fn makeMemDefinedIfAddressable(qzz: []u8) i1 { |
| 65 | 65 | /// properties of the memory range. |
| 66 | 66 | pub fn createBlock(qzz: []u8, desc: [*]u8) usize { |
| 67 | 67 | return doMemCheckClientRequestExpr(0, // default return |
| 68 | MemCheckClientRequest.CreateBlock, @ptrToInt(qzz.ptr), qzz.len, @ptrToInt(desc), 0, 0); | |
| 68 | .CreateBlock, @ptrToInt(qzz.ptr), qzz.len, @ptrToInt(desc), 0, 0); | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /// Discard a block-description-handle. Returns 1 for an |
| 72 | 72 | /// invalid handle, 0 for a valid handle. |
| 73 | 73 | pub fn discard(blkindex) bool { |
| 74 | 74 | return doMemCheckClientRequestExpr(0, // default return |
| 75 | MemCheckClientRequest.Discard, 0, blkindex, 0, 0, 0) != 0; | |
| 75 | .Discard, 0, blkindex, 0, 0, 0) != 0; | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /// Check that memory at qzz.ptr is addressable for qzz.len bytes. |
| ... | ... | @@ -80,7 +80,7 @@ pub fn discard(blkindex) bool { |
| 80 | 80 | /// error message and returns the address of the first offending byte. |
| 81 | 81 | /// Otherwise it returns zero. |
| 82 | 82 | pub fn checkMemIsAddressable(qzz: []u8) usize { |
| 83 | return doMemCheckClientRequestExpr(0, MemCheckClientRequest.CheckMemIsAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 83 | return doMemCheckClientRequestExpr(0, .CheckMemIsAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /// Check that memory at qzz.ptr is addressable and defined for |
| ... | ... | @@ -88,31 +88,31 @@ pub fn checkMemIsAddressable(qzz: []u8) usize { |
| 88 | 88 | /// established, Valgrind prints an error message and returns the |
| 89 | 89 | /// address of the first offending byte. Otherwise it returns zero. |
| 90 | 90 | pub fn checkMemIsDefined(qzz: []u8) usize { |
| 91 | return doMemCheckClientRequestExpr(0, MemCheckClientRequest.CheckMemIsDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 91 | return doMemCheckClientRequestExpr(0, .CheckMemIsDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /// Do a full memory leak check (like --leak-check=full) mid-execution. |
| 95 | 95 | pub fn doLeakCheck() void { |
| 96 | doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK, 0, 0, 0, 0, 0); | |
| 96 | doMemCheckClientRequestStmt(.DO_LEAK_CHECK, 0, 0, 0, 0, 0); | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /// Same as doLeakCheck() but only showing the entries for |
| 100 | 100 | /// which there was an increase in leaked bytes or leaked nr of blocks |
| 101 | 101 | /// since the previous leak search. |
| 102 | 102 | pub fn doAddedLeakCheck() void { |
| 103 | doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK, 0, 1, 0, 0, 0); | |
| 103 | doMemCheckClientRequestStmt(.DO_LEAK_CHECK, 0, 1, 0, 0, 0); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /// Same as doAddedLeakCheck() but showing entries with |
| 107 | 107 | /// increased or decreased leaked bytes/blocks since previous leak |
| 108 | 108 | /// search. |
| 109 | 109 | pub fn doChangedLeakCheck() void { |
| 110 | doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK, 0, 2, 0, 0, 0); | |
| 110 | doMemCheckClientRequestStmt(.DO_LEAK_CHECK, 0, 2, 0, 0, 0); | |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /// Do a summary memory leak check (like --leak-check=summary) mid-execution. |
| 114 | 114 | pub fn doQuickLeakCheck() void { |
| 115 | doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK, 1, 0, 0, 0, 0); | |
| 115 | doMemCheckClientRequestStmt(.DO_LEAK_CHECK, 1, 0, 0, 0, 0); | |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /// Return number of leaked, dubious, reachable and suppressed bytes found by |
| ... | ... | @@ -131,7 +131,7 @@ pub fn countLeaks() CountResult { |
| 131 | 131 | .reachable = 0, |
| 132 | 132 | .suppressed = 0, |
| 133 | 133 | }; |
| 134 | doMemCheckClientRequestStmt(MemCheckClientRequest.CountLeaks, &res.leaked, &res.dubious, &res.reachable, &res.suppressed, 0); | |
| 134 | doMemCheckClientRequestStmt(.CountLeaks, &res.leaked, &res.dubious, &res.reachable, &res.suppressed, 0); | |
| 135 | 135 | return res; |
| 136 | 136 | } |
| 137 | 137 | |
| ... | ... | @@ -142,7 +142,7 @@ pub fn countLeakBlocks() CountResult { |
| 142 | 142 | .reachable = 0, |
| 143 | 143 | .suppressed = 0, |
| 144 | 144 | }; |
| 145 | doMemCheckClientRequestStmt(MemCheckClientRequest.CountLeakBlocks, &res.leaked, &res.dubious, &res.reachable, &res.suppressed, 0); | |
| 145 | doMemCheckClientRequestStmt(.CountLeakBlocks, &res.leaked, &res.dubious, &res.reachable, &res.suppressed, 0); | |
| 146 | 146 | return res; |
| 147 | 147 | } |
| 148 | 148 | |
| ... | ... | @@ -156,7 +156,7 @@ pub fn countLeakBlocks() CountResult { |
| 156 | 156 | /// impossible to segfault your system by using this call. |
| 157 | 157 | pub fn getVbits(zza: []u8, zzvbits: []u8) u2 { |
| 158 | 158 | std.debug.assert(zzvbits.len >= zza.len / 8); |
| 159 | return @intCast(u2, doMemCheckClientRequestExpr(0, MemCheckClientRequest.GetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0)); | |
| 159 | return @intCast(u2, doMemCheckClientRequestExpr(0, .GetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0)); | |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /// Set the validity data for addresses zza, copying it |
| ... | ... | @@ -169,17 +169,17 @@ pub fn getVbits(zza: []u8, zzvbits: []u8) u2 { |
| 169 | 169 | /// impossible to segfault your system by using this call. |
| 170 | 170 | pub fn setVbits(zzvbits: []u8, zza: []u8) u2 { |
| 171 | 171 | std.debug.assert(zzvbits.len >= zza.len / 8); |
| 172 | return @intCast(u2, doMemCheckClientRequestExpr(0, MemCheckClientRequest.SetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0)); | |
| 172 | return @intCast(u2, doMemCheckClientRequestExpr(0, .SetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0)); | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /// Disable and re-enable reporting of addressing errors in the |
| 176 | 176 | /// specified address range. |
| 177 | 177 | pub fn disableAddrErrorReportingInRange(qzz: []u8) usize { |
| 178 | 178 | return doMemCheckClientRequestExpr(0, // default return |
| 179 | MemCheckClientRequest.DisableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 179 | .DisableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | pub fn enableAddrErrorReportingInRange(qzz: []u8) usize { |
| 183 | 183 | return doMemCheckClientRequestExpr(0, // default return |
| 184 | MemCheckClientRequest.EnableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 184 | .EnableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0); | |
| 185 | 185 | } |