中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

run-clang-prob-annotate源码标注

run-clang-prob-annotate.py对clang-prob-annotate标注工具进行了一层封装,以便在大型项目工程中应用,使用该脚本时依旧需要依赖clang-prob-annotate工具,请配置合理的环境变量PATH。

通过-h/--help,可以查看脚本支持的选项。

脚本工具支持四种标注模式:1. 单个源码文件标注;2. 全量源码文件标注;3. 指定目录(包含子目录)下源码文件标注;4. 指定源码路径列表下批量源码文件标注。

具体使用方法如下:

  1. 前置工作说明

执行具体标注工作前,确保已经根据前文描述的流程获取了正确的profile data文件,compile_commands.json文件。

本脚本工具支持通过解析compile_commands.json获取每个源文件的构建信息。通过参数-p /path/to/compile_commands.json指定文件路径,且该参数为必选参数。支持通过参数-r /path/to/***.profdata传递profile data文件,该选项为可选参数,但是如果当前compile_commands.json是正常编译项目工程生成的文件,即编译选项中不包含-fproile-instr-use=/path/to/***.profdata,此时必须通过该参数指定profile data文件路径以提供数据输入。

  1. 单个源码文件标注

参考命令:

  • compile_commands.json中不包含-fprofile-instr-use
1
python3 run-clang-prob-annotate.py -p /path/to/compile_commands.json -s /path/to/annotate-source-file -r /path/to/***.profdata
  • compile_commands.json中包含-fprofile-instr-use
1
python3 run-clang-prob-annotate.py -p /path/to/compile_commands.json -s /path/to/annotate-source-file
  1. 全量源码文件标注

参考命令:

  • compile_commands.json中不包含-fprofile-instr-use
1
python3 run-clang-prob-annotate.py -p /path/to/compile_commands.json -a -r /path/to/***.profdata
  • compile_commands.json中包含-fprofile-instr-use
1
python3 run-clang-prob-annotate.py -p /path/to/compile_commands.json -a
  1. 指定目录(包含子目录)下源码文件标注

参考命令:

  • compile_commands.json中不包含-fprofile-instr-use
1
python3 run-clang-prob-annotate.py -p /path/to/compile_commands.json -d /path/to/annotate-source-directory -r /path/to/***.profdata
  • compile_commands.json中包含-fprofile-instr-use
1
python3 run-clang-prob-annotate.py -p /path/to/compile_commands.json -d /path/to/annotate-source-directory
  1. 指定源码路径列表下批量源码文件标注

参考命令:

  • compile_commands.json中不包含-fprofile-instr-use
1
python3 run-clang-prob-annotate.py -p /path/to/compile_commands.json -b /path/to/***.json -r /path/to/***.profdata
  • compile_commands.json中包含-fprofile-instr-use
1
python3 run-clang-prob-annotate.py -p /path/to/compile_commands.json -b /path/to/***.json
  • 通过json格式文件指定源码路径列表

参考格式如下:

1
2
3
4
{
"path": "/path/to/prob-annotate",
"files": ["func.cpp", "test/test.cpp"]
}

使用者需要严格按照上述格式指定路径列表,确保path + / + files为完整文件路径。且不支持使用多个{}对象作为输入。