Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
M
mbedtls
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
esp-mirror
Mbed-TLS
mbedtls
提交
7b23c515
提交
7b23c515
编辑于
9 years ago
作者:
Manuel Pégourié-Gonnard
浏览文件
操作
下载
补丁
差异文件
Print "thread ID" in debug messages
closes #218
上级
d68434ef
No related branches found
No related tags found
无相关合并请求
变更
3
隐藏空白变更内容
行内
左右并排
显示
3 个更改的文件
ChangeLog
+2
-0
2 个添加, 0 个删除
ChangeLog
library/debug.c
+37
-12
37 个添加, 12 个删除
library/debug.c
tests/suites/test_suite_debug.function
+5
-0
5 个添加, 0 个删除
tests/suites/test_suite_debug.function
有
44 个添加
和
12 个删除
ChangeLog
+
2
−
0
浏览文件 @
7b23c515
...
...
@@ -35,6 +35,8 @@ Changes
* It is now possible to #include a user-provided configuration file at the
end of the default config.h by defining MBEDTLS_USER_CONFIG_FILE on the
compiler's command line.
* Prepend a "thread identifier" to debug messages (issue pointed out by
Hugo Leisink) (#210).
= mbed TLS 2.0.0 released 2015-07-13
...
...
此差异已折叠。
点击以展开。
library/debug.c
+
37
−
12
浏览文件 @
7b23c515
...
...
@@ -43,6 +43,10 @@
#define mbedtls_snprintf snprintf
#endif
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && !defined(inline)
#define inline __inline
#endif
#define DEBUG_BUF_SIZE 512
static
int
debug_threshold
=
0
;
...
...
@@ -52,6 +56,27 @@ void mbedtls_debug_set_threshold( int threshold )
debug_threshold
=
threshold
;
}
/*
* All calls to f_dbg must be made via this function
*/
static
inline
void
debug_send_line
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
const
char
*
str
)
{
/*
* If in a threaded environment, we need a thread identifier.
* Since there is no portable way to get one, use the address of the ssl
* context instead, as it shouldn't be shared between threads.
*/
#if defined(MBEDTLS_THREADING_C)
char
idstr
[
20
+
DEBUG_BUF_SIZE
];
/* 0x + 16 nibbles + ': ' */
mbedtls_snprintf
(
idstr
,
sizeof
(
idstr
),
"%p: %s"
,
ssl
,
str
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
idstr
);
#else
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
#endif
}
void
mbedtls_debug_print_msg
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
const
char
*
format
,
...
)
...
...
@@ -86,7 +111,7 @@ void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
str
[
ret
+
1
]
=
'\0'
;
}
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
}
void
mbedtls_debug_print_ret
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
...
...
@@ -109,7 +134,7 @@ void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
mbedtls_snprintf
(
str
,
sizeof
(
str
),
"%s() returned %d (-0x%04x)
\n
"
,
text
,
ret
,
-
ret
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
}
void
mbedtls_debug_print_buf
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
...
...
@@ -126,7 +151,7 @@ void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
mbedtls_snprintf
(
str
+
idx
,
sizeof
(
str
)
-
idx
,
"dumping '%s' (%u bytes)
\n
"
,
text
,
(
unsigned
int
)
len
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
idx
=
0
;
memset
(
txt
,
0
,
sizeof
(
txt
)
);
...
...
@@ -140,7 +165,7 @@ void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
if
(
i
>
0
)
{
mbedtls_snprintf
(
str
+
idx
,
sizeof
(
str
)
-
idx
,
" %s
\n
"
,
txt
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
idx
=
0
;
memset
(
txt
,
0
,
sizeof
(
txt
)
);
...
...
@@ -162,7 +187,7 @@ void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
idx
+=
mbedtls_snprintf
(
str
+
idx
,
sizeof
(
str
)
-
idx
,
" "
);
mbedtls_snprintf
(
str
+
idx
,
sizeof
(
str
)
-
idx
,
" %s
\n
"
,
txt
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
}
}
...
...
@@ -207,7 +232,7 @@ void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
mbedtls_snprintf
(
str
+
idx
,
sizeof
(
str
)
-
idx
,
"value of '%s' (%d bits) is:
\n
"
,
text
,
(
int
)
(
(
n
*
(
sizeof
(
mbedtls_mpi_uint
)
<<
3
)
)
+
j
+
1
)
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
idx
=
0
;
for
(
i
=
n
+
1
,
j
=
0
;
i
>
0
;
i
--
)
...
...
@@ -227,7 +252,7 @@ void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
if
(
j
>
0
)
{
mbedtls_snprintf
(
str
+
idx
,
sizeof
(
str
)
-
idx
,
"
\n
"
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
idx
=
0
;
}
}
...
...
@@ -244,7 +269,7 @@ void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
idx
+=
mbedtls_snprintf
(
str
+
idx
,
sizeof
(
str
)
-
idx
,
" 00"
);
mbedtls_snprintf
(
str
+
idx
,
sizeof
(
str
)
-
idx
,
"
\n
"
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
}
#endif
/* MBEDTLS_BIGNUM_C */
...
...
@@ -261,7 +286,7 @@ static void debug_print_pk( const mbedtls_ssl_context *ssl, int level,
if
(
mbedtls_pk_debug
(
pk
,
items
)
!=
0
)
{
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
debug_send_line
(
ssl
,
level
,
file
,
line
,
"invalid PK context
\n
"
);
return
;
}
...
...
@@ -282,7 +307,7 @@ static void debug_print_pk( const mbedtls_ssl_context *ssl, int level,
mbedtls_debug_print_ecp
(
ssl
,
level
,
file
,
line
,
name
,
items
[
i
].
value
);
else
#endif
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
debug_send_line
(
ssl
,
level
,
file
,
line
,
"should not happen
\n
"
);
}
}
...
...
@@ -305,7 +330,7 @@ static void debug_print_line_by_line( const mbedtls_ssl_context *ssl, int level,
memcpy
(
str
,
start
,
len
);
str
[
len
]
=
'\0'
;
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
start
=
cur
+
1
;
}
...
...
@@ -327,7 +352,7 @@ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
char
buf
[
1024
];
mbedtls_snprintf
(
str
,
sizeof
(
str
),
"%s #%d:
\n
"
,
text
,
++
i
);
ssl
->
conf
->
f_dbg
(
ssl
->
conf
->
p_dbg
,
level
,
file
,
line
,
str
);
debug_send_line
(
ssl
,
level
,
file
,
line
,
str
);
mbedtls_x509_crt_info
(
buf
,
sizeof
(
buf
)
-
1
,
""
,
crt
);
debug_print_line_by_line
(
ssl
,
level
,
file
,
line
,
buf
);
...
...
此差异已折叠。
点击以展开。
tests/suites/test_suite_debug.function
+
5
−
0
浏览文件 @
7b23c515
...
...
@@ -25,6 +25,11 @@ void string_debug(void *data, int level, const char *file, int line, const char
*p++ = ':';
*p++ = ' ';
#if defined(MBEDTLS_THREADING_C)
/* Skip "thread ID" (up to the first space) as it is not predictable */
while( *str++ != ' ' );
#endif
memcpy( p, str, strlen( str ) );
p += strlen( str );
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录