use of com.intellij.debugger.impl.DebuggerContextImpl in project smali by JesusFreke.
the class LazyValue method getNullableValue.
@Nullable
protected T getNullableValue(boolean allowNull) {
if (value == null) {
try {
if (evaluationContext == null) {
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
evaluationContext = debuggerContext.createEvaluationContext();
if (evaluationContext == null) {
if (!allowNull) {
throw new IllegalStateException("Can't create evaluation context");
}
return null;
}
}
value = SmaliCodeFragmentFactory.evaluateRegister(evaluationContext, method, registerNumber, type);
evaluationContext = null;
} catch (EvaluateException ex) {
if (!allowNull) {
throw new IllegalStateException(ex);
}
return null;
}
}
return (T) value;
}
use of com.intellij.debugger.impl.DebuggerContextImpl in project android by JetBrains.
the class InstantRunManager method refreshDebugger.
private void refreshDebugger(@NotNull String packageName) {
// First we reapply the breakpoints on the new code, otherwise the breakpoints
// remain set on the old classes and will never be hit again.
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
if (!debugger.getSessions().isEmpty()) {
List<Breakpoint> breakpoints = debugger.getBreakpointManager().getBreakpoints();
for (Breakpoint breakpoint : breakpoints) {
if (breakpoint.isEnabled()) {
breakpoint.setEnabled(false);
breakpoint.setEnabled(true);
}
}
}
}
});
// Now we refresh the call-stacks and the variable panes.
DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
for (final DebuggerSession session : debugger.getSessions()) {
Client client = session.getProcess().getProcessHandler().getUserData(AndroidSessionInfo.ANDROID_DEBUG_CLIENT);
if (client != null && client.isValid() && StringUtil.equals(packageName, client.getClientData().getClientDescription())) {
session.getProcess().getManagerThread().invoke(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
DebuggerContextImpl context = session.getContextManager().getContext();
SuspendContextImpl suspendContext = context.getSuspendContext();
if (suspendContext != null) {
XExecutionStack stack = suspendContext.getActiveExecutionStack();
if (stack != null) {
((JavaExecutionStack) stack).initTopFrame();
}
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
session.refresh(false);
XDebugSession xSession = session.getXDebugSession();
if (xSession != null) {
xSession.resume();
}
}
});
}
});
}
}
}
use of com.intellij.debugger.impl.DebuggerContextImpl in project intellij-community by JetBrains.
the class EditSourceAction method update.
public void update(AnActionEvent e) {
final Project project = e.getProject();
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
final DebuggerTreeNodeImpl node = getSelectedNode(e.getDataContext());
final Presentation presentation = e.getPresentation();
if (debuggerContext.getDebugProcess() != null) {
presentation.setEnabled(true);
debuggerContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
public void threadAction() {
final SourcePosition position = getSourcePosition(node, debuggerContext);
if (position == null) {
DebuggerInvocationUtil.swingInvokeLater(project, () -> presentation.setEnabled(false));
}
}
});
} else {
presentation.setEnabled(false);
}
e.getPresentation().setText(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getTemplatePresentation().getText());
}
use of com.intellij.debugger.impl.DebuggerContextImpl in project intellij-community by JetBrains.
the class EditSourceAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
final DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
if (selectedNode != null) {
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process != null) {
process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
public void threadAction() {
final SourcePosition sourcePosition = getSourcePosition(selectedNode, debuggerContext);
if (sourcePosition != null) {
sourcePosition.navigate(true);
}
}
});
}
}
}
use of com.intellij.debugger.impl.DebuggerContextImpl in project intellij-community by JetBrains.
the class InterruptThreadAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final DebuggerTreeNodeImpl[] nodes = getSelectedNodes(e.getDataContext());
if (nodes == null) {
return;
}
//noinspection ConstantConditions
final List<ThreadReferenceProxyImpl> threadsToInterrupt = new ArrayList<>();
for (final DebuggerTreeNodeImpl debuggerTreeNode : nodes) {
final NodeDescriptorImpl descriptor = debuggerTreeNode.getDescriptor();
if (descriptor instanceof ThreadDescriptorImpl) {
threadsToInterrupt.add(((ThreadDescriptorImpl) descriptor).getThreadReference());
}
}
if (!threadsToInterrupt.isEmpty()) {
final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess != null) {
debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
protected void action() throws Exception {
boolean unsupported = false;
for (ThreadReferenceProxyImpl thread : threadsToInterrupt) {
try {
thread.getThreadReference().interrupt();
} catch (UnsupportedOperationException ignored) {
unsupported = true;
}
}
if (unsupported) {
final Project project = debugProcess.getProject();
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification("Thread operation 'interrupt' is not supported by VM", MessageType.INFO).notify(project);
}
}
});
}
}
}
Aggregations