mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use opened methods from jb-jdi 1.1
GitOrigin-RevId: b825f44a06fa3f5b82574075594a6f832f3edb1e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
43b68f44f2
commit
ba66332827
@@ -36,13 +36,13 @@
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="jb-jdi" type="repository">
|
||||
<properties maven-id="org.jetbrains.intellij.deps:jb-jdi:1.0" />
|
||||
<properties maven-id="org.jetbrains.intellij.deps:jb-jdi:1.1" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/jb-jdi/1.0/jb-jdi-1.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/jb-jdi/1.1/jb-jdi-1.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/jb-jdi/1.0/jb-jdi-1.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/jb-jdi/1.1/jb-jdi-1.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</orderEntry>
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ class LocalVariableEvaluator implements Evaluator {
|
||||
frameProxy.setValue(myEvaluatedVariable, value);
|
||||
}
|
||||
else { // no debug info
|
||||
LocalVariablesUtil.setValue(frameProxy.getStackFrame(), myEvaluatedDecompiledVariable.getSlot(), value);
|
||||
LocalVariablesUtil.setValue(frameProxy.getStackFrame(), myEvaluatedDecompiledVariable, value);
|
||||
}
|
||||
}
|
||||
catch (EvaluateException e) {
|
||||
|
||||
+3
-3
@@ -38,15 +38,15 @@ public class ArgValueData extends DescriptorData<ArgumentValueDescriptorImpl>{
|
||||
public boolean equals(Object object) {
|
||||
if(!(object instanceof ArgValueData)) return false;
|
||||
|
||||
return myVariable.getSlot() == ((ArgValueData)object).myVariable.getSlot();
|
||||
return myVariable.slot() == ((ArgValueData)object).myVariable.slot();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return myVariable.getSlot();
|
||||
return myVariable.slot();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayKey<ArgumentValueDescriptorImpl> getDisplayKey() {
|
||||
return new SimpleDisplayKey<>(myVariable.getSlot());
|
||||
return new SimpleDisplayKey<>(myVariable.slot());
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
package com.intellij.debugger.jdi;
|
||||
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.jetbrains.jdi.JNITypeParser;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -28,11 +28,7 @@ public interface ClassesByNameProvider {
|
||||
|
||||
@Override
|
||||
public List<ReferenceType> get(@NotNull String s) {
|
||||
String signature = VirtualMachineProxyImpl.JNITypeParserReflect.typeNameToSignature(s);
|
||||
if (signature != null) {
|
||||
return (List<ReferenceType>)myCache.get(signature);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return (List<ReferenceType>)myCache.get(JNITypeParser.typeNameToSignature(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package com.intellij.debugger.jdi;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.jetbrains.jdi.SlotLocalVariable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -10,7 +11,7 @@ import java.util.Collection;
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
*/
|
||||
public class DecompiledLocalVariable{
|
||||
public class DecompiledLocalVariable implements SlotLocalVariable {
|
||||
public static final String PARAM_PREFIX = "param_";
|
||||
public static final String SLOT_PREFIX = "slot_";
|
||||
private final int mySlot;
|
||||
@@ -25,12 +26,14 @@ public class DecompiledLocalVariable{
|
||||
myMatchedNames = names;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
@Override
|
||||
public int slot() {
|
||||
return mySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getSignature() {
|
||||
public String signature() {
|
||||
return mySignature;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.jetbrains.jdi.SlotLocalVariable;
|
||||
import com.jetbrains.jdi.StackFrameImpl;
|
||||
import com.sun.jdi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -179,23 +181,29 @@ public class LocalVariablesUtil {
|
||||
private static Map<DecompiledLocalVariable, Value> fetchSlotValues(Map<DecompiledLocalVariable, Value> map,
|
||||
List<? extends DecompiledLocalVariable> vars,
|
||||
StackFrame frame) throws Exception {
|
||||
final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, "id");
|
||||
final VirtualMachine vm = frame.virtualMachine();
|
||||
final Method stateMethod = vm.getClass().getDeclaredMethod("state");
|
||||
stateMethod.setAccessible(true);
|
||||
|
||||
Object slotInfoArray = createSlotInfoArray(vars);
|
||||
|
||||
Object ps;
|
||||
final Object vmState = stateMethod.invoke(vm);
|
||||
synchronized(vmState) {
|
||||
ps = ourEnqueueMethod.invoke(null, vm, frame.thread(), frameId, slotInfoArray);
|
||||
final Value[] values;
|
||||
if (frame instanceof StackFrameImpl) {
|
||||
values = ((StackFrameImpl)frame).getSlotsValues(vars);
|
||||
}
|
||||
else {
|
||||
final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, "id");
|
||||
final VirtualMachine vm = frame.virtualMachine();
|
||||
final Method stateMethod = vm.getClass().getDeclaredMethod("state");
|
||||
stateMethod.setAccessible(true);
|
||||
|
||||
final Object reply = ourWaitForReplyMethod.invoke(null, vm, ps);
|
||||
final Value[] values = ReflectionUtil.getField(reply.getClass(), reply, Value[].class, "values");
|
||||
if (vars.size() != values.length) {
|
||||
throw new InternalException("Wrong number of values returned from target VM");
|
||||
Object slotInfoArray = createSlotInfoArray(vars);
|
||||
|
||||
Object ps;
|
||||
final Object vmState = stateMethod.invoke(vm);
|
||||
synchronized (vmState) {
|
||||
ps = ourEnqueueMethod.invoke(null, vm, frame.thread(), frameId, slotInfoArray);
|
||||
}
|
||||
|
||||
final Object reply = ourWaitForReplyMethod.invoke(null, vm, ps);
|
||||
values = ReflectionUtil.getField(reply.getClass(), reply, Value[].class, "values");
|
||||
if (vars.size() != values.length) {
|
||||
throw new InternalException("Wrong number of values returned from target VM");
|
||||
}
|
||||
}
|
||||
int idx = 0;
|
||||
for (DecompiledLocalVariable var : vars) {
|
||||
@@ -208,22 +216,27 @@ public class LocalVariablesUtil {
|
||||
return ourInitializationOkSet;
|
||||
}
|
||||
|
||||
public static void setValue(StackFrame frame, int slot, Value value) throws EvaluateException {
|
||||
public static void setValue(StackFrame frame, SlotLocalVariable variable, Value value) throws EvaluateException {
|
||||
try {
|
||||
final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, "id");
|
||||
final VirtualMachine vm = frame.virtualMachine();
|
||||
final Method stateMethod = vm.getClass().getDeclaredMethod("state");
|
||||
stateMethod.setAccessible(true);
|
||||
|
||||
Object slotInfoArray = createSlotInfoArraySet(slot, value);
|
||||
|
||||
Object ps;
|
||||
final Object vmState = stateMethod.invoke(vm);
|
||||
synchronized (vmState) {
|
||||
ps = ourEnqueueMethodSet.invoke(null, vm, frame.thread(), frameId, slotInfoArray);
|
||||
if (frame instanceof StackFrameImpl) {
|
||||
((StackFrameImpl)frame).setSlotValue(variable, value);
|
||||
}
|
||||
else {
|
||||
final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, "id");
|
||||
final VirtualMachine vm = frame.virtualMachine();
|
||||
final Method stateMethod = vm.getClass().getDeclaredMethod("state");
|
||||
stateMethod.setAccessible(true);
|
||||
|
||||
ourWaitForReplyMethodSet.invoke(null, vm, ps);
|
||||
Object slotInfoArray = createSlotInfoArraySet(variable.slot(), value);
|
||||
|
||||
Object ps;
|
||||
final Object vmState = stateMethod.invoke(vm);
|
||||
synchronized (vmState) {
|
||||
ps = ourEnqueueMethodSet.invoke(null, vm, frame.thread(), frameId, slotInfoArray);
|
||||
}
|
||||
|
||||
ourWaitForReplyMethodSet.invoke(null, vm, ps);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new EvaluateException("Unable to set value", e);
|
||||
@@ -242,7 +255,7 @@ public class LocalVariablesUtil {
|
||||
|
||||
int idx = 0;
|
||||
for (DecompiledLocalVariable var : vars) {
|
||||
final Object info = slotInfoConstructor.newInstance(var.getSlot(), (byte)var.getSignature().charAt(0));
|
||||
final Object info = slotInfoConstructor.newInstance(var.slot(), (byte)var.signature().charAt(0));
|
||||
Array.set(arrayInstance, idx++, info);
|
||||
}
|
||||
|
||||
@@ -288,7 +301,7 @@ public class LocalVariablesUtil {
|
||||
if (slot >= firstLocalVariableSlot) {
|
||||
DecompiledLocalVariable variable = usedVars.get(slot);
|
||||
String typeSignature = MethodBytecodeUtil.getVarInstructionType(opcode).getDescriptor();
|
||||
if (variable == null || !typeSignature.equals(variable.getSignature())) {
|
||||
if (variable == null || !typeSignature.equals(variable.signature())) {
|
||||
variable = new DecompiledLocalVariable(slot, false, typeSignature, namesMap.get(slot));
|
||||
usedVars.put(slot, variable);
|
||||
}
|
||||
@@ -300,7 +313,7 @@ public class LocalVariablesUtil {
|
||||
}
|
||||
|
||||
List<DecompiledLocalVariable> vars = new ArrayList<>(usedVars.values());
|
||||
vars.sort(Comparator.comparingInt(DecompiledLocalVariable::getSlot));
|
||||
vars.sort(Comparator.comparingInt(DecompiledLocalVariable::slot));
|
||||
return vars;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,36 +95,6 @@ public class VirtualMachineProxyImpl implements JdiTimer, VirtualMachineProxy {
|
||||
return myVirtualMachine;
|
||||
}
|
||||
|
||||
static final class JNITypeParserReflect {
|
||||
static final Method typeNameToSignatureMethod;
|
||||
|
||||
static {
|
||||
Method method = null;
|
||||
try {
|
||||
method = ReflectionUtil.getDeclaredMethod(Class.forName("com.sun.tools.jdi.JNITypeParser"), "typeNameToSignature", String.class);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
LOG.warn(e);
|
||||
}
|
||||
typeNameToSignatureMethod = method;
|
||||
if (typeNameToSignatureMethod == null) {
|
||||
LOG.warn("Unable to find JNITypeParser.typeNameToSignature method");
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static String typeNameToSignature(@NotNull String name) {
|
||||
if (typeNameToSignatureMethod != null) {
|
||||
try {
|
||||
return (String)typeNameToSignatureMethod.invoke(null, name);
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ClassesByNameProvider getClassesByNameProvider() {
|
||||
return this::classesByName;
|
||||
}
|
||||
|
||||
+11
-5
@@ -10,6 +10,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.jdi.ReferenceTypeImpl;
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.event.LocatableEvent;
|
||||
import one.util.streamex.StreamEx;
|
||||
@@ -90,7 +91,7 @@ public class InstrumentationTracker {
|
||||
}
|
||||
|
||||
private void noticeRedefineClass(ReferenceType type) {
|
||||
if (!ourNoticeRedefineClassMethod.getDeclaringClass().isAssignableFrom(type.getClass())) {
|
||||
if (!(type instanceof ReferenceTypeImpl) && !ourNoticeRedefineClassMethod.getDeclaringClass().isAssignableFrom(type.getClass())) {
|
||||
return;
|
||||
}
|
||||
List<Requestor> requestors = StreamEx.of(type.virtualMachine().eventRequestManager().breakpointRequests())
|
||||
@@ -99,11 +100,16 @@ public class InstrumentationTracker {
|
||||
.toList();
|
||||
requestors.forEach(myDebugProcess.getRequestsManager()::deleteRequest);
|
||||
|
||||
try {
|
||||
ourNoticeRedefineClassMethod.invoke(type);
|
||||
if (type instanceof ReferenceTypeImpl) {
|
||||
((ReferenceTypeImpl)type).noticeRedefineClass();
|
||||
}
|
||||
catch (IllegalAccessException | InvocationTargetException e) {
|
||||
LOG.error(e);
|
||||
else {
|
||||
try {
|
||||
ourNoticeRedefineClassMethod.invoke(type);
|
||||
}
|
||||
catch (IllegalAccessException | InvocationTargetException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
StreamEx.of(requestors).select(Breakpoint.class).forEach(b -> b.createRequest(myDebugProcess));
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public class ArgumentValueDescriptorImpl extends ValueDescriptorImpl{
|
||||
public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException,
|
||||
InvalidTypeException,
|
||||
EvaluateException {
|
||||
LocalVariablesUtil.setValue(debuggerContext.getFrameProxy().getStackFrame(), local.getSlot(), newValue);
|
||||
LocalVariablesUtil.setValue(debuggerContext.getFrameProxy().getStackFrame(), local, newValue);
|
||||
update(debuggerContext);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user