1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
/*
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2008 The Trustees of Indiana University.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/**
* @file
*
* memchecker (memory checker) valgrind framework component interface.
*
* Intent
*/
#include "opal_config.h"
#include "memchecker_valgrind.h"
#include "opal/constants.h"
#include "opal/mca/base/mca_base_var.h"
#include "opal/mca/memchecker/base/base.h"
#include "opal/mca/memchecker/memchecker.h"
#include "valgrind/memcheck.h"
#include "valgrind/valgrind.h"
/*
* Local functions
*/
static int valgrind_module_init(void);
static int valgrind_module_runindebugger(void);
static int valgrind_module_isaddressable(void *p, size_t len);
static int valgrind_module_isdefined(void *p, size_t len);
static int valgrind_module_mem_noaccess(void *p, size_t len);
static int valgrind_module_mem_undefined(void *p, size_t len);
static int valgrind_module_mem_defined(void *p, size_t len);
static int valgrind_module_mem_defined_if_addressable(void *p, size_t len);
static int valgrind_module_create_block(void *p, size_t len, char *description);
static int
valgrind_module_discard_block(void *p); /* Here, we need to do some mapping for valgrind */
static int valgrind_module_leakcheck(void);
#if 0
static int valgrind_module_get_vbits(void * p, char * vbits, size_t len);
static int valgrind_module_set_vbits(void * p, char * vbits, size_t len);
#endif
extern int opal_memchecker_component_priority;
/*
* Valgrind memchecker module
*/
static const opal_memchecker_base_module_1_0_0_t loc_module = {
/* Initialization function */
valgrind_module_init,
/* Module function pointers */
valgrind_module_runindebugger, valgrind_module_isaddressable, valgrind_module_isdefined,
valgrind_module_mem_noaccess, valgrind_module_mem_undefined, valgrind_module_mem_defined,
valgrind_module_mem_defined_if_addressable, valgrind_module_create_block,
valgrind_module_discard_block, valgrind_module_leakcheck};
int opal_memchecker_valgrind_component_query(mca_base_module_t **module, int *priority)
{
*priority = opal_memchecker_component_priority;
*module = (mca_base_module_t *) &loc_module;
return OPAL_SUCCESS;
}
static int valgrind_module_init(void)
{
/* Nothing to do yet, possibly update the amount of memory blocks. */
return OPAL_SUCCESS;
}
static int valgrind_module_runindebugger(void)
{
return RUNNING_ON_VALGRIND;
}
static int valgrind_module_isaddressable(void *p, size_t len)
{
if (len > 0) {
VALGRIND_CHECK_MEM_IS_ADDRESSABLE(p, len);
}
return OPAL_SUCCESS;
}
static int valgrind_module_isdefined(void *p, size_t len)
{
if (len > 0) {
VALGRIND_CHECK_MEM_IS_DEFINED(p, len);
}
return OPAL_SUCCESS;
}
static int valgrind_module_mem_noaccess(void *p, size_t len)
{
if (len > 0) {
VALGRIND_MAKE_MEM_NOACCESS(p, len);
}
return OPAL_SUCCESS;
}
static int valgrind_module_mem_undefined(void *p, size_t len)
{
if (len > 0) {
VALGRIND_MAKE_MEM_UNDEFINED(p, len);
}
return OPAL_SUCCESS;
}
static int valgrind_module_mem_defined(void *p, size_t len)
{
if (len > 0) {
VALGRIND_MAKE_MEM_DEFINED(p, len);
}
return OPAL_SUCCESS;
}
static int valgrind_module_mem_defined_if_addressable(void *p, size_t len)
{
if (len > 0) {
VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(p, len);
}
return OPAL_SUCCESS;
}
static int valgrind_module_create_block(void *p, size_t len, char *description)
{
if (len > 0) {
VALGRIND_CREATE_BLOCK(p, len, description);
/*
* Add p to some list atomically
*/
}
return OPAL_SUCCESS;
}
static int valgrind_module_discard_block(void *p)
{
/* Here, we need to do some mapping for valgrind */
/*
* If p in list, then get rid of name
*/
return OPAL_SUCCESS;
}
static int valgrind_module_leakcheck(void)
{
VALGRIND_DO_LEAK_CHECK;
return OPAL_SUCCESS;
}
#if 0
static int valgrind_module_get_vbits(void * p, char * vbits, size_t len)
{
if (len > 0) {
VALGRIND_GET_VBITS(p, vbits, len);
}
return OPAL_SUCCESS;
}
static int valgrind_module_set_vbits(void * p, char * vbits, size_t len)
{
if (len > 0) {
VALGRIND_SET_VBITS(p, vbits, len);
}
return OPAL_SUCCESS;
}
#endif
|