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

时间:2014-05-19 21:53:28

标签: java c valgrind execvp memcheck

我有一个C程序,其中execvp呼叫java,如下所示:

execvp(path_to_java, args);

其中path_to_java="/usr/java/latest/jre/bin/java"args包含指向jar我正在投放的链接。我知道它有效 - 我只是想描述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)

Owch。我做错了什么?

1 个答案:

答案 0 :(得分:1)

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

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

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