加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 如何排除某些子进程在valgrind下运行?

发布时间:2020-12-14 02:01:14 所属栏目:Linux 来源:网络整理
导读:我正在 Linux中运行一个守护进程,我想在valgrind下运行这个守护进程来查找与内存相关的错误.由于它是一个守护进程,我需要使用–trace-children = yes选项,但是这会在以后的生命周期中生成许多进程,我不希望它们在valgrind下运行.有没有办法排除某些孩子在val
我正在 Linux中运行一个守护进程,我想在valgrind下运行这个守护进程来查找与内存相关的错误.由于它是一个守护进程,我需要使用–trace-children = yes选项,但是这会在以后的生命周期中生成许多进程,我不希望它们在valgrind下运行.有没有办法排除某些孩子在valgrind下运行?

解决方法

当前发布的版本(valgrind 3.5.0)无法跟踪某些但不是所有子项.
但是,如果您愿意使用 the latest code from the SVN repository,它包含一个 new option –trace-children-skip用于此目的:

--trace-children-skip=patt1,patt2

This option only has an effect when --trace-children=yes is specified. It allows for some children to be skipped. The option takes a comma separated list of patterns for the names of child executables that Valgrind should not trace into. Patterns may include the metacharacters ? and *,which have the usual meaning.

This can be useful for pruning uninteresting branches from a tree of processes being run on Valgrind. But you should be careful when using it. When Valgrind skips tracing into an executable,it doesn’t just skip tracing that executable,it also skips tracing any of that executable’s child processes. In other words,the flag doesn’t merely cause tracing to stop at the specified executables — it skips tracing of entire process subtrees rooted at any of the specified executables.

较旧的方法是省略–trace-children = yes,对于您想要跟踪的子项,将其替换为在valgrind下运行实际程序的简单脚本:

#!/bin/sh
exec valgrind --log-file=myprog.vg.%p myprog-real "$@"

即使使用新选项,如果您有这样的脚本,这种脚本也很有用.你想在valgrind下追踪但想跳过它的父亲的孙子.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读