Search in sources :

Example 1 with AndroidDebugger

use of com.android.tools.idea.run.editor.AndroidDebugger in project android by JetBrains.

the class AndroidProcessChooserDialog method setupDebuggerSelection.

private void setupDebuggerSelection(boolean showDebuggerSelection, @Nullable String lastSelectedDebuggerId) {
    if (!showDebuggerSelection) {
        myDebuggerLabel.setVisible(false);
        myDebuggerTypeCombo.setVisible(false);
        return;
    }
    AndroidDebugger selectedDebugger = null;
    AndroidDebugger defaultDebugger = null;
    List<AndroidDebugger> androidDebuggers = Lists.newLinkedList();
    for (AndroidDebugger androidDebugger : AndroidDebugger.EP_NAME.getExtensions()) {
        if (androidDebugger.supportsProject(myProject)) {
            androidDebuggers.add(androidDebugger);
            if (selectedDebugger == null && lastSelectedDebuggerId != null && androidDebugger.getId().equals(lastSelectedDebuggerId)) {
                selectedDebugger = androidDebugger;
            } else if (androidDebugger.shouldBeDefault()) {
                defaultDebugger = androidDebugger;
            }
        }
    }
    if (selectedDebugger == null) {
        selectedDebugger = defaultDebugger;
    }
    androidDebuggers.sort((left, right) -> left.getId().compareTo(right.getId()));
    myDebuggerTypeCombo.setModel(new CollectionComboBoxModel(androidDebuggers));
    myDebuggerTypeCombo.setRenderer(new AndroidDebugger.Renderer());
    if (selectedDebugger != null) {
        myDebuggerTypeCombo.setSelectedItem(selectedDebugger);
    }
}
Also used : AndroidDebugger(com.android.tools.idea.run.editor.AndroidDebugger)

Example 2 with AndroidDebugger

use of com.android.tools.idea.run.editor.AndroidDebugger in project intellij by bazelbuild.

the class BlazeAndroidLaunchTasksProvider method getConnectDebuggerTask.

@Nullable
@Override
public DebugConnectorTask getConnectDebuggerTask(@NotNull LaunchStatus launchStatus, @Nullable AndroidVersion version) {
    if (!isDebug) {
        return null;
    }
    Set<String> packageIds = Sets.newHashSet();
    try {
        String packageName = applicationIdProvider.getPackageName();
        packageIds.add(packageName);
    } catch (ApkProvisionException e) {
        Logger.getInstance(AndroidLaunchTasksProvider.class).error(e);
    }
    try {
        String packageName = applicationIdProvider.getTestPackageName();
        if (packageName != null) {
            packageIds.add(packageName);
        }
    } catch (ApkProvisionException e) {
        // not as severe as failing to obtain package id for main application
        Logger.getInstance(AndroidLaunchTasksProvider.class).warn("Unable to obtain test package name, will not connect debugger " + "if tests don't instantiate main application");
    }
    AndroidDebugger androidDebugger = debuggerManager.getAndroidDebugger();
    AndroidDebuggerState androidDebuggerState = debuggerManager.getAndroidDebuggerState(project);
    if (androidDebugger == null || androidDebuggerState == null) {
        return null;
    }
    try {
        return runContext.getDebuggerTask(androidDebugger, androidDebuggerState, packageIds, monitorRemoteProcess());
    } catch (ExecutionException e) {
        launchStatus.terminateLaunch(e.getMessage());
        return null;
    }
}
Also used : AndroidDebugger(com.android.tools.idea.run.editor.AndroidDebugger) ApkProvisionException(com.android.tools.idea.run.ApkProvisionException) AndroidDebuggerState(com.android.tools.idea.run.editor.AndroidDebuggerState) ExecutionException(com.intellij.execution.ExecutionException) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with AndroidDebugger

use of com.android.tools.idea.run.editor.AndroidDebugger in project android by JetBrains.

the class ConnectDebuggerTask method logUnsupportedBreakpoints.

