LCOV - code coverage report
Current view: top level - adump/host - adx_datadump_callback.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 30 30
Test Date: 2026-07-28 10:54:24 Functions: 100.0 % 4 4

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : #include "log/adx_log.h"
      11              : #include "adx_dump_process.h"
      12              : #include "extra_config.h"
      13              : #include "acl_dump.h"
      14              : #include "adump_error_manager.h"
      15              : #include "str_utils.h"
      16              : 
      17              : namespace Adx {
      18           18 : int32_t AdxRegDumpProcessCallBack(int32_t (*const messageCallback)(const Adx::DumpChunk *, int32_t))
      19              : {
      20           18 :     if (messageCallback == nullptr) {
      21            3 :         IDE_LOGE("The param MessageCallback is null, please check it!");
      22            3 :         return IDE_DAEMON_ERROR;
      23              :     }
      24           15 :     Adx::AdxDumpProcess::Instance().MessageCallbackRegister(messageCallback);
      25           15 :     IDE_LOGI("MessageCallback registered success!");
      26           15 :     return IDE_DAEMON_OK;
      27              : }
      28              : 
      29           42 : void AdxUnRegDumpProcessCallBack()
      30              : {
      31           42 :     Adx::AdxDumpProcess::Instance().MessageCallbackUnRegister();
      32           42 :     IDE_LOGI("MessageCallback unregistered success!");
      33           42 : }
      34              : }
      35              : 
      36              : /**
      37              :  * @param messageCallback : record file Path
      38              :  * @param flag :  0 not save other is invalid
      39              :  * @return
      40              :  *
      41              :  * @retval ACL_SUCCESS The function is successfully executed.
      42              :  * @retval OtherValues Failure
      43              :  */
      44           21 : aclError acldumpRegCallback(int32_t (* const messageCallback)(const acldumpChunk *, int32_t), int32_t flag)
      45              : {
      46           21 :     if (messageCallback == nullptr) {
      47          108 :         REPORT_EP0007_NULL_POINTER(
      48              :             Adx::FUNC_NAME_ACL_DUMP_REG_CALLBACK, Adx::FUNC_ACL_DUMP_REG_CALLBACK_PARAM_CLBK);
      49            6 :         return ACL_ERROR_FAILURE;
      50              :     }
      51              : 
      52           15 :     if (flag != 0) {
      53            6 :         std::string flagStr = std::to_string(flag);
      54            6 :         std::string reason = Adx::StrUtils::Format(Adx::ADUMP_REASON_RESERVED_PARAM_MUST_EQUAL, "0");
      55          138 :         REPORT_EP0006_INVALID_ARGUMENT(
      56              :             Adx::FUNC_NAME_ACL_DUMP_REG_CALLBACK, flagStr, Adx::FUNC_ACL_DUMP_REG_CALLBACK_PARAM_FLAG, reason);
      57            6 :         return ACL_ERROR_FAILURE;
      58            6 :     }
      59              : 
      60            9 :     Adx::MessageCallback adxMessageCallback = reinterpret_cast<Adx::MessageCallback>(messageCallback);
      61            9 :     int32_t ret = Adx::AdxRegDumpProcessCallBack(adxMessageCallback);
      62            9 :     if (ret != IDE_DAEMON_OK) {
      63            3 :         return ACL_ERROR_FAILURE;
      64              :     }
      65              : 
      66            6 :     return ACL_SUCCESS;
      67           12 : }
      68              : 
      69           33 : void acldumpUnregCallback()
      70              : {
      71           33 :     Adx::AdxUnRegDumpProcessCallBack();
      72           33 : }
        

Generated by: LCOV version 2.0-1