aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/util/valgrind.h
blob: 3eb75a1a31319da7edfd3eed3433257fc8c19a7e (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <sys/types.h>

namespace vespalib {

/**
 * utilities to help valgrind perform better checking of your program
 **/
class Valgrind
{
public:
    /**
     * This method will write the buffer to '/dev/null' and thereby provoke the
     * valgrind check of parameters to system calls.
     * @param buf The buffer to write.
     * @param sz The size of the buffer
     * @return The number of bytes written.
     */
    static size_t testSystemCall(const void * buf, size_t sz);
    /**
     * This method will use the buffer given in a way that will trigger valgrind
     * check for uninitialized data.
     * @param buf The buffer to check.
     * @param sz The size of the buffer
     * @return Just a hash value of the buffer.
     */
    static size_t testUninitialized(const void * buf, size_t sz);
};

}