This source file includes following definitions.
- opal_memchecker_valgrind_component_query
- valgrind_module_init
- 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
- valgrind_module_get_vbits
- valgrind_module_set_vbits
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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);
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
55
56 static const opal_memchecker_base_module_1_0_0_t loc_module = {
57
58 valgrind_module_init,
59
60
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
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
164
165 }
166 return OPAL_SUCCESS;
167 }
168
169
170 static int valgrind_module_discard_block(void * p)
171 {
172
173
174
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