Question

I want to trace the execution of a java process. For that I am using strace to analyse it.

I have written two basic programs.

Prog1 : Simple hello world

Prog2 : Prime number calculation with lots of Sysout's. By lots I really mean lots !!

I am taking strace using : strace java classfile

Both the program work correctly. However, when I compare their straces, their outputs were same i.e. the system calls and their order.

My queries are :

  1. What can be reason behind this ?
  2. What would be the correct way to strace a java program ?
  3. The statements being printed are not part of the strace ... actually there is no write system call in the strace output ?
Was it helpful?

Solution

By default, the program strace does not trace child processes. However, the Java VM creates early in the process a child process for the actual work. That's the reason, why the two different programs generate the same result when invoked with strace.

To also trace child processes, use the option -f to strace, i.e.:

strace -f java Hello
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top