当使用'bazel‘命令构建和执行一个目标时,可以使用参数’-run_under=‘在执行前加上valgrind。Val差尔通常在目标目录中输出其结果文件,但是当使用bazel run运行时,输出文件就找不到了。
示例:
bazel run //path/to/package:target_name --copt="-g" --run_under='valgrind --tool=callgrind'会对我的目标发动攻击:
INFO: Build completed successfully, 1 total action
INFO: Running command line: /bin/bash -c 'valgrind --tool=callgrind /home/user/.cache/bazel/_bazel_user/8d1c200e573b8da3ee18c97f4656aca6/execroot/workspace/bazel-out/k8-opt/bin/path/to/package/s
INFO: Build completed successfully, 1 total action
==15166== Callgrind, a call-graph generating cache profiler
==15166== Copyright (C) 2002-2017, and GNU GPL'd, by Josef Weidendorfer et al.
==15166== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==15166== Command: /home/user/.cache/bazel/_bazel_user/8d1c200e573b8da3ee18c97f4656aca6/execroot/workspace/bazel-out/k8-opt/bin/path/to/package/target_name
... (further output omitted) ...通常,文件'callgrind.out‘将被写入当前目录,但我在任何地方都找不到它。
发布于 2019-05-14 04:11:44
你上面提供的输出似乎不完整。通过捕获的事件来终止Call研磨机输出。
在任何情况下,您都可以使用以下选项来控制回调在何处创建结果文件:
--callgrind-out-file=<f> Output file name [callgrind.out.%p]给定的文件名可以以目录名开头。如果要启动多个进程,请不要忘记使用%p (而且,在这种情况下,使用--跟踪-子程序=是)。
https://stackoverflow.com/questions/56122309
复制相似问题