gpt4 book ai didi

c++ - 是否可以在部分代码上运行 valgrind?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:36:04 29 4
gpt4 key购买 nike

我在相当大的系统的已知部分中发生了内存泄漏。我想全速运行直到该部分代码,在该部分运行 valgrind memcheck,并在该部分末尾收集 valgrind memcheck 报告而不进一步完成运行。这可能吗?

最佳答案

不是 memcheck,不。根据valgrind FAQ ,callgrind 是目前唯一支持这个的 valgrind 组件:

5.4. Is it possible to attach Valgrind to a program that is already running?

No. The environment that Valgrind provides for running programs is significantly different to that for normal programs, e.g. due to different layout of memory. Therefore Valgrind has to have full control from the very start.

It is possible to achieve something like this by running your program without any instrumentation (which involves a slow-down of about 5x, less than that of most tools), and then adding instrumentation once you get to a point of interest. Support for this must be provided by the tool, however, and Callgrind is the only tool that currently has such support. See the instructions on the callgrind_control program for details.

关于c++ - 是否可以在部分代码上运行 valgrind?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27827072/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com