Questions tagged [btrace]

BTrace is a safe, dynamic tracing tool for Java. BTrace works by dynamically (bytecode) instrumenting classes of a running Java program. BTrace inserts tracing actions into the classes of a running Java program and hotswaps the traced program classes.

BTrace is a safe, dynamic tracing tool for Java. BTrace works by dynamically (bytecode) instrumenting classes of a running Java program. BTrace inserts tracing actions into the classes of a running Java program and hotswaps the traced program classes.

BTrace Terminology

Probe Point

"location" or "event" at which a set of tracing statements are executed. Probe point is "place" or "event" of interest where we want to execute some tracing statements. Trace Actions or Actions

Trace statements that are executed whenever a probe "fires".

Action Methods

BTrace trace statements that are executed when a probe fires are defined inside a static method a class. Such methods are called "action" methods.

BTrace Program Structure

A BTrace program is a plain Java class that has one or more

public static void

methods that are annotated with BTrace annotations. The annotations are used to specify traced program "locations" (also known as "probe points"). The tracing actions are specified inside the static method bodies. These static methods are referred as "action" methods.

BTrace Restrictions

To guarantee that the tracing actions are "read-only" (i.e., the trace actions don't change the state of the program traced) and bounded (i.e., trace actions terminate in bounded time), a BTrace program is allowed to do only a restricted set of actions. In particular, a BTrace class

  • can not create new objects.
  • can not create new arrays.
  • can not throw exceptions.
  • can not catch exceptions.
  • can not make arbitrary instance or static method calls - only the public static methods of com.sun.btrace.BTraceUtils class or methods declared in the same program may be called from a BTrace program.
  • (pre 1.2) can not have instance fields and methods. Only static public void returning methods are allowed for a BTrace class. And all fields have to be static.
  • can not assign to static or instance fields of target program's classes and objects. But, BTrace class can assign to it's own static fields ("trace state" can be mutated).
  • can not have outer, inner, nested or local classes.
  • can not have synchronized blocks or synchronized methods.
  • can not have loops (for, while, do..while)
  • can not extend arbitrary class (super class has to be java.lang.Object)
  • can not implement interfaces.
  • can not contains assert statements.
  • can not use class literals.

Reference : https://github.com/btraceio/btrace/wiki

46 questions
1
vote
1 answer

COMPUTE_MAXS is deleting a StackMapTable

I am using the open-source library Btrace to profile a Java application. I have been messing with it because I have found a few bugs, and while trying to fix them I have come upon a mysterious occurrence. Essentially, I am using a ClassWriter with…
Hassan Syyid
  • 1,559
  • 1
  • 13
  • 24
1
vote
0 answers

How to shutdown btrace?

I'm using btrace to instrument an application. What Btrace does is inject bytecode into the running JVM to trace the target application. It also sets up a socket connection to communicate between the tracer client and the application. When I stop…
Kshitiz Sharma
  • 17,947
  • 26
  • 98
  • 169
1
vote
1 answer

How to get all live thread IDs in btrace?

I've only found a method that gives me the number of all live threads: BTraceUtils.threadCount() But how to get the IDs? I want to know which threads are live when a method (@OnMethod) is called.
ka3ak
  • 2,435
  • 2
  • 30
  • 57
1
vote
1 answer

BTrace failing to instantiate legal properties

I am trying to run btrace v.1.3 (20150516) using Java 1.8 on Windows 7 Enterprise and having many issues. In my btrace script I am creating an Aggregation using: private static Aggregation methodDuration = Aggregations …
Victor Grazi
  • 15,563
  • 14
  • 61
  • 94
1
vote
1 answer

JVM process - print every method argument

We use InstallAnywhere to create installers. Recently an installer created using it started failing with StackOverFlow error (in silent installation).. Error stack has thousands of lines like below. java.lang.StackOverflowError at…
Jayan
  • 18,003
  • 15
  • 89
  • 143
1
vote
0 answers

How to btrace JBoss AS 7

I'm trying to instrument JBoss AS 7 using btrace but can't get it to work. I'm using visualvm 1.3.7 and the btrace workbench 0.6.7 (right click -> "Trace applicaiton..."). I'm always setting the following non-descriptive error. !!! Error occured !!!…
Philippe Marschall
  • 4,452
  • 1
  • 34
  • 52
1
vote
1 answer

BTrace - Can it trace the button click event?

I know that BTrace can trace any target method of a java program. However, I want to know if it can trace a method that is directly defined in code. Like the button listener method, cause I want to trace this event. button1.addActionListener(new…
TrangVu
  • 43
  • 7
1
vote
1 answer

BTrace Script to Kill Java Virtual Machine Thread

VisualVM supports executing unsafe BTrace scripts (https://kenai.com/projects/btrace/pages/UserGuide). Is it possible to use an unsafe BTrace script to kill/interrupt some Java thread? Some threads in my Eclipse IDE are deadlocked and I'd like to…
buzz3791
  • 1,683
  • 2
  • 20
  • 38
1
vote
2 answers

How to use btrace

I want to study btrace. java process user is yubaofu yubaofu@btrace sudo sh /home/yubaofu/study/btrace/bin/btrace 24234 JInfo.class well-known file is not secure yubaofu@btrace sh /home/yubaofu/study/btrace/bin/btrace 24234 JInfo.class…
fuyou001
  • 1,594
  • 4
  • 16
  • 27
1
vote
1 answer

Running multiple Btrace scripts

Do anyone know how to run multiple btrace scripts at the same time? I dont want to pre compile and start my program with them. I want plug into the running process with multiple btrace scripts.
rupa
  • 603
  • 2
  • 7
  • 8
0
votes
1 answer

I got an error("Handler dispatch failed; nested exception is java.lang.NoSuchFieldError: runtime") when I tried to trace a spring project using btrace

As I mentioned in the title,I tried to using btrace to trace the execution of a restful api and got this error:"Handler dispatch failed; nested exception is java.lang.NoSuchFieldError: runtime" when I invoked the restful api.And before I start the…
mango
  • 1
  • 1
0
votes
1 answer

btrace didn't print out anything when the specified method is invoked

I'm learning how to use btrace. In order to do that, I created a spring-boot project which contained the following code. @Controller public class MainController { private static Logger logger = LoggerFactory.getLogger(MainController.class); …
Searene
  • 25,920
  • 39
  • 129
  • 186
0
votes
1 answer

Btrace: Filter class with same name by Application

I'm trying to instrument my app to monitor a connection pool. We use apache commons pool 1.6 for connection pooling, with all the applications deployed on the same AS (we use Jboss EAP 6). Trace script works, but it triggers when pool methods are…
0
votes
1 answer

btrace with glassfish web container

Recently I use BTrace to check exceptions that are thrown inside glassfish VM. I use script: @BTrace public class OnThrow { // store current exception in a thread local // variable (@TLS annotation). Note that we can't // store it in…
maciek
  • 83
  • 7
0
votes
1 answer

how to print exception and params together using btrace?

I am trying to print the exception and params in my method. But I can`t get any result from my code. import com.sun.btrace.annotations.*; import static com.sun.btrace.BTraceUtils.*; @BTrace public class HelloWorld { @OnMethod(clazz =…
Felix
  • 1,253
  • 7
  • 22
  • 41