Open cf0415 opened 6 months ago
Most probably the problem is trying to raise the D probe while not running on Solaris (I assume you are not running on Solaris). Please, try using https://github.com/btraceio/btrace/blob/develop/btrace-dist/src/main/resources/samples/AllMethods1.java as an example and see if that fixes your problem.
Most probably the problem is trying to raise the D probe while not running on Solaris (I assume you are not running on Solaris). Please, try using https://github.com/btraceio/btrace/blob/develop/btrace-dist/src/main/resources/samples/AllMethods1.java as an example and see if that fixes your problem.
The example provided in the URL, https://github.com/btraceio/btrace/blob/develop/btrace-dist/src/main/resources/samples/AllMethods1.java, works fine and can get trace logs. However, if you change clazz = "/javax.swing../" to clazz = "/java.lang../", there will be no any output. It seems that BTrace versions 2.1.0 and above do not support tracing java.lang, but BTrace versions below 2.0.2 can support it. My runtime environment is Ubuntu 20.04.
The example provided in the URL, https://github.com/btraceio/btrace/blob/develop/btrace-dist/src/main/resources/samples/AllMethods1.java, works fine and can get trace logs. However, if you change clazz = "/javax.swing../" to clazz = "/java.lang../", there will be no any output. It seems that BTrace versions 2.1.0 and above do not support tracing java.lang, but BTrace versions below 2.0.2 can support it. My runtime environment is Ubuntu 20.04.
Ah, I see. Currently, BTrace is not able to trace java.lang.*
classes - due to the necessity to use invoke dynamic in anything newer than Java 8 there is a good chance of deadlocking the indy bootstrap if some of the lang classes used from that bootstrap internally get instrumented and the instrumentation needs to bootstrap the binding again :/
Ah, I see. Currently, BTrace is not able to trace
java.lang.*
classes - due to the necessity to use invoke dynamic in anything newer than Java 8 there is a good chance of deadlocking the indy bootstrap if some of the lang classes used from that bootstrap internally get instrumented and the instrumentation needs to bootstrap the binding again :/
Are there any good solutions or viable alternatives to address this issue currently?
No, not really. Except of patching and building BTrace yourself. I did several attempts to relax the filter but it would take tracing the bootstrap process in detail to see which classes are involved and even then it would be brittle as the bootstrap process is an internal detail of JVM and can change from version to version. An alternative would be to modify the BTrace instrumentation to add guard calls before calling invokedynamic (doing the checks in the generated probe code is too late) - that will increase the amount of disturbance to the instrumented method (adding more branches, potentially changing JIT decisions etc.) and as such I did not have enough motivation to proceed with that, just to allow tracing core Java classes ...
No, not really. Except of patching and building BTrace yourself. I did several attempts to relax the filter but it would take tracing the bootstrap process in detail to see which classes are involved and even then it would be brittle as the bootstrap process is an internal detail of JVM and can change from version to version. An alternative would be to modify the BTrace instrumentation to add guard calls before calling invokedynamic (doing the checks in the generated probe code is too late) - that will increase the amount of disturbance to the instrumented method (adding more branches, potentially changing JIT decisions etc.) and as such I did not have enough motivation to proceed with that, just to allow tracing core Java classes ...
Okay,Another question: why BTrace v2.0.2 is unable to enable the unsafe mode? btrace WARNING:Unable to load BTrace script...... And no any trace output.
Okay,Another question: why BTrace v2.0.2 is unable to enable the unsafe mode? btrace WARNING:Unable to load BTrace script...... And no any trace output.
Stale issue message
TBH, I don't know why unsafe mode does not work with 2.0.2
Does it work with 2.2.6 (the most recent version)?
Hey, brother! When I use the BTrace tool to trace methods in java.lang, I don't see any log output. I have already tried to use jdk version 8 , 11 and 17,the btrace version is v2.3.0. Can you provide any insights or suggestions to help me troubleshoot this issue? ?
Here are the steps I followed:
import java.io.IOException; import java.util.Scanner; import java.lang.Thread;
public class Demo { public static void main(String[] args) throws InterruptedException {
}
And,I have used the trace script from the sample directory, as following:
import org.openjdk.btrace.core.annotations.BTrace; import org.openjdk.btrace.core.annotations.OnMethod; import org.openjdk.btrace.core.annotations.Self;
import static org.openjdk.btrace.core.BTraceUtils.*;
/*