# hook **Repository Path**: tajh/hook ## Basic Information - **Project Name**: hook - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-05-09 - **Last Updated**: 2024-05-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # hook #### 介绍 {**Hook机制调用简介**} - 请先下载[mindspore代码仓](https://gitee.com/mindspore/mindspore) - 下载完成后下载本仓编译为so文件,使用命令示例:`g++ -fPIC -shared msdebugger.cpp -o libmsdebugger.so` 在mindspore/mindspore/ccsrc/plugin/device/ascend/hal/hardware/ge_kernel_executor.cc中的LaunchKernel函数内`bool ret = kernel_mod->Launch(inputs, workspace, outputs, stream);`前后添加`Hooker`函数调用 #### 导入so - 使用`dlopen`流程导入so,通过环境变量形式获取so路径,如`TOOL_SO_PATH` - 导入后加载符号`MSDEBUG_KbkHooker`,注意参数列表一致性 - 之后如果加载符号的函数写在另一个头文件中需要在`ge_kernel_executor.cc`包含该头文件,或者直接在`ge_kernel_executor.cc`中直接调用加载函数 - 需要将所需要的参数列表自行处理好,会用到`ConvertType`函数将`kernelTensor`转换为`aclTensor`