!559 Feat:add dfx trace

Merge pull request !559 from susha/dfx-trace
This commit is contained in:
openharmony_ci
2022-05-09 08:31:34 +00:00
committed by Gitee
7 changed files with 170 additions and 1 deletions
+8 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@@ -185,6 +185,13 @@ config DRIVERS_HDF_PLATFORM_WATCHDOG
depends on DRIVERS_HDF_PLATFORM
help
Answer Y to enable HDF platform watchdog driver.
config DRIVERS_HDF_PLATFORM_TRACE
bool "Enable HDF platform trace driver"
default n
depends on DRIVERS_HDF_PLATFORM
help
Answer Y to enable HDF platform trace driver.
config DRIVERS_HDF_PLATFORM_TIMER
bool "Enable HDF platform timer driver"
+7
View File
@@ -42,6 +42,13 @@ hdf_driver(module_name) {
"src/plat_common.c",
]
if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_TRACE)) {
sources += [
"$HDF_FRAMEWORKS_PATH/support/platform/src/fwk/platform_trace_transfer.c",
"src/platform_trace.c",
]
}
if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_I2C)) {
sources += [
"$HDF_FRAMEWORKS_PATH/support/platform/src/i2c/i2c_core.c",
+5
View File
@@ -45,6 +45,11 @@ ifeq ($(LOSCFG_DRIVERS_HDF_PLATFORM), y)
$(HDF_FRAMEWORKS)/support/platform/src/fwk/platform_common.c
endif
ifeq ($(LOSCFG_DRIVERS_HDF_PLATFORM_TRACE), y)
LOCAL_SRCS += ./src/platform_trace.c \
$(HDF_FRAMEWORKS)/support/platform/src/fwk/platform_trace_transfer.c
endif
ifeq ($(LOSCFG_DRIVERS_HDF_PLATFORM_I2C), y)
LOCAL_SRCS += $(HDF_FRAMEWORKS)/support/platform/src/i2c/i2c_if.c \
$(HDF_FRAMEWORKS)/support/platform/src/i2c/i2c_core.c
+141
View File
@@ -0,0 +1,141 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "platform_trace.h"
#include "hdf_base.h"
#include "hdf_log.h"
#include "los_trace.h"
int32_t PlatformTraceStart(void)
{
#ifdef LOSCFG_KERNEL_TRACE
uint32_t ret;
ret = LOS_TraceStart();
if (ret != LOS_OK) {
HDF_LOGE("PlatformTraceStart error:%d", ret);
return HDF_FAILURE;
}
#endif
return HDF_SUCCESS;
}
int32_t PlatformTraceStop(void)
{
#ifdef LOSCFG_KERNEL_TRACE
LOS_TraceStop();
#endif
return HDF_SUCCESS;
}
void PlatformTraceReset(void)
{
#ifdef LOSCFG_KERNEL_TRACE
LOS_TraceReset();
#endif
}
#ifdef LOSCFG_KERNEL_TRACE
static void TraceMeanPrint(void)
{
uint32_t i = 0;
dprintf("********trace moudle and function explain:********\t");
const struct PlatformTraceModuleExplain *explains = PlatformTraceModuleExplainGetAll();
int32_t size = PlatformTraceModuleExplainCount();
for (i = 0; i < size; i++) {
if (explains[i].moduleInfo < PLATFORM_TRACE_MODULE_MAX) {
dprintf("meaning of module num 0x%x is %s\t", explains[i].moduleInfo, explains[i].moduleMean);
} else if (explains[i].moduleInfo > PLATFORM_TRACE_MODULE_MAX) {
dprintf("meaning of function num 0x%x is %s\t", explains[i].moduleInfo, explains[i].moduleMean);
}
}
}
#endif
void PlatformTraceInfoDump(void)
{
#ifdef LOSCFG_KERNEL_TRACE
TraceMeanPrint();
LOS_TraceRecordDump(FALSE);
#endif
}
#define PLATFORM_TRACE_IDENTIFY 0x33
void PlatformTraceAddUintMsg(int module, int moduleFun, uint infos[], uint8_t size)
{
#ifdef LOSCFG_KERNEL_TRACE
if ((size <= 0) || (size > PLATFORM_TRACE_UINT_PARAM_SIZE_MAX)) {
HDF_LOGE("PlatformTraceAddUintMsg %hhu size illegal", size);
return;
}
if ((module < PLATFORM_TRACE_MODULE_I2S) || (module >= PLATFORM_TRACE_MODULE_MAX)) {
HDF_LOGE("PlatformTraceAddUintMsg %d module illegal", module);
return;
}
if ((moduleFun < PLATFORM_TRACE_MODULE_I2S_FUN) || (moduleFun >= PLATFORM_TRACE_MODULE_MAX_FUN)) {
HDF_LOGE("PlatformTraceAddUintMsg %d moduleFun illegal", moduleFun);
return;
}
switch (size) {
case PLATFORM_TRACE_UINT_PARAM_SIZE_1:
LOS_TRACE_EASY(TRACE_SYS_FLAG, PLATFORM_TRACE_IDENTIFY, module, moduleFun,
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_1 - 1]);
break;
case PLATFORM_TRACE_UINT_PARAM_SIZE_2:
LOS_TRACE_EASY(TRACE_SYS_FLAG, PLATFORM_TRACE_IDENTIFY, module, moduleFun,
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_1 - 1], infos[PLATFORM_TRACE_UINT_PARAM_SIZE_2 - 1]);
break;
case PLATFORM_TRACE_UINT_PARAM_SIZE_3:
LOS_TRACE_EASY(TRACE_SYS_FLAG, PLATFORM_TRACE_IDENTIFY, module, moduleFun,
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_1 - 1], infos[PLATFORM_TRACE_UINT_PARAM_SIZE_2 - 1],
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_3 - 1]);
break;
case PLATFORM_TRACE_UINT_PARAM_SIZE_4:
LOS_TRACE_EASY(TRACE_SYS_FLAG, PLATFORM_TRACE_IDENTIFY, module, moduleFun,
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_1 - 1], infos[PLATFORM_TRACE_UINT_PARAM_SIZE_2 - 1],
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_3 - 1], infos[PLATFORM_TRACE_UINT_PARAM_SIZE_4 - 1]);
break;
case PLATFORM_TRACE_UINT_PARAM_SIZE_MAX:
LOS_TRACE_EASY(TRACE_SYS_FLAG, PLATFORM_TRACE_IDENTIFY, module, moduleFun,
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_1 - 1], infos[PLATFORM_TRACE_UINT_PARAM_SIZE_2 - 1],
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_3 - 1], infos[PLATFORM_TRACE_UINT_PARAM_SIZE_4 - 1],
infos[PLATFORM_TRACE_UINT_PARAM_SIZE_MAX - 1]);
break;
default:
HDF_LOGE("PlatformTraceAddUintMsg %hhu size illegal", size);
break;
}
#endif
}
void PlatformTraceAddMsg(const char *module, const char *moduleFun, const char *fmt, ...)
{
// not support, return
return;
}
+5
View File
@@ -89,6 +89,11 @@ hdf_driver(module_name) {
"$HDF_TEST_FRAMWORK_ROOT/platform/entry/hdf_platform_core_entry_test.c",
]
if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_TRACE)) {
sources +=
[ "$HDF_TEST_FRAMWORK_ROOT/platform/common/platform_trace_test.c" ]
}
if (defined(LOSCFG_DRIVERS_HDF_PLATFORM_GPIO)) {
sources += [
"$HDF_TEST_FRAMWORK_ROOT/platform/common/gpio_driver_test.c",
+3
View File
@@ -69,6 +69,9 @@ LOCAL_SRCS += $(HDF_TEST_FRAMWORK_ROOT)/platform/common/platform_dumper_test.c
LOCAL_SRCS += $(HDF_TEST_FRAMWORK_ROOT)/platform/common/platform_device_test.c
LOCAL_SRCS += $(HDF_TEST_FRAMWORK_ROOT)/platform/common/platform_manager_test.c
LOCAL_SRCS += $(HDF_TEST_FRAMWORK_ROOT)/platform/entry/hdf_platform_core_entry_test.c
ifeq ($(LOSCFG_DRIVERS_HDF_PLATFORM_TRACE), y)
LOCAL_SRCS += $(HDF_TEST_FRAMWORK_ROOT)/platform/common/platform_trace_test.c
endif
ifeq ($(LOSCFG_DRIVERS_HDF_PLATFORM_GPIO), y)
LOCAL_SRCS += $(HDF_TEST_FRAMWORK_ROOT)/platform/common/gpio_test.c
LOCAL_SRCS += $(HDF_TEST_FRAMWORK_ROOT)/platform/common/gpio_driver_test.c
+1
View File
@@ -43,6 +43,7 @@ if (board_name == "hi3516dv300" || board_name == "hispark_taurus") {
"//drivers/framework/support/platform/test/unittest/common/hdf_platform_event_test.cpp",
"//drivers/framework/support/platform/test/unittest/common/hdf_platform_manager_test.cpp",
"//drivers/framework/support/platform/test/unittest/common/hdf_platform_queue_test.cpp",
"//drivers/framework/support/platform/test/unittest/common/hdf_platform_trace_test.cpp",
"//drivers/framework/support/platform/test/unittest/common/hdf_pwm_test.cpp",
"//drivers/framework/support/platform/test/unittest/common/hdf_regulator_test.cpp",
"//drivers/framework/support/platform/test/unittest/common/hdf_rtc_test.cpp",