Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/target
**/.DS_Store
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/use_plugins.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Monitor/trunk/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Plugin-Name: Monitor
Plugin-Version: 0.1
Plugin-Publisher: Lars Hamann
Main-Class: org.tzi.use.plugins.monitor.MonitorPlugin
Class-Path: ../tools.jar ../lablib-checkboxtree-3.2.jar ../guava-12.0.jar
Class-Path: ../lablib-checkboxtree-3.2.jar ../guava-12.0.jar
25 changes: 25 additions & 0 deletions Monitor/trunk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# USE Monitor

This plugin adds runtime monitoring capabilities to USE.

## Instructions

### 1. Build the JAR with Maven

The following command will build the `MonitorPlugin.jar` in the target directory:
```
mvn clean package
```

### 2. Copy the MonitorPlugin.jar and its Dependencies Over to USE

- Copy `MonitorPlugin.jar` over to USE under `${USE_DIR}/lib/plugins`
- Copy `lablib-checkboxtree-3.2.jar` over to USE under `${USE_DIR}/lib`
- Copy `guava-12.0.jar` over to USE under `${USE_DIR}/lib`

### 3. Modify the USE Start Script

Add the following argument to the java command in the USE start script for your OS under `${USE_DIR}/bin`.
```
--add-exports jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED
```
83 changes: 83 additions & 0 deletions Monitor/trunk/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.tzi.use</groupId>
<artifactId>plugins</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>monitor</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>it.cnr.imaa.essi</groupId>
<artifactId>lablib-checkboxtree</artifactId>
<version>3.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/lablib-checkboxtree-3.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>12.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/guava-12.0.jar</systemPath>
</dependency>
</dependencies>

<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<resources>
<resource>
<directory>${project.basedir}/resources</directory>
<targetPath>resources</targetPath>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>${project.basedir}</directory>
<includes>
<include>useplugin.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<fork>true</fork>
<compilerArgs>
--add-exports=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<finalName>MonitorPlugin</finalName>
<archive>
<manifestFile>${project.basedir}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>

