diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ICSourceNotFoundDescription.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ICSourceNotFoundDescription.java index 090e4fb8512..aa44c6907fc 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ICSourceNotFoundDescription.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/ICSourceNotFoundDescription.java @@ -28,4 +28,14 @@ public interface ICSourceNotFoundDescription { */ String getDescription(); + /** + * Return true if the debug element only is an address, false if not. This + * is used by the editor to know wich type of message he should use. + * + * @return a boolean that is true if the debug element only is an address + */ + default boolean isAddressOnly() { + return false; + } + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java index 59349d19989..e6daf48c58f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java @@ -176,11 +176,18 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { if (context == null) return super.getText(); String contextDescription; + boolean isAddressOnly; ICSourceNotFoundDescription description = context.getAdapter(ICSourceNotFoundDescription.class); - if (description != null) + if (description != null) { contextDescription = description.getDescription(); - else + isAddressOnly = description.isAddressOnly(); + } else { contextDescription = context.toString(); + isAddressOnly = false; + } + if (isAddressOnly) { + return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_8, contextDescription); + } return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_3, contextDescription); } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties index 0cf258584e5..0d2889b9a04 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties @@ -54,6 +54,7 @@ CSourceNotFoundEditor_4=View Disassembly... CSourceNotFoundEditor_5=Edit Source Lookup Path... CSourceNotFoundEditor_6=Configure when this editor is shown CSourceNotFoundEditor_7=Preferences... +CSourceNotFoundEditor_8=Break at address \"{0}\" with no debug information available, or outside of program code. CompilationDirectorySourceContainerDialog_0=Directory Selection CompilationDirectorySourceContainerDialog_1=Choose directory to add: CompilationDirectorySourceContainerDialog_2=Compilation directory diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/CSourceNotFoundDescriptionFactory.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/CSourceNotFoundDescriptionFactory.java index 54eaf4c62d0..a58896ccb3c 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/CSourceNotFoundDescriptionFactory.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/CSourceNotFoundDescriptionFactory.java @@ -44,39 +44,32 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory { public T getAdapter(Object adaptableObject, Class adapterType) { if (adapterType.equals(ICSourceNotFoundDescription.class) && adaptableObject instanceof IFrameDMContext) { final IFrameDMContext frameDMC = (IFrameDMContext) adaptableObject; - return (T) new ICSourceNotFoundDescription() { - + Query query = new Query() { @Override - public String getDescription() { - Query query = new Query() { - @Override - protected void execute(DataRequestMonitor rm) { - DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), - frameDMC.getSessionId()); + protected void execute(DataRequestMonitor rm) { + DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), + frameDMC.getSessionId()); - IStack stack = tracker.getService(IStack.class); - if (stack != null) { - stack.getFrameData(frameDMC, rm); - } else { - rm.setData(null); - rm.done(); - } - tracker.dispose(); - } - }; - DsfSession session = DsfSession.getSession(frameDMC.getSessionId()); - if (session != null && session.getExecutor() != null) { - session.getExecutor().execute(query); - try { - IFrameDMData dmData = query.get(); - return getFrameDescription(dmData); - } catch (Exception e) { - return frameDMC.toString(); - } + IStack stack = tracker.getService(IStack.class); + if (stack != null) { + stack.getFrameData(frameDMC, rm); + } else { + rm.setData(null); + rm.done(); } - return frameDMC.toString(); + tracker.dispose(); } }; + DsfSession session = DsfSession.getSession(frameDMC.getSessionId()); + if (session != null && session.getExecutor() != null) { + session.getExecutor().execute(query); + try { + IFrameDMData dmData = query.get(); + return (T) getFrameDescription(dmData); + } catch (Exception e) { + // fall through, not able to adapt + } + } } return null; } @@ -93,7 +86,7 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory { * @param frame * @return the frame description */ - private static String getFrameDescription(IStack.IFrameDMData frame) { + private static ICSourceNotFoundDescription getFrameDescription(IStack.IFrameDMData frame) { String formatString = ""; //$NON-NLS-1$ String[] propertyNames = null; HashMap properties = new HashMap(); @@ -103,6 +96,9 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory { String file = (String) properties.get(ILaunchVMConstants.PROP_FRAME_FILE); String function = (String) properties.get(ILaunchVMConstants.PROP_FRAME_FUNCTION); String module = (String) properties.get(ILaunchVMConstants.PROP_FRAME_MODULE); + + boolean isAddress = false; + if (line != null && line >= 0 && file != null && !file.isEmpty()) { if (function != null && function.contains(")")) //$NON-NLS-1$ formatString = MessagesForLaunchVM.StackFramesVMNode_No_columns__text_format; @@ -133,6 +129,7 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory { } else { formatString = MessagesForLaunchVM.StackFramesVMNode_No_columns__Address_only__text_format; propertyNames = new String[] { ILaunchVMConstants.PROP_FRAME_ADDRESS }; + isAddress = true; } Object[] propertyValues = new Object[propertyNames.length]; @@ -140,7 +137,24 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory { propertyValues[i] = properties.get(propertyNames[i]); } - return new MessageFormat(formatString).format(propertyValues, new StringBuffer(), null).toString(); + String description = new MessageFormat(formatString).format(propertyValues, new StringBuffer(), null) + .toString(); + // makes the variable effectively final + boolean isAddressReturn = isAddress; + + return new ICSourceNotFoundDescription() { + + @Override + public String getDescription() { + return description; + } + + @Override + public boolean isAddressOnly() { + return isAddressReturn; + } + + }; } private static void fillFrameDataProperties(java.util.Map properties, IFrameDMData data) {