Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mbedtls
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
external
mbedtls
Commits
b74c245a
Commit
b74c245a
authored
Jun 29, 2015
by
Manuel Pégourié-Gonnard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework debug to not need dynamic alloc
But introduces dependency on variadic macros
parent
a7c8903c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
26 deletions
+25
-26
debug.h
include/mbedtls/debug.h
+7
-8
debug.c
library/debug.c
+16
-16
test_suite_debug.function
tests/suites/test_suite_debug.function
+2
-2
No files found.
include/mbedtls/debug.h
View file @
b74c245a
...
@@ -38,8 +38,11 @@
...
@@ -38,8 +38,11 @@
#if defined(MBEDTLS_DEBUG_C)
#if defined(MBEDTLS_DEBUG_C)
#define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__
#define MBEDTLS_SSL_DEBUG_MSG( level, args ) \
#define MBEDTLS_SSL_DEBUG_MSG( level, args ) \
mbedtls_debug_print_msg_free( ssl, level, __FILE__, __LINE__, mbedtls_debug_fmt args )
mbedtls_debug_print_fmt( ssl, level, __FILE__, __LINE__, \
MBEDTLS_DEBUG_STRIP_PARENS args )
#define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \
#define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \
mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret )
mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret )
...
@@ -86,13 +89,9 @@ extern "C" {
...
@@ -86,13 +89,9 @@ extern "C" {
*/
*/
void
mbedtls_debug_set_threshold
(
int
threshold
);
void
mbedtls_debug_set_threshold
(
int
threshold
);
char
*
mbedtls_debug_fmt
(
const
char
*
format
,
...
);
void
mbedtls_debug_print_fmt
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
void
mbedtls_debug_print_msg
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
format
,
...
);
const
char
*
file
,
int
line
,
const
char
*
text
);
void
mbedtls_debug_print_msg_free
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
char
*
text
);
void
mbedtls_debug_print_ret
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
void
mbedtls_debug_print_ret
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
const
char
*
file
,
int
line
,
...
...
library/debug.c
View file @
b74c245a
...
@@ -52,35 +52,35 @@ void mbedtls_debug_set_threshold( int threshold )
...
@@ -52,35 +52,35 @@ void mbedtls_debug_set_threshold( int threshold )
debug_threshold
=
threshold
;
debug_threshold
=
threshold
;
}
}
char
*
mbedtls_debug_fmt
(
const
char
*
format
,
...
)
void
mbedtls_debug_print_fmt
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
const
char
*
format
,
...
)
{
{
va_list
argp
;
va_list
argp
;
char
*
str
=
mbedtls_calloc
(
DEBUG_BUF_SIZE
,
1
);
char
str
[
DEBUG_BUF_SIZE
];
int
ret
;
if
(
s
tr
==
NULL
)
if
(
s
sl
->
conf
==
NULL
||
ssl
->
conf
->
f_dbg
==
NULL
||
level
>
debug_threshold
)
return
(
NULL
)
;
return
;
va_start
(
argp
,
format
);
va_start
(
argp
,
format
);
#if defined(_WIN32)
#if defined(_WIN32)
_vsnprintf_s
(
str
,
DEBUG_BUF_SIZE
,
_TRUNCATE
,
format
,
argp
);
ret
=
_vsnprintf_s
(
str
,
DEBUG_BUF_SIZE
,
_TRUNCATE
,
format
,
argp
);
#else
#else
vsnprintf
(
str
,
DEBUG_BUF_SIZE
,
format
,
argp
);
ret
=
vsnprintf
(
str
,
DEBUG_BUF_SIZE
,
format
,
argp
);
#endif
#endif
va_end
(
argp
);
va_end
(
argp
);
return
(
str
);
if
(
ret
>=
0
&&
ret
<
DEBUG_BUF_SIZE
-
1
)
}
{
str
[
ret
]
=
'\n'
;
void
mbedtls_debug_print_msg_free
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
str
[
ret
+
1
]
=
'\0'
;
const
char
*
file
,
int
line
,
char
*
text
)
}
{
if
(
text
!=
NULL
)
mbedtls_debug_print_msg
(
ssl
,
level
,
file
,
line
,
text
);
mbedtls_free
(
text
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
}
}
void
mbedtls_debug_print_msg
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
static
void
mbedtls_debug_print_msg
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
const
char
*
text
)
const
char
*
file
,
int
line
,
const
char
*
text
)
{
{
char
str
[
DEBUG_BUF_SIZE
];
char
str
[
DEBUG_BUF_SIZE
];
...
...
tests/suites/test_suite_debug.function
View file @
b74c245a
...
@@ -59,8 +59,8 @@ void debug_print_msg_threshold( int threshold, int level, char *file, int line,
...
@@ -59,8 +59,8 @@ void debug_print_msg_threshold( int threshold, int level, char *file, int line,
mbedtls_debug_set_threshold( threshold );
mbedtls_debug_set_threshold( threshold );
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
mbedtls_debug_print_
msg_free
( &ssl, level, file, line,
mbedtls_debug_print_
fmt
( &ssl, level, file, line,
mbedtls_debug_fmt("Text message, 2 == %d", 2 )
);
"Text message, 2 == %d", 2
);
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment