View all system calls made with the Java program

How can I find out what system calls my Java program makes? Is there a tool that will do this on Linux?

+5
java linux system-calls
source share
3 answers

Use strace :

strace java your_program 
+7
source share

Use strace. But there is a trick for my business. The -f option is required. For example, the following code:

 public class Foo { public static void main (String [] args) { System.out.println("XXX"); } } 

After executing javac Foo.java to compile it strace java Foo 2>&1 | grep write strace java Foo 2>&1 | grep write do not print anything. But strace -f java Foo 2>&1 | grep write strace -f java Foo 2>&1 | grep write prints:

 [pid 11655] write(3, "0x63", 4) = 4 [pid 11655] write(3, "\0", 1) = 1 [pid 11655] write(3, "\0", 1) = 1 [pid 11655] write(3, "\0", 1) = 1 [pid 11655] write(3, "\0", 1) = 1 [pid 11655] write(3, "\0", 1) = 1 [pid 11655] write(3, "\0", 1) = 1 [pid 11655] write(3, "\0", 1) = 1 [pid 11655] write(3, "\0", 1) = 1 [pid 11655] write(1, "XXX", 3XXX) = 3 [pid 11655] write(1, "\n", 1 

[pid 11655] write(1, "XXX", 3XXX) = 3 shows the system call made for System.out.println("XXX") .

+9
source share
+1
source share

All Articles