Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
0915ec27
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0915ec27
编写于
11月 09, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
!656 add musl log
Merge pull request !656 from zhangcui/master
上级
5b97a1a7
befa74a7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
11 addition
and
2 deletion
+11
-2
musl_src.gni
musl_src.gni
+2
-0
porting/linux/user/src/hook/musl_preinit.c
porting/linux/user/src/hook/musl_preinit.c
+7
-2
porting/linux/user/src/internal/hilog_adapter.h
porting/linux/user/src/internal/hilog_adapter.h
+2
-0
未找到文件。
musl_src.gni
浏览文件 @
0915ec27
...
...
@@ -2140,6 +2140,8 @@ musl_src_porting_file = [
]
musl_inc_hook_files = [
"porting/linux/user/src/internal/hilog_adapter.h",
"porting/linux/user/src/internal/musl_log.h",
"porting/linux/user/src/hook/memory_tag.h",
"porting/linux/user/src/hook/musl_malloc_dispatch_table.h",
"porting/linux/user/src/hook/musl_malloc_dispatch.h",
...
...
porting/linux/user/src/hook/musl_preinit.c
浏览文件 @
0915ec27
...
...
@@ -34,6 +34,7 @@ which need be escaped.
#include <assert.h>
#include <string.h>
#include <malloc.h>
#include "musl_log.h"
void
*
ohos_malloc_hook_init_function
(
size_t
bytes
);
...
...
@@ -252,7 +253,7 @@ void* load_malloc_hook_shared_library(const char* shared_lib, const char* prefix
shared_library_handle
=
dlopen
(
shared_lib
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
shared_library_handle
==
NULL
)
{
printf
(
"Unable to open shared library %s: %s
\n
"
,
shared_lib
,
dlerror
());
MUSL_LOGI
(
"HiProfiler, Unable to open shared library %{public}s: %{public}s.
"
,
shared_lib
,
dlerror
());
return
NULL
;
}
...
...
@@ -260,7 +261,7 @@ void* load_malloc_hook_shared_library(const char* shared_lib, const char* prefix
dlclose
(
shared_library_handle
);
shared_library_handle
=
NULL
;
}
// printf("load_malloc_hook_shared_library success new version test\n
");
MUSL_LOGI
(
"HiProfiler, load_malloc_hook_shared_library success.
"
);
return
shared_library_handle
;
}
...
...
@@ -342,6 +343,7 @@ void* ohos_malloc_hook_init_function(size_t bytes)
{
if
(
atomic_exchange
(
&
__musl_libc_globals
.
current_dispatch_table
,
(
volatile
const
long
long
)
NULL
))
{
pthread_t
thread_id
;
MUSL_LOGI
(
"HiProfiler, ohos_malloc_hook_init_function, pthread_create."
);
if
(
pthread_create
(
&
thread_id
,
NULL
,
init_ohos_malloc_hook
,
NULL
)
!=
0
)
{
// __musl_log(__MUSL_LOG_ERROR, "%s: ohos_malloc_hook: failed to pthread_create\n", getprogname());
}
else
if
(
pthread_detach
(
thread_id
)
!=
0
)
{
...
...
@@ -364,6 +366,7 @@ static void __install_malloc_hook()
volatile
void
*
shared_library_handle
=
(
volatile
void
*
)
atomic_load_explicit
(
&
ohos_malloc_hook_shared_library
,
memory_order_acquire
);
if
(
shared_library_handle
==
NULL
)
{
MUSL_LOGI
(
"HiProfiler, __install_malloc_hook __hook_mode %{public}d"
,
__hook_mode
);
if
(
__hook_mode
==
STEP_HOOK_MODE
)
{
atomic_store_explicit
(
&
__musl_libc_globals
.
current_dispatch_table
,
(
volatile
const
long
long
)
&
__ohos_malloc_hook_init_dispatch
,
memory_order_seq_cst
);
atomic_store_explicit
(
&
ohos_malloc_hook_shared_library
,
(
volatile
long
long
)
-
1
,
memory_order_seq_cst
);
...
...
@@ -417,6 +420,7 @@ __attribute__((constructor(1))) static void __musl_initialize()
__set_default_malloc
();
char
hook_process_path
[
MAX_PROC_NAME_SIZE
+
1
]
=
{
0
};
parse_hook_variable
(
&
__hook_mode
,
hook_process_path
,
sizeof
(
hook_process_path
)
-
1
);
MUSL_LOGI
(
"HiProfiler, __musl_initialize %{public}d"
,
__hook_mode
);
if
(
__hook_mode
==
STARTUP_HOOK_MODE
)
{
char
proc_name
[
MAX_PROC_NAME_SIZE
+
1
]
=
{
0
};
if
(
get_proc_name
(
getpid
(),
proc_name
,
sizeof
(
proc_name
)
-
1
))
{
...
...
@@ -427,6 +431,7 @@ __attribute__((constructor(1))) static void __musl_initialize()
}
else
{
file_name
=
proc_name
;
}
MUSL_LOGI
(
"HiProfiler, current proc %{public}s, , target proc %{public}s"
,
file_name
,
hook_process_path
);
if
(
strncmp
(
file_name
,
hook_process_path
,
strlen
(
hook_process_path
))
==
0
)
{
atomic_store_explicit
(
&
__hook_enable_hook_flag
,
(
volatile
bool
)
true
,
memory_order_seq_cst
);
init_ohos_malloc_hook
();
...
...
porting/linux/user/src/internal/hilog_adapter.h
浏览文件 @
0915ec27
...
...
@@ -20,6 +20,8 @@
#include <stdarg.h>
#include <stdbool.h>
#define hidden __attribute__((visibility("hidden")))
// Log type
typedef
enum
{
LOG_TYPE_MIN
=
0
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录