未验证 提交 ca8fe5a6 编写于 作者: O openharmony_ci 提交者: Gitee

!887 【Realease挑单】增加dlclose debug开关

Merge pull request !887 from fangting/OpenHarmony-3.2-Release
......@@ -1229,12 +1229,21 @@ static void unmap_library(struct dso *dso)
for (i=0; i<dso->loadmap->nsegs; i++) {
if (!dso->loadmap->segs[i].p_memsz)
continue;
munmap((void *)dso->loadmap->segs[i].addr,
dso->loadmap->segs[i].p_memsz);
if (!is_dlclose_debug_enable()) {
munmap((void *)dso->loadmap->segs[i].addr,
dso->loadmap->segs[i].p_memsz);
} else {
(void)mprotect((void *)dso->loadmap->segs[i].addr,
dso->loadmap->segs[i].p_memsz, PROT_NONE);
}
}
internal_free(dso->loadmap);
} else if (dso->map && dso->map_len) {
munmap(dso->map, dso->map_len);
if (!is_dlclose_debug_enable()) {
munmap(dso->map, dso->map_len);
} else {
mprotect(dso->map, dso->map_len, PROT_NONE);
}
}
}
......
......@@ -16,6 +16,7 @@
#include "ld_log.h"
static bool ld_log_enable = false;
static bool ld_dlclose_debug = false;
#ifdef OHOS_ENABLE_PARAMETER
#include <fcntl.h>
......@@ -73,11 +74,21 @@ static bool get_ld_log_value()
}
return (get_bool_sysparam(app_param_handle) || get_bool_sysparam(all_param_handle));
}
static bool get_ld_debug_dlclose_value()
{
static CachedHandle param_handle = NULL;
if (param_handle == NULL) {
param_handle = CachedParameterCreate("musl.ld.debug.dlclose", "false");
}
return get_bool_sysparam(param_handle);
}
#endif
void ld_log_reset()
{
#if (defined(OHOS_ENABLE_PARAMETER))
ld_dlclose_debug = get_ld_debug_dlclose_value();
if (!is_musl_log_enable()) {
ld_log_enable = false;
return;
......@@ -92,3 +103,8 @@ bool get_ld_log_enable()
{
return ld_log_enable;
}
bool is_dlclose_debug_enable()
{
return ld_dlclose_debug;
}
......@@ -34,6 +34,8 @@ extern "C" {
hidden bool get_ld_log_enable();
hidden void ld_log_reset();
hidden bool is_dlclose_debug_enable();
#if ((LD_LOG_LEVEL & LD_LOG_ERROR) && (defined(OHOS_ENABLE_PARAMETER) || defined(ENABLE_MUSL_LOG)))
#define LD_LOGE(...) if (get_ld_log_enable()) { \
(void)HiLogAdapterPrint(MUSL_LOG_TYPE, LOG_ERROR, MUSL_LOG_DOMAIN, LD_LOG_TAG, __VA_ARGS__); \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册