BTrace unsafe not works for me

  3 posts   Feedicon  
Replies: 2 - Last Post: September 02, 2014 09:08
by: chinaxing
« Older Topic » Newer Topic
showing 1 - 3 of 3
Posted: September 02, 2014 02:31 by chinaxing

$ uname -a
Linux mofa2114 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

CentOS release 6.5 (Final) as following:

package com.mogujie.lotusq;

import com.sun.btrace.AnyType;
import com.sun.btrace.annotations.*;

import java.lang.reflect.Field;

import static com.sun.btrace.BTraceUtils.*;

 *  * Created by ChinaXing on 14-8-29.
@BTrace(unsafe = true)
public class BtraceTest {

            clazz = "",
            method = "getTopicQueueProducerOffset",
            location = @Location(Kind.ENTRY)
    public static void trace(AnyType[] args) {
        println("getBrokerProducer end");
        Class<?> c = classOf(args[1]);
        Field field = field(c, "body",true);
        byte[] ba = (byte[])get(field, args[1]);
        String s = new String(ba);

            clazz = "",
            method = "isKeyTopicOnly",
            location = @Location(Kind.RETURN)
    public static void traceK(@Return String v, String k){
        println("enter isKeyTopicOnly");
        println(strcat("K is : ",k));
        println(strcat("r is : ",v));

The Unsafe flag is open too :

 ${JAVA_HOME}/bin/java -Dcom.sun.btrace.probeDescPath=. -Dcom.sun.btrace.dumpClasses=false -Dcom.sun.btrace.debug=true -Dcom.sun.btrace.unsafe=true -cp ${BTRACE_HOME}/build/btrace-client.jar:${TOOLS_JAR}\:/usr/share/lib/java/dtrace.jar com.sun.btrace.client.Main $*

$ ./bin/btrace 23820
DEBUG: btrace debug mode is set
DEBUG: btrace unsafe mode is set
DEBUG: assuming default port 2020
DEBUG: assuming default classpath '.'
DEBUG: compiling
DEBUG: compiled
DEBUG: attaching to 23820
DEBUG: checking port availability: 2020
DEBUG: attached to 23820
DEBUG: loading /root/btrace/build/btrace-agent.jar
DEBUG: agent args: port=2020,debug=true,unsafe=true,systemClassPath=/usr/lib/jvm/java-1.7.0-openjdk-,probeDescPath=.
DEBUG: loaded /root/btrace/build/btrace-agent.jar
DEBUG: registering shutdown hook
DEBUG: registering signal handler for SIGINT
DEBUG: submitting the BTrace program
DEBUG: opening socket to 2020
DEBUG: sending instrument command
DEBUG: entering into command loop
DEBUG: received com.sun.btrace.comm.ErrorCommand@53ac539d
java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key agent.unsafe.not.allowed
at java.util.ResourceBundle.getObject(
at java.util.ResourceBundle.getString(
at com.sun.btrace.util.Messages.get(
at com.sun.btrace.runtime.Verifier.reportError(
at com.sun.btrace.runtime.Verifier.reportError(
at com.sun.btrace.runtime.Verifier$1.visit(
at Source)
at Source)
at Source)
at Source)
at com.sun.btrace.runtime.InstrumentUtils.accept(
at com.sun.btrace.runtime.InstrumentUtils.accept(
at com.sun.btrace.agent.Client.verify(
at com.sun.btrace.agent.Client.loadClass(
at com.sun.btrace.agent.RemoteClient.<init>(
at com.sun.btrace.agent.Main.startServer(
at com.sun.btrace.agent.Main.access$000(
at com.sun.btrace.agent.Main$
DEBUG: received com.sun.btrace.comm.ExitCommand@5e517550
Posted: September 02, 2014 06:23 by Jaroslav Bachorik
This could be caused by a previous attach to the JVM without allowing unsafe mode. The agent gets initialized only on the first attach and ignores the parameters on the subsequent attaches.

Could you provide the output of the traced application? It might provide more information.

Posted: September 02, 2014 09:08 by chinaxing
That's right !

BTW: can we unload the agent when inject the new one ? or some other method to fix this problem Smile
Replies: 2 - Last Post: September 02, 2014 09:08
by: chinaxing
« Older Topic » Newer Topic
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2014, Oracle Corporation and/or its affiliates
(revision 20160708.bf2ac18)
Please Confirm