Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DiSL
DiSL
Commits
67a94f4e
Commit
67a94f4e
authored
Jul 02, 2013
by
Lubomir Bulej
Browse files
Fixed the C agent Makefile to do the right thing on OS X.
parent
d9fa8e9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
README
View file @
67a94f4e
DiSL
====
DiSL is inspired by AOP, but in contrast to mainstream AOP languages, it features
an open join point model where any region of bytecodes can be selected as a join
point (i.e., code location to be instrumented). DiSL reconciles high-level
language constructs resulting in concise instrumentations, high expressiveness,
and efficiency of the inserted instrumentation code. Thanks to the
pointcut/advice model adopted by DiSL, instrumentations are similarly compact as
aspects written in AspectJ. However, in contrast to AspectJ, DiSL does not
restrict the code locations that can be instrumented, and the code generated by
DiSL avoids expensive operations (such as object allocations that are not visible
to the programmer). Furthermore, DiSL supports instrumentations with complete
bytecode coverage out-of-the-box and avoids structural modifications of classes
that would be visible through reflection and could break the instrumented code.
DiSL is a Java bytecode instrumentation framework intended for observation
of programs executing in the Java Virtual Machine. It has been mainly used
for development of dynamic program analysis instrumentations, but it can be
used equally well to develop instrumentations for, e.g. runtime performance
monitoring, or other tasks not bent on altering program execution.
DiSL is inspired by AOP, but in contrast to mainstream AOP languages, it
features an open join point model where any region of bytecodes can serve as
a join point (i.e., code location to be instrumented). DiSL also reconciles
high-level language concepts, such as the pointcut/advice programming model
found in AOP, with high expressiveness, and efficiency of bytecode
manipulation performed using low-level libraries such as ASM. As a result,
instrumentations written using DiSL almost as compact as aspects written in
AspectJ, but perform about as fast as those written using ASM.
However, in contrast to AspectJ, DiSL does not restrict the code locations
that can be instrumented, and the code generated by DiSL avoids expensive
operations (such as object allocations that are not visible to the
programmer). Furthermore, DiSL supports instrumentations with complete
bytecode coverage out-of-the-box and avoids structural modifications of
classes that would be visible through reflection and could break the
instrumented code.
link: http://forge.ow2.org/projects/disl/
INSTALL
=======
DiSL currently fully supports Linux with installed Java, ant, GCC and make.
DiSL currently fully supports "Linux" and "OS X" platforms with Java, ant, GCC
and make installed and found on the executable path. DiSL has been used on the
Windows/Cygwin platform as well, but it was not extensively tested there.
While most of the DiSL is written in Java, it requires a JVM enhanced with a
native agent written in C, which must be compiled first. For that, the simple
build system needs to know where your JDK is installed to be able to find JNI
header files for your platform. On many systems, the JAVA_HOME environment
variable points to the root of the JDK installation and you should be fine.
To compile DiSL please run the "ant" command in the root directory. If "make" is
complaining about missing java headers, modify the Makefile.local.tmpl in
src-agent-c directory accordingly.
If this is not the case, please enter the src-agent-c directory, copy the
Makefile.local.tmpl file to Makefile.local and modify it to set the JAVA_HOME
variable to point to the root of the JDK installation you want to use.
Finally, to compile DiSL, run the "ant" command in the root directory.
You can create javadoc documentation by running "ant javadoc".
EXAMPLES
========
For the basic instrumentation example, please look in the example directory.
Also the src-test directory contains simple examples of DiSL features.
DOCUMENTATION
=============
Please look at http://disl.projects.ow2.org/xwiki/bin/view/Main/Doc.
USER ERRORS
===========
If you get a
n j
ava error during instrumentation or running your application,
If you get a
J
ava error during instrumentation or running your application,
please look at USERERRORS document describing most common problems.
src-agent-c/Makefile
View file @
67a94f4e
...
...
@@ -11,13 +11,17 @@ SOURCES=dislagent.c
# Object files needed to create library
OBJECTS
=
$(SOURCES:%.c=%.o)
# Library name and options needed to build it
UNAME
:=
$(
shell
uname
)
ifeq
($(UNAME), Linux)
LIBRARY
=
lib
$(LIBNAME)
.so
endif
ifeq
($(UNAME), Darwin)
JNI_OS
=
linux
else
ifeq
($(UNAME), Darwin)
LIBRARY
=
lib
$(LIBNAME)
.jnilib
JNI_OS
=
darwin
else
$(error error
:
unsupported operating system: $(UNAME))
endif
...
...
@@ -31,7 +35,7 @@ COMMON_FLAGS+= -W -Wall -Wextra -O3 -Wno-unused-parameter
CFLAGS
+=
$(COMMON_FLAGS)
CFLAGS
+=
-I
$(JAVA_HOME)
/include
-I
$(JAVA_HOME)
/include/
linux
CFLAGS
+=
-I
$(JAVA_HOME)
/include
-I
$(JAVA_HOME)
/include/
$(JNI_OS)
# add debugging output
ifeq
($(DEBUG), TRUE)
...
...
@@ -52,4 +56,4 @@ clean:
debug
:
$(MAKE)
DEBUG
=
TRUE
all
:
build
\ No newline at end of file
all
:
build
src/ch/usi/dag/disl/staticcontext/FieldAccessStaticContext.java
0 → 100644
View file @
67a94f4e
package
ch.usi.dag.disl.staticcontext
;
import
org.objectweb.asm.Type
;
import
org.objectweb.asm.tree.FieldInsnNode
;
import
ch.usi.dag.disl.marker.BytecodeMarker
;
/**
* Represents a field access static context. Provides field's name and type
* descriptor, along with the internal name of the field's owner class.
* <p>
* <b>Note:</b> This context can only be used with {@link BytecodeMarker}
* triggering on field access instructions, i.e., GETFIELD, PUTFIELD, GETSTATIC,
* and PUTSTATIC. If you are not sure whether the context can be used, use the
* {@link #isValid()} method to check if the context is valid.
*
* @author Aibek Sarimbekov
* @author Lubomir Bulej
*/
final
class
FieldAccessStaticContext
extends
AbstractStaticContext
{
public
FieldAccessStaticContext
()
{
// invoked by DiSL
}
/**
* @return {@code True} if the context is valid.
*/
public
boolean
isValid
()
{
return
staticContextData
.
getRegionStart
()
instanceof
FieldInsnNode
;
}
/**
* @return The field's name.
*/
public
String
getName
()
{
return
__getFieldInsnNode
().
name
;
}
/**
* @return The field's type descriptor.
*/
public
String
getDescriptor
()
{
return
__getFieldInsnNode
().
desc
;
}
/**
* @return The name of the field's owner class.
*/
public
String
getOwnerClassName
()
{
return
Type
.
getObjectType
(
__getFieldInsnNode
().
owner
).
getClassName
();
}
/**
* @return The internal name of the field's owner class.
*/
public
String
getOwnerInternalName
()
{
return
__getFieldInsnNode
().
owner
;
}
//
private
FieldInsnNode
__getFieldInsnNode
()
{
//
// This will throw an exception when used in a region that does not
// start with a field access instruction.
//
return
(
FieldInsnNode
)
staticContextData
.
getRegionStart
();
}
}
src/ch/usi/dag/disl/staticcontext/MethodInvocationStaticContext.java
0 → 100644
View file @
67a94f4e
package
ch.usi.dag.disl.staticcontext
;
import
org.objectweb.asm.Type
;
import
org.objectweb.asm.tree.MethodInsnNode
;
import
ch.usi.dag.disl.marker.BytecodeMarker
;
/**
* Represents a static context for method invocations. Provides information
* related to a method invocation at a particular call site.
* <p>
* <b>Note:</b> This context can only be used with the {@link BytecodeMarker}
* triggering on method invocation instructions, i.e., INVOKESTATIC,
* INVOKEVIRTUAL, INVOKESPECIAL, and INVOKEINTERFACE. If you are not sure
* whether the context can be used, use the {@link #isValid()} method to check
* if the context is valid.
*
* @author Aibek Sarimbekov
* @author Lubomir Bulej
*/
final
class
MethodInvocationStaticContext
extends
AbstractStaticContext
{
public
MethodInvocationStaticContext
()
{
// invoked by DiSL
}
/**
* @return {@code True} if the context is valid.
*/
public
boolean
isValid
()
{
return
staticContextData
.
getRegionStart
()
instanceof
MethodInsnNode
;
}
public
String
invocationTarget
()
{
final
MethodInsnNode
node
=
__methodInsnNode
();
return
String
.
format
(
"%s.%s%s"
,
node
.
owner
,
node
.
name
,
node
.
desc
);
}
/**
* @return The name of the method being invoked.
*/
public
String
getName
()
{
return
__methodInsnNode
().
name
;
}
/**
* @return The descriptor of the method being invoked.
*/
public
String
getDescriptor
()
{
return
__descriptor
();
}
/**
* @return The return type descriptor of the method being invoked.
*/
public
String
getReturnTypeDescriptor
()
{
return
Type
.
getReturnType
(
__descriptor
()).
getDescriptor
();
}
/**
* @return The internal name of the invoked method's owner.
*/
public
String
getOwnerInternalName
()
{
return
__methodInsnNode
().
owner
;
}
//
private
String
__descriptor
()
{
return
__methodInsnNode
().
desc
;
}
private
MethodInsnNode
__methodInsnNode
()
{
//
// This will throw an exception when used in a region that does not
// start with a method invocation instruction.
//
return
((
MethodInsnNode
)
staticContextData
.
getRegionStart
());
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment