Mbed TLS v4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
debug.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  */
10 #ifndef MBEDTLS_DEBUG_H
11 #define MBEDTLS_DEBUG_H
12 
13 #include "mbedtls/build_info.h"
14 
15 #include "mbedtls/ssl.h"
16 
17 #if defined(MBEDTLS_DEBUG_C)
18 
19 #define MBEDTLS_DEBUG_STRIP_PARENS(...) __VA_ARGS__
20 
21 #define MBEDTLS_SSL_DEBUG_MSG(level, args) \
22  mbedtls_debug_print_msg(ssl, level, __FILE__, __LINE__, \
23  MBEDTLS_DEBUG_STRIP_PARENS args)
24 
25 #define MBEDTLS_SSL_DEBUG_RET(level, text, ret) \
26  mbedtls_debug_print_ret(ssl, level, __FILE__, __LINE__, text, ret)
27 
28 #define MBEDTLS_SSL_DEBUG_BUF(level, text, buf, len) \
29  mbedtls_debug_print_buf(ssl, level, __FILE__, __LINE__, text, buf, len)
30 
31 #if defined(MBEDTLS_X509_CRT_PARSE_C)
32 #if !defined(MBEDTLS_X509_REMOVE_INFO)
33 #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) \
34  mbedtls_debug_print_crt(ssl, level, __FILE__, __LINE__, text, crt)
35 #else
36 #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) do { } while (0)
37 #endif /* MBEDTLS_X509_REMOVE_INFO */
38 #endif /* MBEDTLS_X509_CRT_PARSE_C */
39 
40 #else /* MBEDTLS_DEBUG_C */
41 
42 #define MBEDTLS_SSL_DEBUG_MSG(level, args) do { } while (0)
43 #define MBEDTLS_SSL_DEBUG_RET(level, text, ret) do { } while (0)
44 #define MBEDTLS_SSL_DEBUG_BUF(level, text, buf, len) do { } while (0)
45 #define MBEDTLS_SSL_DEBUG_ECP(level, text, X) do { } while (0)
46 #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) do { } while (0)
47 
48 #endif /* MBEDTLS_DEBUG_C */
49 
62 #if defined(__has_attribute)
63 #if __has_attribute(format)
64 #if defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 1
65 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \
66  __attribute__((__format__(gnu_printf, string_index, first_to_check)))
67 #else /* defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 1 */
68 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \
69  __attribute__((format(printf, string_index, first_to_check)))
70 #endif
71 #else /* __has_attribute(format) */
72 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check)
73 #endif /* __has_attribute(format) */
74 #else /* defined(__has_attribute) */
75 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check)
76 #endif
77 
90 #if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900)
91  #include <inttypes.h>
92  #define MBEDTLS_PRINTF_SIZET PRIuPTR
93  #define MBEDTLS_PRINTF_LONGLONG "I64d"
94 #else \
95  /* defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900) */
96  #define MBEDTLS_PRINTF_SIZET "zu"
97  #define MBEDTLS_PRINTF_LONGLONG "lld"
98 #endif \
99  /* defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900) */
100 
101 #if !defined(MBEDTLS_PRINTF_MS_TIME)
102 #include <inttypes.h>
103 #if !defined(PRId64)
104 #define MBEDTLS_PRINTF_MS_TIME MBEDTLS_PRINTF_LONGLONG
105 #else
106 #define MBEDTLS_PRINTF_MS_TIME PRId64
107 #endif
108 #endif /* MBEDTLS_PRINTF_MS_TIME */
109 
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
113 
129 void mbedtls_debug_set_threshold(int threshold);
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* MBEDTLS_DEBUG_H */
void mbedtls_debug_set_threshold(int threshold)
Set the threshold error level to handle globally all debug output. Debug messages that have a level o...
Build-time configuration info.
SSL/TLS functions.