0

I have a C program in which I make an execvp call out to java like so:

execvp(path_to_java, args);

Where path_to_java="/usr/java/latest/jre/bin/java" and args contains a link to the jar I'm running. I know it is working - I just want to profile the C portion.

I'm trying to run memcheck on it with this command in an attempt to avoid profiling the java child process, while profiling all of the other child processes:

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

However, among other problems, I see the following in the LOGFILE:

valgrind: No match.

I tried --trace-children-skip=java as well, which didn't cause the "No match" error, but it failed entirely to prevent valgrind from stepping into the java subprocesses.

The reason why I am doing this is that I don't care to profile the java subprocesses, especially because valgrind and the JVM don't play nice. For instance:

==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. What am I doing wrong?

2rs2ts
  • 10,662
  • 10
  • 51
  • 95
  • This may be a silly question, but if you don't need to trace any children what about omitting the `--trace-children` arguments (or `--trace-children=no` if that's not the default)? – nobody May 19 '14 at 22:20
  • @AndrewMedico I don't want to trace any `java` child processes. I have several other child processes that are not invocations of `java` which I *do* want to trace :) – 2rs2ts May 19 '14 at 22:22
  • Possibly another silly question: do you `exec*()` the other children directly from your main process, or are they started by the Java processes? The manual warns that the children of skipped children won't be traced. – nobody May 19 '14 at 22:30
  • @AndrewMedico I do it from the main process, so no worries there. – 2rs2ts May 20 '14 at 14:07

1 Answers1

1

Did you put the *java* pattern into quotes in your command line? Eg. like this:

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

Otherwise the asterisks will be interpreted by the shell, which will cause the valgrind: No match. message.

oliver
  • 6,204
  • 9
  • 46
  • 50