hiview_lite prio可定制

Signed-off-by: lipengfei <lipengfei53@huawei.com>
This commit is contained in:
lipengfei
2025-01-02 09:55:11 +00:00
committed by Gitee
parent 2710986c04
commit dca6736fd5
6 changed files with 68 additions and 23 deletions
+23 -18
View File
@@ -12,20 +12,22 @@
# limitations under the License.
declare_args() {
ohos_hiviewdfx_hiview_lite_output_option = 1
ohos_hiviewdfx_hilog_lite_level = 1
ohos_hiviewdfx_hilog_lite_level_release = 3
ohos_hiviewdfx_hilog_lite_log_switch = 1
ohos_hiviewdfx_dump_lite_dump_switch = 0
ohos_hiviewdfx_hievent_lite_event_switch = 1
ohos_hiviewdfx_hiview_lite_output_module = -1
ohos_hiviewdfx_hiview_lite_dir = ""
ohos_hiviewdfx_hiview_lite_stack_size = 4096
hiview_lite_output_option = 1
hiview_lite_hilog_lite_level = 1
hiview_lite_hilog_lite_level_release = 3
hiview_lite_hilog_lite_log_switch = 1
hiview_lite_dump_lite_dump_switch = 0
hiview_lite_hievent_lite_event_switch = 1
hiview_lite_output_module = -1
hiview_lite_dir = ""
hiview_lite_stack_size = 4096
hiview_lite_stack_prio = 24
hiview_lite_customize_implementation = false
hiview_lite_disable_core_init = false
}
config("hiview_lite_config") {
defines = [ "HIVIEW_FILE_DIR=\"$ohos_hiviewdfx_hiview_lite_dir\"" ]
defines = [ "HIVIEW_FILE_DIR=\"$hiview_lite_dir\"" ]
include_dirs = [
"//base/hiviewdfx/hiview_lite",
"//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr",
@@ -44,17 +46,20 @@ static_library("hiview_lite_static") {
"hiview_util.c",
]
defines = [
"OUTPUT_OPTION=$ohos_hiviewdfx_hiview_lite_output_option",
"HILOG_LITE_SWITCH=$ohos_hiviewdfx_hilog_lite_log_switch",
"DUMP_LITE_SWITCH=$ohos_hiviewdfx_dump_lite_dump_switch",
"HIEVENT_LITE_SWITCH=$ohos_hiviewdfx_hievent_lite_event_switch",
"LOG_OUTPUT_MODULE=$ohos_hiviewdfx_hiview_lite_output_module",
"HIVIEW_STACK_SIZE=$ohos_hiviewdfx_hiview_lite_stack_size",
"OUTPUT_OPTION=$hiview_lite_output_option",
"HILOG_LITE_SWITCH=$hiview_lite_hilog_lite_log_switch",
"DUMP_LITE_SWITCH=$hiview_lite_dump_lite_dump_switch",
"HIEVENT_LITE_SWITCH=$hiview_lite_hievent_lite_event_switch",
"LOG_OUTPUT_MODULE=$hiview_lite_output_module",
"HIVIEW_STACK_SIZE=$hiview_lite_stack_size",
]
if (ohos_build_type == "debug") {
defines += [ "OUTPUT_LEVEL=$ohos_hiviewdfx_hilog_lite_level" ]
defines += [ "OUTPUT_LEVEL=$hiview_lite_hilog_lite_level" ]
} else {
defines += [ "OUTPUT_LEVEL=$ohos_hiviewdfx_hilog_lite_level_release" ]
defines += [ "OUTPUT_LEVEL=$hiview_lite_hilog_lite_level_release" ]
}
if (hiview_lite_disable_core_init) {
defines += [ "DISABLE_HIVIEW_LITE_CORE_INIT" ]
}
if (board_toolchain_type == "iccarm") {
cflags = [
+12 -1
View File
@@ -17,7 +17,18 @@
"mini"
],
"features": [
"hiview_lite_customize_implementation"
"hiview_lite_output_option",
"hiview_lite_hilog_lite_level",
"hiview_lite_hilog_lite_level_release",
"hiview_lite_hilog_lite_log_switch",
"hiview_lite_dump_lite_dump_switch",
"hiview_lite_hievent_lite_event_switch",
"hiview_lite_output_module",
"hiview_lite_dir",
"hiview_lite_stack_size",
"hiview_lite_stack_prio",
"hiview_lite_customize_implementation",
"hiview_lite_disable_core_init"
],
"rom": "10KB",
"ram": "~10KB",
+4 -1
View File
@@ -26,10 +26,13 @@ HiviewConfig g_hiviewConfig = {
.writeFailureCount = 0,
};
static void HiviewConfigInit(void)
void HiviewConfigInit(void)
{
g_hiviewConfig.hiviewInited = FALSE;
g_hiviewConfig.logOutputModule = (uint64_t)LOG_OUTPUT_MODULE;
g_hiviewConfig.writeFailureCount = 0;
}
#ifndef DISABLE_HIVIEW_LITE_CORE_INIT
CORE_INIT_PRI(HiviewConfigInit, 0);
#endif
+2
View File
@@ -96,6 +96,8 @@ typedef enum {
extern HiviewConfig g_hiviewConfig;
void HiviewConfigInit(void);
#ifdef __cplusplus
#if __cplusplus
}
+25 -3
View File
@@ -34,11 +34,17 @@
#include "../../../kernel/liteos_m/arch/include/los_interrupt.h"
#endif
extern void HAL_NVIC_SystemReset(void);
extern void __disable_irq(void);
extern void __enable_irq(void);
#define HIVIEW_WAIT_FOREVER osWaitForever
#define HIVIEW_MS_PER_SECOND 1000
#define HIVIEW_NS_PER_MILLISECOND 1000000
#define BUFFER_SIZE 128
static uint64 HIVIEW_GetCurrentTimeDef(void);
static void HIVIEW_UartPrintDef(const char *str);
static int (*hiview_open)(const char *, int, ...) = open;
static int (*hiview_close)(int) = close;
static ssize_t (*hiview_read)(int, void *, size_t) = read;
@@ -47,6 +53,8 @@ static off_t (*hiview_lseek)(int, off_t, int) = lseek;
static int (*hiview_fsync)(int) = fsync;
static int (*hiview_unlink)(const char *) = unlink;
static int (*hiview_rename)(const char *, const char *) = NULL; // not all platform support rename
static uint64 (*hiview_get_time)(void) = HIVIEW_GetCurrentTimeDef;
static void (*hiview_uart_print)(const char *) = HIVIEW_UartPrintDef;
void *HIVIEW_MemAlloc(uint8 modId, uint32 size)
{
@@ -60,7 +68,7 @@ void HIVIEW_MemFree(uint8 modId, void *pMem)
free(pMem);
}
uint64 HIVIEW_GetCurrentTime()
static uint64 HIVIEW_GetCurrentTimeDef(void)
{
struct timespec current = {0};
int ret = clock_gettime(CLOCK_REALTIME, &current);
@@ -70,6 +78,11 @@ uint64 HIVIEW_GetCurrentTime()
return (uint64)current.tv_sec * HIVIEW_MS_PER_SECOND + current.tv_nsec / HIVIEW_NS_PER_MILLISECOND;
}
uint64 HIVIEW_GetCurrentTime(void)
{
return hiview_get_time();
}
int32 HIVIEW_RtcGetCurrentTime(uint64 *val, HIVIEW_RtcTime *time)
{
(void)val;
@@ -121,11 +134,16 @@ uint32 HIVIEW_GetTaskId()
return (uint32)osThreadGetId();
}
void HIVIEW_UartPrint(const char *str)
static void HIVIEW_UartPrintDef(const char *str)
{
printf("%s\n", str);
}
void HIVIEW_UartPrint(const char *str)
{
hiview_uart_print(str);
}
void HIVIEW_Sleep(uint32 ms)
{
osDelay(ms / HIVIEW_MS_PER_SECOND);
@@ -143,6 +161,8 @@ void HIVIEW_InitHook(HIVIEW_Hooks *hooks)
hiview_fsync = fsync;
hiview_unlink = unlink;
hiview_rename = NULL;
hiview_get_time = HIVIEW_GetCurrentTimeDef;
hiview_uart_print = HIVIEW_UartPrintDef;
return;
}
hiview_open = (hooks->open_fn) == NULL ? open : hooks->open_fn;
@@ -152,7 +172,9 @@ void HIVIEW_InitHook(HIVIEW_Hooks *hooks)
hiview_lseek = (hooks->lseek_fn) == NULL ? lseek : hooks->lseek_fn;
hiview_fsync = (hooks->fsync_fn) == NULL ? fsync : hooks->fsync_fn;
hiview_unlink = (hooks->unlink_fn) == NULL ? unlink : hooks->unlink_fn;
hiview_rename = (hooks->rename_fn) == NULL ? rename : hooks->rename_fn;
hiview_rename = hooks->rename_fn;
hiview_get_time = (hooks->hiview_get_time_fn) == NULL ? HIVIEW_GetCurrentTimeDef : hooks->hiview_get_time_fn;
hiview_uart_print = (hooks->hiview_uart_print_fn) == NULL ? HIVIEW_UartPrintDef : hooks->hiview_uart_print_fn;
}
int32 HIVIEW_FileOpen(const char *path)
+2
View File
@@ -69,6 +69,8 @@ typedef struct {
int (*fsync_fn)(int);
int (*unlink_fn)(const char *);
int (*rename_fn)(const char *, const char *);
uint64 (*hiview_get_time_fn)(void);
void (*hiview_uart_print_fn)(const char *);
} HIVIEW_Hooks;
uint64 HIVIEW_GetCurrentTime(void);