Runing btrace in a single command


/ Published in: Java
Save to your folder(s)

Running a btrace script takes two separate steps by default:
1. Running jps to get the Java process ID.
2. Running btrace on the ID.
A simple awk script can merge the two into a single step.


Copy this code and paste it in your HTML
  1. # instead of running
  2. $ jps
  3. 18904 Main
  4. 18951 SpringMain
  5. 19055 Jps
  6. $ btrace 18951 jdftm/ReflecTracer.class
  7.  
  8. # We issue (the traced application main class is SpringMain)
  9. $ jps | awk '/SpringMain/{system("btrace " $1 " jdftm/ReflecTracer.class")}'

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.