LCOV - code coverage report
Current view: top level - adump/device - adx_dump_hdc_api.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 17 17
Test Date: 2026-08-31 10:09:28 Functions: 100.0 % 3 3

            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              : 
      11              : #include "adx_dump_hdc_helper.h"
      12              : #include "adx_dump_soc_helper.h"
      13              : #include "mmpa_api.h"
      14              : /**
      15              :  * @brief dump start api,create a HDC session for dump
      16              :  * @param [in] connectInfo: remote connect info
      17              :  *
      18              :  * @return
      19              :  *      not NULL: Handle used by hdc
      20              :  *      NULL:     dump start failed
      21              :  */
      22            3 : extern "C" IDE_SESSION IdeDumpStart(const char* connectInfo)
      23              : {
      24            3 :     std::string connectInfoStr = connectInfo;
      25            3 :     std::string pid = std::to_string(mmGetPid());
      26            3 :     if (connectInfoStr.length() > pid.length()) {
      27            3 :         std::string::size_type idx = connectInfoStr.rfind(";");
      28            3 :         if (idx != std::string::npos && idx < connectInfoStr.length() - 1 && connectInfoStr.substr(idx + 1) == pid) {
      29            1 :             return Adx::SocDumpStart(connectInfo);
      30              :         }
      31              :     }
      32            2 :     return Adx::HdcDumpStart(connectInfo);
      33            3 : }
      34              : 
      35              : /**
      36              :  * @brief dump data to remote server
      37              :  * @param [in] session: HDC session to dump data
      38              :  * @param [in] dumpChunk: Dump information
      39              :  * @return
      40              :  *      IDE_DAEMON_INVALID_PARAM_ERROR: invalid parameter
      41              :  *      IDE_DAEMON_UNKNOW_ERROR: write data failed
      42              :  *      IDE_DAEMON_NONE_ERROR:   write data succ
      43              :  */
      44           17 : extern "C" IdeErrorT IdeDumpData(IDE_SESSION session, const IdeDumpChunk* dumpChunk)
      45              : {
      46           17 :     if (session == Adx::DEFAULT_SOC_SESSION) {
      47            9 :         return Adx::SocDumpData(session, dumpChunk);
      48              :     }
      49            8 :     return Adx::HdcDumpData(session, dumpChunk);
      50              : }
      51              : 
      52              : /**
      53              :  * @brief send dump end msg
      54              :  * @param [in] session: HDC session to dump data
      55              :  * @return
      56              :  *      IDE_DAEMON_UNKNOW_ERROR: send dump end msg failed
      57              :  *      IDE_DAEMON_NONE_ERROR:   send dump end msg success
      58              :  */
      59            2 : extern "C" IdeErrorT IdeDumpEnd(IDE_SESSION session)
      60              : {
      61            2 :     if (session == Adx::DEFAULT_SOC_SESSION) {
      62            1 :         return Adx::SocDumpEnd(session);
      63              :     }
      64            1 :     return Adx::HdcDumpEnd(session);
      65              : }
        

Generated by: LCOV version 2.0-1