debugger agent: ability to disable capturing

This commit is contained in:
Egor.Ushakov
2017-10-02 12:50:29 +03:00
parent a455dd2160
commit c19a31198e
2 changed files with 17 additions and 0 deletions
@@ -26,9 +26,13 @@ public class CaptureStorage {
private static final JavaLangAccess ourJavaLangAccess = SharedSecrets.getJavaLangAccess();
private static boolean DEBUG = false;
private static boolean ENABLED = true;
@SuppressWarnings("unused")
public static void capture(Object key) {
if (!ENABLED) {
return;
}
if (DEBUG) {
System.out.println("capture - " + key);
}
@@ -50,6 +54,9 @@ public class CaptureStorage {
@SuppressWarnings("unused")
public static void insertEnter(Object key) {
if (!ENABLED) {
return;
}
CapturedStack stack = STORAGE.get(key);
Deque<InsertMatch> currentStacks = CURRENT_STACKS.get();
if (stack != null) {
@@ -68,6 +75,9 @@ public class CaptureStorage {
@SuppressWarnings("unused")
public static void insertExit(Object key) {
if (!ENABLED) {
return;
}
Deque<InsertMatch> currentStacks = CURRENT_STACKS.get();
currentStacks.removeLast();
if (DEBUG) {
@@ -156,4 +166,8 @@ public class CaptureStorage {
public static void setDebug(boolean debug) {
DEBUG = debug;
}
public static void setEnabled(boolean enabled) {
ENABLED = enabled;
}
}
@@ -68,6 +68,9 @@ public class CaptureAgent {
DEBUG = true;
CaptureStorage.setDebug(true);
}
else if ("disabled".equals(s)) {
CaptureStorage.setEnabled(false);
}
else {
asmPath = s;
}