mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
made agent self-contained for IDEA-194359
This commit is contained in:
1
.idea/artifacts/debugger_agent.xml
generated
1
.idea/artifacts/debugger_agent.xml
generated
@@ -7,6 +7,7 @@
|
||||
<element id="file-copy" path="$PROJECT_DIR$/java/debugger/debugger-agent/META-INF/MANIFEST.MF" />
|
||||
</element>
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/java/debugger/debugger-agent/lib/asm-capture.jar" path-in-jar="/" />
|
||||
<element id="artifact" artifact-name="debugger-agent-storage" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
|
||||
|
||||
@@ -91,7 +89,6 @@ abstract class BaseIdeaProperties extends ProductProperties {
|
||||
withModule("intellij.java.rt", "idea_rt.jar", null)
|
||||
withModule("intellij.tools.jetCheck", "jetCheck.jar")
|
||||
withArtifact("debugger-agent", "rt")
|
||||
withArtifact("debugger-agent-storage", "rt")
|
||||
withProjectLibrary("Eclipse")
|
||||
withProjectLibrary("jgoodies-common")
|
||||
withProjectLibrary("commons-net")
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Premain-Class: com.intellij.rt.debugger.agent.CaptureAgent
|
||||
Can-Retransform-Classes: true
|
||||
Boot-Class-Path: debugger-agent-storage.jar
|
||||
|
||||
@@ -3,16 +3,14 @@ package com.intellij.rt.debugger.agent;
|
||||
|
||||
import org.jetbrains.capture.org.objectweb.asm.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.lang.instrument.UnmodifiableClassException;
|
||||
import java.net.URI;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.*;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
/**
|
||||
* @author egor
|
||||
@@ -30,6 +28,16 @@ public class CaptureAgent {
|
||||
try {
|
||||
readSettings(args);
|
||||
|
||||
try {
|
||||
appendStorageJar(instrumentation);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
System.out.println(
|
||||
"Critical error in IDEA Async Stacktraces instrumenting agent. Agent is now disabled. Please report to IDEA support:");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
instrumentation.addTransformer(new CaptureTransformer());
|
||||
|
||||
// Trying to reinstrument java.lang.Thread
|
||||
@@ -58,6 +66,30 @@ public class CaptureAgent {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SSBasedInspection")
|
||||
private static void appendStorageJar(Instrumentation instrumentation) throws IOException {
|
||||
InputStream inputStream = CaptureAgent.class.getResourceAsStream("/debugger-agent-storage.jar");
|
||||
try {
|
||||
File storageJar = File.createTempFile("debugger-agent-storage", "jar");
|
||||
storageJar.deleteOnExit();
|
||||
OutputStream outStream = new FileOutputStream(storageJar);
|
||||
try {
|
||||
byte[] buffer = new byte[10 * 1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
outStream.close();
|
||||
}
|
||||
instrumentation.appendToBootstrapClassLoaderSearch(new JarFile(storageJar));
|
||||
}
|
||||
finally {
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setupJboss() {
|
||||
String modulesKey = "jboss.modules.system.pkgs";
|
||||
String property = System.getProperty(modulesKey, "");
|
||||
|
||||
@@ -504,7 +504,6 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
}
|
||||
|
||||
private static final String AGENT_FILE_NAME = "debugger-agent.jar";
|
||||
private static final String STORAGE_FILE_NAME = "debugger-agent-storage.jar";
|
||||
|
||||
private static void addDebuggerAgent(JavaParameters parameters) {
|
||||
if (StackCapturingLineBreakpoint.isAgentEnabled()) {
|
||||
@@ -533,10 +532,8 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
}
|
||||
}
|
||||
if (agentFile.exists()) {
|
||||
String agentPath = JavaExecutionUtil.handleSpacesInAgentPath(agentFile.getAbsolutePath(), "captureAgent", null, f -> {
|
||||
String name = f.getName();
|
||||
return STORAGE_FILE_NAME.equals(name) || AGENT_FILE_NAME.equals(name);
|
||||
});
|
||||
String agentPath = JavaExecutionUtil.handleSpacesInAgentPath(
|
||||
agentFile.getAbsolutePath(), "captureAgent", null, f -> AGENT_FILE_NAME.equals(f.getName()));
|
||||
if (agentPath != null) {
|
||||
parametersList.add(prefix + agentPath + generateAgentSettings());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user