Skip to content

Commit

Permalink
LLDB: Print an error when lldb is below minimum version
Browse files Browse the repository at this point in the history
Prevent users from using a version of lldb that is too old.
Before version 3.8 there was a hang and other issues. If the
version cannot be determined, the launch stil proceeds. This
is because there is no good way to get the version from the
lldb-mi executable but rather, we can only do a best-effort
to get the version from the normal lldb executable. If the
lldb executable is not present but the lldb-mi is, this is a
valid way to use the debugger but the version cannot be determined.

In the future, it would be better if the lldb-mi executable could
report the lldb version directly. But this would be an improvement
in lldb, not CDT.

Change-Id: Ief8a4ebd3ea1e3d549a5cef41ac3030ec48734c4
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
  • Loading branch information
MarkZ3 committed Aug 28, 2016
1 parent 7ad8cbe commit e5d8f67
Show file tree
Hide file tree
Showing 6 changed files with 376 additions and 1 deletion.
Expand Up @@ -8,6 +8,7 @@

package org.eclipse.cdt.llvm.dsf.lldb.core;

import org.eclipse.cdt.llvm.dsf.lldb.core.internal.ILLDBConstants;
import org.eclipse.cdt.llvm.dsf.lldb.core.internal.LLDBCorePlugin;

/**
Expand All @@ -27,5 +28,5 @@ public class ILLDBLaunchConfigurationConstants {
/**
* Launch configuration attribute value. The key is ATTR_DEBUG_NAME.
*/
public static final String DEBUGGER_DEBUG_NAME_DEFAULT = "lldb-mi"; //$NON-NLS-1$
public static final String DEBUGGER_DEBUG_NAME_DEFAULT = ILLDBConstants.LLDB_MI_EXECUTABLE_NAME;
}
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2016 Ericsson.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/

package org.eclipse.cdt.llvm.dsf.lldb.core.internal;

/**
* Constants related to the LLDB debugger itself.
*
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ILLDBConstants {

/**
* The executable name for lldb-mi
*/
public static final String LLDB_MI_EXECUTABLE_NAME = "lldb-mi"; //$NON-NLS-1$

/**
* The executable name for lldb
*/
public static final String LLDB_EXECUTABLE_NAME = "lldb"; //$NON-NLS-1$
}
Expand Up @@ -13,7 +13,11 @@
*******************************************************************************/
package org.eclipse.cdt.llvm.dsf.lldb.core.internal;

import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;

/**
Expand Down Expand Up @@ -47,4 +51,80 @@ public void stop(BundleContext context) throws Exception {
public static LLDBCorePlugin getDefault() {
return plugin;
}

/**
* Creates an IStatus for this plug-in using a message.
*
* @param msg
* the message
* @return an IStatus
* @noreference This method is not intended to be referenced by clients.
*/
public static IStatus createStatus(String msg) {
return createStatus(msg, null);
}

/**
* Creates an IStatus for this plug-in using a message and exception.
*
* @param msg
* the message
* @param e
* the exception
* @return an IStatus
* @noreference This method is not intended to be referenced by clients.
*/
public static IStatus createStatus(String msg, Throwable e) {
return new Status(IStatus.ERROR, PLUGIN_ID, msg, e);
}

/**
* Logs an IStatus
*
* @param status the IStatus
*
* @noreference This method is not intended to be referenced by clients.
*/
public static void log(IStatus status) {
getDefault().getLog().log(status);
}

/**
* Logs a messages with exception.
*
* @param message
* the message
* @param e
* the exception
*
* @noreference This method is not intended to be referenced by clients.
*/
public static void log(String message, Throwable e) {
Throwable nestedException;
if (e instanceof CModelException && (nestedException = ((CModelException) e).getException()) != null) {
e = nestedException;
}
log(createStatus(message, e));
}

/**
* Logs an exception.
*
* @param e
* the exception
*
* @noreference This method is not intended to be referenced by clients.
*/
public static void log(Throwable e) {
if (e instanceof CoreException) {
log(((CoreException) e).getStatus());
} else {
String msg = e.getMessage();
if (msg == null) {
log("Error", e); //$NON-NLS-1$
} else {
log("Error: " + msg, e); //$NON-NLS-1$
}
}
}
}

0 comments on commit e5d8f67

Please sign in to comment.