forked from btraceio/btrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial revision
- Loading branch information
A. Sundararajan
committed
Mar 6, 2008
1 parent
bf88791
commit 5a758fd
Showing
12 changed files
with
476 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /bin/sh | ||
|
||
if [ -z "$BTRACE_HOME" -o ! -d "$BTRACE_HOME" ] ; then | ||
# resolve links - $0 could be a link to btrace's home | ||
PRG="$0" | ||
progname=`basename "$0"` | ||
BTRACE_HOME=`dirname "$PRG"`/.. | ||
BTRACE_HOME=`cd "$BTRACE_HOME" && pwd` | ||
fi | ||
|
||
if [ -f "${BTRACE_HOME}/build/btrace-client.jar" ] ; then | ||
if [ "${JAVA_HOME}" != "" ]; then | ||
${JAVA_HOME}/bin/java -Dcom.sun.btrace.probeDescPath=. -Dcom.sun.btrace.dumpClasses=false -Dcom.sun.btrace.debug=false -cp ${BTRACE_HOME}/build/btrace-client.jar:${BTRACE_HOME}/build/asm-3.0.jar:${JAVA_HOME}/lib/tools.jar:/usr/share/lib/java/dtrace.jar com.sun.btrace.client.Main $* | ||
else | ||
echo "Please set JAVA_HOME before running this script" | ||
fi | ||
else | ||
echo "Please set BTRACE_HOME before running this script" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@echo off | ||
|
||
rem %~dp0 is expanded pathname of the current script under NT | ||
set DEFAULT_BTRACE_HOME=%~dp0.. | ||
|
||
if "%BTRACE_HOME%"=="" set BTRACE_HOME=%DEFAULT_BTRACE_HOME% | ||
set DEFAULT_BTRACE_HOME= | ||
|
||
if not exist "%BTRACE_HOME%\build\btrace-client.jar" goto noBTraceHome | ||
|
||
if "%JAVA_HOME%" == "" goto noJavaHome | ||
%JAVA_HOME%/bin/java -Dcom.sun.btrace.probeDescPath=. -Dcom.sun.btrace.dumpClasses=false -Dcom.sun.btrace.debug=false -cp %BTRACE_HOME%/build/btrace-client.jar;%BTRACE_HOME%/build/asm-3.0.jar;%JAVA_HOME%/lib/tools.jar com.sun.btrace.client.Main %* | ||
goto end | ||
:noJavaHome | ||
echo Please set JAVA_HOME before running this script | ||
goto end | ||
:noBTraceHome | ||
echo Please set BTRACE_HOME before running this script | ||
:end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /bin/sh | ||
|
||
if [ -z "$BTRACE_HOME" -o ! -d "$BTRACE_HOME" ] ; then | ||
# resolve links - $0 could be a link to btrace's home | ||
PRG="$0" | ||
progname=`basename "$0"` | ||
BTRACE_HOME=`dirname "$PRG"`/.. | ||
BTRACE_HOME=`cd "$BTRACE_HOME" && pwd` | ||
fi | ||
|
||
if [ -f "${BTRACE_HOME}/build/btrace-client.jar" ] ; then | ||
if [ "${JAVA_HOME}" != "" ]; then | ||
${JAVA_HOME}/bin/java -cp ${BTRACE_HOME}/build/btrace-client.jar:${JAVA_HOME}/lib/tools.jar com.sun.btrace.compiler.Compiler $* | ||
else | ||
echo "Please set JAVA_HOME before running this script" | ||
fi | ||
else | ||
echo "Please set BTRACE_HOME before running this script" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#! /bin/sh | ||
|
||
if [ -z "$BTRACE_HOME" -o ! -d "$BTRACE_HOME" ] ; then | ||
# resolve links - $0 could be a link to btrace's home | ||
PRG="$0" | ||
progname=`basename "$0"` | ||
BTRACE_HOME=`dirname "$PRG"`/.. | ||
BTRACE_HOME=`cd "$BTRACE_HOME" && pwd` | ||
fi | ||
|
||
if [ -f "${BTRACE_HOME}/build/btrace-agent.jar" ] ; then | ||
java -Xshare:off -javaagent:${BTRACE_HOME}/build/btrace-agent.jar=dumpClasses=false,debug=false,probeDescPath=.,noServer=true,script=$1 $2 $3 $4 $5 $6 $7 $8 $9 | ||
else | ||
echo "Please set BTRACE_HOME before running this script" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@echo off | ||
|
||
rem %~dp0 is expanded pathname of the current script under NT | ||
set DEFAULT_BTRACE_HOME=%~dp0.. | ||
|
||
if "%BTRACE_HOME%"=="" set BTRACE_HOME=%DEFAULT_BTRACE_HOME% | ||
set DEFAULT_BTRACE_HOME= | ||
|
||
if not exist "%BTRACE_HOME%\build\btrace-agent.jar" goto noBTraceHome | ||
|
||
java -Xshare:off -javaagent:%BTRACE_HOME%/build/btrace-agent.jar=dumpClasses=false,debug=false,probeDescPath=.,noServer=true,script=%1 %2 %3 %4 %5 %6 %7 %8 %9 | ||
goto end | ||
|
||
:noBTraceHome | ||
echo Please set BTRACE_HOME before running this script | ||
:end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://www.netbeans.org/ns/project/1"> | ||
<type>org.netbeans.modules.ant.freeform</type> | ||
<configuration> | ||
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1"> | ||
<!-- Do not use Project Properties customizer when editing this file manually. --> | ||
<name>BTrace</name> | ||
<properties> | ||
<property name="ant.script">make/build.xml</property> | ||
</properties> | ||
<folders> | ||
<source-folder> | ||
<label>src</label> | ||
<type>java</type> | ||
<location>src</location> | ||
</source-folder> | ||
</folders> | ||
<ide-actions> | ||
<action name="build"> | ||
<script>${ant.script}</script> | ||
<target>all</target> | ||
</action> | ||
<action name="clean"> | ||
<script>${ant.script}</script> | ||
<target>clean</target> | ||
</action> | ||
<action name="rebuild"> | ||
<script>${ant.script}</script> | ||
<target>clean</target> | ||
<target>all</target> | ||
</action> | ||
</ide-actions> | ||
<view> | ||
<items> | ||
<source-folder style="packages"> | ||
<label>src/share/classes</label> | ||
<location>src/share/classes</location> | ||
</source-folder> | ||
<source-file> | ||
<location>${ant.script}</location> | ||
</source-file> | ||
</items> | ||
<context-menu> | ||
<ide-action name="build"/> | ||
<ide-action name="clean"/> | ||
<ide-action name="rebuild"/> | ||
</context-menu> | ||
</view> | ||
<subprojects/> | ||
</general-data> | ||
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1"> | ||
<compilation-unit> | ||
<package-root>src/share/classes</package-root> | ||
<classpath mode="compile">lib/asm-2.2.3.jar;../jdk1.6.0/lib/tools.jar</classpath> | ||
<source-level>1.5</source-level> | ||
</compilation-unit> | ||
</java-data> | ||
</configuration> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Sun designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Sun in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | ||
* CA 95054 USA or visit www.sun.com if you need additional information or | ||
* have any questions. | ||
*/ | ||
|
||
import com.sun.btrace.annotations.*; | ||
import static com.sun.btrace.BTraceUtils.*; | ||
|
||
@DTraceRef("syscalls.d") | ||
@BTrace | ||
public class Test { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Sun designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Sun in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | ||
* CA 95054 USA or visit www.sun.com if you need additional information or | ||
* have any questions. | ||
*/ | ||
|
||
import com.sun.btrace.annotations.*; | ||
import static com.sun.btrace.BTraceUtils.*; | ||
import com.sun.btrace.annotations.Export; | ||
|
||
/** | ||
* This sample creates a jvmstat counter and | ||
* increments it everytime Thread.start() is | ||
* called. This thread count may be accessed | ||
* from outside the process. The @Export annotated | ||
* fields are mapped to jvmstat counters. The counter | ||
* name is "btrace." + <className> + "." + <fieldName> | ||
*/ | ||
@BTrace public class ThreadCounter { | ||
|
||
// create a jvmstat counter using @Export | ||
@Export private static long count; | ||
|
||
@OnMethod( | ||
clazz="java.lang.Thread", | ||
method="start" | ||
) | ||
public static void onnewThread(Thread t) { | ||
// updating counter is easy. Just assign to | ||
// the static field! | ||
count++; | ||
} | ||
|
||
@OnTimer(2000) | ||
public static void ontimer() { | ||
// we can access counter as "count" as well | ||
// as from jvmstat counter directly. | ||
println(count); | ||
// or equivalently println(perfLong("btrace.ThreadCounter.count")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Sun designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Sun in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | ||
* CA 95054 USA or visit www.sun.com if you need additional information or | ||
* have any questions. | ||
*/ | ||
|
||
import com.sun.btrace.annotations.*; | ||
import static com.sun.btrace.BTraceUtils.*; | ||
|
||
/* | ||
* This BTrace script inserts a probe into | ||
* method entry of java.lang.Thread.start() method. | ||
* At each Thread.start(), it raises a DTrace probe | ||
* in addition to printing the name of the thread. | ||
* A D-script like jthread.d may be used to get the | ||
* associated DTrace probe events. | ||
*/ | ||
@BTrace public class ThreadStart { | ||
@OnMethod( | ||
clazz="java.lang.Thread", | ||
method="start" | ||
) | ||
public static void onnewThread(Thread t) { | ||
dtraceProbe("jthreadstart", name(t)); | ||
println(strcat("starting ", name(t))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Sun designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Sun in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | ||
* CA 95054 USA or visit www.sun.com if you need additional information or | ||
* have any questions. | ||
*/ | ||
|
||
import com.sun.btrace.annotations.*; | ||
import static com.sun.btrace.BTraceUtils.*; | ||
|
||
/** | ||
* Demonstrates multiple timer probes with different | ||
* periods to fire. | ||
*/ | ||
@BTrace public class Timers { | ||
|
||
// when starting print the target VM version and start time | ||
static { | ||
println(strcat("vm version ", vmVersion())); | ||
println(strcat("vm starttime ", str(vmStartTime()))); | ||
} | ||
|
||
@OnTimer(1000) | ||
public static void f() { | ||
println(strcat("1000 msec: ", str(vmUptime()))); | ||
} | ||
|
||
@OnTimer(3000) | ||
public static void f1() { | ||
println(strcat("3000 msec: ", str(timeMillis()))); | ||
} | ||
|
||
} |
Oops, something went wrong.