use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.
the class ThreadDumpAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
final DebuggerSession session = context.getDebuggerSession();
if (session != null && session.isAttached()) {
final DebugProcessImpl process = context.getDebugProcess();
process.getManagerThread().invoke(new DebuggerCommandImpl() {
protected void action() throws Exception {
final VirtualMachineProxyImpl vm = process.getVirtualMachineProxy();
vm.suspend();
try {
final List<ThreadState> threads = buildThreadStates(vm);
ApplicationManager.getApplication().invokeLater(() -> {
XDebugSession xSession = session.getXDebugSession();
if (xSession != null) {
DebuggerUtilsEx.addThreadDump(project, threads, xSession.getUI(), session);
}
}, ModalityState.NON_MODAL);
} finally {
vm.resume();
}
}
});
}
}
use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.
the class ValueHint method evaluateAndShowHint.
@Override
protected void evaluateAndShowHint() {
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
final DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
if (debuggerSession == null || !debuggerSession.isPaused())
return;
try {
final ExpressionEvaluator evaluator = getExpressionEvaluator(debuggerContext);
if (evaluator == null)
return;
debuggerContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {
@Override
public Priority getPriority() {
return Priority.HIGH;
}
@Override
public void threadAction() {
try {
final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
return myCurrentExpression.getText();
}
});
final TextWithImports text = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expressionText);
final Value value = myValueToShow != null ? myValueToShow : evaluator.evaluate(evaluationContext);
final WatchItemDescriptor descriptor = new WatchItemDescriptor(getProject(), text, value);
if (!isActiveTooltipApplicable(value) || getType() == ValueHintType.MOUSE_OVER_HINT) {
if (getType() == ValueHintType.MOUSE_OVER_HINT) {
// force using default renderer for mouse over hint in order to not to call accidentally methods while rendering
// otherwise, if the hint is invoked explicitly, show it with the right "auto" renderer
descriptor.setRenderer(DebugProcessImpl.getDefaultRenderer(value));
}
descriptor.updateRepresentation(evaluationContext, new DescriptorLabelListener() {
@Override
public void labelChanged() {
if (getCurrentRange() != null) {
if (getType() != ValueHintType.MOUSE_OVER_HINT || descriptor.isValueValid()) {
final SimpleColoredText simpleColoredText = DebuggerTreeRenderer.getDescriptorText(debuggerContext, descriptor, true);
if (isActiveTooltipApplicable(value)) {
simpleColoredText.append(" (" + DebuggerBundle.message("active.tooltip.suggestion") + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
showHint(simpleColoredText, descriptor);
}
}
}
});
} else {
createAndShowTree(expressionText, descriptor);
}
} catch (EvaluateException e) {
LOG.debug(e);
}
}
});
} catch (EvaluateException e) {
LOG.debug(e);
}
}
use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.
the class ThreadsDebuggerTree method build.
protected void build(DebuggerContextImpl context) {
DebuggerSession session = context.getDebuggerSession();
final RefreshThreadsTreeCommand command = new RefreshThreadsTreeCommand(session);
final DebuggerSession.State state = session != null ? session.getState() : DebuggerSession.State.DISPOSED;
if (ApplicationManager.getApplication().isUnitTestMode() || state == DebuggerSession.State.PAUSED || state == DebuggerSession.State.RUNNING) {
showMessage(MessageDescriptor.EVALUATING);
context.getDebugProcess().getManagerThread().schedule(command);
} else {
showMessage(session != null ? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
}
}
use of com.intellij.debugger.impl.DebuggerSession in project intellij-community by JetBrains.
the class JavaAwareTestConsoleProperties method getDebugSession.
@Nullable
public DebuggerSession getDebugSession() {
final DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(getProject());
if (debuggerManager == null)
return null;
final Collection<DebuggerSession> sessions = debuggerManager.getSessions();
for (final DebuggerSession debuggerSession : sessions) {
if (getConsole() == debuggerSession.getProcess().getExecutionResult().getExecutionConsole())
return debuggerSession;
}
return null;
}
use of com.intellij.debugger.impl.DebuggerSession in project intellij by bazelbuild.
the class BlazeNativeAndroidDebugger method attachToClient.
@Override
public void attachToClient(Project project, Client client) {
final String clientDescr = client.getClientData().getClientDescription();
Module module = null;
final List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
for (AndroidFacet facet : facets) {
try {
final String packageName = ApkProviderUtil.computePackageName(facet);
if (clientDescr.startsWith(packageName)) {
module = facet.getModule();
break;
}
} catch (ApkProvisionException ignored) {
// ignored
}
}
if (module == null) {
throw new RuntimeException("Cannot find module by package name");
}
if (hasExistingSession(project, client)) {
return;
}
// Detach any existing JDWP debug session - reusing an existing session is troublesome
// because we need to setup a custom XDebugProcess.
DebuggerSession debuggerSession = findJdwpDebuggerSession(project, getClientDebugPort(client));
if (debuggerSession != null) {
debuggerSession.getProcess().stop(false);
}
// Create run configuration
// TODO: Important modification here. Make sure to keep this in refactor.
// We need a custom BlazeAndroidNativeAttachConfiguration to skip a bunch of launch checks so
// validate passes.
ConfigurationFactory factory = BlazeAndroidNativeAttachConfigurationFactory.getInstance();
String runConfigurationName = String.format("Android Native Debugger (%d)", client.getClientData().getPid());
RunnerAndConfigurationSettings runSettings = RunManager.getInstance(project).createRunConfiguration(runConfigurationName, factory);
AndroidNativeAttachConfiguration configuration = (AndroidNativeAttachConfiguration) runSettings.getConfiguration();
configuration.setClient(client);
configuration.getAndroidDebuggerContext().setDebuggerType(getId());
configuration.getConfigurationModule().setModule(module);
// TODO: Important modification here. Make sure to keep this in refactor.
// We need to set the correct working dir to find sources while debugging.
// See BlazeAndroidRunConfigurationDebuggerManager#getAndroidDebuggerState
AndroidDebuggerState state = configuration.getAndroidDebuggerContext().getAndroidDebuggerState();
if (state instanceof NativeAndroidDebuggerState) {
NativeAndroidDebuggerState nativeState = (NativeAndroidDebuggerState) state;
nativeState.setWorkingDir(WorkspaceRoot.fromProject(project).directory().getPath());
}
ProgramRunnerUtil.executeConfiguration(project, runSettings, DefaultDebugExecutor.getDebugExecutorInstance());
}
Aggregations