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 % 18 18
Test Date: 2026-07-28 10:54:24 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
      29            6 :             && connectInfoStr.substr(idx + 1) == pid) {
      30            1 :             return Adx::SocDumpStart(connectInfo);
      31              :         }
      32              :     }
      33            2 :     return Adx::HdcDumpStart(connectInfo);
      34            3 : }
      35              : 
      36              : /**
      37              :  * @brief dump data to remote server
      38              :  * @param [in] session: HDC session to dump data
      39              :  * @param [in] dumpChunk: Dump information
      40              :  * @return
      41              :  *      IDE_DAEMON_INVALID_PARAM_ERROR: invalid parameter
      42              :  *      IDE_DAEMON_UNKNOW_ERROR: write data failed
      43              :  *      IDE_DAEMON_NONE_ERROR:   write data succ
      44              :  */
      45           17 : extern "C" IdeErrorT IdeDumpData(IDE_SESSION session, const IdeDumpChunk *dumpChunk)
      46              : {
      47           17 :     if (session == Adx::DEFAULT_SOC_SESSION) {
      48            9 :         return Adx::SocDumpData(session, dumpChunk);
      49              :     }
      50            8 :     return Adx::HdcDumpData(session, dumpChunk);
      51              : }
      52              : 
      53              : /**
      54              :  * @brief send dump end msg
      55              :  * @param [in] session: HDC session to dump data
      56              :  * @return
      57              :  *      IDE_DAEMON_UNKNOW_ERROR: send dump end msg failed
      58              :  *      IDE_DAEMON_NONE_ERROR:   send dump end msg success
      59              :  */
      60            2 : extern "C" IdeErrorT IdeDumpEnd(IDE_SESSION session)
      61              : {
      62            2 :     if (session == Adx::DEFAULT_SOC_SESSION) {
      63            1 :         return Adx::SocDumpEnd(session);
      64              :     }
      65            1 :     return Adx::HdcDumpEnd(session);
      66              : }
        

Generated by: LCOV version 2.0-1