</project>
57 changes: 33 additions & 24 deletions Monitor/trunk/src/org/tzi/use/plugins/monitor/Monitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ public class Monitor implements ChangeListener {

/**
* Internal mapping for the adapters from a VM specific key
* to the intermediate representation as a {@link VMOperation}.
* to the intermediate representation as a {@link VMMethod}.
*/
private BiMap<Object, VMMethod> adapterMethodMapping;

/**
* Internal mapping for the adapters from a VM specific key
* to the intermediate representation as a {@link VMOperation}.
* to the intermediate representation as a {@link VMMethod}.
*/
private BiMap<Object, VMField> adapterFieldMapping;

Expand Down Expand Up @@ -310,7 +310,7 @@ private void waitForUserInput() {
* In detail the following steps are executed:
* <ol>
* <li>Reset of the USE session.</li>
* <li>Connect to the VM with the settings provided to {@link #configure(Session, String, String)}. </li>
* <li>Connect to the VM with the settings provided to {@link #configure(Session, VMAdapter)}. </li>
* <li>Register for important events in the VM</li>
* <li>Resume the VM</li>
* <li>If <code>suspend</code> is <code>true</code> call {@link #pause(boolean)} without reseting.</li>
Expand Down Expand Up @@ -448,8 +448,7 @@ private void calculateCurrentCallStack() {
/**
* Generates and executes a USE operation call from the provided values.
* @param self The MObject representing self for the operation call.
* @param useOperation
* @param frame
* @param call
* @param validatePreConditions
*/
private boolean createOperationCall(MObject self, VMMethodCall call, boolean validatePreConditions) {
Expand All @@ -476,7 +475,7 @@ private boolean createOperationCall(MObject self, VMMethodCall call, boolean val
PPCHandler handler = (validatePreConditions ? ppcHandler : DoNothingPPCHandler.getInstance());

MEnterOperationStatement operationCall = new MEnterOperationStatement(
new ExpObjRef(self), useOperation, arguments, handler );
new ExpObjRef(self), useOperation, arguments.values().toArray(new Expression[0]), handler);

try {
StatementEvaluationResult result = getSystem().execute(operationCall);
Expand Down Expand Up @@ -640,7 +639,7 @@ private void registerOperationBreakPoints(VMType vmType) {

fireNewLogMessage(Level.FINE, "Registering link modification interest for class " + cls.name());
// Association ends with multiplicity 1 can be handled also
for (Map.Entry<String, MNavigableElement> end : cls.navigableEnds().entrySet()) {
for (Entry<String, ? extends MNavigableElement> end : cls.navigableEnds().entrySet()) {

if (!end.getValue().isCollection() && end.getValue() instanceof MAssociationEnd) {
MAssociationEnd assEnd = (MAssociationEnd)end.getValue();
Expand Down Expand Up @@ -728,7 +727,7 @@ private void setupClassMappings() {
}

VMType vmType = getVMType(useClass);
if (!vmType.isClassType()) {
if (vmType != null && !vmType.isClassType()) {
fireNewLogMessage(Level.FINE, String.format("Found VM type for class %s, but the returned type is not a class", useClass.name()));
}

Expand Down Expand Up @@ -838,8 +837,8 @@ protected MObject createInstance(MClass cls, VMObject vmObj)

if (useSoil) {
MNewObjectStatement stmt = new MNewObjectStatement(cls, (String)null);
getSystem().execute(stmt);
useObject = stmt.getCreatedObject();
StatementEvaluationResult result = getSystem().execute(stmt);
useObject = getSystem().createObject(result, stmt.getObjectClass(), stmt.getObjectName().name());
} else {
String name = getSystem().state().uniqueObjectNameForClass(cls);
useObject = getSystem().state().createObject(cls, name);
Expand All @@ -865,7 +864,7 @@ private void checkForDeletedInstances() {
if (!refObject.isAlive()) {
MObject useObj = refObject.getUSEObject();

ObjectValue valObject = new ObjectValue(useObj.type(), useObj);
ObjectValue valObject = new ObjectValue(useObj.cls(), useObj);
MObjectDestructionStatement delStmt = new MObjectDestructionStatement(valObject);
try {
this.getSystem().execute(delStmt);
Expand Down Expand Up @@ -1066,7 +1065,7 @@ private void readLink(VMObject objRef, MObject source, MAssociationEnd end) {
} catch (Exception e) {
fireNewLogMessage(Level.SEVERE, "ERROR: " + e.getMessage());
}
} else if (fieldValue.isSet() && ((SetValue)fieldValue).elemType().isTupleType(true)) {
} else if (fieldValue.isSet() && ((SetValue)fieldValue).elemType().isTypeOfTupleType()) {
// Qualified association
SetValue setValue = (SetValue)fieldValue;

Expand All @@ -1090,8 +1089,7 @@ private void readLink(VMObject objRef, MObject source, MAssociationEnd end) {
* Reads qualified links from a Set(Tuple(key,value))
* @param source
* @param end
* @param seqValue
* @param qualifierValues
* @param setValue
*/
private void readQualifiedLinks(MObject source, MAssociationEnd end, SetValue setValue) {
List<Value> qualifier = new LinkedList<Value>();
Expand All @@ -1114,9 +1112,10 @@ private void readQualifiedLinks(MObject source, MAssociationEnd end, SetValue se
}

/**
* @param i
* @param source
* @param end
* @param seqValue
* @param qualifierValues
* @return
*/
private void readQualifiedLinks(MObject source, MAssociationEnd end, SequenceValue seqValue, List<Value> qualifierValues) {
for (int i = 0; i < seqValue.size(); ++i) {
Expand Down Expand Up @@ -1299,7 +1298,17 @@ public void handlePostConditions(MSystem system,
if (oneFailed) {
throw new PostConditionCheckFailedException(operationCall);
}


}

@Override
public void handleTransitionsPre(MSystem system, MOperationCall operationCall) throws PreConditionCheckFailedException {

}

@Override
public void handleTransitionsPost(MSystem system, MOperationCall operationCall) throws PostConditionCheckFailedException {

}
}

Expand Down Expand Up @@ -1466,10 +1475,9 @@ public void storeVMMethod(Object key, VMMethod type) {
}

/**
* Needs to be called if a method is called
* which the monitor registered for.
* The monitor will call all other adapter methods.
* @param vmMethodId The id of the method returned by {@link VMMethod#getId()}
* Needs to be called if a method is called, which the monitor registered for.
* The monitor will call all other adapter methods.
* @param vmMethodCall The method called
*/
public void onMethodCall(VMMethodCall vmMethodCall) {
/*
Expand Down Expand Up @@ -1566,7 +1574,7 @@ public void onMethodExit(Object adapterExitInformation, Object adapterMethodId)
result = new ExpressionWithValue(resultValue);
}

MExitOperationStatement stmt = new MExitOperationStatement(result, ppcHandler, currentUseOperationCall);
MExitOperationStatement stmt = new MExitOperationStatement(result, ppcHandler);

try {
StatementEvaluationResult statResult = getSystem().execute(stmt);
Expand Down Expand Up @@ -1594,6 +1602,7 @@ public void onMethodExit(Object adapterExitInformation, Object adapterMethodId)


/**
* @param adapterEventInformation
* @param type
*/
public void onNewVMTypeLoaded(Object adapterEventInformation, JVMType type) {
Expand Down Expand Up @@ -1626,8 +1635,8 @@ public void onNewVMObject(VMObject newInstance) {
}

/**
* @param obj
* @param field
* @param objId
* @param fieldId
* @param useValue
*/
public void onUpdateAttribute(Object objId, Object fieldId, Value useValue) {
Expand Down
Loading