2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
8 * Copyright (C) 2002-2009 OpenVPN Technologies, Inc. <sales@openvpn.net>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program (see the file COPYING included with this
21 * distribution); if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * Valgrind debugging support.
31 * Valgrind is a great tool for debugging memory issues,
32 * though it seems to generate a lot of warnings in OpenSSL
33 * about uninitialized data. To silence these warnings,
34 * I've put together a suppressions file
35 * in debug/valgrind-suppress.
37 * Also, grep for VALGRIND_MAKE_READABLE in the OpenVPN source.
38 * Because valgrind thinks that some of the data passed from
39 * OpenSSL back to OpenVPN is tainted due to being sourced
40 * from uninitialized data, we need to untaint it before use --
41 * otherwise we will get a lot of useless warnings.
43 * valgrind --tool=memcheck --error-limit=no --suppressions=debug/valgrind-suppress --gen-suppressions=yes ./openvpn ...
48 #include "valgrind/memcheck.h"
50 #define VALGRIND_MAKE_READABLE(addr, len)
54 #define VALGRIND_MAKE_READABLE(addr, len)
58 #ifdef DMALLOC /* see ./configure options to enable */
61 * See ./configure options to enable dmalloc
62 * support for memory leak checking.
64 * The dmalloc package can be downloaded from:
68 * When dmalloc is installed and enabled,
69 * use this command prior to running openvpn:
71 * dmalloc -l dlog -i 100 low -p log-unknown
73 * Also, put this in your .bashrc file:
75 * function dmalloc { eval `command dmalloc -b $*`; }
77 * Or take a more low-level approach:
79 * export DMALLOC_OPTIONS="debug=0x4e48503,inter=100,log=dlog"
81 * NOTE: When building dmalloc you need to add something
82 * like this to dmalloc's settings.h -- it will allocate a static
83 * buffer to be used as the malloc arena:
85 * #define INTERNAL_MEMORY_SPACE (1024 * 1024 * 50)
90 #define openvpn_dmalloc(file, line, size) dmalloc_malloc((file), (line), (size), DMALLOC_FUNC_MALLOC, 0, 0)
93 * This #define will put the line number of the log
94 * file position where leaked memory was allocated instead
95 * of the source code file and line number. Make sure
96 * to increase the size of dmalloc's info tables,
97 * (MEMORY_TABLE_SIZE in settings.h)
98 * otherwise it might get overwhelmed by the large
99 * number of unique file/line combinations.
103 #define malloc(size) openvpn_dmalloc("logfile", x_msg_line_num, (size))
109 * Force buffers to be zeroed after allocation.
110 * For debugging only.
112 /*#define ZERO_BUFFER_ON_ALLOC*/
114 #endif /* MEMDBG_H */