LCOV - code coverage report
Current view: top level - adump/exception - kernel_info_collector.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-08-31 10:09:28 Functions: 100.0 % 2 2

            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              : #ifndef KERNEL_INFO_COLLECTOR_H
      11              : #define KERNEL_INFO_COLLECTOR_H
      12              : #include <memory>
      13              : #include <string>
      14              : #include <vector>
      15              : #include <elf.h>
      16              : #include "adump_pub.h"
      17              : #include "runtime/rt.h"
      18              : 
      19              : namespace Adx {
      20              : 
      21              : class KernelInfoCollector {
      22              : public:
      23          282 :     KernelInfoCollector() : kernelBinHandle_(nullptr), kernelBinSize_(0){};
      24          282 :     ~KernelInfoCollector() = default;
      25              :     void LoadKernelInfo(const rtExceptionArgsInfo& argsInfo);
      26              :     int32_t InitFromBinHandle(rtBinHandle BinHandle, const std::string& kernelName);
      27              :     int32_t LoadKernelBinBuffer();
      28              :     int32_t StartCollectKernel(const std::string& dumpPath) const;
      29              :     // 快速同步落 _host.o(纯内存 buffer 写),从 StartCollectKernel 拆出、供调用方单独同步调用;
      30              :     // outHostOPath 回传落盘绝对路径,供后续 symbolize 使用。
      31              :     int32_t DumpHostKernelBin(const std::string& dumpPath, std::string& outHostOPath) const;
      32              :     // 拼出 _host.o 落盘路径(不落盘),供回退/校验使用。
      33              :     std::string GetHostOFilePath(const std::string& dumpPath) const;
      34              :     std::string GetProcessedKernelName() const;
      35              :     std::vector<std::string> GetSearchPath() const;
      36              :     std::string SearchJsonFiles(const std::string& rootPath, const std::string& targetString) const;
      37              : 
      38              : private:
      39              :     bool ContainsString(const std::string& filePath, const std::string& targetString) const;
      40              :     std::string GetFirstItem(const std::string& curLine, size_t& curPlace) const;
      41              :     bool IsTargetLine(const std::string& currentLine, const std::string& key, const std::string& value) const;
      42              :     int32_t CollectKernelFile(const std::string& kernelName, const std::string& dumpPath) const;
      43              :     std::vector<std::string> SplitString(const std::string& str, char delimiter) const;
      44              :     rtBinHandle kernelBinHandle_;
      45              :     std::string kernelBinData_;
      46              :     uint32_t kernelBinSize_;
      47              :     std::string kernelName_;
      48              : };
      49              : int32_t StartCollectKernelAsync(std::shared_ptr<KernelInfoCollector> collector, const std::string& dumpPath);
      50              : } // namespace Adx
      51              : #endif // KERNEL_INFO_COLLECTOR_H
        

Generated by: LCOV version 2.0-1