From 0ebd9baba0d0f969be8f21c8dc944256edbb4a22 Mon Sep 17 00:00:00 2001 From: zhou_xq Date: Thu, 24 Jul 2025 19:41:12 +0800 Subject: [PATCH 1/2] The log template is not exposed in the header file Signed-off-by: zhou_xq --- common/dfxlog/BUILD.gn | 6 ++++++ common/dfxlog/dfx_log.h | 1 - common/dfxlog/dfx_log_define.h | 33 --------------------------------- common/dfxutil/dfx_util.cpp | 2 +- common/dfxutil/smart_fd.h | 6 +++--- 5 files changed, 10 insertions(+), 38 deletions(-) delete mode 100644 common/dfxlog/dfx_log_define.h diff --git a/common/dfxlog/BUILD.gn b/common/dfxlog/BUILD.gn index 98d72e018..27aa329d4 100644 --- a/common/dfxlog/BUILD.gn +++ b/common/dfxlog/BUILD.gn @@ -25,6 +25,12 @@ if (defined(ohos_lite)) { "is_ohos=${is_ohos}", "is_ohos_lite", ] + if (defined(__cplusplus)) { + defines += [ + "LOG_DOMAIN=0xD002D11", + "LOG_TAG=\\\"DfxFaultLogger\\\"", + ] + } } static_library("dfx_hilog") { diff --git a/common/dfxlog/dfx_log.h b/common/dfxlog/dfx_log.h index 3fea0fa2f..25f268d13 100644 --- a/common/dfxlog/dfx_log.h +++ b/common/dfxlog/dfx_log.h @@ -22,7 +22,6 @@ #else #include #endif -#include "dfx_log_define.h" #endif #ifdef __cplusplus diff --git a/common/dfxlog/dfx_log_define.h b/common/dfxlog/dfx_log_define.h deleted file mode 100644 index 1a8cce46d..000000000 --- a/common/dfxlog/dfx_log_define.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DFX_LOG_DEFINE_H -#define DFX_LOG_DEFINE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#undef LOG_DOMAIN -#undef LOG_TAG -#define LOG_DOMAIN 0xD002D11 -#define LOG_TAG "DfxFaultLogger" - -#define LOG_BUF_LEN 1024 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/common/dfxutil/dfx_util.cpp b/common/dfxutil/dfx_util.cpp index c59fd9e12..03897c6ad 100644 --- a/common/dfxutil/dfx_util.cpp +++ b/common/dfxutil/dfx_util.cpp @@ -46,8 +46,8 @@ // defile Domain ID #ifndef LOG_DOMAIN #undef LOG_DOMAIN -#endif #define LOG_DOMAIN 0xD002D11 +#endif #ifdef LOG_TAG #undef LOG_TAG diff --git a/common/dfxutil/smart_fd.h b/common/dfxutil/smart_fd.h index fd5e83843..f24d67f43 100644 --- a/common/dfxutil/smart_fd.h +++ b/common/dfxutil/smart_fd.h @@ -19,7 +19,6 @@ #include #include #include -#include "dfx_log_define.h" namespace OHOS { namespace HiviewDFX { @@ -29,7 +28,7 @@ public: explicit SmartFd(int fd, bool fdsan = true) : fd_(fd), fdsan_(fdsan) { if (fd_ >= 0 && fdsan_) { - fdsan_exchange_owner_tag(fd_, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + fdsan_exchange_owner_tag(fd_, 0, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, DFX_FDSAN_DOMAIN)); } } @@ -86,12 +85,13 @@ private: return; } if (fdsan_) { - fdsan_close_with_tag(fd_, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, LOG_DOMAIN)); + fdsan_close_with_tag(fd_, fdsan_create_owner_tag(FDSAN_OWNER_TYPE_FILE, DFX_FDSAN_DOMAIN)); return; } close(fd_); } + static constexpr uint64_t DFX_FDSAN_DOMAIN = 0xD002D11; int fd_{-1}; bool fdsan_{false}; }; -- Gitee From 7bfd0e179e87cb34da4dc338b6204374debd78e5 Mon Sep 17 00:00:00 2001 From: zhou_xq Date: Mon, 28 Jul 2025 09:23:13 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20comm?= =?UTF-8?q?on/dfxlog/BUILD.gn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/dfxlog/BUILD.gn | 82 ------------------------------------------ 1 file changed, 82 deletions(-) delete mode 100644 common/dfxlog/BUILD.gn diff --git a/common/dfxlog/BUILD.gn b/common/dfxlog/BUILD.gn deleted file mode 100644 index 27aa329d4..000000000 --- a/common/dfxlog/BUILD.gn +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2022-2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//base/hiviewdfx/faultloggerd/faultloggerd.gni") - -if (defined(ohos_lite)) { - config("dfx_log_config") { - visibility = [ ":*" ] - include_dirs = [ - ".", - "$faultloggerd_interfaces_path/common", - "$hilog_lite_include_path", - ] - defines = [ - "is_ohos=${is_ohos}", - "is_ohos_lite", - ] - if (defined(__cplusplus)) { - defines += [ - "LOG_DOMAIN=0xD002D11", - "LOG_TAG=\\\"DfxFaultLogger\\\"", - ] - } - } - - static_library("dfx_hilog") { - public_configs = [ ":dfx_log_config" ] - deps = [ "$hilog_lite_deps_path" ] - } -} else { - config("dfx_log_config") { - visibility = [ ":*" ] - include_dirs = [ - ".", - "$faultloggerd_interfaces_path/common", - ] - } - - ohos_static_library("dfx_hilog") { - public_configs = [ ":dfx_log_config" ] - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - ] - part_name = "faultloggerd" - subsystem_name = "hiviewdfx" - } - - ohos_static_library("dfx_hilog_base") { - public_configs = [ ":dfx_log_config" ] - defines = [ "DFX_LOG_HILOG_BASE" ] - external_deps = [ - "c_utils:utils", - "hilog:libhilog_base", - ] - part_name = "faultloggerd" - subsystem_name = "hiviewdfx" - } - - # just for updater subsystem, use dfx_libhilog_base first - ohos_static_library("dfx_hilog_base_static") { - public_configs = [ ":dfx_log_config" ] - defines = [ "DFX_LOG_HILOG_BASE" ] - external_deps = [ - "bounds_checking_function:libsec_static", - "c_utils:utilsbase", - "hilog:libhilog_base", - ] - part_name = "faultloggerd" - subsystem_name = "hiviewdfx" - } -} -- Gitee