#include #include #include "valgrind/valgrind.h" #include "valgrind/cachegrind.h" #include "valgrind/callgrind.h" #include "valgrind/dhat.h" #include "valgrind/drd.h" #include "valgrind/helgrind.h" #include "valgrind/memcheck.h" #ifdef VALGRIND_DO_CLIENT_REQUEST_EXPR const bool IC_IS_PLATFORM_SUPPORTED_BY_VALGRIND = true; #else const bool IC_IS_PLATFORM_SUPPORTED_BY_VALGRIND = false; #endif #ifdef __VALGRIND_MAJOR__ const unsigned int IC_VALGRIND_MAJOR = __VALGRIND_MAJOR__; #else const unsigned int IC_VALGRIND_MAJOR = 0; #endif #ifdef __VALGRIND_MINOR__ const unsigned int IC_VALGRIND_MINOR = __VALGRIND_MINOR__; #else const unsigned int IC_VALGRIND_MINOR = 0; #endif /* * Instead of taking the original enums, we wrap the enum variants in our own * type. So, we stay in control which client requests we offer and can sort out * client requests which are not available in a specific valgrind version. * * If a definition does not exist we still assign a value to the enum variant. * Values <= 0x1000 indicate that this enum variant does not exists and we * cannot execute the client request. * * The check usage of the enum variant value is done in the rust source code * which uses the bindings to our enums from this header file. */ /* * VALGRIND * */ typedef enum { #ifdef RUNNING_ON_VALGRIND IC_RUNNING_ON_VALGRIND = VG_USERREQ__RUNNING_ON_VALGRIND, #else IC_RUNNING_ON_VALGRIND = 0, #endif #ifdef VALGRIND_DISCARD_TRANSLATIONS IC_DISCARD_TRANSLATIONS = VG_USERREQ__DISCARD_TRANSLATIONS, #else IC_DISCARD_TRANSLATIONS = 1, #endif #ifdef VALGRIND_NON_SIMD_CALL0 IC_CLIENT_CALL0 = VG_USERREQ__CLIENT_CALL0, #else IC_CLIENT_CALL0 = 3, #endif #ifdef VALGRIND_NON_SIMD_CALL1 IC_CLIENT_CALL1 = VG_USERREQ__CLIENT_CALL1, #else IC_CLIENT_CALL1 = 4, #endif #ifdef VALGRIND_NON_SIMD_CALL2 IC_CLIENT_CALL2 = VG_USERREQ__CLIENT_CALL2, #else IC_CLIENT_CALL2 = 5, #endif #ifdef VALGRIND_NON_SIMD_CALL3 IC_CLIENT_CALL3 = VG_USERREQ__CLIENT_CALL3, #else IC_CLIENT_CALL3 = 6, #endif #ifdef VALGRIND_COUNT_ERRORS IC_COUNT_ERRORS = VG_USERREQ__COUNT_ERRORS, #else IC_COUNT_ERRORS = 7, #endif #ifdef VALGRIND_MALLOCLIKE_BLOCK IC_MALLOCLIKE_BLOCK = VG_USERREQ__MALLOCLIKE_BLOCK, #else IC_MALLOCLIKE_BLOCK = 8, #endif #ifdef VALGRIND_RESIZEINPLACE_BLOCK IC_RESIZEINPLACE_BLOCK = VG_USERREQ__RESIZEINPLACE_BLOCK, #else IC_RESIZEINPLACE_BLOCK = 9, #endif #ifdef VALGRIND_FREELIKE_BLOCK IC_FREELIKE_BLOCK = VG_USERREQ__FREELIKE_BLOCK, #else IC_FREELIKE_BLOCK = 10, #endif #if defined(VALGRIND_CREATE_MEMPOOL) || defined(VALGRIND_CREATE_MEMPOOL_EXT) IC_CREATE_MEMPOOL = VG_USERREQ__CREATE_MEMPOOL, #else IC_CREATE_MEMPOOL = 11, #endif #ifdef VALGRIND_DESTROY_MEMPOOL IC_DESTROY_MEMPOOL = VG_USERREQ__DESTROY_MEMPOOL, #else IC_DESTROY_MEMPOOL = 12, #endif #ifdef VALGRIND_MEMPOOL_ALLOC IC_MEMPOOL_ALLOC = VG_USERREQ__MEMPOOL_ALLOC, #else IC_MEMPOOL_ALLOC = 13, #endif #ifdef VALGRIND_MEMPOOL_FREE IC_MEMPOOL_FREE = VG_USERREQ__MEMPOOL_FREE, #else IC_MEMPOOL_FREE = 14, #endif #ifdef VALGRIND_MEMPOOL_TRIM IC_MEMPOOL_TRIM = VG_USERREQ__MEMPOOL_TRIM, #else IC_MEMPOOL_TRIM = 15, #endif #ifdef VALGRIND_MOVE_MEMPOOL IC_MOVE_MEMPOOL = VG_USERREQ__MOVE_MEMPOOL, #else IC_MOVE_MEMPOOL = 16, #endif #ifdef VALGRIND_MEMPOOL_CHANGE IC_MEMPOOL_CHANGE = VG_USERREQ__MEMPOOL_CHANGE, #else IC_MEMPOOL_CHANGE = 17, #endif #ifdef VALGRIND_MEMPOOL_EXISTS IC_MEMPOOL_EXISTS = VG_USERREQ__MEMPOOL_EXISTS, #else IC_MEMPOOL_EXISTS = 18, #endif #ifdef VALGRIND_STACK_REGISTER IC_STACK_REGISTER = VG_USERREQ__STACK_REGISTER, #else IC_STACK_REGISTER = 19, #endif #ifdef VALGRIND_STACK_DEREGISTER IC_STACK_DEREGISTER = VG_USERREQ__STACK_DEREGISTER, #else IC_STACK_DEREGISTER = 20, #endif #ifdef VALGRIND_STACK_CHANGE IC_STACK_CHANGE = VG_USERREQ__STACK_CHANGE, #else IC_STACK_CHANGE = 21, #endif #ifdef VALGRIND_LOAD_PDB_DEBUGINFO IC_LOAD_PDB_DEBUGINFO = VG_USERREQ__LOAD_PDB_DEBUGINFO, #else IC_LOAD_PDB_DEBUGINFO = 22, #endif #ifdef VALGRIND_MAP_IP_TO_SRCLOC IC_MAP_IP_TO_SRCLOC = VG_USERREQ__MAP_IP_TO_SRCLOC, #else IC_MAP_IP_TO_SRCLOC = 23, #endif #if defined(VALGRIND_DISABLE_ERROR_REPORTING) || \ defined(VALGRIND_ENABLE_ERROR_REPORTING) IC_CHANGE_ERR_DISABLEMENT = VG_USERREQ__CHANGE_ERR_DISABLEMENT, #else IC_CHANGE_ERR_DISABLEMENT = 24, #endif #ifdef VALGRIND_MONITOR_COMMAND IC_GDB_MONITOR_COMMAND = VG_USERREQ__GDB_MONITOR_COMMAND, #else IC_GDB_MONITOR_COMMAND = 25, #endif #ifdef VALGRIND_CLO_CHANGE IC_CLO_CHANGE = VG_USERREQ__CLO_CHANGE, #else IC_CLO_CHANGE = 26, #endif } IC_ValgrindClientRequest; /* * CALLGRIND * */ typedef enum { #ifdef CALLGRIND_DUMP_STATS IC_DUMP_STATS = VG_USERREQ__DUMP_STATS, #else IC_DUMP_STATS = 0, #endif #ifdef CALLGRIND_DUMP_STATS_AT IC_DUMP_STATS_AT = VG_USERREQ__DUMP_STATS_AT, #else IC_DUMP_STATS_AT = 1, #endif #ifdef CALLGRIND_ZERO_STATS IC_ZERO_STATS = VG_USERREQ__ZERO_STATS, #else IC_ZERO_STATS = 2, #endif #ifdef CALLGRIND_TOGGLE_COLLECT IC_TOGGLE_COLLECT = VG_USERREQ__TOGGLE_COLLECT, #else IC_TOGGLE_COLLECT = 3, #endif #ifdef CALLGRIND_START_INSTRUMENTATION IC_START_INSTRUMENTATION = VG_USERREQ__START_INSTRUMENTATION, #else IC_START_INSTRUMENTATION = 4, #endif #ifdef CALLGRIND_STOP_INSTRUMENTATION IC_STOP_INSTRUMENTATION = VG_USERREQ__STOP_INSTRUMENTATION, #else IC_STOP_INSTRUMENTATION = 5, #endif } IC_CallgrindClientRequest; /* * DHAT * */ typedef enum { #ifdef DHAT_AD_HOC_EVENT IC_DHAT_AD_HOC_EVENT = VG_USERREQ__DHAT_AD_HOC_EVENT, #else IC_DHAT_AD_HOC_EVENT = 0, #endif #ifdef DHAT_HISTOGRAM_MEMORY IC_DHAT_HISTOGRAM_MEMORY = VG_USERREQ__DHAT_HISTOGRAM_MEMORY, #else IC_DHAT_HISTOGRAM_MEMORY = 1, #endif } IC_DHATClientRequest; /* * Memcheck * */ typedef enum { #ifdef VALGRIND_MAKE_MEM_NOACCESS IC_MAKE_MEM_NOACCESS = VG_USERREQ__MAKE_MEM_NOACCESS, #else IC_MAKE_MEM_NOACCESS = 0, #endif #ifdef VALGRIND_MAKE_MEM_UNDEFINED IC_MAKE_MEM_UNDEFINED = VG_USERREQ__MAKE_MEM_UNDEFINED, #else IC_MAKE_MEM_UNDEFINED = 1, #endif #ifdef VALGRIND_MAKE_MEM_DEFINED IC_MAKE_MEM_DEFINED = VG_USERREQ__MAKE_MEM_DEFINED, #else IC_MAKE_MEM_DEFINED = 2, #endif #ifdef VALGRIND_DISCARD IC_DISCARD = VG_USERREQ__DISCARD, #else IC_DISCARD = 3, #endif #ifdef VALGRIND_CHECK_MEM_IS_ADDRESSABLE IC_CHECK_MEM_IS_ADDRESSABLE = VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE, #else IC_CHECK_MEM_IS_ADDRESSABLE = 4, #endif #if defined(VALGRIND_CHECK_MEM_IS_DEFINED) || \ defined(VALGRIND_CHECK_VALUE_IS_DEFINED) IC_CHECK_MEM_IS_DEFINED = VG_USERREQ__CHECK_MEM_IS_DEFINED, #else IC_CHECK_MEM_IS_DEFINED = 5, #endif #if defined(VALGRIND_DO_LEAK_CHECK) || \ defined(VALGRIND_DO_ADDED_LEAK_CHECK) || \ defined(VALGRIND_DO_CHANGED_LEAK_CHECK) || \ defined(VALGRIND_DO_NEW_LEAK_CHECK) || \ defined(VALGRIND_DO_QUICK_LEAK_CHECK) IC_DO_LEAK_CHECK = VG_USERREQ__DO_LEAK_CHECK, #else IC_DO_LEAK_CHECK = 6, #endif #ifdef VALGRIND_COUNT_LEAKS IC_COUNT_LEAKS = VG_USERREQ__COUNT_LEAKS, #else IC_COUNT_LEAKS = 7, #endif #ifdef VALGRIND_GET_VBITS IC_GET_VBITS = VG_USERREQ__GET_VBITS, #else IC_GET_VBITS = 8, #endif #ifdef VALGRIND_SET_VBITS IC_SET_VBITS = VG_USERREQ__SET_VBITS, #else IC_SET_VBITS = 9, #endif #ifdef VALGRIND_CREATE_BLOCK IC_CREATE_BLOCK = VG_USERREQ__CREATE_BLOCK, #else IC_CREATE_BLOCK = 10, #endif #ifdef VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE IC_MAKE_MEM_DEFINED_IF_ADDRESSABLE = VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, #else IC_MAKE_MEM_DEFINED_IF_ADDRESSABLE = 11, #endif #ifdef VALGRIND_COUNT_LEAK_BLOCKS IC_COUNT_LEAK_BLOCKS = VG_USERREQ__COUNT_LEAK_BLOCKS, #else IC_COUNT_LEAK_BLOCKS = 12, #endif #ifdef VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE IC_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE = VG_USERREQ__ENABLE_ADDR_ERROR_REPORTING_IN_RANGE, #else IC_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE = 13, #endif #ifdef VALGRIND_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE IC_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE = VG_USERREQ__DISABLE_ADDR_ERROR_REPORTING_IN_RANGE, #else IC_DISABLE_ADDR_ERROR_REPORTING_IN_RANGE = 14, #endif } IC_MemcheckClientRequest; typedef enum { #ifdef VALGRIND_HG_CLEAN_MEMORY IC_HG_CLEAN_MEMORY = VG_USERREQ__HG_CLEAN_MEMORY, #else IC_HG_CLEAN_MEMORY = 1, #endif #ifdef ANNOTATE_HAPPENS_BEFORE IC_HG_USERSO_SEND_PRE = _VG_USERREQ__HG_USERSO_SEND_PRE, #else IC_HG_USERSO_SEND_PRE = 2, #endif #ifdef ANNOTATE_HAPPENS_AFTER IC_HG_USERSO_RECV_POST = _VG_USERREQ__HG_USERSO_RECV_POST, #else IC_HG_USERSO_RECV_POST = 3, #endif #ifdef ANNOTATE_HAPPENS_BEFORE_FORGET_ALL IC_HG_USERSO_FORGET_ALL = _VG_USERREQ__HG_USERSO_FORGET_ALL, #else IC_HG_USERSO_FORGET_ALL = 4, #endif #ifdef ANNOTATE_RWLOCK_CREATE IC_HG_PTHREAD_RWLOCK_INIT_POST = _VG_USERREQ__HG_PTHREAD_RWLOCK_INIT_POST, #else IC_HG_PTHREAD_RWLOCK_INIT_POST = 5, #endif #ifdef ANNOTATE_RWLOCK_DESTROY IC_HG_PTHREAD_RWLOCK_DESTROY_PRE = _VG_USERREQ__HG_PTHREAD_RWLOCK_DESTROY_PRE, #else IC_HG_PTHREAD_RWLOCK_DESTROY_PRE = 6, #endif #ifdef ANNOTATE_RWLOCK_ACQUIRED IC_HG_PTHREAD_RWLOCK_ACQUIRED = _VG_USERREQ__HG_PTHREAD_RWLOCK_ACQUIRED, #else IC_HG_PTHREAD_RWLOCK_ACQUIRED = 7, #endif #ifdef ANNOTATE_RWLOCK_RELEASED IC_HG_PTHREAD_RWLOCK_RELEASED = _VG_USERREQ__HG_PTHREAD_RWLOCK_RELEASED, #else IC_HG_PTHREAD_RWLOCK_RELEASED = 8, #endif } IC_HelgrindClientRequest; typedef enum { #ifdef DRD_GET_VALGRIND_THREADID IC_DRD_GET_VALGRIND_THREAD_ID = VG_USERREQ__DRD_GET_VALGRIND_THREAD_ID, #else IC_DRD_GET_VALGRIND_THREAD_ID = 0, #endif #ifdef DRD_GET_DRD_THREADID IC_DRD_GET_DRD_THREAD_ID = VG_USERREQ__DRD_GET_DRD_THREAD_ID, #else IC_DRD_GET_DRD_THREAD_ID = 1, #endif #if defined(DRD_IGNORE_VAR) || defined(ANNOTATE_BENIGN_RACE) || \ defined(ANNOTATE_BENIGN_RACE_SIZED) IC_DRD_START_SUPPRESSION = VG_USERREQ__DRD_START_SUPPRESSION, #else IC_DRD_START_SUPPRESSION = 2, #endif #ifdef DRD_STOP_IGNORING_VAR IC_DRD_FINISH_SUPPRESSION = VG_USERREQ__DRD_FINISH_SUPPRESSION, #else IC_DRD_FINISH_SUPPRESSION = 3, #endif #if defined(DRD_TRACE_VAR) || defined(ANNOTATE_TRACE_MEMORY) IC_DRD_START_TRACE_ADDR = VG_USERREQ__DRD_START_TRACE_ADDR, #else IC_DRD_START_TRACE_ADDR = 4, #endif #ifdef DRD_STOP_TRACING_VAR IC_DRD_STOP_TRACE_ADDR = VG_USERREQ__DRD_STOP_TRACE_ADDR, #else IC_DRD_STOP_TRACE_ADDR = 5, #endif #ifdef ANNOTATE_SEM_INIT_PRE IC_DRD_ANNOTATE_SEM_INIT_PRE = VG_USERREQ__DRD_ANNOTATE_SEM_INIT_PRE, #else IC_DRD_ANNOTATE_SEM_INIT_PRE = 6, #endif #ifdef ANNOTATE_SEM_DESTROY_POST IC_DRD_ANNOTATE_SEM_DESTROY_POST = VG_USERREQ__DRD_ANNOTATE_SEM_DESTROY_POST, #else IC_DRD_ANNOTATE_SEM_DESTROY_POST = 7, #endif #ifdef ANNOTATE_SEM_WAIT_PRE IC_DRD_ANNOTATE_SEM_WAIT_PRE = VG_USERREQ__DRD_ANNOTATE_SEM_WAIT_PRE, #else IC_DRD_ANNOTATE_SEM_WAIT_PRE = 8, #endif #ifdef ANNOTATE_SEM_WAIT_POST IC_DRD_ANNOTATE_SEM_WAIT_POST = VG_USERREQ__DRD_ANNOTATE_SEM_WAIT_POST, #else IC_DRD_ANNOTATE_SEM_WAIT_POST = 9, #endif #ifdef ANNOTATE_SEM_POST_PRE IC_DRD_ANNOTATE_SEM_POST_PRE = VG_USERREQ__DRD_ANNOTATE_SEM_POST_PRE, #else IC_DRD_ANNOTATE_SEM_POST_PRE = 10, #endif #if defined(ANNOTATE_IGNORE_READS_BEGIN) || defined(ANNOTATE_IGNORE_READS_END) IC_DRD_RECORD_LOADS = VG_USERREQ__DRD_RECORD_LOADS, #else IC_DRD_RECORD_LOADS = 11, #endif #if defined(ANNOTATE_IGNORE_WRITES_BEGIN) || defined(ANNOTATE_IGNORE_WRITES_END) IC_DRD_RECORD_STORES = VG_USERREQ__DRD_RECORD_STORES, #else IC_DRD_RECORD_STORES = 12, #endif #ifdef ANNOTATE_NEW_MEMORY IC_DRD_CLEAN_MEMORY = VG_USERREQ__DRD_CLEAN_MEMORY, #else IC_DRD_CLEAN_MEMORY = 13, #endif #ifdef ANNOTATE_THREAD_NAME IC_DRD_SET_THREAD_NAME = VG_USERREQ__DRD_SET_THREAD_NAME, #else IC_DRD_SET_THREAD_NAME = 14, #endif } IC_DRDClientRequest; typedef enum { #ifdef CACHEGRIND_START_INSTRUMENTATION IC_CG_START_INSTRUMENTATION = VG_USERREQ__CG_START_INSTRUMENTATION, #else IC_CG_START_INSTRUMENTATION = 0, #endif #ifdef CACHEGRIND_STOP_INSTRUMENTATION IC_CG_STOP_INSTRUMENTATION = VG_USERREQ__CG_STOP_INSTRUMENTATION, #else IC_CG_STOP_INSTRUMENTATION = 1, #endif } IC_CachegrindClientRequest;