private void logUnsupportedBreakpoints(@NotNull AndroidVersion version, @NotNull final ConsolePrinter printer) {
    final Set<XBreakpointType<?, ?>> allBpTypes = Sets.newHashSet();
    for (AndroidDebugger androidDebugger : AndroidDebugger.EP_NAME.getExtensions()) {
        allBpTypes.addAll(androidDebugger.getSupportedBreakpointTypes(myProject, version));
    }
    allBpTypes.removeAll(myDebugger.getSupportedBreakpointTypes(myProject, version));
    if (allBpTypes.isEmpty()) {
        return;
    }
    ApplicationManager.getApplication().runReadAction(new Runnable() {

        @Override
        public void run() {
            XBreakpointManager bpManager = XDebuggerManager.getInstance(myProject).getBreakpointManager();
            // Try to find breakpoints which are using unsupported breakpoint types.
            for (XBreakpointType<?, ?> bpType : allBpTypes) {
                Collection bps = bpManager.getBreakpoints(bpType);
                if (!bps.isEmpty()) {
                    String warnMsg = String.format("The currently selected %1$s debugger doesn't support breakpoints of type '%2$s'. As a result, these breakpoints will " + "not be hit.\nThe debugger selection can be modified in the run configuration dialog.", myDebugger.getDisplayName(), bpType.getTitle());
                    printer.stderr(warnMsg);
                    Logger.getInstance(ConnectDebuggerTask.class).info(warnMsg);
                    return;
                }
            }
        }
    });
}
Also used : AndroidDebugger(com.android.tools.idea.run.editor.AndroidDebugger) XBreakpointManager(com.intellij.xdebugger.breakpoints.XBreakpointManager) XBreakpointType(com.intellij.xdebugger.breakpoints.XBreakpointType)

Example 4 with AndroidDebugger

use of com.android.tools.idea.run.editor.AndroidDebugger in project android by JetBrains.

the class AndroidLaunchTasksProvider method getConnectDebuggerTask.

@Nullable
@Override
public DebugConnectorTask getConnectDebuggerTask(@NotNull LaunchStatus launchStatus, @Nullable AndroidVersion version) {
    if (!myLaunchOptions.isDebug()) {
        return null;
    }
    Logger logger = Logger.getInstance(AndroidLaunchTasksProvider.class);
    Set<String> packageIds = Sets.newHashSet();
    try {
        String packageName = myApplicationIdProvider.getPackageName();
        packageIds.add(packageName);
    } catch (ApkProvisionException e) {
        logger.error(e);
    }
    try {
        String packageName = myApplicationIdProvider.getTestPackageName();
        if (packageName != null) {
            packageIds.add(packageName);
        }
    } catch (ApkProvisionException e) {
        // not as severe as failing to obtain package id for main application
        logger.warn("Unable to obtain test package name, will not connect debugger if tests don't instantiate main application");
    }
    AndroidDebuggerContext androidDebuggerContext = myRunConfig.getAndroidDebuggerContext();
    AndroidDebugger debugger = androidDebuggerContext.getAndroidDebugger();
    if (debugger == null) {
        logger.warn("Unable to determine debugger to use for this launch");
        return null;
    }
    logger.info("Using debugger: " + debugger.getId());
    AndroidDebuggerState androidDebuggerState = androidDebuggerContext.getAndroidDebuggerState();
    if (androidDebuggerState != null) {
        //noinspection unchecked
        return debugger.getConnectDebuggerTask(myEnv, version, packageIds, myFacet, androidDebuggerState, myRunConfig.getType().getId(), monitorRemoteProcess());
    }
    return null;
}
Also used : AndroidDebugger(com.android.tools.idea.run.editor.AndroidDebugger) AndroidDebuggerState(com.android.tools.idea.run.editor.AndroidDebuggerState) AndroidDebuggerContext(com.android.tools.idea.run.editor.AndroidDebuggerContext) Logger(com.intellij.openapi.diagnostic.Logger) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AndroidDebugger (com.android.tools.idea.run.editor.AndroidDebugger)4 AndroidDebuggerState (com.android.tools.idea.run.editor.AndroidDebuggerState)2 Nullable (org.jetbrains.annotations.Nullable)2 ApkProvisionException (com.android.tools.idea.run.ApkProvisionException)1 AndroidDebuggerContext (com.android.tools.idea.run.editor.AndroidDebuggerContext)1 ExecutionException (com.intellij.execution.ExecutionException)1 Logger (com.intellij.openapi.diagnostic.Logger)1 XBreakpointManager (com.intellij.xdebugger.breakpoints.XBreakpointManager)1 XBreakpointType (com.intellij.xdebugger.breakpoints.XBreakpointType)1