0

I have problem similar to my previous one presented here.

This time I want use program written in c/c++ to track execution of JAVA program. So as I stated before same code which track stdout printing for c/c++ and register syscall 4 haven't done it for JAVA. I assume it's because execlp which I trace is used just to run jvm. And later on there are created more processes (by inner mechanism of jvm) which I do not track. I found this topic which seems to be partial solution. If I got it right every child will be traced. But that's is a problem as well I want to track only that process which handles my application and not all others that jvm might create. Is there any chance to get know which jvm thread/process handles my program and track only it?

For make it a bit easier let's assume my JAVA program is one-thread.

Community
  • 1
  • 1
abc
  • 2,371
  • 3
  • 25
  • 36

1 Answers1

0

If you start the binary through your tracer app, all threads will be traced.

But if you attach to a process, then you won't attach to all it's threads. You have to attach to all of its threads using the threadids, that you can found listed eg. in /proc/%d/task/.

Also, I suggest reading through strace's source code, I've learnt a lot from it. If you can use strace to successfully follow java threads as you want, you can get the logic from it.

Koshinae
  • 2,240
  • 2
  • 30
  • 40