gpt4 book ai didi

java - 防止 valgrind 跟踪使用 execvp 创建的任何 java 子进程

转载 作者:行者123 更新时间:2023-11-30 15:33:22 32 4
gpt4 key购买 nike

我有一个 C 程序,在其中对 java 进行 execvp 调用,如下所示:

execvp(path_to_java, args);

其中 path_to_java="/usr/java/latest/jre/bin/java"args 包含指向 jar I 的链接我正在运行。我知道它正在工作 - 我只想分析 C 部分。

我尝试使用此命令对其运行 memcheck,以避免分析 java 子进程,同时分析所有其他子进程:

valgrind --leak-check=yes --trace-children=yes --trace-children-skip=*java* myprog >>& LOGFILE

但是,除其他问题外,我在 LOGFILE 中看到以下内容:

valgrind: No match.

我也尝试了--trace-children-skip=java,这并没有导致“不匹配”错误,但它完全无法阻止valgrind从单步进入 java 子进程。

我这样做的原因是我不关心分析 java 子进程,特别是因为 valgrind 和 JVM 运行得不好。例如:

==4873== 32,744 bytes in 1 blocks are possibly lost in loss record 946 of 986
==4873== at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==4873== by 0x5A455E8: os::malloc(unsigned long, unsigned short, unsigned cha
r*) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x54D7D32: ChunkPool::allocate(unsigned long, AllocFailStrategy::
AllocFailEnum) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x54D7950: Arena::grow(unsigned long, AllocFailStrategy::AllocFai
lEnum) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x56BDCFE: constMethodKlass::allocate(int, int, int, int, int, bo
ol, Thread*) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x5A3EDF9: oopFactory::new_method(int, AccessFlags, int, int, int
, int, bool, Thread*) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x563BD38: ClassFileParser::parse_method(constantPoolHandle, bool
, AccessFlags*, typeArrayHandle*, typeArrayHandle*, typeArrayHandle*, Thread*) (
in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x563C81B: ClassFileParser::parse_methods(constantPoolHandle, bool, AccessFlags*, bool*, objArrayOopDesc**, objArrayOopDesc**, objArrayOopDesc**, Thread*) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x563F8B0: ClassFileParser::parseClassFile(Symbol*, Handle, Handle, KlassHandle, GrowableArray<Handle>*, TempNewSymbol&, bool, Thread*) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x5643BF2: ClassLoader::load_classfile(Symbol*, Thread*) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x5B4FC86: SystemDictionary::load_instance_class(Symbol*, Handle, Thread*) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)
==4873== by 0x5B50490: SystemDictionary::resolve_instance_class_or_null(Symbol*, Handle, Handle, Thread*) (in /usr/java/jdk1.7.0_45/jre/lib/amd64/server/libjvm.so)

哎哟。我做错了什么?

最佳答案

您是否将 *java* 模式放入命令行中的引号中?例如。像这样:

valgrind --leak-check=yes --trace-children=yes --trace-children-skip="*java*"myprog >>& LOGFILE

否则星号将由 shell 解释,这将导致 valgrind: No match. 消息。

关于java - 防止 valgrind 跟踪使用 execvp 创建的任何 java 子进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23747827/

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