core/sys/valgrind
sys_valgrind
Types
7Callgrind_Client_Request
Callgrind_Client_Request :: enum uintptr {
Dump_Stats = 'C'<<24 | 'T'<<16,
Zero_Stats,
Toggle_Collect,
Dump_Stats_At,
Start_Instrumentation,
Stop_Instrumentation,
}SourceClient_Request
Client_Request :: enum uintptr {
Running_On_Valgrind = 4097,
Discard_Translations = 4098,
Client_Call0 = 4353,
Client_Call1 = 4354,
Client_Call2 = 4355,
Client_Call3 = 4356,
Count_Errors = 4609,
Gdb_Monitor_Command = 4610,
Malloc_Like_Block = 4865,
Resize_Inplace_Block = 4875,
Free_Like_Block = 4866,
Create_Mem_Pool = 4867,
Destroy_Mem_Pool = 4868,
Mem_Pool_Alloc = 4869,
Mem_Pool_Free = 4870,
Mem_Pool_Trim = 4871,
Move_Mem_Pool = 4872,
Mem_Pool_Change = 4873,
Mem_Pool_Exists = 4874,
Printf = 5121,
Printf_Backtrace = 5122,
Printf_Valist_By_Ref = 5123,
Printf_Backtrace_Valist_By_Ref = 5124,
Stack_Register = 5377,
Stack_Deregister = 5378,
Stack_Change = 5379,
Load_Pdb_Debug_Info = 5633,
Map_Ip_To_Src_Loc = 5889,
Change_Err_Disablement = 6145,
Vex_Init_For_Iri = 6401,
Inner_Threads = 6402,
}SourceCount_Result
Count_Result :: struct {
leaked: uint,
dubious: uint,
reachable: uint,
suppressed: uint,
}SourceHelgrind_Client_Request
Helgrind_Client_Request :: enum uintptr {
Clean_Memory = 'H'<<24 | 'G'<<16,
Set_My_pthread_t = ('H'<<25 | 'G'<<16)+256,
Pthread_Join_Post,
Pthread_Mutex_Init_Post,
Pthread_Mutex_Destroy_Pre,
Pthread_Mutex_Unlock_Pre,
Pthread_Mutex_Unlock_Post,
Pthread_Mutex_Lock_Pre,
Pthread_Mutex_Lock_Post,
Pthread_Cond_Signal_Pre,
Pthread_Cond_Broadcast_Pre,
Pthread_Cond_Wait_Pre,
Pthread_Cond_Wait_Post,
Pthread_Cond_Destroy_Pre,
Pthread_Rwlock_Init_Post,
Pthread_Rwlock_Destroy_Pre,
Pthread_Rwlock_Lock_Pre,
Pthread_Rwlock_Lock_Post,
Pthread_Rwlock_Unlock_Pre,
Pthread_Rwlock_Unlock_Post,
Posix_Sem_Init_Post,
Posix_Sem_Destroy_Pre,
Posix_Sem_Post_Pre,
Posix_Sem_Wait_Post,
Pthread_Barrier_Init_Pre,
Pthread_Barrier_Wait_Pre,
Pthread_Barrier_Destroy_Pre,
Pthread_Spin_Init_Or_Unlock_Pre,
Pthread_Spin_Init_Or_Unlock_Post,
Pthread_Spin_Lock_Pre,
Pthread_Spin_Lock_Post,
Pthread_Spin_Destroy_Pre,
Clientreq_Unimp,
Userso_Send_Pre,
Userso_Recv_Post,
Userso_Forget_All,
Reserved2,
Reserved3,
Reserved4,
Arange_Make_Untracked,
Arange_Make_Tracked,
Pthread_Barrier_Resize_Pre,
Clean_Memory_Heapblock,
Pthread_Cond_Init_Post,
}SourceMem_Check_Client_Request
Mem_Check_Client_Request :: enum uintptr {
Make_Mem_No_Access = 'M'<<24 | 'C'<<16,
Make_Mem_Undefined,
Make_Mem_Defined,
Discard,
Check_Mem_Is_Addressable,
Check_Mem_Is_Defined,
Do_Leak_Check,
Count_Leaks,
Get_Vbits,
Set_Vbits,
Create_Block,
Make_Mem_Defined_If_Addressable,
Count_Leak_Blocks,
Enable_Addr_Error_Reporting_In_Range,
Disable_Addr_Error_Reporting_In_Range,
}SourceMem_Pool_Flag
Mem_Pool_Flag :: enum uintptr {
Auto_Free = 0,
Meta_Pool = 1,
}SourceMem_Pool_Flags
Mem_Pool_Flags :: bit_set[Mem_Pool_Flag; uintptr]SourceProcedures
92added_leak_check
added_leak_check :: proc()SourceSame as leak_check() but only showing the entries for which there was an increase in leaked bytes or leaked nr of blocks since the previous leak search.
callgrind_client_request_expr
callgrind_client_request_expr :: proc(
default: uintptr,
request: Callgrind_Client_Request,
a0: uintptr,
a1: uintptr,
a2: uintptr,
a3: uintptr,
a4: uintptr,
) -> (uintptr)Sourcecallgrind_client_request_stmt
callgrind_client_request_stmt :: proc(
request: Callgrind_Client_Request,
a0: uintptr,
a1: uintptr,
a2: uintptr,
a3: uintptr,
a4: uintptr,
)Sourcechanged_leak_check
changed_leak_check :: proc()SourceSame as added_leak_check() but showing entries with increased or decreased leaked bytes/blocks since previous leak search.
check_mem_is_addressable
check_mem_is_addressable :: proc(qzz: []u8) -> (uintptr)SourceCheck that memory at raw_data(qzz) is addressable for len(qzz) bytes. If suitable addressibility is not established, Valgrind prints an error message and returns the address of the first offending byte. Otherwise it returns zero.
check_mem_is_defined
check_mem_is_defined :: proc(qzz: []u8) -> (uintptr)SourceCheck that memory at raw_data(qzz) is addressable and defined for len(qzz) bytes. If suitable addressibility and definedness are not established, Valgrind prints an error message and returns the address of the first offending byte. Otherwise it returns zero.
client_request_expr
client_request_expr :: proc(
default: uintptr,
request: Client_Request,
a0: uintptr,
a1: uintptr,
a2: uintptr,
a3: uintptr,
a4: uintptr,
) -> (uintptr)Sourceclient_request_stmt
client_request_stmt :: proc(
request: Client_Request,
a0: uintptr,
a1: uintptr,
a2: uintptr,
a3: uintptr,
a4: uintptr,
)Sourcecount_errrors
count_errrors :: proc() -> (uint)SourceCounts the number of errors that have been recorded by a tool.
count_leak_blocks
count_leak_blocks :: proc() -> (res: Count_Result)Sourcecount_leaks
count_leaks :: proc() -> (res: Count_Result)Sourcecreate_block
create_block :: proc(qzz: []u8, desc: cstring) -> (bool)SourceCreate a block-description handle. The description is an ascii string which is included in any messages pertaining to addresses within the specified memory range. Has no other effect on the properties of the memory range.
create_mem_pool
create_mem_pool :: proc(pool: rawptr, rz_b: uintptr, is_zeroed: bool, flags: Mem_Pool_Flags)SourceCreate a memory pool.
destroy_mem_pool
destroy_mem_pool :: proc(pool: rawptr)SourceDestroy a memory pool.
disable_addr_error_reporting_in_range
disable_addr_error_reporting_in_range :: proc(qzz: []u8) -> (uintptr)SourceDisable reporting of addressing errors in the specified address range.
disable_error_reporting
disable_error_reporting :: proc()SourceDisable error reporting for the current thread/ It behaves in a stack-like way, meaning you can safely call this multiple times given that enable_error_reporting() is called the same number of times to re-enable the error reporting. The first call of this macro disables reporting. Subsequent calls have no effect except to increase the number of enable_error_reporting() calls needed to re-enable reporting. Child threads do not inherit this setting from their parents; they are always created with reporting enabled.
discard
discard :: proc(blk_index: uintptr) -> (bool)SourceDiscard a block-description-handle. Returns true for an invalid handle, false for a valid handle.
discard_translations
discard_translations :: proc(qzz: []u8)SourceDiscard translation of code in the slice qzz. Useful if you are debugging a JIT-er or some such, since it provides a way to make sure valgrind will retranslate the invalidated area.
dump_stats
dump_stats :: proc()SourceDump current state of cost centres, and zero them afterwards.
dump_stats_at
dump_stats_at :: proc(pos_str: rawptr)SourceDump current state of cost centres, 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.
enable_addr_error_reporting_in_range
enable_addr_error_reporting_in_range :: proc(qzz: []u8) -> (uintptr)Source(Re-)enable reporting of addressing errors in the specified address range.
enable_error_reporting
enable_error_reporting :: proc()SourceRe-enable error reporting
free_like_block
free_like_block :: proc(addr: rawptr, rz_b: uintptr)Sourceget_vbits
get_vbits :: proc(zza: []u8, zzvbits: []u8) -> (u8)SourceGet the validity data for addresses zza and copy it into the provided zzvbits array. Return values: 0 - if not running on valgrind 1 - success 2 - [previously indicated unaligned arrays; these are now allowed] 3 - if any parts of zzsrc/zzvbits are not addressable. The metadata is not copied in cases 0, 2 or 3 so it should be impossible to segfault your system by using this call.
helgrind_annotate_condvar_lock_wait
helgrind_annotate_condvar_lock_wait :: proc(cv: rawptr, lock: rawptr)Sourcehelgrind_annotate_condvar_signal
helgrind_annotate_condvar_signal :: proc(cv: rawptr)Sourcehelgrind_annotate_condvar_signal_all
helgrind_annotate_condvar_signal_all :: proc(cv: rawptr)Sourcehelgrind_annotate_condvar_wait
helgrind_annotate_condvar_wait :: proc(cv: rawptr)Sourcehelgrind_barrier_destroy_pre
helgrind_barrier_destroy_pre :: proc(bar: rawptr)Sourcehelgrind_barrier_init_pre
helgrind_barrier_init_pre :: proc(bar: rawptr, count: uint, resizable: bool)Sourcehelgrind_barrier_resize_pre
helgrind_barrier_resize_pre :: proc(bar: rawptr, new_count: uint)Sourcehelgrind_barrier_wait_pre
helgrind_barrier_wait_pre :: proc(bar: rawptr)Sourcehelgrind_clean_memory
helgrind_clean_memory :: proc(qzz_start: rawptr, qzz_len: uint)Sourcehelgrind_clean_memory_heap_block
helgrind_clean_memory_heap_block :: proc(qzz_blockstart: rawptr) -> (int)Sourcehelgrind_clean_memory_slice
helgrind_clean_memory_slice :: proc(qzz: []u8)Sourcehelgrind_client_request_expr
helgrind_client_request_expr :: proc(
default: uintptr,
request: Helgrind_Client_Request,
a0: uintptr,
a1: uintptr,
a2: uintptr,
a3: uintptr,
a4: uintptr,
) -> (uintptr)Sourcehelgrind_client_request_stmt
helgrind_client_request_stmt :: proc(
request: Helgrind_Client_Request,
a0: uintptr,
a1: uintptr,
a2: uintptr,
a3: uintptr,
a4: uintptr,
)Sourcehelgrind_client_request_unimp
helgrind_client_request_unimp :: proc(msg: cstring)Sourcehelgrind_cond_broadcast_pre
helgrind_cond_broadcast_pre :: proc(cond: rawptr)Sourcehelgrind_cond_destroy_pre
helgrind_cond_destroy_pre :: proc(cond: rawptr)Sourcehelgrind_cond_init_post
helgrind_cond_init_post :: proc(cond: rawptr)Sourcehelgrind_cond_signal_pre
helgrind_cond_signal_pre :: proc(cond: rawptr)Sourcehelgrind_cond_wait_post
helgrind_cond_wait_post :: proc(cond: rawptr, lock: rawptr) -> (bool)Sourcehelgrind_cond_wait_pre
helgrind_cond_wait_pre :: proc(cond: rawptr, lock: rawptr) -> (bool)Sourcehelgrind_disable_checking
helgrind_disable_checking :: proc(qzz_start: rawptr, qzz_len: uint)Sourcehelgrind_enable_checking
helgrind_enable_checking :: proc(qzz_start: rawptr, qzz_len: uint)Sourcehelgrind_mutex_destroy_pre
helgrind_mutex_destroy_pre :: proc(mutex: rawptr)Sourcehelgrind_mutex_init_post
helgrind_mutex_init_post :: proc(mutex: rawptr, mb_rec: uint)Sourcehelgrind_mutex_lock_post
helgrind_mutex_lock_post :: proc(mutex: rawptr)Sourcehelgrind_mutex_lock_pre
helgrind_mutex_lock_pre :: proc(mutex: rawptr, is_try_lock: bool)Sourcehelgrind_mutex_unlock_post
helgrind_mutex_unlock_post :: proc(mutex: rawptr)Sourcehelgrind_mutex_unlock_pre
helgrind_mutex_unlock_pre :: proc(mutex: rawptr)Sourcehelgrind_rwlock_destroy_pre
helgrind_rwlock_destroy_pre :: proc(lock: rawptr)Sourcehelgrind_rwlock_init_post
helgrind_rwlock_init_post :: proc(lock: rawptr)Sourcehelgrind_rwlock_lock_pre
helgrind_rwlock_lock_pre :: proc(lock: rawptr, is_w: bool)Sourcehelgrind_rwlock_unlock_post
helgrind_rwlock_unlock_post :: proc(lock: rawptr, is_w: bool)Sourcehelgrind_sem_destroy_pre
helgrind_sem_destroy_pre :: proc(sem: rawptr)Sourcehelgrind_sem_init_post
helgrind_sem_init_post :: proc(sem: rawptr, value: uint)Sourcehelgrind_sem_post_pre
helgrind_sem_post_pre :: proc(sem: rawptr)Sourcehelgrind_sem_wait_post
helgrind_sem_wait_post :: proc(sem: rawptr)Sourceinner_threads
inner_threads :: proc(qzz: rawptr)Sourceleak_check
leak_check :: proc()SourceDo a full memory leak check (like --leak-check=full) mid-execution.
make_mem_defined
make_mem_defined :: proc(qzz: []u8) -> (bool)SourceMark memory at raw_data(qzz) as addressable for len(qzz) bytes. Returns true when run on Valgrind and false otherwise.
make_mem_defined_if_addressable
make_mem_defined_if_addressable :: proc(qzz: []u8) -> (bool)SourceSimilar to make_mem_defined(qzz) except that addressability is not altered: bytes which are addressable are marked as defined, but those which are not addressable are left unchanged. Returns true when run on Valgrind and false otherwise.
make_mem_no_access
make_mem_no_access :: proc(qzz: []u8) -> (bool)SourceMark memory at raw_data(qzz) as unaddressable for len(qzz) bytes. Returns true when run on Valgrind and false otherwise.
make_mem_undefined
make_mem_undefined :: proc(qzz: []u8) -> (bool)SourceMark memory at raw_data(qzz) as addressable but undefined for len(qzz) bytes. Returns true when run on Valgrind and false otherwise.
malloc_like_block
malloc_like_block :: proc(mem: []u8, rz_b: uintptr, is_zeroed: bool)Sourcemap_ip_to_src_loc
map_ip_to_src_loc :: proc(addr: rawptr, buf64: ^[64]u8) -> (uintptr)SourceMap a code address to a source file name and line number. buf64 must point to a 64-byte buffer in the caller's address space. The result will be dumped in there and is guaranteed to be zero terminated. If no info is found, the first byte is set to zero.
mem_check_client_request_expr
mem_check_client_request_expr :: proc(
default: uintptr,
request: Mem_Check_Client_Request,
a0: uintptr,
a1: uintptr,
a2: uintptr,
a3: uintptr,
a4: uintptr,
) -> (uintptr)Sourcemem_check_client_request_stmt
mem_check_client_request_stmt :: proc(
request: Mem_Check_Client_Request,
a0: uintptr,
a1: uintptr,
a2: uintptr,
a3: uintptr,
a4: uintptr,
)Sourcemem_pool_alloc
mem_pool_alloc :: proc(pool: rawptr, mem: []u8)SourceAssociate a section of memory with a memory pool.
mem_pool_change
mem_pool_change :: proc(pool: rawptr, addr_a: rawptr, mem: []u8)SourceResize and/or move a section of memory associated with a memory pool.
mem_pool_exists
mem_pool_exists :: proc(pool: rawptr) -> (bool)SourceReturn true if a memory pool exists
mem_pool_free
mem_pool_free :: proc(pool: rawptr, addr: rawptr)SourceDisassociate a section of memory from a memory pool.
mem_pool_trim
mem_pool_trim :: proc(pool: rawptr, mem: []u8)SourceDisassociate parts of a section of memory outside a particular range.
monitor_command
monitor_command :: proc(command: cstring) -> (bool)Sourcemove_mem_pool
move_mem_pool :: proc(pool_a: rawptr, pool_b: rawptr)SourceResize and/or move a section of memory associated with a memory pool.
non_simd_call0
non_simd_call0 :: proc(p: proc() -> (uintptr)) -> (uintptr)Sourcenon_simd_call1
non_simd_call1 :: proc(p: proc() -> (uintptr), a0: uintptr) -> (uintptr)Sourcenon_simd_call2
non_simd_call2 :: proc(p: proc() -> (uintptr), a0: uintptr, a1: uintptr) -> (uintptr)Sourcenon_simd_call3
non_simd_call3 :: proc(p: proc() -> (uintptr), a0: uintptr, a1: uintptr, a2: uintptr) -> (uintptr)Sourcequick_leak_check
quick_leak_check :: proc()SourceDo a summary memory leak check (like --leak-check=summary) mid-execution.
resize_inplace_block
resize_inplace_block :: proc(old_mem: []u8, new_size: uint, rz_b: uintptr)Sourcerunning_on_valgrind
running_on_valgrind :: proc() -> (uint)SourceReturns the number of Valgrinds this code is running under 0 - running natively 1 - running under Valgrind 2 - running under Valgrind which is running under another Valgrind
set_vbits
set_vbits :: proc(zzvbits: []u8, zza: []u8) -> (u8)SourceSet the validity data for addresses zza, copying it from the provided zzvbits array. Return values: 0 - if not running on valgrind 1 - success 2 - [previously indicated unaligned arrays; these are now allowed] 3 - if any parts of zza/zzvbits are not addressable. The metadata is not copied in cases 0, 2 or 3 so it should be impossible to segfault your system by using this call.
stack_change
stack_change :: proc(id: uint, new_stack: []u8)SourceChange the start and end address of the stack id with the new_stack slice.
stack_deregister
stack_deregister :: proc(id: uintptr)SourceUnmark a section of memory associated with a stack id as being a stack.
stack_register
stack_register :: proc(stack: []u8) -> (stack_id: uintptr)SourceMark a section of memory as being a stack. Returns a stack id.
start_instrumentation
start_instrumentation :: proc()SourceStart 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.
stop_instrumentation
stop_instrumentation :: proc()SourceStop full callgrind instrumentation if not already switched off. This flushes Valgrinds translation cache, and does no additional instrumentation afterwards, which effectivly 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".
toggle_collect
toggle_collect :: proc()SourceToggles 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 centre.
zero_stats
zero_stats :: proc()SourceZero cost centres