Quick Start:
- Download BTrace from here
- Extract the release to a directory e.g.
~/btrace
- Write a BTrace program. There are many samples present in the
samples
directory. Here is one of mine: the program below prints a message whenever the target program calls theArrayList.add()
method.
import com.sun.btrace.annotations.*; import static com.sun.btrace.BTraceUtils.*; import java.util.*; @BTrace public class ArrayListTrace { // @OnMethod annotation tells where to probe. // In this example, we are interested in entry // into the ArrayList.add() method. @OnMethod( clazz="java.util.ArrayList", method="add"; ) // print out what was added public static void alert(@Self ArrayList self, Object o) { print("ADDED "); println(o); } }
javac -cp "~/btrace/build/*" ArrayListTrace.java
~/btrace/bin/btrace -cp ".:~/btrace/build/*" <PID> ArrayListTrace.classUseful BTrace Programs:
Here are a few useful BTrace programs I have used in the past:
- OnThrow: Prints out the stack trace of an exception whenever a Throwable is created. This way you can capture all exceptions, even those that have been swallowed.
- LogTracer: Prints out log messages.
- AllMethods: Prints out the name of every method entered.
ReplyDeleteThank you for taking the time to write about this much needed subject. I felt that your remarks on this technology is helpful and were especially timely.
devops course fees in chennai | devops training in chennai with placement | devops training in chennai omr | best devops training in chennai quora | devops foundation certification chennai
Wonderful blog!!! Thanks for your information sharing with us.
ReplyDeleteselenium training
selenium course in coimbatore
Best Software Testing Training Institute in Coimbatore
Software Testing Training Center in Coimbatore
Software testing Institute in Coimbatore
hello sir,
ReplyDeletethanks for giving that type of information.
best digital marketing company in delhi
HP DesignJet T520 In Delhi
Thanks for giving great kind of information. So useful and practical for me. Thanks for your excellent blog, nice work keep it up thanks for sharing the knowledge.
ReplyDeletedining room interior designer in noida
Thanks for giving great kind of information. So useful and practical for me. Thanks for your excellent blog, nice work keep it up thanks for sharing the knowledge.
ReplyDeletedining room interior designer in noida
افضل شركة ترميم وتشطيب المنازل بالجنوب
ReplyDeleteVery nice post here thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
ReplyDeletemachine learning training center in Chennai
machine learning training in velachery
machine learning certification course in Chennai
nice work keep it up thanks for sharing the knowledge.Thanks for sharing this type of information, it is so useful.
ReplyDeleteEpoxy Grout manufacturer in delhi