root/opal/mca/memchecker/valgrind/memchecker_valgrind_module.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. opal_memchecker_valgrind_component_query
  2. valgrind_module_init
  3. valgrind_module_runindebugger
  4. valgrind_module_isaddressable
  5. valgrind_module_isdefined
  6. valgrind_module_mem_noaccess
  7. valgrind_module_mem_undefined
  8. valgrind_module_mem_defined
  9. valgrind_module_mem_defined_if_addressable
  10. valgrind_module_create_block
  11. valgrind_module_discard_block
  12. valgrind_module_leakcheck
  13. valgrind_module_get_vbits
  14. valgrind_module_set_vbits

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

/* [<][>][^][v][top][bottom][index][help] */