Skip to content

Instantly share code, notes, and snippets.

@ChinaXing
Created August 19, 2016 10:48
Show Gist options
  • Save ChinaXing/0b7153f311b570bb319a998879a25bd5 to your computer and use it in GitHub Desktop.
Save ChinaXing/0b7153f311b570bb319a998879a25bd5 to your computer and use it in GitHub Desktop.
btrace probe field set
import com.sun.btrace.annotations.*;
import com.sun.btrace.AnyType;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class Q{
@OnMethod(
clazz="java.nio.Buffer",
method="/.*/",
location=@Location(value=Kind.FIELD_SET, clazz="java.nio.Buffer", field="po
sition")
)
public static void S(@Self Object self, int v){ // type must match the field's type
if(v == 0){
// long id = getLong(field(classForName("com.alibaba.cobar.net.F
rontendConnection",contextClassLoader()),"id"),self);
int hash = identityHashCode(self);
println(concat(concat(concat("====", str(hash)) ,"======== set posist
ion : \n"), jstackStr()));
}
}
@OnMethod(
clazz="com.alibaba.cobar.net.buffer.BufferPool",
method="insert"
)
public static void insert(AnyType[] args){
println(concat("insert>>>>",str(identityHashCode(args[0]))));
}
@OnMethod(
clazz="com.alibaba.cobar.net.buffer.BufferPool",
method="extract",
location=@Location(Kind.RETURN)
)
public static void extract(@Return Object arg){
println(concat("extract>>>>",str(identityHashCode(arg))));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment