* This file is part of the MindStudio project.
* Copyright (c) 2025 Huawei Technologies Co.,Ltd.
*
* MindStudio is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* ------------------------------------------------------------------------- */
#ifndef __CORE_HIJACKED_LAYER_MANAGER_H__
#define __CORE_HIJACKED_LAYER_MANAGER_H__
#include <list>
#include <string>
#include "utils/Singleton.h"
* CANN 软件栈中存在不同接口的层级调用,如 aclrtMalloc -> rtMalloc,基础组件
* 当前会同时对不同层级的接口做劫持。为了防止不同层级的接口上报相同的信息,
* 需要对层级之间的 mask 关系进行处理。本类中以栈的形式保存劫持接口的调用上
* 下文,高层接口和低层接口之间的 mask 关系以 map 保存。当低层接口被劫持时,
* 需要检查上下文中所有的高层接口是否会 mask 掉当前的劫持接口
*
* 限制:HijackedLayerManager 类当前仅能处理单层接口调用
*/
class HijackedLayerManager : public Singleton<HijackedLayerManager, true> {
public:
* @param func - [in] 要管理的高层函数
*/
void Push(std::string const &func);
*/
void Pop(void);
* @param func - [in] 要校验的函数
*/
bool ParentInCallStack(std::string const &func) const;
* @param func - [in] 要校验的函数
*/
bool InCallStack(std::string const &func) const;
#if defined (__BUILD_TESTS__)
std::list<std::string> &Layers(void) { return this->layers_; }
#endif
private:
std::list<std::string> layers_;
};
*/
class LayerGuard {
public:
LayerGuard(HijackedLayerManager &manager, std::string const &func);
~LayerGuard(void);
private:
HijackedLayerManager &manager_;
};
#endif