{"action":"opened","issue":{"url":"https://api.github.com/repos/btraceio/btrace/issues/241","repository_url":"https://api.github.com/repos/btraceio/btrace","labels_url":"https://api.github.com/repos/btraceio/btrace/issues/241/labels{/name}","comments_url":"https://api.github.com/repos/btraceio/btrace/issues/241/comments","events_url":"https://api.github.com/repos/btraceio/btrace/issues/241/events","html_url":"https://github.com/btraceio/btrace/issues/241","id":173049260,"number":241,"title":"Why doesn't this CALL tracing example work?","user":{"login":"Kshitiz-Sharma","id":6263572,"avatar_url":"https://avatars.githubusercontent.com/u/6263572?v=3","gravatar_id":"","url":"https://api.github.com/users/Kshitiz-Sharma","html_url":"https://github.com/Kshitiz-Sharma","followers_url":"https://api.github.com/users/Kshitiz-Sharma/followers","following_url":"https://api.github.com/users/Kshitiz-Sharma/following{/other_user}","gists_url":"https://api.github.com/users/Kshitiz-Sharma/gists{/gist_id}","starred_url":"https://api.github.com/users/Kshitiz-Sharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kshitiz-Sharma/subscriptions","organizations_url":"https://api.github.com/users/Kshitiz-Sharma/orgs","repos_url":"https://api.github.com/users/Kshitiz-Sharma/repos","events_url":"https://api.github.com/users/Kshitiz-Sharma/events{/privacy}","received_events_url":"https://api.github.com/users/Kshitiz-Sharma/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-24T20:24:45Z","updated_at":"2016-08-24T20:24:45Z","closed_at":null,"body":"I'm struggling to get a CALL tracing program to work. Since the probe weaving has happened correctly and method call replaced with \r\n\r\nConsider following program:\r\n```\r\npublic class MethodCallTracingExample {\r\n    public static void main(String[] args) throws InterruptedException {\r\n        while (true) {\r\n            System.out.println(\"calling method\");\r\n            new UtilClass().utilMethod();\r\n            Thread.sleep(2000);\r\n        }\r\n    }\r\n}\r\npublic class UtilClass {\r\n    public String utilMethod() {\r\n        System.out.println(\"Returning useful data\");\r\n        return \"useful data\";\r\n    }\r\n}\r\n```\r\n\r\nAnd following trace script:\r\n```\r\n@BTrace\r\npublic class MethodCallTracer {\r\n    @OnMethod(clazz = \"/.*MethodCallTracingExample.*/\", method = \"/.*main.*/\",\r\n            location = @Location(value = Kind.CALL, clazz = \"/.*UtilClass.*/\", method = \"/.*utilMethod.*/\"))\r\n    public static void m(@Self Object self, @TargetMethodOrField String method,\r\n                         @ProbeMethodName String probeMethod) {\r\n        BTraceUtils.println(\"hello\");\r\n    }\r\n    @OnError\r\n    public static void onTraceProblem(Throwable t) {\r\n        BTraceUtils.println(\"UNABLE TO TRACE: \" + t);\r\n    }\r\n}\r\n```\r\n\r\nI've dumped the class and decompiled it to ensure that probe weaving is happening correctly:\r\n```\r\npublic class MethodCallTracingExample {\r\n    public MethodCallTracingExample() {\r\n    }\r\n\r\n    public static void main(String[] args) throws InterruptedException {\r\n        while(true) {\r\n            System.out.println(\"calling method\");\r\n            UtilClass var10000 = new UtilClass();\r\n            $btrace$MethodCallTracer$m((Object)null, \"utilMethod\", \"main\");\r\n            var10000.utilMethod();\r\n            Thread.sleep(5000L);\r\n        }\r\n    }\r\n\r\n    @OnMethod(\r\n        clazz = \"/.*MethodCallTracingExample.*/\",\r\n        method = \"/.*main.*/\",\r\n        location =             @Location(\r\n                value = Kind.CALL,\r\n                clazz = \"/.*UtilClass.*/\",\r\n                method = \"/.*utilMethod.*/\"\r\n            )\r\n    )\r\n    private static void $btrace$MethodCallTracer$m(@Self Object var0, @TargetMethodOrField String var1, @ProbeMethodName String var2) {\r\n        if(BTraceRuntime.enter(MethodCallTracer.runtime)) {\r\n            try {\r\n                BTraceUtils.println(\"hello\");\r\n                BTraceRuntime.leave();\r\n            } catch (Throwable var3) {\r\n                BTraceRuntime.handleException(var3);\r\n                BTraceRuntime.leave();\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nApplication BTrace debug log:\r\n```\r\nbtrace DEBUG: debugMode is true\r\nbtrace DEBUG: startupRetransform is true\r\nbtrace DEBUG: dumpClasses is true\r\nbtrace DEBUG: dumpDir is C:/Development/temp\r\nbtrace DEBUG: unsafeMode is false\r\nbtrace DEBUG: probe descriptor path is .\r\nbtrace DEBUG: stdout is false\r\nbtrace DEBUG: starting agent thread\r\nbtrace DEBUG: starting server at 2020\r\nbtrace DEBUG: waiting for clients\r\nbtrace DEBUG: client accepted Socket[addr=/127.0.0.1,port=63250,localport=2020]\r\nbtrace DEBUG: got instrument command\r\nbtrace DEBUG: loading BTrace class\r\nbtrace DEBUG: verifying BTrace class ...\r\nbtrace DEBUG: BTrace class MethodCallTracer verified\r\nbtrace DEBUG: preprocessing BTrace class MethodCallTracer ...\r\nbtrace DEBUG: ... preprocessed\r\nbtrace DEBUG: loaded 'MethodCallTracer' successfully\r\nbtrace DEBUG: creating BTraceRuntime instance for MethodCallTracer\r\nbtrace DEBUG: created BTraceRuntime instance for MethodCallTracer\r\nbtrace DEBUG: sending Okay command\r\nbtrace DEBUG: client MethodCallTracer: got com.sun.btrace.comm.OkayCommand@107dd570\r\nbtrace DEBUG: about to defineClass MethodCallTracer\r\nbtrace DEBUG: defineClass succeeded for MethodCallTracer\r\nbtrace DEBUG: skipping transform for BTrace class com/sun/btrace/runtime/BTraceProbe$2\r\nbtrace DEBUG: skipping transform for BTrace class com/sun/btrace/agent/RemoteClient$1\r\nbtrace DEBUG: starting client command handler thread\r\nbtrace DEBUG: skipping transform for BTrace class com/sun/btrace/agent/Main$3\r\nbtrace DEBUG: new Client created com.sun.btrace.agent.RemoteClient@2fbe83f2\r\nbtrace DEBUG: retransforming loaded classes\r\nbtrace DEBUG: filtering loaded classes\r\nbtrace DEBUG: skipping transform for BTrace class com/sun/btrace/runtime/ClassCache$Singleton\r\nbtrace DEBUG: candidate class MethodCallTracingExample added\r\nbtrace DEBUG: client MethodCallTracer: got com.sun.btrace.comm.RetransformationStartNotification@6b9d01\r\nbtrace DEBUG: calling retransformClasses (1 classes to be retransformed)\r\nbtrace DEBUG: transformed class MethodCallTracingExample\r\nbtrace DEBUG: waiting for clients\r\nbtrace DEBUG: client MethodCallTracer: got com.sun.btrace.comm.OkayCommand@463b64f6\r\n```\r\n\r\nClient DEBUG log:\r\n```\r\nDEBUG: dumpDir is C:/Development/temp\r\nDEBUG: assuming default port 2020\r\nDEBUG: assuming default classpath '.'\r\nDEBUG: compiling MethodCallTracer.java\r\nDEBUG: compiled MethodCallTracer.java\r\nDEBUG: attaching to 4820\r\nDEBUG: checking port availability: 2020\r\nDEBUG: attached to 4820\r\nDEBUG: loading C:\\Development\\Software\\btrace-1.3.8\\build\\btrace-agent.jar\r\nDEBUG: agent args: port=2020,statsd=,debug=true,dumpClasses=true,dumpDir=C:/Development/temp,bootClassPath=.,systemClassPath=C:\\Program Files\\Java\\jdk1.8.0_92\\jre/../lib/tools.jar,probeDescPath=.\r\nDEBUG: loaded C:\\Development\\Software\\btrace-1.3.8\\build\\btrace-agent.jar\r\nDEBUG: registering shutdown hook\r\nDEBUG: submitting the BTrace program\r\nDEBUG: opening socket to 2020\r\nDEBUG: setting up client settings\r\nDEBUG: sending instrument command\r\nDEBUG: entering into command loop\r\nDEBUG: received com.sun.btrace.comm.OkayCommand@a74868d\r\nDEBUG: received com.sun.btrace.comm.RetransformationStartNotification@12c8a2c0\r\nDEBUG: received com.sun.btrace.comm.OkayCommand@7e0e6aa2\r\n```"}}
{"actor":{"display_login":"Kshitiz-Sharma"}}