Mbed TLS v4.1.1
Loading...
Searching...
No Matches
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) && !defined(MBEDTLS_X509_REMOVE_INFO)
32#define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) \
33 mbedtls_debug_print_crt(ssl, level, __FILE__, __LINE__, text, crt)
34#else
35#define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) do { } while (0)
36#endif /* MBEDTLS_X509_CRT_PARSE_C && !MBEDTLS_X509_REMOVE_INFO */
37
38#else /* MBEDTLS_DEBUG_C */
39
40#define MBEDTLS_SSL_DEBUG_MSG(level, args) do { } while (0)
41#define MBEDTLS_SSL_DEBUG_RET(level, text, ret) do { } while (0)
42#define MBEDTLS_SSL_DEBUG_BUF(level, text, buf, len) do { } while (0)
43#define MBEDTLS_SSL_DEBUG_ECP(level, text, X) do { } while (0)
44#define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) do { } while (0)
45
46#endif /* MBEDTLS_DEBUG_C */
47
60#if defined(__has_attribute)
61#if __has_attribute(format)
62#if defined(__MINGW32__) && !defined(__clang__)
63#define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \
64 __attribute__((__format__(gnu_printf, string_index, first_to_check)))
65#else /* defined(__MINGW32__) */
66#define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \
67 __attribute__((format(printf, string_index, first_to_check)))
68#endif
69#else /* __has_attribute(format) */
70#define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check)
71#endif /* __has_attribute(format) */
72#else /* defined(__has_attribute) */
73#define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check)
74#endif
75
76/* Legacy definitions, kept for backward compatibility.
77 * Since Mbed TLS 4.1, the standard specifiers are always valid.
78 * We still define the macros because they're part of the Mbed TLS 4.0 API.
79 * In the library and test code, keep using them for code that's backported
80 * to 3.6.
81 */
82#define MBEDTLS_PRINTF_SIZET "zu"
83#define MBEDTLS_PRINTF_SIZET_HEX "zx"
84#define MBEDTLS_PRINTF_LONGLONG "lld"
85
86#if !defined(MBEDTLS_PRINTF_MS_TIME)
87#include <inttypes.h>
88#if !defined(PRId64)
89#define MBEDTLS_PRINTF_MS_TIME MBEDTLS_PRINTF_LONGLONG
90#else
91#define MBEDTLS_PRINTF_MS_TIME PRId64
92#endif
93#endif /* MBEDTLS_PRINTF_MS_TIME */
94
95#ifdef __cplusplus
96extern "C" {
97#endif
98
114void mbedtls_debug_set_threshold(int threshold);
115
116#ifdef __cplusplus
117}
118#endif
119
120#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.