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)

BtraceTest.java 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 {

    @OnMethod(
            clazz = "com.mogujie.lotusq.broker.controller.AdminHandler",
            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);
        println(s);
    }

    @OnMethod(
            clazz = "com.mogujie.lotusq.broker.controller.support.OffsetManager",
            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 BtraceTest.java
DEBUG: btrace debug mode is set
DEBUG: btrace unsafe mode is set
DEBUG: assuming default port 2020
DEBUG: assuming default classpath '.'
DEBUG: compiling BtraceTest.java
DEBUG: compiled BtraceTest.java
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-1.7.0.51.x86_64/jre/../lib/tools.jar,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(ResourceBundle.java:395)
at java.util.ResourceBundle.getString(ResourceBundle.java:355)
at com.sun.btrace.util.Messages.get(Messages.java:41)
at com.sun.btrace.runtime.Verifier.reportError(Verifier.java:381)
at com.sun.btrace.runtime.Verifier.reportError(Verifier.java:376)
at com.sun.btrace.runtime.Verifier$1.visit(Verifier.java:141)
at com.sun.btrace.org.objectweb.asm.ClassReader.a(Unknown Source)
at com.sun.btrace.org.objectweb.asm.ClassReader.a(Unknown Source)
at com.sun.btrace.org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.sun.btrace.org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.sun.btrace.runtime.InstrumentUtils.accept(InstrumentUtils.java:66)
at com.sun.btrace.runtime.InstrumentUtils.accept(InstrumentUtils.java:62)
at com.sun.btrace.agent.Client.verify(Client.java:404)
at com.sun.btrace.agent.Client.loadClass(Client.java:231)
at com.sun.btrace.agent.RemoteClient.<init>(RemoteClient.java:59)
at com.sun.btrace.agent.Main.startServer(Main.java:379)
at com.sun.btrace.agent.Main.access$000(Main.java:65)
at com.sun.btrace.agent.Main$3.run(Main.java:166)
at java.lang.Thread.run(Thread.java:744)
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.

-JB-
 
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)
 
 
Close
loading
Please Confirm
Close