MCPcopy Index your code
hub / github.com/btraceio/btrace

github.com/btraceio/btrace @v2.2.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.2.6 ↗ · + Follow
4,082 symbols 12,721 edges 564 files 870 documented · 21% updated todayv2.2.6 · 2024-11-09★ 5,9914 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Dev build Download codecov.io huhu Join the chat at https://gitter.im/jbachorik/btrace Project Stats

btrace

A safe, dynamic tracing tool for the Java platform

Version

2.2.6

Quick Summary

BTrace is a safe, dynamic tracing tool for the Java platform.

BTrace can be used to dynamically trace a running Java program (similar to DTrace for OpenSolaris applications and OS). BTrace dynamically instruments the classes of the target application to inject tracing code ("bytecode tracing").

Credits

Building BTrace

Setup

You will need the following applications installed

  • Git
  • (optionally, the default launcher is the bundled gradlew wrapper) Gradle

Build

Gradle

cd <btrace>
./gradlew :btrace-dist:build

The binary dist packages can be found in <btrace>/btrace-dist/build/distributions as the .tar.gz, .zip, .rpm and .deb files. The exploded binary folder which can be used right away is located at <btrace>/btrace-dist/build/resources/main which serves as the BTRACE_HOME location.

Using BTrace

Installation

Download a distribution file from the release page. Explode the binary distribution file (either .tar.gz or .zip) to a directory of your choice.

You may set the system environment variable BTRACE_HOME to point to the directory containing the exploded distribution.

You may enhance the system environment variable PATH with $BTRACE_HOME/bin for your convenience.

Or, alternatively, you may install one of the .rpm or .deb packages

Running

  • <btrace>/bin/btrace <PID> <trace_script> will attach to the java application with the given PID and compile and submit the trace script
  • <btrace>/bin/btracec <trace_script> will compile the provided trace script
  • <btrace>/bin/btracer <compiled_script> <args to launch a java app> will start the specified java application with the btrace agent running and the script previously compiled by btracec loaded

For the detailed user guide, please, check the Wiki.

Maven Integration

The maven plugin is providing easy compilation of BTrace scripts as a part of the build process. As a bonus you can utilize the BTrace Project Archetype to bootstrap developing BTrace scripts.

Contributing - !!! Important !!!

Pull requests can be accepted only from the signers of Oracle Contributor Agreement

Deb Repository

Using the command line, add the following to your /etc/apt/sources.list system config file:

echo "deb http://dl.bintray.com/btraceio/deb xenial universe" | sudo tee -a /etc/apt/sources.list

Or, add the repository URLs using the "Software Sources" admin UI:

deb http://dl.bintray.com/btraceio/deb xenial universe

RPM Repository

Grab the *.repo file wget https://bintray.com/btraceio/rpm/rpm -O bintray-btraceio-rpm.repo and use it.

Extension points exported contracts — how you extend this code

TestPrinter (Interface)
@author Jaroslav Bachorik [24 implementers]
integration-tests/src/test/java/resources/TestPrinter.java
PrintableCommand (Interface)
Marks any command which is able to print its internal info into the provided plain PrintWriter @author Jaroslav [28 implementers]
btrace-core/src/main/java/org/openjdk/btrace/core/comm/PrintableCommand.java
TestPrinter (Interface)
@author Jaroslav Bachorik [24 implementers]
btrace-instr/src/test/java/resources/TestPrinter.java
PerfReader (Interface)
This interface hides jvmstat classes from the caller. The implementor of this interface should read perf counters and re [8 …
btrace-runtime/src/main/java/org/openjdk/btrace/runtime/PerfReader.java
RuntimeContext (Interface)
(no doc) [7 implementers]
btrace-services-api/src/main/java/org/openjdk/btrace/services/api/RuntimeContext.java
DTraceCommand (Interface)
A marker interface to tell whether a given BTrace command is a wrapper of a DTrace event. @author A. Sundararajan [4 implementers]
btrace-dtrace/src/main/java/org/openjdk/btrace/dtrace/DTraceCommand.java
PackGenerator (Interface)
(no doc) [2 implementers]
btrace-compiler/src/main/java/org/openjdk/btrace/compiler/PackGenerator.java
ProcessOutputProcessor (Interface)
(no doc) [1 implementers]
integration-tests/src/test/java/tests/RuntimeTest.java

Core symbols most depended-on inside this repo

println
called by 531
btrace-instr/src/main/java/org/openjdk/btrace/instr/Assembler.java
add
called by 417
btrace-core/src/main/java/org/openjdk/btrace/core/aggregation/AggregationValue.java
append
called by 245
btrace-core/src/main/java/org/openjdk/btrace/core/BTraceRuntime.java
visitLdcInsn
called by 169
btrace-instr/src/main/java/org/openjdk/btrace/instr/MethodVerifier.java
get
called by 154
btrace-core/src/main/java/org/openjdk/btrace/core/ArgsMap.java
visitInsn
called by 141
btrace-instr/src/main/java/org/openjdk/btrace/instr/MethodVerifier.java
put
called by 139
btrace-core/src/main/java/org/openjdk/btrace/core/ArgsMap.java
peek
called by 130
btrace-instr/src/main/java/org/openjdk/btrace/instr/StackTrackingMethodVisitor.java

Shape

Method 3,426
Class 614
Interface 28
Enum 14

Languages

Java100%

Modules by API surface

btrace-core/src/main/java/org/openjdk/btrace/core/BTraceUtils.java409 symbols
btrace-core/src/main/java/org/openjdk/btrace/core/BTraceRuntime.java167 symbols
btrace-instr/src/test/java/org/openjdk/btrace/instr/InstrumentorTest.java110 symbols
btrace-instr/src/test/java/org/openjdk/btrace/instr/InstrStackTest.java102 symbols
btrace-runtime/src/main/java/org/openjdk/btrace/runtime/BTraceRuntimeImplBase.java86 symbols
btrace-instr/src/main/java/org/openjdk/btrace/instr/StackTrackingMethodVisitor.java76 symbols
btrace-instr/src/main/java/org/openjdk/btrace/instr/InstrumentingMethodVisitor.java74 symbols
btrace-instr/src/main/java/org/openjdk/btrace/instr/Preprocessor.java67 symbols
btrace-instr/src/main/java/org/openjdk/btrace/instr/BTraceProbePersisted.java59 symbols
btrace-instr/src/main/java/org/openjdk/btrace/instr/MethodInstrumentor.java57 symbols
btrace-runtime/src/main/java/org/openjdk/btrace/runtime/DOTWriter.java54 symbols
btrace-instr/src/main/java/org/openjdk/btrace/instr/Instrumentor.java50 symbols

For agents

$ claude mcp add btrace \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact