I have a very specific requirement. I need to monitor a live process & get the stack of "some" of the threads belonging to my process (from the process itself).

To be precise, I am instrumenting Java programs. Through some capability, I can get to know when native binding occurs in this program (I can also get the corresponding OS thread at this stage). With this capability, I can get the list of OS threads(that can keep changing) that I need to monitor at my wish. for instance get the stack trace, at some frequency etc...
Have tried using ptrace, but getting issues with permissions to ATTACH & GETREGS etc.
Can someone guide me how this can be achieved?