Search in sources :

Example 16 with DebugProcess

use of com.intellij.debugger.engine.DebugProcess in project intellij-community by JetBrains.

the class GroovyPositionManager method createPrepareRequest.

@Override
public ClassPrepareRequest createPrepareRequest(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) throws NoDataException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("createPrepareRequest: " + position);
    }
    checkGroovyFile(position);
    String qName = getOuterClassName(position);
    if (qName != null) {
        return myDebugProcess.getRequestsManager().createClassPrepareRequest(requestor, qName);
    }
    qName = findEnclosingName(position);
    if (qName == null)
        throw NoDataException.INSTANCE;
    ClassPrepareRequestor waitRequestor = new ClassPrepareRequestor() {

        @Override
        public void processClassPrepare(DebugProcess debuggerProcess, ReferenceType referenceType) {
            final CompoundPositionManager positionManager = ((DebugProcessImpl) debuggerProcess).getPositionManager();
            if (!positionManager.locationsOfLine(referenceType, position).isEmpty()) {
                requestor.processClassPrepare(debuggerProcess, referenceType);
            }
        }
    };
    return myDebugProcess.getRequestsManager().createClassPrepareRequest(waitRequestor, qName + "$*");
}
Also used : ClassPrepareRequestor(com.intellij.debugger.requests.ClassPrepareRequestor) DebugProcess(com.intellij.debugger.engine.DebugProcess) CompoundPositionManager(com.intellij.debugger.engine.CompoundPositionManager) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ReferenceType(com.sun.jdi.ReferenceType)

Example 17 with DebugProcess

use of com.intellij.debugger.engine.DebugProcess in project android by JetBrains.

the class DynamicResourceIdResolver method getAndroidResourceName.

@Nullable
@Override
public String getAndroidResourceName(int resId) {
    String id = myDelegate.getAndroidResourceName(resId);
    if (id != null) {
        return id;
    }
    DebugProcess debugProcess = myContext.getDebugProcess();
    VirtualMachineProxyImpl vmProxy = (VirtualMachineProxyImpl) debugProcess.getVirtualMachineProxy();
    List<ReferenceType> classes = vmProxy.classesByName(CLASS_RESOURCES);
    if (classes.isEmpty()) {
        LOG.warn(CLASS_RESOURCES + " class not loaded?");
        return null;
    }
    if (classes.size() != 1) {
        LOG.warn("Expected a single Resource class loaded, but found " + classes.size());
    }
    ReferenceType resourcesClassType = classes.get(0);
    Method getResourceNameMethod = DebuggerUtils.findMethod(resourcesClassType, "getResourceName", "(I)Ljava/lang/String;");
    if (getResourceNameMethod == null) {
        LOG.warn("Unable to locate getResourceName(int id) in class " + resourcesClassType.name());
        return null;
    }
    List<ObjectReference> instances = resourcesClassType.instances(10);
    if (instances.isEmpty()) {
        LOG.warn("No instances of Resource class found");
        return null;
    }
    List args = Collections.singletonList(DebuggerUtilsEx.createValue(vmProxy, "int", resId));
    for (ObjectReference ref : instances) {
        try {
            Value value = debugProcess.invokeMethod(myContext, ref, getResourceNameMethod, args);
            if (value instanceof StringReference) {
                StringReference nameRef = (StringReference) value;
                return nameRef.value();
            }
        } catch (EvaluateException e) {
            ObjectReference exception = e.getExceptionFromTargetVM();
            // do not log Resources$NotFoundException
            if (exception == null || !DebuggerUtils.instanceOf(exception.type(), "android.content.res.Resources$NotFoundException")) {
                LOG.warn("Unexpected error while invoking Resources.getResourceName()", e);
            // continue and try this on other object references
            }
        }
    }
    return null;
}
Also used : DebugProcess(com.intellij.debugger.engine.DebugProcess) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) List(java.util.List) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with DebugProcess

use of com.intellij.debugger.engine.DebugProcess in project android by JetBrains.

the class AndroidRemoteDebugProcessHandler method detachProcessImpl.

@Override
protected void detachProcessImpl() {
    DebugProcess debugProcess = DebuggerManager.getInstance(myProject).getDebugProcess(this);
    if (debugProcess != null) {
        debugProcess.stop(false);
    }
    notifyProcessDetached();
}
Also used : DebugProcess(com.intellij.debugger.engine.DebugProcess)

Aggregations

DebugProcess (com.intellij.debugger.engine.DebugProcess)18 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)4 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)3 DebugProcessListener (com.intellij.debugger.engine.DebugProcessListener)3 DebugEnvironment (com.intellij.debugger.DebugEnvironment)2 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 EvaluationContext (com.intellij.debugger.engine.evaluation.EvaluationContext)2 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)2 ClassPrepareRequestor (com.intellij.debugger.requests.ClassPrepareRequestor)2 ExecutionException (com.intellij.execution.ExecutionException)2 RemoteConnection (com.intellij.execution.configurations.RemoteConnection)2 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)2 ReferenceType (com.sun.jdi.ReferenceType)2 Nullable (org.jetbrains.annotations.Nullable)2 DebugUIEnvironment (com.intellij.debugger.DebugUIEnvironment)1 DefaultDebugEnvironment (com.intellij.debugger.DefaultDebugEnvironment)1 SourcePosition (com.intellij.debugger.SourcePosition)1 CompoundPositionManager (com.intellij.debugger.engine.CompoundPositionManager)1 RemoteDebugProcessHandler (com.intellij.debugger.engine.RemoteDebugProcessHandler)1 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)1