Skip to content
Merged
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
9 changes: 5 additions & 4 deletions configCSHistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
"port": "5006"
},
"entrypoint": {
"className": "com.example.ObjectRefSimulation",
"className": "dummies.ObjectArgsTypes",
"methodName": "main",
"methodArguments": [
"java.lang.String[]"
],
"repBefore": 0
},
"endpoint": {
"className": "java.lang.Runtime",
"methodName": "exec",
"className": "dummies.ObjectArgsTypes",
"methodName": "endpoint",
"methodArguments": [
"java.lang.String"
"java.util.List",
"int"
],
"repBefore": 0
},
Expand Down
9 changes: 5 additions & 4 deletions configCSSnapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
"port": "5006"
},
"entrypoint": {
"className": "com.example.ObjectRefSimulation",
"className": "dummies.ObjectArgsTypes",
"methodName": "main",
"methodArguments": [
"java.lang.String[]"
],
"repBefore": 0
},
"endpoint": {
"className": "java.lang.Runtime",
"methodName": "exec",
"className": "dummies.ObjectArgsTypes",
"methodName": "endpoint",
"methodArguments": [
"java.lang.String"
"java.util.List",
"int"
],
"repBefore": 0
},
Expand Down
15 changes: 8 additions & 7 deletions configTrace.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@
"port": "5006"
},
"entrypoint": {
"className": "com.example.ObjectRefSimulation",
"className": "dummies.ObjectArgsTypes",
"methodName": "main",
"methodArguments": [
"java.lang.String[]"
],
"repBefore": 0
},
"endpoint": {
"className": "java.lang.Runtime",
"methodName": "exec",
"className": "dummies.ObjectArgsTypes",
"methodName": "endpoint",
"methodArguments": [
"java.lang.String"
"java.util.List",
"int"
],
"repBefore": 0
},
"activateEndpoint" : false,
"collectValues" : true,
"maxObjectDepth" : 14,
"maxMethodDepth" : 21,
"maxSteps" : -1,
"maxObjectDepth" : 1,
"maxMethodDepth" : 23,
"maxSteps" : 10000,
"logging": {
"outputName" : "JDIOutput",
"extension": "tr"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
package org.jdiextractor.config;
package jdiextractor.config;

import org.jdiextractor.config.components.BreakpointConfig;
import org.jdiextractor.config.components.LoggingConfig;
import org.jdiextractor.config.components.VmConfig;
import jdiextractor.config.components.BreakpointConfig;
import jdiextractor.config.components.LoggingConfig;
import jdiextractor.config.components.VmConfig;

import com.fasterxml.jackson.databind.JsonNode;

public class AbstractExtractorConfig {

protected final int DEFAULT_MAX_DEPTH = 20;
public final static int DEFAULT_MAX_DEPTH = 20;

protected BreakpointConfig entrypoint;
protected BreakpointConfig endpoint;
protected VmConfig vm;
protected LoggingConfig logging;
protected int maxObjectDepth;

protected AbstractExtractorConfig() {
}

protected AbstractExtractorConfig(BreakpointConfig entrypoint, BreakpointConfig endpoint, VmConfig vm,
LoggingConfig logging, int maxObjectDepth) {
this.entrypoint = entrypoint;
this.endpoint = endpoint;
this.vm = vm;
this.logging = logging;
this.maxObjectDepth = maxObjectDepth;
}

protected void fillFromJson(JsonNode rootNode) {
this.vm = VmConfig.fromJson(rootNode.get("vm"));
this.entrypoint = BreakpointConfig.fromJson(rootNode.get("entrypoint"));
this.endpoint = BreakpointConfig.fromJson(rootNode.get("endpoint"));
this.logging = LoggingConfig.fromJson(rootNode.get("logging"));
this.maxObjectDepth = rootNode.has("maxObjectDepth") ? rootNode.get("maxObjectDepth").asInt() : DEFAULT_MAX_DEPTH;
this.maxObjectDepth = rootNode.has("maxObjectDepth") ? rootNode.get("maxObjectDepth").asInt()
: DEFAULT_MAX_DEPTH;
}

public BreakpointConfig getEntrypoint() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package jdiextractor.config;

import com.fasterxml.jackson.databind.JsonNode;

import jdiextractor.config.builder.CallStackHistoryExtractorConfigBuilder;
import jdiextractor.config.components.BreakpointConfig;
import jdiextractor.config.components.LoggingConfig;
import jdiextractor.config.components.VmConfig;

public class CallStackHistoryExtractorConfig extends AbstractExtractorConfig {

public CallStackHistoryExtractorConfig(BreakpointConfig entrypoint, BreakpointConfig endpoint, VmConfig vm,
LoggingConfig logging, int maxObjectDepth) {
super(entrypoint, endpoint, vm, logging, maxObjectDepth);
}

public CallStackHistoryExtractorConfig() {
super();
}


public static CallStackHistoryExtractorConfig fromJson(JsonNode rootNode) {
CallStackHistoryExtractorConfig config = new CallStackHistoryExtractorConfig();
config.fillFromJson(rootNode);
return config;
}

public static CallStackHistoryExtractorConfigBuilder builder() {
return new CallStackHistoryExtractorConfigBuilder();
}

@Override
protected void fillFromJson(JsonNode rootNode) {
super.fillFromJson(rootNode);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package jdiextractor.config;

import com.fasterxml.jackson.databind.JsonNode;

import jdiextractor.config.builder.CallStackSnapshotExtractorConfigBuilder;
import jdiextractor.config.components.BreakpointConfig;
import jdiextractor.config.components.LoggingConfig;
import jdiextractor.config.components.VmConfig;

public class CallStackSnapshotExtractorConfig extends AbstractExtractorConfig {

public CallStackSnapshotExtractorConfig(BreakpointConfig entrypoint, BreakpointConfig endpoint, VmConfig vm,
LoggingConfig logging, int maxObjectDepth) {
super(entrypoint, endpoint, vm, logging, maxObjectDepth);
}

public CallStackSnapshotExtractorConfig() {
super();
}

public static CallStackSnapshotExtractorConfig fromJson(JsonNode rootNode) {
CallStackSnapshotExtractorConfig config = new CallStackSnapshotExtractorConfig();
config.fillFromJson(rootNode);
return config;
}

public static CallStackSnapshotExtractorConfigBuilder builder() {
return new CallStackSnapshotExtractorConfigBuilder();
}

@Override
protected void fillFromJson(JsonNode rootNode) {
super.fillFromJson(rootNode);

}

}
70 changes: 70 additions & 0 deletions src/main/java/jdiextractor/config/TraceExtractorStepConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package jdiextractor.config;

import com.fasterxml.jackson.databind.JsonNode;

import jdiextractor.config.builder.TraceExtractorStepConfigBuilder;
import jdiextractor.config.components.BreakpointConfig;
import jdiextractor.config.components.LoggingConfig;
import jdiextractor.config.components.VmConfig;

public class TraceExtractorStepConfig extends AbstractExtractorConfig {

public final static boolean DEFAULT_ACTIVATE_ENDPOINT = false;
public final static boolean DEFAULT_COLLECT_VALUES = true;
public final static int DEFAULT_MAX_METHOD_DEPTH = 14;
public final static int DEFAULT_MAX_STEPS = 21;

protected boolean activateEndpoint;
protected boolean collectValues;
protected int maxMethodDepth;
protected int maxSteps = 21;

public TraceExtractorStepConfig(BreakpointConfig entrypoint, BreakpointConfig endpoint, VmConfig vm,
LoggingConfig logging, int maxObjectDepth, boolean activateEndpoint, boolean collectValues,
int maxMethodDepth, int maxSteps) {
super(entrypoint, endpoint, vm, logging, maxObjectDepth);
this.activateEndpoint = activateEndpoint;
this.collectValues = collectValues;
this.maxMethodDepth = maxMethodDepth;
this.maxSteps = maxSteps;
}

public TraceExtractorStepConfig() {
super();
}

public static TraceExtractorStepConfig fromJson(JsonNode rootNode) {
TraceExtractorStepConfig config = new TraceExtractorStepConfig();
config.fillFromJson(rootNode);
return config;
}

public static TraceExtractorStepConfigBuilder builder() {
return new TraceExtractorStepConfigBuilder();
}

@Override
protected void fillFromJson(JsonNode rootNode) {
super.fillFromJson(rootNode);
this.activateEndpoint = rootNode.get("activateEndpoint").asBoolean();
this.collectValues = rootNode.get("collectValues").asBoolean();
this.maxMethodDepth = rootNode.get("maxMethodDepth").asInt();
this.maxSteps = rootNode.get("maxSteps").asInt();
}

public boolean activateEndpoint() {
return this.activateEndpoint;
}

public boolean collectValues() {
return this.collectValues;
}

public int getMaxMethodDepth() {
return this.maxMethodDepth;
}

public int getMaxSteps() {
return this.maxSteps;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package jdiextractor.config.builder;

import java.util.List;

import jdiextractor.config.AbstractExtractorConfig;
import jdiextractor.config.components.BreakpointConfig;
import jdiextractor.config.components.LoggingConfig;
import jdiextractor.config.components.VmConfig;

public abstract class AbstractExtractorConfigBuilder<T extends AbstractExtractorConfigBuilder<T, C>, C extends AbstractExtractorConfig> {

protected BreakpointConfig entrypoint = null;
protected BreakpointConfig endpoint = null;
protected VmConfig vmConfig = null;
protected LoggingConfig logging = null;
protected int maxObjectDepth = AbstractExtractorConfig.DEFAULT_MAX_DEPTH;

public abstract T self();

public abstract C build();

protected void ensureConfig() {
if (entrypoint == null) {
entrypoint = new BreakpointConfig("dummies.ObjectArgsSimulation", "main",
List.of("java.lang.String[]", "int"), 0);
}
if (endpoint == null) {
entrypoint = new BreakpointConfig("dummies.ObjectArgsSimulation", "endpoint", List.of("java.lang.String[]"),
0);
}
if (vmConfig == null) {
vmConfig = new VmConfig("localhost", "5006");
}
if (logging == null) {
logging = new LoggingConfig("JDIOutput", "tr");
}
}

public T entrypoint(BreakpointConfig entrypoint) {
this.entrypoint = entrypoint;
return self();
}

public T endpoint(BreakpointConfig endpoint) {
this.endpoint = endpoint;
return self();
}

public T vmConfig(VmConfig vmConfig) {
this.vmConfig = vmConfig;
return self();
}

public T logging(LoggingConfig logging) {
this.logging = logging;
return self();
}

public T maxObjectDepth(int maxObjectDepth) {
this.maxObjectDepth = maxObjectDepth;
return self();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package jdiextractor.config.builder;

import jdiextractor.config.CallStackHistoryExtractorConfig;

public class CallStackHistoryExtractorConfigBuilder extends
AbstractExtractorConfigBuilder<CallStackHistoryExtractorConfigBuilder, CallStackHistoryExtractorConfig> {

@Override
public CallStackHistoryExtractorConfigBuilder self() {
return this;
}

@Override
public CallStackHistoryExtractorConfig build() {
ensureConfig();
return new CallStackHistoryExtractorConfig(entrypoint, endpoint, vmConfig, logging, maxObjectDepth);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package jdiextractor.config.builder;

import jdiextractor.config.CallStackSnapshotExtractorConfig;

public class CallStackSnapshotExtractorConfigBuilder extends
AbstractExtractorConfigBuilder<CallStackSnapshotExtractorConfigBuilder, CallStackSnapshotExtractorConfig> {

@Override
public CallStackSnapshotExtractorConfigBuilder self() {
return this;
}

@Override
public CallStackSnapshotExtractorConfig build() {
ensureConfig();
return new CallStackSnapshotExtractorConfig(entrypoint, endpoint, vmConfig, logging, maxObjectDepth);
}

}
Loading