diff options
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse')
146 files changed, 8563 insertions, 8606 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java index 86b27ad36dd..1aa91a4f768 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Navid Mehregani (TI) - Bug 289526 - Migrate the Restart feature to the new one, as supported by the platform @@ -43,140 +43,135 @@ import org.eclipse.debug.ui.contexts.ISuspendTrigger; * for the launch object. But it also manages the creation and destruction * of the session-based adapters which are returned by the * IDMContext.getAdapter() methods. - * + * * When extending the GdbAdapterFactory, it is important to register all the * types declaratively (in the plugin.xml) that the factory can adapt the * extended launch to. - * + * * See the plugin.xml that references GdbAdapterFactory for the current list, * and it should match {@link #getAdapterList()}. */ @ThreadSafe public class GdbAdapterFactory implements IAdapterFactory, ILaunchesListener2 { - /** - * Active adapter sets. They are accessed using the launch instance - * which owns the debug services session. - */ - private static Map<GdbLaunch, GdbSessionAdapters> fgLaunchAdapterSets = - Collections.synchronizedMap(new HashMap<>()); - - /** - * Map of launches for which adapter sets have already been disposed. - * This map (used as a set) is maintained in order to avoid re-creating an - * adapter set after the launch was removed from the launch manager, but - * while the launch is still being held by other classes which may - * request its adapters. A weak map is used to avoid leaking - * memory once the launches are no longer referenced. - * <p> - * Access to this map is synchronized using the fgLaunchAdapterSets - * instance. - * </p> - */ - private static Map<ILaunch, GdbSessionAdapters> fgDisposedLaunchAdapterSets = new WeakHashMap<>(); - - static void disposeAdapterSet(ILaunch launch) { - synchronized(fgLaunchAdapterSets) { - if (fgLaunchAdapterSets.containsKey(launch)) { - fgLaunchAdapterSets.remove(launch).dispose(); - fgDisposedLaunchAdapterSets.put(launch, null); - } - } - } - - public GdbAdapterFactory() { - DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); - } - - /** - * This method only actually returns adapters for the launch object. - */ - @Override + /** + * Active adapter sets. They are accessed using the launch instance + * which owns the debug services session. + */ + private static Map<GdbLaunch, GdbSessionAdapters> fgLaunchAdapterSets = Collections + .synchronizedMap(new HashMap<>()); + + /** + * Map of launches for which adapter sets have already been disposed. + * This map (used as a set) is maintained in order to avoid re-creating an + * adapter set after the launch was removed from the launch manager, but + * while the launch is still being held by other classes which may + * request its adapters. A weak map is used to avoid leaking + * memory once the launches are no longer referenced. + * <p> + * Access to this map is synchronized using the fgLaunchAdapterSets + * instance. + * </p> + */ + private static Map<ILaunch, GdbSessionAdapters> fgDisposedLaunchAdapterSets = new WeakHashMap<>(); + + static void disposeAdapterSet(ILaunch launch) { + synchronized (fgLaunchAdapterSets) { + if (fgLaunchAdapterSets.containsKey(launch)) { + fgLaunchAdapterSets.remove(launch).dispose(); + fgDisposedLaunchAdapterSets.put(launch, null); + } + } + } + + public GdbAdapterFactory() { + DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); + } + + /** + * This method only actually returns adapters for the launch object. + */ + @Override public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { - if (!(adaptableObject instanceof GdbLaunch)) return null; - - GdbLaunch launch = (GdbLaunch)adaptableObject; - - // Check for valid session. - // Note: even if the session is no longer active, the adapter set - // should still be returned. This is because the view model may still - // need to show elements representing a terminated process/thread/etc. - DsfSession session = launch.getSession(); - if (session == null) return null; - - // Find the correct set of adapters based on the launch session-ID. If not found - // it means that we have a new launch and new session, and we have to create a - // new set of adapters. - - GdbSessionAdapters adapterSet; - synchronized(fgLaunchAdapterSets) { - // The adapter set for the given launch was already disposed. - // Return a null adapter. - if (fgDisposedLaunchAdapterSets.containsKey(launch)) { - return null; - } - adapterSet = fgLaunchAdapterSets.get(launch); - if (adapterSet == null) { - // If the first time we attempt to create an adapterSet is once the session is - // already inactive, we should not create it and return null. - // This can happen, for example, when we run JUnit tests and we don't actually - // have a need for any adapters until the launch is actually being removed. - // Note that we must do this here because fgDisposedLaunchAdapterSets - // may not already know that the launch has been removed because of a race - // condition with the caller which is also processing a launchRemoved method. - // Bug 334687 - if (session.isActive() == false) { - return null; - } - adapterSet = createGdbSessionAdapters(launch, session); - fgLaunchAdapterSets.put(launch, adapterSet); - } - } - - // Returns the adapter type for the launch object. - return adapterSet.getLaunchAdapter(adapterType); - } - - /** - * This list must match the list in the plugin.xml. See class comment. - */ - @Override - public Class<?>[] getAdapterList() { - return new Class<?>[] { - IElementContentProvider.class, - IModelProxyFactory.class, - ISuspendTrigger.class, - IColumnPresentationFactory.class, - ITerminateHandler.class, - IConnectHandler.class, - IDisconnectHandler.class, - IDebugNewExecutableHandler.class, - }; - } - - @Override - public void launchesRemoved(ILaunch[] launches) { - // Dispose the set of adapters for a launch only after the launch is - // removed. - for (ILaunch launch : launches) { - if (launch instanceof GdbLaunch) { - disposeAdapterSet(launch); - } - } - } - - @Override - public void launchesTerminated(ILaunch[] launches) { - } - - @Override - public void launchesAdded(ILaunch[] launches) { - } - - @Override - public void launchesChanged(ILaunch[] launches) { - } - - protected GdbSessionAdapters createGdbSessionAdapters(ILaunch launch, DsfSession session) { - return new GdbSessionAdapters(launch, session, getAdapterList()); - } + if (!(adaptableObject instanceof GdbLaunch)) + return null; + + GdbLaunch launch = (GdbLaunch) adaptableObject; + + // Check for valid session. + // Note: even if the session is no longer active, the adapter set + // should still be returned. This is because the view model may still + // need to show elements representing a terminated process/thread/etc. + DsfSession session = launch.getSession(); + if (session == null) + return null; + + // Find the correct set of adapters based on the launch session-ID. If not found + // it means that we have a new launch and new session, and we have to create a + // new set of adapters. + + GdbSessionAdapters adapterSet; + synchronized (fgLaunchAdapterSets) { + // The adapter set for the given launch was already disposed. + // Return a null adapter. + if (fgDisposedLaunchAdapterSets.containsKey(launch)) { + return null; + } + adapterSet = fgLaunchAdapterSets.get(launch); + if (adapterSet == null) { + // If the first time we attempt to create an adapterSet is once the session is + // already inactive, we should not create it and return null. + // This can happen, for example, when we run JUnit tests and we don't actually + // have a need for any adapters until the launch is actually being removed. + // Note that we must do this here because fgDisposedLaunchAdapterSets + // may not already know that the launch has been removed because of a race + // condition with the caller which is also processing a launchRemoved method. + // Bug 334687 + if (session.isActive() == false) { + return null; + } + adapterSet = createGdbSessionAdapters(launch, session); + fgLaunchAdapterSets.put(launch, adapterSet); + } + } + + // Returns the adapter type for the launch object. + return adapterSet.getLaunchAdapter(adapterType); + } + + /** + * This list must match the list in the plugin.xml. See class comment. + */ + @Override + public Class<?>[] getAdapterList() { + return new Class<?>[] { IElementContentProvider.class, IModelProxyFactory.class, ISuspendTrigger.class, + IColumnPresentationFactory.class, ITerminateHandler.class, IConnectHandler.class, + IDisconnectHandler.class, IDebugNewExecutableHandler.class, }; + } + + @Override + public void launchesRemoved(ILaunch[] launches) { + // Dispose the set of adapters for a launch only after the launch is + // removed. + for (ILaunch launch : launches) { + if (launch instanceof GdbLaunch) { + disposeAdapterSet(launch); + } + } + } + + @Override + public void launchesTerminated(ILaunch[] launches) { + } + + @Override + public void launchesAdded(ILaunch[] launches) { + } + + @Override + public void launchesChanged(ILaunch[] launches) { + } + + protected GdbSessionAdapters createGdbSessionAdapters(ILaunch launch, DsfSession session) { + return new GdbSessionAdapters(launch, session, getAdapterList()); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java index 923603dcc56..2ed7803e2b4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Ericsson - Updated hover to use the new Details format @@ -23,30 +23,29 @@ import org.eclipse.core.runtime.Platform; /** * Debug editor text hover for GDB. - * + * * @since 2.1 */ public class GdbDebugTextHover extends AbstractDsfDebugTextHover { - @Override - protected String getModelId() { - return GdbLaunchDelegate.GDB_DEBUG_MODEL_ID; - } + @Override + protected String getModelId() { + return GdbLaunchDelegate.GDB_DEBUG_MODEL_ID; + } - @Override + @Override protected String getHoverFormat() { - return MIExpressions.DETAILS_FORMAT; - } + return MIExpressions.DETAILS_FORMAT; + } - @Override - protected boolean useExpressionExplorer() { - // The preference is part of the GdbPlugin preference store - // Bug 414622 - if (Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID, - IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, - true, null)) { - return true; - } - return false; - } + @Override + protected boolean useExpressionExplorer() { + // The preference is part of the GdbPlugin preference store + // Bug 414622 + if (Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID, + IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, true, null)) { + return true; + } + return false; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinColorTracker.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinColorTracker.java index b497df1e3f1..42d021179b9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinColorTracker.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinColorTracker.java @@ -26,27 +26,30 @@ class GdbPinColorTracker { private class Pair { Integer refCount; String context; + Pair(String context, Integer refCount) { this.context = context; this.refCount = refCount; } } - - private static List<Pair> gsColorBuckets = Collections.synchronizedList( new ArrayList<Pair>() ); - + + private static List<Pair> gsColorBuckets = Collections.synchronizedList(new ArrayList<Pair>()); + /** * The static instance. */ static GdbPinColorTracker INSTANCE = new GdbPinColorTracker(); - + /** * Singleton object - make constructor private. */ - private GdbPinColorTracker() {} - + private GdbPinColorTracker() { + } + int addRef(String context) { - if (context == null) return IPinElementColorDescriptor.UNDEFINED; - + if (context == null) + return IPinElementColorDescriptor.UNDEFINED; + // look in the buckets and see if it is already exist for (int i = 0; i < gsColorBuckets.size(); ++i) { Pair pair = gsColorBuckets.get(i); @@ -55,10 +58,10 @@ class GdbPinColorTracker { return i % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT; } } - + // if not exist in the buckets, then add to the bucket collection int size = gsColorBuckets.size(); - int index = size; + int index = size; for (int i = 0; i < size; ++i) { Pair pair = gsColorBuckets.get(i); if (pair.refCount <= 0) { @@ -70,15 +73,16 @@ class GdbPinColorTracker { gsColorBuckets.add(index, new Pair(context, 1)); return (index) % IPinElementColorDescriptor.DEFAULT_COLOR_COUNT; } - + void removeRef(String context) { - if (context == null) return; - + if (context == null) + return; + for (int i = 0; i < gsColorBuckets.size(); ++i) { Pair pair = gsColorBuckets.get(i); if (pair.context.equals(context)) { pair.refCount--; - + return; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java index 0da015fb802..286c2cd92ef 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java @@ -60,54 +60,56 @@ import org.eclipse.ui.IWorkbenchPart; public class GdbPinProvider implements IPinProvider { private static class GdbPinElementColorDescriptor implements IPinElementColorDescriptor { int fColor = GREEN; - + GdbPinElementColorDescriptor(int color) { fColor = color; } - @Override + + @Override public int getOverlayColor() { return fColor; } - @Override + + @Override public ImageDescriptor getToolbarIconDescriptor() { return null; } } - + /** * A set of pinned element handles and their callback. */ - private static Map<IPinElementHandle, IPinModelListener> gsPinnedHandles = - Collections.synchronizedMap(new HashMap<IPinElementHandle, IPinModelListener>()); - + private static Map<IPinElementHandle, IPinModelListener> gsPinnedHandles = Collections + .synchronizedMap(new HashMap<IPinElementHandle, IPinModelListener>()); + /** * Dsf session. */ private final DsfSession fSession; - + /** * Constructor. - * + * * @param session */ public GdbPinProvider(DsfSession session) { fSession = session; - - session.getExecutor().execute(new Runnable() { - @Override + + session.getExecutor().execute(new Runnable() { + @Override public void run() { fSession.addServiceEventListener(GdbPinProvider.this, null); } - }); + }); } - + /** * Dispose all resources. */ public void dispose() { try { - fSession.getExecutor().execute(new Runnable() { - @Override + fSession.getExecutor().execute(new Runnable() { + @Override public void run() { fSession.removeServiceEventListener(GdbPinProvider.this); } @@ -116,31 +118,31 @@ public class GdbPinProvider implements IPinProvider { // Session already gone. } } - + /** * Returns the pinned element handles. - * + * * @return the element handles. */ public static Set<IPinElementHandle> getPinnedHandles() { return gsPinnedHandles.keySet(); } - - private static IMIExecutionDMContext getExecutionDmc(IDMContext dmc) { - return DMContexts.getAncestorOfType(dmc, IMIExecutionDMContext.class); + + private static IMIExecutionDMContext getExecutionDmc(IDMContext dmc) { + return DMContexts.getAncestorOfType(dmc, IMIExecutionDMContext.class); } - + private static IProcessDMContext getProcessDmc(IDMContext dmc) { return DMContexts.getAncestorOfType(dmc, IProcessDMContext.class); } - + private IThreadDMData getData(final IThreadDMContext threadDmc) { - if (threadDmc == null || !fSession.isActive()) - return null; - + if (threadDmc == null || !fSession.isActive()) + return null; + IThreadDMData data = null; final DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); - try { + try { Query<IThreadDMData> query = new Query<IThreadDMData>() { @Override protected void execute(final DataRequestMonitor<IThreadDMData> rm) { @@ -153,10 +155,10 @@ public class GdbPinProvider implements IPinProvider { } } }; - - ImmediateInDsfExecutor immediateExecutor = new ImmediateInDsfExecutor(fSession.getExecutor()); + + ImmediateInDsfExecutor immediateExecutor = new ImmediateInDsfExecutor(fSession.getExecutor()); immediateExecutor.execute(query); - data = query.get(2, TimeUnit.SECONDS); // timeout in 2 seconds, in case the call to execute got stuck + data = query.get(2, TimeUnit.SECONDS); // timeout in 2 seconds, in case the call to execute got stuck } catch (Exception e) { GdbUIPlugin.log(e); } finally { @@ -165,7 +167,7 @@ public class GdbPinProvider implements IPinProvider { } return data; } - + private String getLabel(IThreadDMData data) { String label = ""; //$NON-NLS-1$ if (data != null) { @@ -178,72 +180,72 @@ public class GdbPinProvider implements IPinProvider { } return label; } - + private String getCombinedLabels(IThreadDMContext processDmc, IMIExecutionDMContext execDmc) { // get the process label IThreadDMData processData = getData(processDmc); String label = getLabel(processData); - + // get the execution (thread) context label if (execDmc != null) { String threadId = execDmc.getThreadId(); - label += !label.isEmpty() ? ": " : ""; //$NON-NLS-1$//$NON-NLS-2$ - label += "Thread [" + threadId + "]"; //$NON-NLS-1$//$NON-NLS-2$ + label += !label.isEmpty() ? ": " : ""; //$NON-NLS-1$//$NON-NLS-2$ + label += "Thread [" + threadId + "]"; //$NON-NLS-1$//$NON-NLS-2$ } return label; } - + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider#isPinnable(org.eclipse.ui.IWorkbenchPart, java.lang.Object) */ - @Override + @Override public boolean isPinnable(IWorkbenchPart part, Object debugContext) { if (debugContext instanceof IAdaptable) { return ((IAdaptable) debugContext).getAdapter(IDMContext.class) != null; } return false; } - + /* * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider#pin(org.eclipse.ui.IWorkbenchPart, java.lang.Object, org.eclipse.cdt.debug.ui.IPinModelListener) */ - @Override + @Override public IPinElementHandle pin(IWorkbenchPart part, Object debugContext, IPinModelListener listener) { Object pinContext = debugContext; String label = ""; //$NON-NLS-1$ String sessionId = ""; //$NON-NLS-1$ - + IDMContext dmc = null; if (debugContext instanceof IAdaptable) { dmc = ((IAdaptable) debugContext).getAdapter(IDMContext.class); - + if (dmc != null) { sessionId = dmc.getSessionId() + "."; //$NON-NLS-1$ IMIExecutionDMContext execDmc = getExecutionDmc(dmc); IProcessDMContext processDmc = getProcessDmc(dmc); - + label = getCombinedLabels(processDmc, execDmc); - + // set the pin context to a thread if it exist if (execDmc != null) { dmc = execDmc; pinContext = execDmc; - - // otherwise, set it to the DM context + + // otherwise, set it to the DM context } else { pinContext = dmc; } } } - IPinElementColorDescriptor colorDesc = - new GdbPinElementColorDescriptor(GdbPinColorTracker.INSTANCE.addRef(sessionId + label)); + IPinElementColorDescriptor colorDesc = new GdbPinElementColorDescriptor( + GdbPinColorTracker.INSTANCE.addRef(sessionId + label)); PinElementHandle handle = new PinElementHandle(pinContext, label, colorDesc); gsPinnedHandles.put(handle, listener); dispatchChangedEvent(dmc); - + return handle; } @@ -251,18 +253,18 @@ public class GdbPinProvider implements IPinProvider { * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider#unpin(org.eclipse.ui.IWorkbenchPart, org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle) */ - @Override + @Override public void unpin(IWorkbenchPart part, IPinElementHandle handle) { // remove the handle from the cache - gsPinnedHandles.remove(handle); - + gsPinnedHandles.remove(handle); + // dispatch the event to update the handle DM context Object debugContext = handle.getDebugContext(); if (debugContext instanceof IAdaptable) { IDMContext dmc = ((IAdaptable) debugContext).getAdapter(IDMContext.class); GdbPinColorTracker.INSTANCE.removeRef(dmc.getSessionId() + "." + handle.getLabel()); //$NON-NLS-1$ dispatchChangedEvent(dmc); - + } } @@ -270,37 +272,37 @@ public class GdbPinProvider implements IPinProvider { * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider#isPinnedTo(java.lang.Object, org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle) */ - @Override + @Override public boolean isPinnedTo(Object debugContext, IPinElementHandle handle) { Object handleDebugContext = handle.getDebugContext(); - - if (debugContext instanceof IAdaptable && handleDebugContext instanceof IAdaptable) { + + if (debugContext instanceof IAdaptable && handleDebugContext instanceof IAdaptable) { IDMContext dmc = ((IAdaptable) debugContext).getAdapter(IDMContext.class); IDMContext hDmc = ((IAdaptable) handleDebugContext).getAdapter(IDMContext.class); - + if (dmc != null && hDmc != null) { - if (dmc.getSessionId().equals(hDmc.getSessionId())) { + if (dmc.getSessionId().equals(hDmc.getSessionId())) { IMIExecutionDMContext execDmc = getExecutionDmc(dmc); IProcessDMContext processDmc = getProcessDmc(dmc); - + String label = getCombinedLabels(processDmc, execDmc); - return label.equals(handle.getLabel()); + return label.equals(handle.getLabel()); } } } return false; } - + /** * Dispatch the change event for the given DM context. - * + * * @param dmc the DM context */ private void dispatchChangedEvent(IDMContext dmc) { if (dmc == null) return; - - try { + + try { DsfSession session = DsfSession.getSession(dmc.getSessionId()); if (session != null && session.isActive()) session.dispatchEvent(new StateChangedEvent(dmc), null); @@ -308,34 +310,37 @@ public class GdbPinProvider implements IPinProvider { // Session already gone. } } - + /** * Handle start event and re-attach the DM context to the pinned handles. The DM context * is used for dispatching event to update the element label. */ @DsfServiceEventHandler - public void handleEvent(final IStartedDMEvent event) { - final IDMContext eventDmc = event.getDMContext(); - final IMIExecutionDMContext eventExecDmc = getExecutionDmc(eventDmc); - final IProcessDMContext eventProcessDmc = getProcessDmc(eventDmc); - - if (eventProcessDmc != null) { + public void handleEvent(final IStartedDMEvent event) { + final IDMContext eventDmc = event.getDMContext(); + final IMIExecutionDMContext eventExecDmc = getExecutionDmc(eventDmc); + final IProcessDMContext eventProcessDmc = getProcessDmc(eventDmc); + + if (eventProcessDmc != null) { for (final IPinElementHandle h : getPinnedHandles()) { new Job("Updating pin handler debug context") { //$NON-NLS-1$ - {setPriority(INTERACTIVE);} + { + setPriority(INTERACTIVE); + } + @Override - protected IStatus run(IProgressMonitor monitor) { + protected IStatus run(IProgressMonitor monitor) { // only attach to the same pin handle if the session is not active - PinElementHandle handle = ((PinElementHandle)h); + PinElementHandle handle = ((PinElementHandle) h); Object handleDebugContext = handle.getDebugContext(); - if (handleDebugContext instanceof IAdaptable) { + if (handleDebugContext instanceof IAdaptable) { IDMContext handleDmc = ((IAdaptable) handleDebugContext).getAdapter(IDMContext.class); if (handleDmc != null) { DsfSession session = DsfSession.getSession(handleDmc.getSessionId()); - if (session == null || !session.isActive()) { + if (session == null || !session.isActive()) { String handleLabel = handle.getLabel(); String label = getCombinedLabels(eventProcessDmc, eventExecDmc); - + if (label.equals(handleLabel)) { IDMContext newDmc = eventExecDmc != null ? eventExecDmc : eventDmc; handle.setDebugContext(newDmc); @@ -350,7 +355,7 @@ public class GdbPinProvider implements IPinProvider { } } } - + @DsfServiceEventHandler public void handleEvent(final ICommandControlShutdownDMEvent event) { handleInvalidModelContext(event); @@ -360,29 +365,31 @@ public class GdbPinProvider implements IPinProvider { public void handleEvent(final IExitedDMEvent event) { handleInvalidModelContext(event); } - + @DsfServiceEventHandler public void handleEvent(final IResumedDMEvent event) { handleInvalidModelContext(event); } - + private void handleInvalidModelContext(IDMEvent<?> event) { Set<Entry<IPinElementHandle, IPinModelListener>> entries = gsPinnedHandles.entrySet(); - for (final Entry<IPinElementHandle, IPinModelListener> e : entries) { + for (final Entry<IPinElementHandle, IPinModelListener> e : entries) { final IPinModelListener listener = e.getValue(); if (listener != null) { IPinElementHandle handle = e.getKey(); - + Object handleObject = handle.getDebugContext(); if (handleObject instanceof IDMContext) { - IDMContext handleDmc = (IDMContext)handleObject; + IDMContext handleDmc = (IDMContext) handleObject; IDMContext eventDmc = event.getDMContext(); - + // First check if we have a thread. We must use IMIExecutionDMContext and not // IExecutionDMContext because IExecutionDMContext also represents a process - IMIExecutionDMContext execEventDmc = DMContexts.getAncestorOfType(eventDmc, IMIExecutionDMContext.class); - IMIExecutionDMContext execHandleDmc = DMContexts.getAncestorOfType(handleDmc, IMIExecutionDMContext.class); - + IMIExecutionDMContext execEventDmc = DMContexts.getAncestorOfType(eventDmc, + IMIExecutionDMContext.class); + IMIExecutionDMContext execHandleDmc = DMContexts.getAncestorOfType(handleDmc, + IMIExecutionDMContext.class); + // Make sure both dmcs are not null to know if we should compare thread dmcs or container dmcs if (execEventDmc != null && execHandleDmc != null) { // It is a thread event, but is it the same as the pin handle? @@ -391,19 +398,21 @@ public class GdbPinProvider implements IPinProvider { } continue; } - + // If we weren't dealing with a thread for either the event or the handle, // let's check for IMIContainerDMContext - IMIContainerDMContext procEventDmc = DMContexts.getAncestorOfType(eventDmc, IMIContainerDMContext.class); - IMIContainerDMContext procHandleDmc = DMContexts.getAncestorOfType(handleDmc, IMIContainerDMContext.class); + IMIContainerDMContext procEventDmc = DMContexts.getAncestorOfType(eventDmc, + IMIContainerDMContext.class); + IMIContainerDMContext procHandleDmc = DMContexts.getAncestorOfType(handleDmc, + IMIContainerDMContext.class); if (procEventDmc != null && procHandleDmc != null) { if (procEventDmc.equals(procHandleDmc)) { fireModleChangeEvent(listener, null); } continue; } - - // If we got a shutdown event + + // If we got a shutdown event if (eventDmc instanceof ICommandControlDMContext) { fireModleChangeEvent(listener, null); continue; @@ -412,15 +421,18 @@ public class GdbPinProvider implements IPinProvider { } } } - + private void fireModleChangeEvent(final IPinModelListener listener, final ISelection selection) { new Job("Model Changed") { //$NON-NLS-1$ - { setSystem(true); } + { + setSystem(true); + } + @Override protected IStatus run(IProgressMonitor arg0) { listener.modelChanged(selection); return Status.OK_STATUS; - } + } }.schedule(); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSessionAdapters.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSessionAdapters.java index e8aa96b06d8..236478ae874 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSessionAdapters.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSessionAdapters.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Marc Khouzam (Ericsson) - initial API and implementation * Mikhail Khodjaiants (Mentor Graphics) - initial API and implementation @@ -103,254 +103,225 @@ import org.eclipse.debug.ui.sourcelookup.ISourceDisplay; */ @Immutable public class GdbSessionAdapters { - private final ILaunch fLaunch; - private final DsfSession fSession; + private final ILaunch fLaunch; + private final DsfSession fSession; + + private final Map<Class<?>, Object> fLaunchAdapters = new HashMap<>(); + private final Class<?>[] fLaunchAdapterTypes; - private final Map<Class<?>, Object> fLaunchAdapters = new HashMap<>(); - private final Class<?>[] fLaunchAdapterTypes; - - public GdbSessionAdapters(ILaunch launch, DsfSession session, Class<?>[] launchAdapterTypes) { + public GdbSessionAdapters(ILaunch launch, DsfSession session, Class<?>[] launchAdapterTypes) { fLaunch = launch; fSession = session; fLaunchAdapterTypes = launchAdapterTypes; createAdapters(); - } + } - /** - * Creates all model and launch adapters. - */ - protected void createAdapters() { - for (Class<?> adapterType : getModelAdapters()) { - Object adapter = createModelAdapter(adapterType, getLaunch(), getSession()); - if (adapter != null) { - getSession().registerModelAdapter(adapterType, adapter); - } - } - for (Class<?> adapterType : fLaunchAdapterTypes) { - Object adapter = createLaunchAdapter(adapterType, getLaunch(), getSession()); - if (adapter != null) { - fLaunchAdapters.put(adapterType, adapter); - } - } - } + /** + * Creates all model and launch adapters. + */ + protected void createAdapters() { + for (Class<?> adapterType : getModelAdapters()) { + Object adapter = createModelAdapter(adapterType, getLaunch(), getSession()); + if (adapter != null) { + getSession().registerModelAdapter(adapterType, adapter); + } + } + for (Class<?> adapterType : fLaunchAdapterTypes) { + Object adapter = createLaunchAdapter(adapterType, getLaunch(), getSession()); + if (adapter != null) { + fLaunchAdapters.put(adapterType, adapter); + } + } + } - /** - * Returns the adapter object registered with the session for the given adapter type - * or null if no adapter is registered. - */ - @SuppressWarnings("unchecked") + /** + * Returns the adapter object registered with the session for the given adapter type + * or null if no adapter is registered. + */ + @SuppressWarnings("unchecked") public <T> T getModelAdapter(Class<T> adapterType) { - return (T)fSession.getModelAdapter(adapterType); - } + return (T) fSession.getModelAdapter(adapterType); + } - /** - * Returns the adapter object registered with {@link ILaunch} for the given adapter type - * or null if no adapter is registered. - */ - @SuppressWarnings("unchecked") + /** + * Returns the adapter object registered with {@link ILaunch} for the given adapter type + * or null if no adapter is registered. + */ + @SuppressWarnings("unchecked") public <T> T getLaunchAdapter(Class<T> adapterType) { - if (adapterType.equals(ITerminateHandler.class) || - adapterType.equals(IConnectHandler.class) || - adapterType.equals(IDisconnectHandler.class) || - adapterType.equals(IDebugNewExecutableHandler.class)) { - // These launch adapters re-use the session adapters. - // Return them directly instead of including them - // in fLaunchAdapters to avoid trying to dispose of them - // twice when dispose() is called. - return (T)fSession.getModelAdapter(adapterType); - } + if (adapterType.equals(ITerminateHandler.class) || adapterType.equals(IConnectHandler.class) + || adapterType.equals(IDisconnectHandler.class) + || adapterType.equals(IDebugNewExecutableHandler.class)) { + // These launch adapters re-use the session adapters. + // Return them directly instead of including them + // in fLaunchAdapters to avoid trying to dispose of them + // twice when dispose() is called. + return (T) fSession.getModelAdapter(adapterType); + } - return (T)fLaunchAdapters.get(adapterType); - } + return (T) fLaunchAdapters.get(adapterType); + } - public void dispose() { - for (Class<?> adapterType : getModelAdapters()) { - Object adapter = getSession().getModelAdapter(adapterType); - if (adapter != null) { - getSession().unregisterModelAdapter(adapterType); - disposeAdapter(adapter); - } - } - for (Class<?> adapterType : fLaunchAdapterTypes) { - Object adapter = fLaunchAdapters.remove(adapterType); - if (adapter != null) { - disposeAdapter(adapter); - } - } - } + public void dispose() { + for (Class<?> adapterType : getModelAdapters()) { + Object adapter = getSession().getModelAdapter(adapterType); + if (adapter != null) { + getSession().unregisterModelAdapter(adapterType); + disposeAdapter(adapter); + } + } + for (Class<?> adapterType : fLaunchAdapterTypes) { + Object adapter = fLaunchAdapters.remove(adapterType); + if (adapter != null) { + disposeAdapter(adapter); + } + } + } - /** - * Returns all adapter types registered with the session. - * Clients can override this method to add a new adapter type and - * then override {@link GdbSessionAdapters.createModelAdapter()} - * to provide the adapter object. - */ - protected List<Class<?>> getModelAdapters() { - // Return a list to which elements can be added - return new ArrayList<>(Arrays.asList( - SteppingController.class, - IViewerInputProvider.class, - ISteppingModeTarget.class, - ISourceDisplay.class, - IStepIntoHandler.class, - IStepIntoSelectionHandler.class, - IReverseStepIntoHandler.class, - IStepOverHandler.class, - IReverseStepOverHandler.class, - IStepReturnHandler.class, - IUncallHandler.class, - ISuspendHandler.class, - IResumeHandler.class, - IReverseResumeHandler.class, - IResumeWithoutSignalHandler.class, - IRestartHandler.class, - ITerminateHandler.class, - IDebugNewExecutableHandler.class, - IConnectHandler.class, - IDisconnectHandler.class, - IModelSelectionPolicyFactory.class, - IRefreshAllTarget.class, - IReverseToggleHandler.class, - IStartTracingHandler.class, - IStopTracingHandler.class, - ISaveTraceDataHandler.class, - ISelectNextTraceRecordHandler.class, - ISelectPrevTraceRecordHandler.class, - IPinProvider.class, - IDebugModelProvider.class, - ILaunch.class, - ICEditorTextHover.class, - IMemoryBlockAddressInfoRetrieval.class)); - } + /** + * Returns all adapter types registered with the session. + * Clients can override this method to add a new adapter type and + * then override {@link GdbSessionAdapters.createModelAdapter()} + * to provide the adapter object. + */ + protected List<Class<?>> getModelAdapters() { + // Return a list to which elements can be added + return new ArrayList<>(Arrays.asList(SteppingController.class, IViewerInputProvider.class, + ISteppingModeTarget.class, ISourceDisplay.class, IStepIntoHandler.class, + IStepIntoSelectionHandler.class, IReverseStepIntoHandler.class, IStepOverHandler.class, + IReverseStepOverHandler.class, IStepReturnHandler.class, IUncallHandler.class, ISuspendHandler.class, + IResumeHandler.class, IReverseResumeHandler.class, IResumeWithoutSignalHandler.class, + IRestartHandler.class, ITerminateHandler.class, IDebugNewExecutableHandler.class, IConnectHandler.class, + IDisconnectHandler.class, IModelSelectionPolicyFactory.class, IRefreshAllTarget.class, + IReverseToggleHandler.class, IStartTracingHandler.class, IStopTracingHandler.class, + ISaveTraceDataHandler.class, ISelectNextTraceRecordHandler.class, ISelectPrevTraceRecordHandler.class, + IPinProvider.class, IDebugModelProvider.class, ILaunch.class, ICEditorTextHover.class, + IMemoryBlockAddressInfoRetrieval.class)); + } - /** - * Creates the adapter object for the given adapter type to register it with {@link ILaunch}. - * Clients can override this method to provide their own adapters. - */ - @SuppressWarnings("unchecked") + /** + * Creates the adapter object for the given adapter type to register it with {@link ILaunch}. + * Clients can override this method to provide their own adapters. + */ + @SuppressWarnings("unchecked") protected <T> T createLaunchAdapter(Class<T> adapterType, ILaunch launch, DsfSession session) { - if (adapterType.equals(IElementContentProvider.class) || - adapterType.equals(IModelProxyFactory.class) || - adapterType.equals(IColumnPresentationFactory.class)) { - return (T)getViewModelAdapter(); - } - - if (adapterType.equals(ISuspendTrigger.class)) { - return (T)new GdbSuspendTrigger(session, launch); - } + if (adapterType.equals(IElementContentProvider.class) || adapterType.equals(IModelProxyFactory.class) + || adapterType.equals(IColumnPresentationFactory.class)) { + return (T) getViewModelAdapter(); + } - return null; - } + if (adapterType.equals(ISuspendTrigger.class)) { + return (T) new GdbSuspendTrigger(session, launch); + } - /** - * Creates the adapter object for the given adapter type to register it with the model. - * Clients can override this method to provide their own adapters. - */ - @SuppressWarnings("unchecked") + return null; + } + + /** + * Creates the adapter object for the given adapter type to register it with the model. + * Clients can override this method to provide their own adapters. + */ + @SuppressWarnings("unchecked") protected <T> T createModelAdapter(Class<T> adapterType, ILaunch launch, DsfSession session) { if (SteppingController.class.equals(adapterType)) { - return (T)new SteppingController(session); + return (T) new SteppingController(session); } if (IViewerInputProvider.class.equals(adapterType)) { - return (T)new GdbViewModelAdapter(session, getSteppingController()); + return (T) new GdbViewModelAdapter(session, getSteppingController()); } if (ISteppingModeTarget.class.equals(adapterType)) { - return (T)new GdbSteppingModeTarget(session); + return (T) new GdbSteppingModeTarget(session); } - if (ISourceDisplay.class.equals(adapterType)) { - return launch.getSourceLocator() instanceof ISourceLookupDirector ? - (T)new DsfSourceDisplayAdapter( - session, - (ISourceLookupDirector)launch.getSourceLocator(), - getSteppingController() - ) : null; + if (ISourceDisplay.class.equals(adapterType)) { + return launch.getSourceLocator() instanceof ISourceLookupDirector + ? (T) new DsfSourceDisplayAdapter(session, (ISourceLookupDirector) launch.getSourceLocator(), + getSteppingController()) + : null; } if (IStepIntoHandler.class.equals(adapterType)) { - return (T)new DsfStepIntoCommand(session, getSteppingModeTarget()); + return (T) new DsfStepIntoCommand(session, getSteppingModeTarget()); } if (IStepIntoSelectionHandler.class.equals(adapterType)) { - return (T)new DsfStepIntoSelectionCommand(session); + return (T) new DsfStepIntoSelectionCommand(session); } if (IReverseStepIntoHandler.class.equals(adapterType)) { - return (T)new GdbReverseStepIntoCommand(session, getSteppingModeTarget()); + return (T) new GdbReverseStepIntoCommand(session, getSteppingModeTarget()); } if (IStepOverHandler.class.equals(adapterType)) { - return (T)new DsfStepOverCommand(session, getSteppingModeTarget()); + return (T) new DsfStepOverCommand(session, getSteppingModeTarget()); } if (IReverseStepOverHandler.class.equals(adapterType)) { - return (T)new GdbReverseStepOverCommand(session, getSteppingModeTarget()); + return (T) new GdbReverseStepOverCommand(session, getSteppingModeTarget()); } if (IStepReturnHandler.class.equals(adapterType)) { - return (T)new DsfStepReturnCommand(session); + return (T) new DsfStepReturnCommand(session); } if (IUncallHandler.class.equals(adapterType)) { - return (T)new GdbUncallCommand(session, getSteppingModeTarget()); + return (T) new GdbUncallCommand(session, getSteppingModeTarget()); } if (ISuspendHandler.class.equals(adapterType)) { - return (T)new DsfSuspendCommand(session); + return (T) new DsfSuspendCommand(session); } if (IResumeHandler.class.equals(adapterType)) { - return (T)new DsfResumeCommand(session); + return (T) new DsfResumeCommand(session); } if (IReverseResumeHandler.class.equals(adapterType)) { - return (T)new GdbReverseResumeCommand(session); + return (T) new GdbReverseResumeCommand(session); } if (IResumeWithoutSignalHandler.class.equals(adapterType)) { - return (T)new GdbResumeWithoutSignalCommand(session); + return (T) new GdbResumeWithoutSignalCommand(session); } if (IRestartHandler.class.equals(adapterType)) { - return (T)new GdbRestartCommand(session, getLaunch()); + return (T) new GdbRestartCommand(session, getLaunch()); } - if (ITerminateHandler.class.equals(adapterType)) { - return (T)new DsfTerminateCommand(session); + if (ITerminateHandler.class.equals(adapterType)) { + return (T) new DsfTerminateCommand(session); } if (IDebugNewExecutableHandler.class.equals(adapterType)) { - return (T)new GdbDebugNewExecutableCommand(session, launch); + return (T) new GdbDebugNewExecutableCommand(session, launch); } - if (IConnectHandler.class.equals(adapterType)) { - return (T)new GdbConnectCommand(session, launch); + if (IConnectHandler.class.equals(adapterType)) { + return (T) new GdbConnectCommand(session, launch); } - if (IDisconnectHandler.class.equals(adapterType)) { - return (T)new GdbDisconnectCommand(session); + if (IDisconnectHandler.class.equals(adapterType)) { + return (T) new GdbDisconnectCommand(session); } - if (IModelSelectionPolicyFactory.class.equals(adapterType)) { - return (T)new DefaultDsfModelSelectionPolicyFactory(); + if (IModelSelectionPolicyFactory.class.equals(adapterType)) { + return (T) new DefaultDsfModelSelectionPolicyFactory(); } - if (IRefreshAllTarget.class.equals(adapterType)) { - return (T)new DefaultRefreshAllTarget(); + if (IRefreshAllTarget.class.equals(adapterType)) { + return (T) new DefaultRefreshAllTarget(); } if (IReverseToggleHandler.class.equals(adapterType)) { - return (T)new GdbReverseToggleCommand(session); + return (T) new GdbReverseToggleCommand(session); } - if (IStartTracingHandler.class.equals(adapterType)) { - return (T)new GdbStartTracingCommand(session); + if (IStartTracingHandler.class.equals(adapterType)) { + return (T) new GdbStartTracingCommand(session); } if (IStopTracingHandler.class.equals(adapterType)) { - return (T)new GdbStopTracingCommand(session); + return (T) new GdbStopTracingCommand(session); } - if (ISaveTraceDataHandler.class.equals(adapterType)) { - return (T)new GdbSaveTraceDataCommand(session); + if (ISaveTraceDataHandler.class.equals(adapterType)) { + return (T) new GdbSaveTraceDataCommand(session); } - if (ISelectNextTraceRecordHandler.class.equals(adapterType)) { - return (T)new GdbSelectNextTraceRecordCommand(session); + if (ISelectNextTraceRecordHandler.class.equals(adapterType)) { + return (T) new GdbSelectNextTraceRecordCommand(session); } - if (ISelectPrevTraceRecordHandler.class.equals(adapterType)) { - return (T)new GdbSelectPrevTraceRecordCommand(session); + if (ISelectPrevTraceRecordHandler.class.equals(adapterType)) { + return (T) new GdbSelectPrevTraceRecordCommand(session); } - if (IPinProvider.class.equals(adapterType)) { - return (T)new GdbPinProvider(session); + if (IPinProvider.class.equals(adapterType)) { + return (T) new GdbPinProvider(session); } if (IDebugModelProvider.class.equals(adapterType)) { - return (T)new IDebugModelProvider() { - // @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers() - @Override - public String[] getModelIdentifiers() { - return new String[] { - GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, - ICBreakpoint.C_BREAKPOINTS_DEBUG_MODEL_ID, - "org.eclipse.cdt.gdb" //$NON-NLS-1$ - }; - } + return (T) new IDebugModelProvider() { + // @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers() + @Override + public String[] getModelIdentifiers() { + return new String[] { GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, + ICBreakpoint.C_BREAKPOINTS_DEBUG_MODEL_ID, "org.eclipse.cdt.gdb" //$NON-NLS-1$ + }; + } }; } @@ -360,83 +331,80 @@ public class GdbSessionAdapters { * session. */ if (ILaunch.class.equals(adapterType)) { - return (T)launch; + return (T) launch; } /* * Register debug hover adapter (bug 309001). */ if (ICEditorTextHover.class.equals(adapterType)) { - return (T)new GdbDebugTextHover(); + return (T) new GdbDebugTextHover(); } if (IMemoryBlockAddressInfoRetrieval.class.equals(adapterType)) { return (T) new GdbMemoryBlockAddressInfoRetrieval(session); } - return null; - } + return null; + } - /** - * Returns the method that will be called to dispose the given object. - * - * @param adapter the object to dispose - * @return "dispose()" method or null if the given object doesn't have "dispose()" method - * - * Clients can override this method to provide dispose methods different than "dispose()" - * for specific adapters. - */ - protected Method getDisposeMethod(Object adapter) { - if (adapter != null) { + /** + * Returns the method that will be called to dispose the given object. + * + * @param adapter the object to dispose + * @return "dispose()" method or null if the given object doesn't have "dispose()" method + * + * Clients can override this method to provide dispose methods different than "dispose()" + * for specific adapters. + */ + protected Method getDisposeMethod(Object adapter) { + if (adapter != null) { try { return adapter.getClass().getMethod("dispose"); //$NON-NLS-1$ - } - catch(NoSuchMethodException | SecurityException e) { + } catch (NoSuchMethodException | SecurityException e) { // ignore } - } + } return null; - } + } + + protected DsfSession getSession() { + return fSession; + } - protected DsfSession getSession() { - return fSession; - } - - protected ILaunch getLaunch() { - return fLaunch; - } + protected ILaunch getLaunch() { + return fLaunch; + } - private void disposeAdapter(Object adapter) { + private void disposeAdapter(Object adapter) { try { Method dispose = getDisposeMethod(adapter); if (dispose != null) { dispose.invoke(adapter); } - } - catch(SecurityException | IllegalAccessException | IllegalArgumentException e) { + } catch (SecurityException | IllegalAccessException | IllegalArgumentException e) { // ignore - } - catch(InvocationTargetException e) { + } catch (InvocationTargetException e) { GdbPlugin.log(e.getTargetException()); } - } - - protected DsfSteppingModeTarget getSteppingModeTarget() { - ISteppingModeTarget target = (ISteppingModeTarget)fSession.getModelAdapter(ISteppingModeTarget.class); - if (target instanceof DsfSteppingModeTarget) { - return (DsfSteppingModeTarget)target; - } - return null; - } + } + + protected DsfSteppingModeTarget getSteppingModeTarget() { + ISteppingModeTarget target = (ISteppingModeTarget) fSession.getModelAdapter(ISteppingModeTarget.class); + if (target instanceof DsfSteppingModeTarget) { + return (DsfSteppingModeTarget) target; + } + return null; + } protected SteppingController getSteppingController() { - return (SteppingController)fSession.getModelAdapter(SteppingController.class); + return (SteppingController) fSession.getModelAdapter(SteppingController.class); } protected IVMAdapter getViewModelAdapter() { - IViewerInputProvider provider = (IViewerInputProvider)fSession.getModelAdapter(IViewerInputProvider.class); + IViewerInputProvider provider = (IViewerInputProvider) fSession.getModelAdapter(IViewerInputProvider.class); if (provider instanceof IVMAdapter) { - return (IVMAdapter)provider; + return (IVMAdapter) provider; } return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbStatusHandler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbStatusHandler.java index 85029dc01b9..de5cd3c62a5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbStatusHandler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbStatusHandler.java @@ -27,43 +27,42 @@ public class GdbStatusHandler implements IStatusHandler { * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) */ @Override - public Object handleStatus( final IStatus status, Object source ) throws CoreException { + public Object handleStatus(final IStatus status, Object source) throws CoreException { Runnable runnable = null; - if ( status.getSeverity() == IStatus.ERROR ) { + if (status.getSeverity() == IStatus.ERROR) { runnable = new Runnable() { - + @Override public void run() { Shell parent = GdbUIPlugin.getActiveWorkbenchShell(); - if ( parent != null ) - MessageDialog.openError( parent, Messages.GdbStatusHandler_Error, status.getMessage() ); + if (parent != null) + MessageDialog.openError(parent, Messages.GdbStatusHandler_Error, status.getMessage()); } }; - } - else if ( status.getSeverity() == IStatus.WARNING ) { + } else if (status.getSeverity() == IStatus.WARNING) { runnable = new Runnable() { - + @Override public void run() { Shell parent = GdbUIPlugin.getActiveWorkbenchShell(); - if ( parent != null ) - MessageDialog.openWarning( parent, Messages.GdbStatusHandler_Warning, status.getMessage() ); + if (parent != null) + MessageDialog.openWarning(parent, Messages.GdbStatusHandler_Warning, status.getMessage()); } }; - } - else if ( status.getSeverity() == IStatus.INFO ) { + } else if (status.getSeverity() == IStatus.INFO) { runnable = new Runnable() { - + @Override public void run() { Shell parent = GdbUIPlugin.getActiveWorkbenchShell(); - if ( parent != null ) - MessageDialog.openInformation( parent, Messages.GdbStatusHandler_Information, status.getMessage() ); + if (parent != null) + MessageDialog.openInformation(parent, Messages.GdbStatusHandler_Information, + status.getMessage()); } }; } - if ( runnable != null ) - Display.getDefault().asyncExec( runnable ); + if (runnable != null) + Display.getDefault().asyncExec(runnable); return null; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendTrigger.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendTrigger.java index 072fc4c4465..20ae5786cd0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendTrigger.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendTrigger.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -33,53 +33,55 @@ import org.eclipse.debug.core.ILaunch; * @since 2.1 */ public class GdbSuspendTrigger extends DsfSuspendTrigger { - - public GdbSuspendTrigger(DsfSession session, ILaunch launch) { - super(session, launch); - } - - @Override - protected void getLaunchTopContainers(final DataRequestMonitor<IContainerDMContext[]> rm) { - try { - getSession().getExecutor().execute(new DsfRunnable() { - @Override + + public GdbSuspendTrigger(DsfSession session, ILaunch launch) { + super(session, launch); + } + + @Override + protected void getLaunchTopContainers(final DataRequestMonitor<IContainerDMContext[]> rm) { + try { + getSession().getExecutor().execute(new DsfRunnable() { + @Override public void run() { - IProcesses processService = getServicesTracker().getService(IProcesses.class); - ICommandControlService controlService = getServicesTracker().getService(ICommandControlService.class); - if (processService == null || controlService == null) { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Not available", null)); //$NON-NLS-1$ - rm.done(); - return; - } + IProcesses processService = getServicesTracker().getService(IProcesses.class); + ICommandControlService controlService = getServicesTracker() + .getService(ICommandControlService.class); + if (processService == null || controlService == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, + "Not available", null)); //$NON-NLS-1$ + rm.done(); + return; + } + + processService.getProcessesBeingDebugged(controlService.getContext(), + new ImmediateDataRequestMonitor<IDMContext[]>(rm) { + @Override + public void handleSuccess() { + IContainerDMContext[] containers = new IContainerDMContext[getData().length]; + for (int i = 0; i < containers.length; i++) { + if (getData()[i] instanceof IContainerDMContext) { + containers[i] = (IContainerDMContext) getData()[i]; + } else { + // By convention the processes should be containers, but the API + // does not enforce this. + assert false; + rm.setData(new IContainerDMContext[0]); + rm.done(); + return; + } - processService.getProcessesBeingDebugged( - controlService.getContext(), - new ImmediateDataRequestMonitor<IDMContext[]>(rm) { - @Override - public void handleSuccess() { - IContainerDMContext[] containers = new IContainerDMContext[getData().length]; - for (int i = 0; i < containers.length; i++) { - if (getData()[i] instanceof IContainerDMContext) { - containers[i] = (IContainerDMContext)getData()[i]; - } else { - // By convention the processes should be containers, but the API - // does not enforce this. - assert false; - rm.setData(new IContainerDMContext[0]); - rm.done(); - return; - } - - } - rm.setData(containers); - rm.done(); - } - }); - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Not available", e)); //$NON-NLS-1$ - rm.done(); - } - } + } + rm.setData(containers); + rm.done(); + } + }); + } + }); + } catch (RejectedExecutionException e) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, + "Not available", e)); //$NON-NLS-1$ + rm.done(); + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java index 95e9d2a2f91..b9603b93f59 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Ericsson - modified to remove dependency on cdt.launch @@ -47,16 +47,16 @@ public class GdbUIPlugin extends AbstractUIPlugin { // The shared instance private static GdbUIPlugin plugin; - - private static BundleContext fgBundleContext; - private static TracingConsoleManager fTracingConsoleManager; - private static GdbCliConsoleManager fGdbConsoleManager; + private static BundleContext fgBundleContext; + + private static TracingConsoleManager fTracingConsoleManager; + private static GdbCliConsoleManager fGdbConsoleManager; + + private static GdbDebugContextSyncManager fGdbSelectionSyncManager; + + private static IPreferenceStore fCorePreferenceStore; - private static GdbDebugContextSyncManager fGdbSelectionSyncManager; - - private static IPreferenceStore fCorePreferenceStore; - /** * The constructor */ @@ -68,17 +68,17 @@ public class GdbUIPlugin extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ @Override - public void start(BundleContext context) throws Exception { - fgBundleContext = context; + public void start(BundleContext context) throws Exception { + fgBundleContext = context; super.start(context); plugin = this; - + fTracingConsoleManager = new TracingConsoleManager(); fTracingConsoleManager.startup(); - + fGdbConsoleManager = new GdbCliConsoleManager(); fGdbConsoleManager.startup(); - + fGdbSelectionSyncManager = new GdbDebugContextSyncManager(); fGdbSelectionSyncManager.startup(); } @@ -88,7 +88,7 @@ public class GdbUIPlugin extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ @Override - public void stop(BundleContext context) throws Exception { + public void stop(BundleContext context) throws Exception { fTracingConsoleManager.shutdown(); fGdbConsoleManager.shutdown(); fGdbSelectionSyncManager.shutdown(); @@ -96,13 +96,13 @@ public class GdbUIPlugin extends AbstractUIPlugin { disposeAdapterSets(); plugin = null; super.stop(context); - fgBundleContext = null; + fgBundleContext = null; } public static GdbCliConsoleManager getCliConsoleManager() { return fGdbConsoleManager; } - + public static GdbDebugContextSyncManager getGdbSelectionSyncManager() { return fGdbSelectionSyncManager; } @@ -111,11 +111,11 @@ public class GdbUIPlugin extends AbstractUIPlugin { * Dispose adapter sets for all launches. */ private void disposeAdapterSets() { - for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) { - if (launch instanceof GdbLaunch) { - GdbAdapterFactory.disposeAdapterSet(launch); - } - } + for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) { + if (launch instanceof GdbLaunch) { + GdbAdapterFactory.disposeAdapterSet(launch); + } + } } /** @@ -127,25 +127,25 @@ public class GdbUIPlugin extends AbstractUIPlugin { return plugin; } - public static BundleContext getBundleContext() { - return fgBundleContext; - } - + public static BundleContext getBundleContext() { + return fgBundleContext; + } + /** * Returns the preference store for this UI plug-in. * It actually uses the preference store of the core plug-in. */ - @Override + @Override public IPreferenceStore getPreferenceStore() { if (fCorePreferenceStore == null) { fCorePreferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, GdbPlugin.PLUGIN_ID); } return fCorePreferenceStore; } - - /** - * copied from org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin - */ + + /** + * copied from org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin + */ private static Shell debugDialogShell; public static Shell getShell() { @@ -180,16 +180,17 @@ public class GdbUIPlugin extends AbstractUIPlugin { /** * Logs the specified status with this plug-in's log. - * + * * @param status * status to log */ public static void log(IStatus status) { getDefault().getLog().log(status); } + /** * Logs an internal error with the specified message. - * + * * @param message * the error message to log */ @@ -199,7 +200,7 @@ public class GdbUIPlugin extends AbstractUIPlugin { /** * Logs an internal error with the specified throwable - * + * * @param e * the exception to be logged */ @@ -209,7 +210,7 @@ public class GdbUIPlugin extends AbstractUIPlugin { /** * Returns the active workbench window - * + * * @return the active workbench window */ public static IWorkbenchWindow getActiveWorkbenchWindow() { @@ -226,7 +227,7 @@ public class GdbUIPlugin extends AbstractUIPlugin { /** * Returns the active workbench shell or <code>null</code> if none - * + * * @return the active workbench shell or <code>null</code> if none */ public static Shell getActiveWorkbenchShell() { @@ -254,32 +255,32 @@ public class GdbUIPlugin extends AbstractUIPlugin { } } - /* (non-Javadoc) + /* (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry) */ @Override - protected void initializeImageRegistry( ImageRegistry reg ) { - super.initializeImageRegistry( reg ); - declareImages( reg ); + protected void initializeImageRegistry(ImageRegistry reg) { + super.initializeImageRegistry(reg); + declareImages(reg); } /** - * Returns an image descriptor for the image file at the given - * plug-in relative path - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return imageDescriptorFromPlugin(PLUGIN_ID, path); - } - - public static Image getImage( String key ) { - return getDefault().getImageRegistry().get( key ); - } - - private void declareImages( ImageRegistry reg ) { - reg.put( IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS, - getImageDescriptor( "icons/full/wizban/advtosettings_wiz.png" ) ); //$NON-NLS-1$ - } + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + public static Image getImage(String key) { + return getDefault().getImageRegistry().get(key); + } + + private void declareImages(ImageRegistry reg) { + reg.put(IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS, + getImageDescriptor("icons/full/wizban/advtosettings_wiz.png")); //$NON-NLS-1$ + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/IGdbUIConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/IGdbUIConstants.java index 4a9dc9c4746..8a082297c7b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/IGdbUIConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/IGdbUIConstants.java @@ -16,7 +16,7 @@ package org.eclipse.cdt.dsf.gdb.internal.ui; /** * @noimplement This interface is not intended to be implemented by clients. - * + * * @since 4.1 */ public interface IGdbUIConstants { @@ -24,8 +24,8 @@ public interface IGdbUIConstants { /** * Plug-in identifier (value <code>"org.eclipse.cdt.dsf.gdb.ui"</code>). */ - public static final String PLUGIN_ID = GdbUIPlugin.PLUGIN_ID; - + public static final String PLUGIN_ID = GdbUIPlugin.PLUGIN_ID; + /** image identifier. */ public static final String IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS = PLUGIN_ID + ".imageAdvancedTimeoutSettings"; //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.java index 06ca62e109b..05690ef5b55 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/Messages.java @@ -24,7 +24,7 @@ public class Messages extends NLS { public static String GdbStatusHandler_Warning; static { // initialize resource bundle - NLS.initializeMessages( Messages.class.getName(), Messages.class ); + NLS.initializeMessages(Messages.class.getName(), Messages.class); } private Messages() { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfLoadSymbolsCommandHandler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfLoadSymbolsCommandHandler.java index 5a1fc270854..a078446cefd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfLoadSymbolsCommandHandler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfLoadSymbolsCommandHandler.java @@ -46,7 +46,9 @@ public class DsfLoadSymbolsCommandHandler extends AbstractHandler { @Override public Object execute(final ExecutionEvent event) { final ISelection iselection = HandlerUtil.getCurrentSelection(event); - final IStructuredSelection selection = (iselection instanceof IStructuredSelection) ? (IStructuredSelection) iselection : null; + final IStructuredSelection selection = (iselection instanceof IStructuredSelection) + ? (IStructuredSelection) iselection + : null; boolean all = event.getCommand().getId().equals("org.eclipse.cdt.debug.ui.command.loadAllSymbols");//$NON-NLS-1$ String sessionId = getSessionIdFromContext(selection); loadSymbols(selection, sessionId, all); @@ -86,7 +88,7 @@ public class DsfLoadSymbolsCommandHandler extends AbstractHandler { try { IModules2 modules = tracker.getService(IModules2.class); if (modules != null) { - modules.loadSymbols((IModuleDMContext)context, new RequestMonitor(session.getExecutor(), null) { + modules.loadSymbols((IModuleDMContext) context, new RequestMonitor(session.getExecutor(), null) { @Override protected void handleSuccess() { doRefresh(session, module); @@ -124,15 +126,15 @@ public class DsfLoadSymbolsCommandHandler extends AbstractHandler { /** * Refresh all VMProviders applying to element, as they could each need to change due to the new symbols. - * - * @param element The element used to establish which VMProviders should refresh + * + * @param element The element used to establish which VMProviders should refresh */ private void doRefresh(DsfSession session, Object element) { if (element != null) { try { - IRefreshAllTarget refreshTarget = (IRefreshAllTarget)session.getModelAdapter(IRefreshAllTarget.class); + IRefreshAllTarget refreshTarget = (IRefreshAllTarget) session.getModelAdapter(IRefreshAllTarget.class); if (refreshTarget != null) { - refreshTarget.refresh(new StructuredSelection(element)); + refreshTarget.refresh(new StructuredSelection(element)); } } catch (CoreException e) { // refresh failed, sad @@ -150,7 +152,7 @@ public class DsfLoadSymbolsCommandHandler extends AbstractHandler { if (sessionId != null) return sessionId; } - + IAdaptable debugContext = DebugUITools.getDebugContext(); String sessionId = null; if (debugContext instanceof IDMVMContext) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java index 50b612a0963..8f83bac2471 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java @@ -7,10 +7,10 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation - * Nokia - create and use backend service. + * Nokia - create and use backend service. *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.actions; @@ -48,153 +48,147 @@ import org.eclipse.debug.core.model.IProcess; public class DsfTerminateCommand implements ITerminateHandler { private final DsfSession fSession; private final DsfExecutor fExecutor; - private final DsfServicesTracker fTracker; - - public DsfTerminateCommand(DsfSession session) { - fSession = session; - fExecutor = session.getExecutor(); - fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } + private final DsfServicesTracker fTracker; + + public DsfTerminateCommand(DsfSession session) { + fSession = session; + fExecutor = session.getExecutor(); + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + } - public void dispose() { - fTracker.dispose(); - } + public void dispose() { + fTracker.dispose(); + } - @Override - public void canExecute(final IEnabledStateRequest request) { - if (request.getElements().length == 0) { - request.setEnabled(false); - request.done(); - return; - } + @Override + public void canExecute(final IEnabledStateRequest request) { + if (request.getElements().length == 0) { + request.setEnabled(false); + request.done(); + return; + } - final GdbLaunch launch = getLaunch(request); - if (launch != null) { - fExecutor.execute(new DsfRunnable() { + final GdbLaunch launch = getLaunch(request); + if (launch != null) { + fExecutor.execute(new DsfRunnable() { @Override public void run() { - request.setEnabled(false); - IGDBControl gdbControl = fTracker.getService(IGDBControl.class); - if (gdbControl != null && gdbControl.isActive()) { - request.setEnabled(true); - } - else { - // The GDB session may be terminated at this moment but if there - // are processes in this launch that are not controlled by GDB - // we need to check them as well. - for (IProcess p : launch.getProcesses()) { - if (p.canTerminate()) { - request.setEnabled(true); - break; - } - } - } - request.done(); + request.setEnabled(false); + IGDBControl gdbControl = fTracker.getService(IGDBControl.class); + if (gdbControl != null && gdbControl.isActive()) { + request.setEnabled(true); + } else { + // The GDB session may be terminated at this moment but if there + // are processes in this launch that are not controlled by GDB + // we need to check them as well. + for (IProcess p : launch.getProcesses()) { + if (p.canTerminate()) { + request.setEnabled(true); + break; + } + } + } + request.done(); } }); - } - else { - fExecutor.execute(new DsfRunnable() { + } else { + fExecutor.execute(new DsfRunnable() { @Override public void run() { - IProcessDMContext[] procDmcs = getProcessDMContexts(request.getElements()); + IProcessDMContext[] procDmcs = getProcessDMContexts(request.getElements()); canTerminate(procDmcs, new DataRequestMonitor<Boolean>(fExecutor, null) { @Override protected void handleCompleted() { - if (!isSuccess()) { - request.setEnabled(false); - } - else { - request.setEnabled(getData()); - } - request.done(); + if (!isSuccess()) { + request.setEnabled(false); + } else { + request.setEnabled(getData()); + } + request.done(); } }); } }); - } - } + } + } - @Override - public boolean execute(final IDebugCommandRequest request) { - if (request.getElements().length == 0) { - request.done(); - return false; - } + @Override + public boolean execute(final IDebugCommandRequest request) { + if (request.getElements().length == 0) { + request.done(); + return false; + } - final GdbLaunch launch = getLaunch(request); - if (launch != null) { - fExecutor.execute(new DsfRunnable() { + final GdbLaunch launch = getLaunch(request); + if (launch != null) { + fExecutor.execute(new DsfRunnable() { @Override public void run() { - IGDBControl gdbControl = fTracker.getService(IGDBControl.class); - if (gdbControl != null && gdbControl.isActive()) { - gdbControl.terminate(new RequestMonitor(fExecutor, null) { - @Override + IGDBControl gdbControl = fTracker.getService(IGDBControl.class); + if (gdbControl != null && gdbControl.isActive()) { + gdbControl.terminate(new RequestMonitor(fExecutor, null) { + @Override protected void handleCompleted() { - if (!isSuccess()) { - request.setStatus(getStatus()); - request.done(); - } - else { - waitForTermination(request); - } - } - }); - } - else { - terminateRemainingProcesses(launch, request); - } + if (!isSuccess()) { + request.setStatus(getStatus()); + request.done(); + } else { + waitForTermination(request); + } + } + }); + } else { + terminateRemainingProcesses(launch, request); + } } }); - } - else { - fExecutor.execute(new DsfRunnable() { + } else { + fExecutor.execute(new DsfRunnable() { @Override public void run() { - IProcessDMContext[] procDmcs = getProcessDMContexts(request.getElements()); + IProcessDMContext[] procDmcs = getProcessDMContexts(request.getElements()); terminate(procDmcs, new RequestMonitor(fExecutor, null) { @Override protected void handleCompleted() { - if (!isSuccess()) { - request.setStatus(getStatus()); - request.done(); - } - else { - waitForTermination(request); - } + if (!isSuccess()) { + request.setStatus(getStatus()); + request.done(); + } else { + waitForTermination(request); + } } }); } - }); - } - return false; - } - - /** - * Wait for the debug session to be fully shutdown before reporting - * that the terminate was completed. This is important for the - * 'Terminate and remove' operation. - * The wait time is limited with a timeout so as to eventually complete the - * request in the case of termination error, or when terminating - * a single process in a multi-process session. - * See bug 377447 - */ - private void waitForTermination(final IDebugCommandRequest request) { - class ScheduledFutureWrapper { - ScheduledFuture<?> fFuture; - }; - - final ScheduledFutureWrapper fFutureWrapper = new ScheduledFutureWrapper(); - - // It is possible that the session already had time to terminate + }); + } + return false; + } + + /** + * Wait for the debug session to be fully shutdown before reporting + * that the terminate was completed. This is important for the + * 'Terminate and remove' operation. + * The wait time is limited with a timeout so as to eventually complete the + * request in the case of termination error, or when terminating + * a single process in a multi-process session. + * See bug 377447 + */ + private void waitForTermination(final IDebugCommandRequest request) { + class ScheduledFutureWrapper { + ScheduledFuture<?> fFuture; + } + ; + + final ScheduledFutureWrapper fFutureWrapper = new ScheduledFutureWrapper(); + + // It is possible that the session already had time to terminate if (!DsfSession.isSessionActive(fSession.getId())) { request.done(); return; } // Listener that will indicate when the shutdown is complete - final SessionEndedListener endedListener = new SessionEndedListener () { + final SessionEndedListener endedListener = new SessionEndedListener() { @Override public void sessionEnded(DsfSession session) { if (fSession.equals(session)) { @@ -204,15 +198,14 @@ public class DsfTerminateCommand implements ITerminateHandler { GdbLaunch launch = getLaunch(request); if (launch != null) { terminateRemainingProcesses(launch, request); - } - else { + } else { request.done(); } } } }; - DsfSession.addSessionEndedListener(endedListener); + DsfSession.addSessionEndedListener(endedListener); // Create the timeout // For a multi-process session, if a single process is @@ -220,7 +213,7 @@ public class DsfTerminateCommand implements ITerminateHandler { // session is also terminated before the timeout). // We haven't found a problem with delaying the completion // of the request that way. - fFutureWrapper.fFuture = fExecutor.schedule(new Runnable() { + fFutureWrapper.fFuture = fExecutor.schedule(new Runnable() { @Override public void run() { // Check that the session is still active when the timeout hits. @@ -228,113 +221,106 @@ public class DsfTerminateCommand implements ITerminateHandler { if (DsfSession.isSessionActive(fSession.getId())) { DsfSession.removeSessionEndedListener(endedListener); - // Marking the request as cancelled will prevent the removal of + // Marking the request as cancelled will prevent the removal of // the launch from the Debug view in case of "Terminate and Remove". // This is important for multi-process sessions when "Terminate and Remove" // is applied to one of the running processes. In this case the selected - // process will be terminated but the associated launch will not be removed + // process will be terminated but the associated launch will not be removed // from the Debug view. request.setStatus(Status.CANCEL_STATUS); request.done(); } - }}, - 1, TimeUnit.MINUTES); - } + } + }, 1, TimeUnit.MINUTES); + } - private IProcessDMContext[] getProcessDMContexts(Object[] elements) { - final Set<IProcessDMContext> procDmcs = new HashSet<IProcessDMContext>(); - for (Object obj : elements) { - if (obj instanceof IDMVMContext) { - IProcessDMContext procDmc = - DMContexts.getAncestorOfType(((IDMVMContext)obj).getDMContext(), IProcessDMContext.class); + private IProcessDMContext[] getProcessDMContexts(Object[] elements) { + final Set<IProcessDMContext> procDmcs = new HashSet<IProcessDMContext>(); + for (Object obj : elements) { + if (obj instanceof IDMVMContext) { + IProcessDMContext procDmc = DMContexts.getAncestorOfType(((IDMVMContext) obj).getDMContext(), + IProcessDMContext.class); if (procDmc != null) { procDmcs.add(procDmc); } - } - } + } + } return procDmcs.toArray(new IProcessDMContext[procDmcs.size()]); - } + } - private void canTerminate(IProcessDMContext[] procDmcs, DataRequestMonitor<Boolean> rm) { - if (procDmcs.length == 0) { - IGDBControl gdbControl = fTracker.getService(IGDBControl.class); - if (gdbControl != null) { - rm.setData(gdbControl.isActive()); - } - else { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service is not available.")); //$NON-NLS-1$ - } - rm.done(); - return; - } - - IMultiTerminate multiTerminate = fTracker.getService(IMultiTerminate.class); - if (multiTerminate != null) { - multiTerminate.canTerminateSome(procDmcs, rm); + private void canTerminate(IProcessDMContext[] procDmcs, DataRequestMonitor<Boolean> rm) { + if (procDmcs.length == 0) { + IGDBControl gdbControl = fTracker.getService(IGDBControl.class); + if (gdbControl != null) { + rm.setData(gdbControl.isActive()); + } else { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service is not available.")); //$NON-NLS-1$ + } + rm.done(); + return; } - else { + + IMultiTerminate multiTerminate = fTracker.getService(IMultiTerminate.class); + if (multiTerminate != null) { + multiTerminate.canTerminateSome(procDmcs, rm); + } else { IProcesses procService = fTracker.getService(IProcesses.class); if (procService != null && procDmcs.length == 1) { procService.canTerminate(procDmcs[0], rm); - } - else { + } else { rm.setData(false); rm.done(); } - } - } - - private void terminate(IProcessDMContext[] procDmcs, RequestMonitor rm) { - if (procDmcs.length == 0) { - IGDBControl gdbControl = fTracker.getService(IGDBControl.class); - if (gdbControl != null) { - gdbControl.terminate(rm); - } - else { - rm.done(); - } - return; - } + } + } + + private void terminate(IProcessDMContext[] procDmcs, RequestMonitor rm) { + if (procDmcs.length == 0) { + IGDBControl gdbControl = fTracker.getService(IGDBControl.class); + if (gdbControl != null) { + gdbControl.terminate(rm); + } else { + rm.done(); + } + return; + } - IMultiTerminate multiTerminate = fTracker.getService(IMultiTerminate.class); - if (multiTerminate != null) { - multiTerminate.terminate(procDmcs, rm); - } - else { - IProcesses procService = fTracker.getService(IProcesses.class); - if (procService != null && procDmcs.length == 1) { - procService.terminate(procDmcs[0], rm); - } - else { - rm.done(); - } - } - } - - private GdbLaunch getLaunch(IDebugCommandRequest request) { - for (Object el : request.getElements()) { - if (el instanceof GdbLaunch) { - return (GdbLaunch)el; - } - } - return null; - } - - private void terminateRemainingProcesses(final GdbLaunch launch, final IDebugCommandRequest request) { - // Run this in a separate job since this method is called from - // the executor thread. The job is scheduled with a delay to make - // sure that MIInferiorProcess is terminated. See MIInferiorProcess.waitForSync() - new Job("Terminate Job") { //$NON-NLS-1$ + IMultiTerminate multiTerminate = fTracker.getService(IMultiTerminate.class); + if (multiTerminate != null) { + multiTerminate.terminate(procDmcs, rm); + } else { + IProcesses procService = fTracker.getService(IProcesses.class); + if (procService != null && procDmcs.length == 1) { + procService.terminate(procDmcs[0], rm); + } else { + rm.done(); + } + } + } + + private GdbLaunch getLaunch(IDebugCommandRequest request) { + for (Object el : request.getElements()) { + if (el instanceof GdbLaunch) { + return (GdbLaunch) el; + } + } + return null; + } + + private void terminateRemainingProcesses(final GdbLaunch launch, final IDebugCommandRequest request) { + // Run this in a separate job since this method is called from + // the executor thread. The job is scheduled with a delay to make + // sure that MIInferiorProcess is terminated. See MIInferiorProcess.waitForSync() + new Job("Terminate Job") { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { - MultiStatus status = - new MultiStatus(GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, Messages.DsfTerminateCommand_Terminate_failed, null); + MultiStatus status = new MultiStatus(GdbUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, + Messages.DsfTerminateCommand_Terminate_failed, null); for (IProcess p : launch.getProcesses()) { if (p.canTerminate()) { try { p.terminate(); - } - catch(DebugException e) { + } catch (DebugException e) { status.merge(e.getStatus()); } } @@ -346,5 +332,5 @@ public class DsfTerminateCommand implements ITerminateHandler { return Status.OK_STATUS; } }.schedule(100); - } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/FetchMoreChildrenAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/FetchMoreChildrenAction.java index a70d7d0832c..134efbe8993 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/FetchMoreChildrenAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/FetchMoreChildrenAction.java @@ -36,12 +36,11 @@ import org.eclipse.ui.IWorkbenchPart; /** * @since 3.0 */ -public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate - implements IObjectActionDelegate { +public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate implements IObjectActionDelegate { private ISelection selection; - - @Override + + @Override public void run(IAction action) { IncompleteChildrenVMC incompleteChildrenVmc = getIncompleteChildrenVMC(); @@ -57,7 +56,7 @@ public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate final FetchMoreChildrenEvent fetchMoreChildrenEvent = new FetchMoreChildrenEvent(exprCtx, path); final AbstractVMProvider vmProvider = (AbstractVMProvider) getVMProvider(); vmProvider.getExecutor().execute(new DsfRunnable() { - @Override + @Override public void run() { vmProvider.handleEvent(fetchMoreChildrenEvent); } @@ -66,19 +65,19 @@ public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate } } - @Override - public void init(IViewPart view) { - super.init(view); + @Override + public void init(IViewPart view) { + super.init(view); updateEnablement(); - } - - @Override - public void debugContextChanged(DebugContextEvent event) { - super.debugContextChanged(event); + } + + @Override + public void debugContextChanged(DebugContextEvent event) { + super.debugContextChanged(event); updateEnablement(); - } + } - @Override + @Override public void selectionChanged(IAction action, ISelection selection) { super.selectionChanged(action, selection); this.selection = selection; @@ -94,17 +93,17 @@ public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate getAction().setEnabled(enabled); } - @Override + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { if (targetPart instanceof IViewPart) { init((IViewPart) targetPart); } } - + private IncompleteChildrenVMC getIncompleteChildrenVMC() { if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; - + if (ss.size() == 1) { // Only single selection is supported. Object selectedObject = ss.getFirstElement(); @@ -113,7 +112,7 @@ public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate } } } - + return null; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbDisconnectCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbDisconnectCommand.java index e14ed0742eb..1f8ced9e17f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbDisconnectCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbDisconnectCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -45,114 +45,111 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; public class GdbDisconnectCommand implements IDisconnectHandler { private final DsfSession fSession; private final DsfExecutor fExecutor; - private final DsfServicesTracker fTracker; + private final DsfServicesTracker fTracker; public GdbDisconnectCommand(DsfSession session) { super(); fSession = session; fExecutor = session.getExecutor(); - fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); } - public void dispose() { - fTracker.dispose(); - } + public void dispose() { + fTracker.dispose(); + } @Override public void canExecute(final IEnabledStateRequest request) { - if (request.getElements().length == 0) { - request.setEnabled(false); - request.done(); - return; - } + if (request.getElements().length == 0) { + request.setEnabled(false); + request.done(); + return; + } - getContainerDMContexts(request.getElements(), new DataRequestMonitor<IContainerDMContext[]>(fExecutor, null) { - @Override - protected void handleCompleted() { - if (!isSuccess()) { - request.setEnabled(false); - request.done(); - } - else { - canDisconnect(getData(), new ImmediateDataRequestMonitor<Boolean>() { - @Override + getContainerDMContexts(request.getElements(), new DataRequestMonitor<IContainerDMContext[]>(fExecutor, null) { + @Override + protected void handleCompleted() { + if (!isSuccess()) { + request.setEnabled(false); + request.done(); + } else { + canDisconnect(getData(), new ImmediateDataRequestMonitor<Boolean>() { + @Override protected void handleCompleted() { - if (!isSuccess()) { - request.setEnabled(false); - } - else { - request.setEnabled(getData());; - } - request.done(); - } - }); - } - } - }); + if (!isSuccess()) { + request.setEnabled(false); + } else { + request.setEnabled(getData()); + ; + } + request.done(); + } + }); + } + } + }); } @Override public boolean execute(final IDebugCommandRequest request) { - if (request.getElements().length == 0) { - request.done(); - return false; - } - - getContainerDMContexts(request.getElements(), new DataRequestMonitor<IContainerDMContext[]>(fExecutor, null) { - @Override - protected void handleCompleted() { - if (!isSuccess()) { - request.setStatus(getStatus()); - request.done(); - } - else { - disconnect(getData(), new ImmediateRequestMonitor() { - @Override + if (request.getElements().length == 0) { + request.done(); + return false; + } + + getContainerDMContexts(request.getElements(), new DataRequestMonitor<IContainerDMContext[]>(fExecutor, null) { + @Override + protected void handleCompleted() { + if (!isSuccess()) { + request.setStatus(getStatus()); + request.done(); + } else { + disconnect(getData(), new ImmediateRequestMonitor() { + @Override protected void handleCompleted() { - if (!isSuccess()) { - request.setStatus(getStatus()); - request.done(); - } - else { - waitForTermination(request); - } - } - }); - } - } - }); - - return false; + if (!isSuccess()) { + request.setStatus(getStatus()); + request.done(); + } else { + waitForTermination(request); + } + } + }); + } + } + }); + + return false; } - - /** - * Wait for the debug session to be fully shutdown before reporting - * that the terminate was completed. This is important for the - * 'Terminate and remove' operation. - * The wait time is limited with a timeout so as to eventually complete the - * request in the case of termination error, or when terminating - * a single process in a multi-process session. - * See bug 377447 - */ - private void waitForTermination(final IDebugCommandRequest request) { - // It is possible that the session already had time to terminate + + /** + * Wait for the debug session to be fully shutdown before reporting + * that the terminate was completed. This is important for the + * 'Terminate and remove' operation. + * The wait time is limited with a timeout so as to eventually complete the + * request in the case of termination error, or when terminating + * a single process in a multi-process session. + * See bug 377447 + */ + private void waitForTermination(final IDebugCommandRequest request) { + // It is possible that the session already had time to terminate if (!DsfSession.isSessionActive(fSession.getId())) { request.done(); return; } // Listener that will indicate when the shutdown is complete - final SessionEndedListener endedListener = new SessionEndedListener () { + final SessionEndedListener endedListener = new SessionEndedListener() { @Override public void sessionEnded(DsfSession session) { if (fSession.equals(session)) { DsfSession.removeSessionEndedListener(this); - request.done(); + request.done(); } } }; - DsfSession.addSessionEndedListener(endedListener); + DsfSession.addSessionEndedListener(endedListener); // Create the timeout // For a multi-process session, if a single process is @@ -164,7 +161,7 @@ public class GdbDisconnectCommand implements IDisconnectHandler { // need it anymore, once the session has terminated; // instead, we let it timeout and ignore it if the session // is already terminated. - fExecutor.schedule(new Runnable() { + fExecutor.schedule(new Runnable() { @Override public void run() { // Check that the session is still active when the timeout hits. @@ -172,122 +169,115 @@ public class GdbDisconnectCommand implements IDisconnectHandler { if (DsfSession.isSessionActive(fSession.getId())) { DsfSession.removeSessionEndedListener(endedListener); - // Marking the request as cancelled will prevent the removal of + // Marking the request as cancelled will prevent the removal of // the launch from the Debug view in case of "Terminate and Remove". // This is important for multi-process sessions when "Terminate and Remove" // is applied to one of the running processes. In this case the selected - // process will be terminated but the associated launch will not be removed + // process will be terminated but the associated launch will not be removed // from the Debug view. request.setStatus(Status.CANCEL_STATUS); request.done(); } - }}, - 1, TimeUnit.MINUTES); - } + } + }, 1, TimeUnit.MINUTES); + } - private void getContainerDMContexts(Object[] elements, final DataRequestMonitor<IContainerDMContext[]> rm) { - GdbLaunch launch = null; - final Set<IContainerDMContext> contDmcs = new HashSet<IContainerDMContext>(); - for (Object obj : elements) { - if (obj instanceof GdbLaunch) { - launch = (GdbLaunch)obj; - break; - } - if (obj instanceof IDMVMContext) { - IContainerDMContext contDmc = - DMContexts.getAncestorOfType(((IDMVMContext)obj).getDMContext(), IContainerDMContext.class); + private void getContainerDMContexts(Object[] elements, final DataRequestMonitor<IContainerDMContext[]> rm) { + GdbLaunch launch = null; + final Set<IContainerDMContext> contDmcs = new HashSet<IContainerDMContext>(); + for (Object obj : elements) { + if (obj instanceof GdbLaunch) { + launch = (GdbLaunch) obj; + break; + } + if (obj instanceof IDMVMContext) { + IContainerDMContext contDmc = DMContexts.getAncestorOfType(((IDMVMContext) obj).getDMContext(), + IContainerDMContext.class); if (contDmc != null) { contDmcs.add(contDmc); } - } - } - if (launch == null) { - rm.setData(contDmcs.toArray(new IContainerDMContext[contDmcs.size()])); - rm.done(); - } - else { - try { - fExecutor.execute(new DsfRunnable() { - @Override - public void run() { - ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); - final IProcesses procService = fTracker.getService(IProcesses.class); - if (commandControl != null && procService != null) { - procService.getProcessesBeingDebugged( - commandControl.getContext(), - new ImmediateDataRequestMonitor<IDMContext[]>() { - @Override - protected void handleCompleted() { - if (!isSuccess()) { - rm.setStatus(getStatus()); - } - else { - for (IDMContext ctx : getData()) { - IContainerDMContext contDmc = DMContexts.getAncestorOfType(ctx, IContainerDMContext.class); - if (contDmc != null) { - contDmcs.add(contDmc); - } - } - rm.setData(contDmcs.toArray(new IContainerDMContext[contDmcs.size()])); - } - rm.done(); - }; - }); - } - else { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service is not available.")); //$NON-NLS-1$ - rm.done(); - } - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, e.getLocalizedMessage())); - rm.done(); - } - } - } + } + } + if (launch == null) { + rm.setData(contDmcs.toArray(new IContainerDMContext[contDmcs.size()])); + rm.done(); + } else { + try { + fExecutor.execute(new DsfRunnable() { + @Override + public void run() { + ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); + final IProcesses procService = fTracker.getService(IProcesses.class); + if (commandControl != null && procService != null) { + procService.getProcessesBeingDebugged(commandControl.getContext(), + new ImmediateDataRequestMonitor<IDMContext[]>() { + @Override + protected void handleCompleted() { + if (!isSuccess()) { + rm.setStatus(getStatus()); + } else { + for (IDMContext ctx : getData()) { + IContainerDMContext contDmc = DMContexts.getAncestorOfType(ctx, + IContainerDMContext.class); + if (contDmc != null) { + contDmcs.add(contDmc); + } + } + rm.setData(contDmcs.toArray(new IContainerDMContext[contDmcs.size()])); + } + rm.done(); + }; + }); + } else { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service is not available.")); //$NON-NLS-1$ + rm.done(); + } + } + }); + } catch (RejectedExecutionException e) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, e.getLocalizedMessage())); + rm.done(); + } + } + } - private void canDisconnect(IContainerDMContext[] contDmcs, DataRequestMonitor<Boolean> rm) { - if (contDmcs.length == 0) { - rm.setData(false); - rm.done(); - return; - } + private void canDisconnect(IContainerDMContext[] contDmcs, DataRequestMonitor<Boolean> rm) { + if (contDmcs.length == 0) { + rm.setData(false); + rm.done(); + return; + } - IMultiDetach multiDetach = fTracker.getService(IMultiDetach.class); + IMultiDetach multiDetach = fTracker.getService(IMultiDetach.class); if (multiDetach != null) { - multiDetach.canDetachDebuggerFromSomeProcesses(contDmcs, rm); - } - else { + multiDetach.canDetachDebuggerFromSomeProcesses(contDmcs, rm); + } else { IProcesses procService = fTracker.getService(IProcesses.class); if (procService != null && contDmcs.length == 1) { procService.canDetachDebuggerFromProcess(contDmcs[0], rm); - } - else { + } else { rm.setData(false); rm.done(); } - } - } + } + } - private void disconnect(IContainerDMContext[] contDmcs, RequestMonitor rm) { - if (contDmcs.length == 0) { - rm.done(); - return; - } + private void disconnect(IContainerDMContext[] contDmcs, RequestMonitor rm) { + if (contDmcs.length == 0) { + rm.done(); + return; + } - IMultiDetach multiDetach = fTracker.getService(IMultiDetach.class); - if (multiDetach != null) { - multiDetach.detachDebuggerFromProcesses(contDmcs, rm); - } - else { - IProcesses procService = fTracker.getService(IProcesses.class); - if (procService != null && contDmcs.length == 1) { - procService.detachDebuggerFromProcess(contDmcs[0], rm); - } - else { - rm.done(); - } - } - } + IMultiDetach multiDetach = fTracker.getService(IMultiDetach.class); + if (multiDetach != null) { + multiDetach.detachDebuggerFromProcesses(contDmcs, rm); + } else { + IProcesses procService = fTracker.getService(IProcesses.class); + if (procService != null && contDmcs.length == 1) { + procService.detachDebuggerFromProcess(contDmcs[0], rm); + } else { + rm.done(); + } + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRestartCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRestartCommand.java index 85e89ed6791..60fa974eacf 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRestartCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRestartCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Navid Mehregani (TI) - Bug 289526 - Migrate the Restart feature to the new one, as supported by the platform @@ -34,91 +34,91 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; import org.eclipse.debug.core.commands.IRestartHandler; public class GdbRestartCommand implements IRestartHandler { - private final DsfExecutor fExecutor; - private final DsfServicesTracker fTracker; - private final ILaunch fLaunch; - - public GdbRestartCommand(DsfSession session, ILaunch launch) { - fExecutor = session.getExecutor(); - fLaunch = launch; - fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } + private final DsfExecutor fExecutor; + private final DsfServicesTracker fTracker; + private final ILaunch fLaunch; + + public GdbRestartCommand(DsfSession session, ILaunch launch) { + fExecutor = session.getExecutor(); + fLaunch = launch; + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + } - public void dispose() { - fTracker.dispose(); - } + public void dispose() { + fTracker.dispose(); + } - @Override - public void canExecute(final IEnabledStateRequest request) { - if (request.getElements().length != 1) { - request.setEnabled(false); - request.done(); - return; - } + @Override + public void canExecute(final IEnabledStateRequest request) { + if (request.getElements().length != 1) { + request.setEnabled(false); + request.done(); + return; + } - fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { - @Override public void doExecute() { - IContainerDMContext containerDmc = DMContexts.getAncestorOfType(getContext(), IContainerDMContext.class); - IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); + fExecutor.submit(new DsfCommandRunnable(fTracker, request.getElements()[0], request) { + @Override + public void doExecute() { + IContainerDMContext containerDmc = DMContexts.getAncestorOfType(getContext(), + IContainerDMContext.class); + IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); - if (procService != null) { - procService.canRestart( - containerDmc, - new DataRequestMonitor<Boolean>(fExecutor, null) { - @Override - protected void handleCompleted() { - request.setEnabled(isSuccess() && getData()); - request.done(); - } - }); - } else { - request.setEnabled(false); + if (procService != null) { + procService.canRestart(containerDmc, new DataRequestMonitor<Boolean>(fExecutor, null) { + @Override + protected void handleCompleted() { + request.setEnabled(isSuccess() && getData()); + request.done(); + } + }); + } else { + request.setEnabled(false); request.done(); - } - } - }); + } + } + }); } - - @Override - public boolean execute(final IDebugCommandRequest request) { - if (request.getElements().length != 1) { - request.done(); - return false; - } - - Object element = request.getElements()[0]; - if (!(element instanceof IDMVMContext)) { - request.done(); - return false; - } - - final IContainerDMContext containerDmc = DMContexts.getAncestorOfType(((IDMVMContext)element).getDMContext(), - IContainerDMContext.class); - - fExecutor.submit(new DsfRunnable() { - @Override + + @Override + public boolean execute(final IDebugCommandRequest request) { + if (request.getElements().length != 1) { + request.done(); + return false; + } + + Object element = request.getElements()[0]; + if (!(element instanceof IDMVMContext)) { + request.done(); + return false; + } + + final IContainerDMContext containerDmc = DMContexts.getAncestorOfType(((IDMVMContext) element).getDMContext(), + IContainerDMContext.class); + + fExecutor.submit(new DsfRunnable() { + @Override public void run() { - IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); + IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); - if (procService != null) { - Map<String, Object> attributes = null; + if (procService != null) { + Map<String, Object> attributes = null; try { attributes = fLaunch.getLaunchConfiguration().getAttributes(); - } catch (CoreException e) {} - - procService.restart(containerDmc, attributes, - new DataRequestMonitor<IContainerDMContext>(fExecutor, null) { - @Override - protected void handleCompleted() { - request.done(); - }; - }); - } else { - request.done(); - } + } catch (CoreException e) { + } + + procService.restart(containerDmc, attributes, + new DataRequestMonitor<IContainerDMContext>(fExecutor, null) { + @Override + protected void handleCompleted() { + request.done(); + }; + }); + } else { + request.done(); + } } - }); - return false; - } + }); + return false; + } } - diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbSteppingModeTarget.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbSteppingModeTarget.java index 71c0b1cb709..d279ba86875 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbSteppingModeTarget.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbSteppingModeTarget.java @@ -25,48 +25,48 @@ import org.eclipse.cdt.dsf.gdb.service.SessionType; import org.eclipse.cdt.dsf.service.DsfServicesTracker; import org.eclipse.cdt.dsf.service.DsfSession; -/** +/** * SteppingModeTarget that allows to disable the button when dealing * with a post-mortem debugging session. - * + * * @since 2.0 */ public class GdbSteppingModeTarget extends DsfSteppingModeTarget { - private final DsfExecutor fExecutor; - private final DsfServicesTracker fTracker; - - public GdbSteppingModeTarget(DsfSession session) { - fExecutor = session.getExecutor(); - fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } + private final DsfExecutor fExecutor; + private final DsfServicesTracker fTracker; - public void dispose() { - fTracker.dispose(); - } + public GdbSteppingModeTarget(DsfSession session) { + fExecutor = session.getExecutor(); + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + } + + public void dispose() { + fTracker.dispose(); + } @Override public boolean supportsInstructionStepping() { - Query<Boolean> supportInstructionStepping = new Query<Boolean>() { - @Override - protected void execute(DataRequestMonitor<Boolean> rm) { - IGDBBackend backend = fTracker.getService(IGDBBackend.class); + Query<Boolean> supportInstructionStepping = new Query<Boolean>() { + @Override + protected void execute(DataRequestMonitor<Boolean> rm) { + IGDBBackend backend = fTracker.getService(IGDBBackend.class); if (backend != null) { // PostMortem sessions do not support instruction stepping rm.setData(backend.getSessionType() != SessionType.CORE); } else { rm.setData(false); } - + rm.done(); - } - }; + } + }; - fExecutor.execute(supportInstructionStepping); - try { - return supportInstructionStepping.get(); - } catch (InterruptedException e1) { - } catch (ExecutionException e1) { - } - return false; + fExecutor.execute(supportInstructionStepping); + try { + return supportInstructionStepping.get(); + } catch (InterruptedException e1) { + } catch (ExecutionException e1) { + } + return false; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java index 894cf82d9b6..5bdad1071d2 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java @@ -7,9 +7,9 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: - * Ericsson - initial API and implementation + * Ericsson - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.actions; @@ -23,11 +23,11 @@ public class ProcessInfo implements IProcessExtendedInfo, Comparable<ProcessInfo private final String[] cores; private final String ownerId; private final String description; - + public ProcessInfo(int pid, String name) { this(pid, name, null, null); } - + /** @since 2.2 */ public ProcessInfo(int pid, String name, String[] cores, String owner) { this(pid, name, cores, owner, null); @@ -44,41 +44,42 @@ public class ProcessInfo implements IProcessExtendedInfo, Comparable<ProcessInfo this.description = description; } - - @Override + @Override public String getName() { return name; } - @Override + @Override public int getPid() { return pid; } - @Override + @Override public String[] getCores() { return cores; } - @Override + @Override public String getOwner() { return ownerId; } - @Override - public String getDescription() { - return description; - } + @Override + public String getDescription() { + return description; + } /** * Sort by name, then by pid. * No need to sort any further since pids are unique. */ - @Override + @Override public int compareTo(ProcessInfo other) { - int nameCompare = getName().compareTo(other.getName()); - if (nameCompare != 0) return nameCompare; - else return (getPid() < other.getPid()) ? -1 : 1; + int nameCompare = getName().compareTo(other.getName()); + if (nameCompare != 0) + return nameCompare; + else + return (getPid() < other.getPid()) ? -1 : 1; } }
\ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ReverseDebuggingPropertyTester.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ReverseDebuggingPropertyTester.java index 4a53833953c..097bb4fefdb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ReverseDebuggingPropertyTester.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ReverseDebuggingPropertyTester.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -20,33 +20,34 @@ import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; import org.eclipse.core.expressions.PropertyTester; /** - * Property tester for reverse debugging information available through the given + * Property tester for reverse debugging information available through the given * object. The object being tested is an {@link IDMVMContext}. * <p> * One property is supported: * <ul> - * <li> "isReverseDebuggingEnabled" - Checks whether reverse debugging is currently + * <li> "isReverseDebuggingEnabled" - Checks whether reverse debugging is currently * enabled given the receiver.</li> * </ul> * </p> */ public class ReverseDebuggingPropertyTester extends PropertyTester { - private static final String ENABLED = "isReverseDebuggingEnabled"; //$NON-NLS-1$ + private static final String ENABLED = "isReverseDebuggingEnabled"; //$NON-NLS-1$ + + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if (ENABLED.equals(property)) { + if (receiver instanceof IDMVMContext) { + return test((IDMVMContext) receiver); + } + } + return false; + } - @Override - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (ENABLED.equals(property)) { - if (receiver instanceof IDMVMContext) { - return test((IDMVMContext)receiver); - } - } - return false; - } - - private boolean test(IDMVMContext context) { - boolean result = false; - ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(context.getDMContext(), ICommandControlDMContext.class); + private boolean test(IDMVMContext context) { + boolean result = false; + ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(context.getDMContext(), + ICommandControlDMContext.class); if (controlDmc != null) { IReverseToggleHandler toggle = (controlDmc.getAdapter(IReverseToggleHandler.class)); if (toggle != null) { @@ -54,5 +55,5 @@ public class ReverseDebuggingPropertyTester extends PropertyTester { } } return result; - } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/CBreakpointGdbThreadFilterPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/CBreakpointGdbThreadFilterPage.java index f68483b91d6..1f8aa4daef0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/CBreakpointGdbThreadFilterPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/CBreakpointGdbThreadFilterPage.java @@ -12,7 +12,7 @@ * QNX Software Systems - Initial API and implementation * Marc Khouzam (Ericsson) - Use IDsfBreakpointExtension directly (Bug 355833) *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; +package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.dsf.debug.service.IDsfBreakpointExtension; @@ -34,36 +34,37 @@ public class CBreakpointGdbThreadFilterPage extends PropertyPage { * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) */ @Override - protected Control createContents( Composite parent ) { + protected Control createContents(Composite parent) { noDefaultAndApplyButton(); - Composite mainComposite = new Composite( parent, SWT.NONE ); - mainComposite.setFont( parent.getFont() ); - mainComposite.setLayout( new GridLayout() ); - mainComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - createThreadFilterEditor( mainComposite ); - setValid( true ); + Composite mainComposite = new Composite(parent, SWT.NONE); + mainComposite.setFont(parent.getFont()); + mainComposite.setLayout(new GridLayout()); + mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); + createThreadFilterEditor(mainComposite); + setValid(true); return mainComposite; } - public ICBreakpoint getBreakpoint() { - return getElement().getAdapter(ICBreakpoint.class); - } + public ICBreakpoint getBreakpoint() { + return getElement().getAdapter(ICBreakpoint.class); + } public IDsfBreakpointExtension getFilterExtension() { - ICBreakpoint bp = getBreakpoint(); - if (bp != null) { - try { - IDsfBreakpointExtension filter = bp.getExtension(GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, - CBreakpointGdbThreadsFilterExtension.class); - filter.initialize(bp); - return filter; - } catch (CoreException e) {} - } - return null; + ICBreakpoint bp = getBreakpoint(); + if (bp != null) { + try { + IDsfBreakpointExtension filter = bp.getExtension(GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, + CBreakpointGdbThreadsFilterExtension.class); + filter.initialize(bp); + return filter; + } catch (CoreException e) { + } + } + return null; } - protected void createThreadFilterEditor( Composite parent ) { - fThreadFilterEditor = new GdbThreadFilterEditor( parent, this ); + protected void createThreadFilterEditor(Composite parent) { + fThreadFilterEditor = new GdbThreadFilterEditor(parent, this); } protected GdbThreadFilterEditor getThreadFilterEditor() { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleDynamicPrintfTarget.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleDynamicPrintfTarget.java index d332cfb98a7..e42e3247f43 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleDynamicPrintfTarget.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleDynamicPrintfTarget.java @@ -37,29 +37,30 @@ public class DisassemblyToggleDynamicPrintfTarget extends AbstractDisassemblyBre */ @Override protected void createLineBreakpoint(String sourceHandle, IResource resource, int lineNumber) throws CoreException { - // We provide a default printf string to make the dynamic printf useful automatically - String printfStr = NLS.bind(Messages.Default_LineDynamicPrintf_String, escapeBackslashes(sourceHandle), lineNumber); - - CDIDebugModel.createLineDynamicPrintf(sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", printfStr, true); //$NON-NLS-1$ + // We provide a default printf string to make the dynamic printf useful automatically + String printfStr = NLS.bind(Messages.Default_LineDynamicPrintf_String, escapeBackslashes(sourceHandle), + lineNumber); + + CDIDebugModel.createLineDynamicPrintf(sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", //$NON-NLS-1$ + printfStr, true); } - + @Override - protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource, int lineNumber) - throws CoreException - { - ICDynamicPrintf dprintf = (ICDynamicPrintf)CDIDebugModel.createBlankLineDynamicPrintf(); + protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource, + int lineNumber) throws CoreException { + ICDynamicPrintf dprintf = (ICDynamicPrintf) CDIDebugModel.createBlankLineDynamicPrintf(); Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setLineBreakpointAttributes( - attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$ + CDIDebugModel.setLineBreakpointAttributes(attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, + ""); //$NON-NLS-1$ - // Although the user will be given the opportunity to provide the printf string - // in the properties dialog, we pre-fill it with the default string to be nice. - attributes.put(ICDynamicPrintf.PRINTF_STRING, - NLS.bind(Messages.Default_LineDynamicPrintf_String, escapeBackslashes(sourceHandle), lineNumber)); + // Although the user will be given the opportunity to provide the printf string + // in the properties dialog, we pre-fill it with the default string to be nice. + attributes.put(ICDynamicPrintf.PRINTF_STRING, + NLS.bind(Messages.Default_LineDynamicPrintf_String, escapeBackslashes(sourceHandle), lineNumber)); openBreakpointPropertiesDialog(dprintf, part, resource, attributes); } - + /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.AbstractDisassemblyBreakpointsTarget#createAddressBreakpoint(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.IAddress) */ @@ -68,8 +69,9 @@ public class DisassemblyToggleDynamicPrintfTarget extends AbstractDisassemblyBre // We provide a default printf string to make the dynamic printf useful automatically String format = getAddressFormat(address); String printfStr = NLS.bind(Messages.Default_AddressDynamicPrintf_String, address, format); - - CDIDebugModel.createAddressDynamicPrintf(null, null, resource, getBreakpointType(), -1, address, true, 0, "", printfStr, true); //$NON-NLS-1$ + + CDIDebugModel.createAddressDynamicPrintf(null, null, resource, getBreakpointType(), -1, address, true, 0, "", //$NON-NLS-1$ + printfStr, true); } /** @@ -83,21 +85,20 @@ public class DisassemblyToggleDynamicPrintfTarget extends AbstractDisassemblyBre return format; } - @Override - protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address) - throws CoreException - { - ICDynamicPrintf dprintf = (ICDynamicPrintf)CDIDebugModel.createBlankAddressDynamicPrintf(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setAddressBreakpointAttributes( - attributes, null, null, getBreakpointType(), -1, address, true, 0, "" ); //$NON-NLS-1$ + @Override + protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address) + throws CoreException { + ICDynamicPrintf dprintf = (ICDynamicPrintf) CDIDebugModel.createBlankAddressDynamicPrintf(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setAddressBreakpointAttributes(attributes, null, null, getBreakpointType(), -1, address, true, 0, + ""); //$NON-NLS-1$ - String format = getAddressFormat(address); + String format = getAddressFormat(address); String printfStr = NLS.bind(Messages.Default_AddressDynamicPrintf_String, address, format); - attributes.put(ICDynamicPrintf.PRINTF_STRING, printfStr); + attributes.put(ICDynamicPrintf.PRINTF_STRING, printfStr); - openBreakpointPropertiesDialog(dprintf, part, resource, attributes); - } + openBreakpointPropertiesDialog(dprintf, part, resource, attributes); + } protected int getBreakpointType() { return ICBreakpointType.REGULAR; @@ -107,7 +108,7 @@ public class DisassemblyToggleDynamicPrintfTarget extends AbstractDisassemblyBre * Escape embedded backslashes for inclusion in C string. */ private static String escapeBackslashes(String str) { - return str.replaceAll(Pattern.quote("\\"), "\\\\\\\\"); //$NON-NLS-1$//$NON-NLS-2$ + return str.replaceAll(Pattern.quote("\\"), "\\\\\\\\"); //$NON-NLS-1$//$NON-NLS-2$ } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleTracepointsTarget.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleTracepointsTarget.java index 87c156d47f0..f2d4d80f32e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleTracepointsTarget.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleTracepointsTarget.java @@ -39,36 +39,35 @@ public class DisassemblyToggleTracepointsTarget extends AbstractDisassemblyBreak protected void createLineBreakpoint(String sourceHandle, IResource resource, int lineNumber) throws CoreException { CDIDebugModel.createLineTracepoint(sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", true); //$NON-NLS-1$ } - + @Override - protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource, int lineNumber) - throws CoreException - { + protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource, + int lineNumber) throws CoreException { ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineTracepoint(); Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setLineBreakpointAttributes( - attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$ + CDIDebugModel.setLineBreakpointAttributes(attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, + ""); //$NON-NLS-1$ openBreakpointPropertiesDialog(lineBp, part, resource, attributes); } - + /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.AbstractDisassemblyBreakpointsTarget#createAddressBreakpoint(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.IAddress) */ @Override protected void createAddressBreakpoint(IResource resource, IAddress address) throws CoreException { - CDIDebugModel.createAddressTracepoint(null, null, resource, getBreakpointType(), -1, address, true, 0, "", true); //$NON-NLS-1$ + CDIDebugModel.createAddressTracepoint(null, null, resource, getBreakpointType(), -1, address, true, 0, "", //$NON-NLS-1$ + true); } - @Override - protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address) - throws CoreException - { - ICLineBreakpoint lineBp = CDIDebugModel.createBlankAddressTracepoint(); - Map<String, Object> attributes = new HashMap<String, Object>(); - CDIDebugModel.setAddressBreakpointAttributes( - attributes, null, null, getBreakpointType(), -1, address, true, 0, "" ); //$NON-NLS-1$ - openBreakpointPropertiesDialog(lineBp, part, resource, attributes); - } + @Override + protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address) + throws CoreException { + ICLineBreakpoint lineBp = CDIDebugModel.createBlankAddressTracepoint(); + Map<String, Object> attributes = new HashMap<String, Object>(); + CDIDebugModel.setAddressBreakpointAttributes(attributes, null, null, getBreakpointType(), -1, address, true, 0, + ""); //$NON-NLS-1$ + openBreakpointPropertiesDialog(lineBp, part, resource, attributes); + } protected int getBreakpointType() { return ICBreakpointType.REGULAR; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBDynamicPrintfPropertyPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBDynamicPrintfPropertyPage.java index 6c650f93a48..0ceb1eae21c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBDynamicPrintfPropertyPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBDynamicPrintfPropertyPage.java @@ -11,7 +11,7 @@ * Contributors: * Marc Khouzam (Ericsson) - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; +package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; @@ -49,7 +49,7 @@ import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.model.IWorkbenchAdapter; /** - * The preference page used to present the properties of a GDB dynamic printf as preferences. + * The preference page used to present the properties of a GDB dynamic printf as preferences. */ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage { @@ -75,7 +75,7 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl /** * Only store if the text control is enabled - * + * * @see FieldEditor#doStore() */ @Override @@ -93,12 +93,11 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl protected void clearErrorMessage() { if (getPage() != null) { String message = getPage().getErrorMessage(); - if ( message != null ) { + if (message != null) { if (getErrorMessage().equals(message)) { super.clearErrorMessage(); } - } - else { + } else { super.clearErrorMessage(); } } @@ -131,11 +130,11 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl super.doStore(); } } - + @Override - protected void doLoad() { + protected void doLoad() { String value = getPreferenceStore().getString(getPreferenceName()); - setStringValue(value); + setStringValue(value); } /** @@ -145,12 +144,11 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl protected void clearErrorMessage() { if (getPage() != null) { String message = getPage().getErrorMessage(); - if ( message != null ) { + if (message != null) { if (getErrorMessage().equals(message)) { super.clearErrorMessage(); } - } - else { + } else { super.clearErrorMessage(); } } @@ -171,6 +169,7 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl textField.setText(fValue); } } + @Override protected void doLoadDefault() { // nothing @@ -185,22 +184,21 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl private Text fIgnoreCountTextControl; private DynamicPrintfIntegerFieldEditor fLineEditor; private DynamicPrintfIntegerFieldEditor fIgnoreCount; - - /** + + /** * Indicates if the page currently aims to create * a breakpoint that already exits. */ private boolean fDuplicateBreakpoint; - private DynamicPrintfStringFieldEditor fPrintString; private IAdaptable fElement; /** - * The preference store used to interface between the dynamic printf and the + * The preference store used to interface between the dynamic printf and the * dynamic printf preference page. This preference store is initialized only - * when the preference store cannot be retrieved from the preference + * when the preference store cannot be retrieved from the preference * dialog's element. * @see #getPreferenceStore() */ @@ -223,24 +221,21 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl } private void createMainLabel(ICDynamicPrintf dprintf) { - addField(createLabelEditor(getFieldEditorParent(), - Messages.PropertyPage_Class, - getDynamicPrintfMainLabel(dprintf))); + addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_Class, + getDynamicPrintfMainLabel(dprintf))); } private void createTypeSpecificLabelFieldEditors(ICDynamicPrintf dprintf) { if (dprintf instanceof ICFunctionBreakpoint) { - createFunctionEditor(getFieldEditorParent()); - } - else if (dprintf instanceof ICAddressBreakpoint) { + createFunctionEditor(getFieldEditorParent()); + } else if (dprintf instanceof ICAddressBreakpoint) { String address = getPreferenceStore().getString(ICLineBreakpoint.ADDRESS); if (address == null || address.trim().length() == 0) { address = Messages.PropertyPage_NotAvailable; } addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_Address, address)); - } - else { // LineDprintf - String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); + } else { // LineDprintf + String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); if (fileName != null) { addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_File, fileName)); } @@ -252,70 +247,74 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl } private String getDynamicPrintfMainLabel(ICDynamicPrintf dprintf) { - IWorkbenchAdapter labelProvider = getElement().getAdapter(IWorkbenchAdapter.class); - if (labelProvider != null) { - return labelProvider.getLabel(getElement()); - } - // default main label is the label of marker type for the dynamic printf - return CDIDebugModel.calculateMarkerType(dprintf); + IWorkbenchAdapter labelProvider = getElement().getAdapter(IWorkbenchAdapter.class); + if (labelProvider != null) { + return labelProvider.getLabel(getElement()); + } + // default main label is the label of marker type for the dynamic printf + return CDIDebugModel.calculateMarkerType(dprintf); + } + + protected void createFunctionEditor(Composite parent) { + ICDynamicPrintf dprintf = getDprintf(); + if (dprintf == null || dprintf.getMarker() == null) { + DynamicPrintfStringFieldEditor expressionEditor = new DynamicPrintfStringFieldEditor( + ICLineBreakpoint.FUNCTION, Messages.PropertyPage_FunctionName, parent); + expressionEditor.setErrorMessage(Messages.PropertyPage_function_value_errorMessage); + expressionEditor.setEmptyStringAllowed(false); + addField(expressionEditor); + } else { + String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION); + if (function == null) { + function = Messages.PropertyPage_NotAvailable; + } + addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_FunctionName, function)); + } } - - protected void createFunctionEditor(Composite parent) { - ICDynamicPrintf dprintf = getDprintf(); - if (dprintf == null || dprintf.getMarker() == null) { - DynamicPrintfStringFieldEditor expressionEditor = new DynamicPrintfStringFieldEditor( - ICLineBreakpoint.FUNCTION, Messages.PropertyPage_FunctionName, parent); - expressionEditor.setErrorMessage(Messages.PropertyPage_function_value_errorMessage); - expressionEditor.setEmptyStringAllowed(false); - addField(expressionEditor); - } else { - String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION); - if (function == null) { - function = Messages.PropertyPage_NotAvailable; - } - addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_FunctionName, function)); - } - } + protected void createLineNumberEditor(Composite parent) { - String title = Messages.PropertyPage_LineNumber; - fLineEditor = new DynamicPrintfIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent); - fLineEditor.setValidRange(1, Integer.MAX_VALUE); - fLineEditor.setErrorMessage(Messages.PropertyPage_lineNumber_errorMessage); - addField(fLineEditor); + String title = Messages.PropertyPage_LineNumber; + fLineEditor = new DynamicPrintfIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent); + fLineEditor.setValidRange(1, Integer.MAX_VALUE); + fLineEditor.setErrorMessage(Messages.PropertyPage_lineNumber_errorMessage); + addField(fLineEditor); } - + protected void createEnabledField(Composite parent) { fEnabled = new BooleanFieldEditor(ICBreakpoint.ENABLED, Messages.PropertyPage_Enabled, parent); addField(fEnabled); } protected void createConditionEditor(Composite parent) { - fCondition = new DynamicPrintfStringFieldEditor(ICBreakpoint.CONDITION, Messages.PropertyPage_Condition, parent); + fCondition = new DynamicPrintfStringFieldEditor(ICBreakpoint.CONDITION, Messages.PropertyPage_Condition, + parent); fCondition.setEmptyStringAllowed(true); fCondition.setErrorMessage(Messages.PropertyPage_InvalidCondition); addField(fCondition); } protected void createIgnoreCountEditor(Composite parent) { - fIgnoreCount = new DynamicPrintfIntegerFieldEditor(ICBreakpoint.IGNORE_COUNT, Messages.PropertyPage_IgnoreCount, parent); + fIgnoreCount = new DynamicPrintfIntegerFieldEditor(ICBreakpoint.IGNORE_COUNT, Messages.PropertyPage_IgnoreCount, + parent); fIgnoreCount.setValidRange(0, Integer.MAX_VALUE); fIgnoreCountTextControl = fIgnoreCount.getTextControl(parent); - fIgnoreCountTextControl.setEnabled( getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0 ); + fIgnoreCountTextControl.setEnabled(getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0); addField(fIgnoreCount); } protected void createPrintStringEditor(Composite parent) { - fPrintString = new DynamicPrintfStringFieldEditor(ICDynamicPrintf.PRINTF_STRING, Messages.DynamicPrintfPropertyPage_PrintString, parent) { + fPrintString = new DynamicPrintfStringFieldEditor(ICDynamicPrintf.PRINTF_STRING, + Messages.DynamicPrintfPropertyPage_PrintString, parent) { @Override protected boolean doCheckState() { - GDBDynamicPrintfUtils.GDBDynamicPrintfString parsedStr = - new GDBDynamicPrintfUtils.GDBDynamicPrintfString(getTextControl().getText()); - + GDBDynamicPrintfUtils.GDBDynamicPrintfString parsedStr = new GDBDynamicPrintfUtils.GDBDynamicPrintfString( + getTextControl().getText()); + boolean valid = parsedStr.isValid(); if (!valid) { setErrorMessage(parsedStr.getErrorMessage()); } - + return valid; } }; @@ -327,14 +326,13 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl // Don't allow to create a duplicate breakpoint return super.isValid() && !fDuplicateBreakpoint; } - + @Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); ICBreakpoint currentBp = getDprintf(); - if (!(currentBp instanceof ICFunctionBreakpoint) && - !(currentBp instanceof ICAddressBreakpoint)) { + if (!(currentBp instanceof ICFunctionBreakpoint) && !(currentBp instanceof ICAddressBreakpoint)) { // Check for duplication of line dprintf if (event.getProperty().equals(FieldEditor.VALUE)) { if (super.isValid()) { @@ -345,7 +343,8 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl fDuplicateBreakpoint = isDuplicateBreakpoint(); if (oldValue != fDuplicateBreakpoint) { if (fDuplicateBreakpoint) { - setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$ + setErrorMessage(BreakpointsMessages + .getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$ } else { setErrorMessage(null); } @@ -356,11 +355,11 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl // update page state updateApplyButton(); } - } + } } } } - + private boolean isDuplicateBreakpoint() { String source = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); int line = fLineEditor.getIntValue(); @@ -386,7 +385,7 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl } return false; } - + protected FieldEditor createLabelEditor(Composite parent, String title, String value) { return new LabelFieldEditor(parent, title, value); } @@ -394,13 +393,13 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl protected ICDynamicPrintf getDprintf() { IAdaptable element = getElement(); if (element instanceof ICDynamicPrintf) { - return (ICDynamicPrintf)element; + return (ICDynamicPrintf) element; } - + if (element instanceof ICBreakpointContext) { - ICBreakpoint breakpoint =((ICBreakpointContext)element).getBreakpoint(); + ICBreakpoint breakpoint = ((ICBreakpointContext) element).getBreakpoint(); if (breakpoint instanceof ICDynamicPrintf) { - return (ICDynamicPrintf)breakpoint; + return (ICDynamicPrintf) breakpoint; } assert false : "Should always have a dprintf"; //$NON-NLS-1$ } @@ -409,68 +408,66 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl } protected Object getDebugContext() { - IDebugContextProvider provider = getElement().getAdapter(IDebugContextProvider.class); - if (provider != null) { - ISelection selection = provider.getActiveContext(); - if (selection instanceof IStructuredSelection) { - return ((IStructuredSelection) selection).getFirstElement(); - } - return null; - } - return DebugUITools.getDebugContext(); + IDebugContextProvider provider = getElement().getAdapter(IDebugContextProvider.class); + if (provider != null) { + ISelection selection = provider.getActiveContext(); + if (selection instanceof IStructuredSelection) { + return ((IStructuredSelection) selection).getFirstElement(); + } + return null; + } + return DebugUITools.getDebugContext(); } - protected IResource getResource() { - IAdaptable element = getElement(); - if (element instanceof ICDynamicPrintf) { - IMarker marker = ((ICDynamicPrintf)element).getMarker(); - if (marker != null) { - return marker.getResource(); - } - } else if (element instanceof ICBreakpointContext) { - return ((ICBreakpointContext)element).getResource(); - } - return null; + IAdaptable element = getElement(); + if (element instanceof ICDynamicPrintf) { + IMarker marker = ((ICDynamicPrintf) element).getMarker(); + if (marker != null) { + return marker.getResource(); + } + } else if (element instanceof ICBreakpointContext) { + return ((ICBreakpointContext) element).getResource(); + } + return null; } @Override public IPreferenceStore getPreferenceStore() { - IAdaptable element = getElement(); - if (element instanceof ICBreakpointContext) { - return ((ICBreakpointContext)element).getPreferenceStore(); - } - - if (fDynamicPrintfPreferenceStore == null) { - CBreakpointContext bpContext = element instanceof CBreakpointContext ? - (CBreakpointContext)element : null; - fDynamicPrintfPreferenceStore = new CBreakpointPreferenceStore(bpContext, null); - } - return fDynamicPrintfPreferenceStore; + IAdaptable element = getElement(); + if (element instanceof ICBreakpointContext) { + return ((ICBreakpointContext) element).getPreferenceStore(); + } + + if (fDynamicPrintfPreferenceStore == null) { + CBreakpointContext bpContext = element instanceof CBreakpointContext ? (CBreakpointContext) element : null; + fDynamicPrintfPreferenceStore = new CBreakpointPreferenceStore(bpContext, null); + } + return fDynamicPrintfPreferenceStore; } @Override public boolean performCancel() { - IPreferenceStore store = getPreferenceStore(); - if (store instanceof CBreakpointPreferenceStore) { - ((CBreakpointPreferenceStore)store).setCanceled(true); - } - return super.performCancel(); + IPreferenceStore store = getPreferenceStore(); + if (store instanceof CBreakpointPreferenceStore) { + ((CBreakpointPreferenceStore) store).setCanceled(true); + } + return super.performCancel(); } @Override - public boolean performOk() { - IPreferenceStore store = getPreferenceStore(); - if (store instanceof CBreakpointPreferenceStore) { - ((CBreakpointPreferenceStore)store).setCanceled(false); - } - return super.performOk(); - } - + public boolean performOk() { + IPreferenceStore store = getPreferenceStore(); + if (store instanceof CBreakpointPreferenceStore) { + ((CBreakpointPreferenceStore) store).setCanceled(false); + } + return super.performOk(); + } + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement() */ - @Override + @Override public IAdaptable getElement() { return fElement; } @@ -478,26 +475,25 @@ public class GDBDynamicPrintfPropertyPage extends FieldEditorPreferencePage impl /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable) */ - @Override + @Override public void setElement(IAdaptable element) { - if (element instanceof ICBreakpoint) { - fElement = new CBreakpointContext((ICBreakpoint)element, null); - } - else { + if (element instanceof ICBreakpoint) { + fElement = new CBreakpointContext((ICBreakpoint) element, null); + } else { fElement = element; } } protected String[] getDebugModelIds() { - String[] debugModelIds = null; - Object debugContext = getDebugContext(); - IDebugModelProvider debugModelProvider = (IDebugModelProvider) - DebugPlugin.getAdapter(debugContext, IDebugModelProvider.class); - if (debugModelProvider != null) { - debugModelIds = debugModelProvider.getModelIdentifiers(); - } else if (debugContext instanceof IDebugElement) { - debugModelIds = new String[] { ((IDebugElement)debugContext).getModelIdentifier() }; - } - return debugModelIds; + String[] debugModelIds = null; + Object debugContext = getDebugContext(); + IDebugModelProvider debugModelProvider = (IDebugModelProvider) DebugPlugin.getAdapter(debugContext, + IDebugModelProvider.class); + if (debugModelProvider != null) { + debugModelIds = debugModelProvider.getModelIdentifiers(); + } else if (debugContext instanceof IDebugElement) { + debugModelIds = new String[] { ((IDebugElement) debugContext).getModelIdentifier() }; + } + return debugModelIds; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java index 57a8fbe356d..15acced2a7c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java @@ -14,7 +14,7 @@ * before creating the tracepoint (Bug 376116) * Marc Khouzam (Ericsson) - Support for dynamic printf (bug 400628) *******************************************************************************/ -package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; +package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints; import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; @@ -51,7 +51,7 @@ import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.model.IWorkbenchAdapter; /** - * The preference page used to present the properties of a GDB tracepoint as preferences. + * The preference page used to present the properties of a GDB tracepoint as preferences. */ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage { @@ -77,7 +77,7 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme /** * Only store if the text control is enabled - * + * * @see FieldEditor#doStore() */ @Override @@ -95,12 +95,11 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme protected void clearErrorMessage() { if (getPage() != null) { String message = getPage().getErrorMessage(); - if ( message != null ) { + if (message != null) { if (getErrorMessage().equals(message)) { super.clearErrorMessage(); } - } - else { + } else { super.clearErrorMessage(); } } @@ -133,11 +132,11 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme super.doStore(); } } - + @Override - protected void doLoad() { + protected void doLoad() { String value = getPreferenceStore().getString(getPreferenceName()); - setStringValue(value); + setStringValue(value); } /** @@ -147,12 +146,11 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme protected void clearErrorMessage() { if (getPage() != null) { String message = getPage().getErrorMessage(); - if ( message != null ) { + if (message != null) { if (getErrorMessage().equals(message)) { super.clearErrorMessage(); } - } - else { + } else { super.clearErrorMessage(); } } @@ -173,6 +171,7 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme textField.setText(fValue); } } + @Override protected void doLoadDefault() { // nothing @@ -185,11 +184,11 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme private TracepointStringFieldEditor fCondition; private Text fIgnoreCountTextControl; - + private TracepointIntegerFieldEditor fLineEditor; private TracepointIntegerFieldEditor fIgnoreCount; - - /** + + /** * Indicates if the page currently aims to create * a breakpoint that already exits. */ @@ -201,9 +200,9 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme private IAdaptable fElement; /** - * The preference store used to interface between the tracepoint and the + * The preference store used to interface between the tracepoint and the * tracepoint preference page. This preference store is initialized only - * when the preference store cannot be retrieved from the preference + * when the preference store cannot be retrieved from the preference * dialog's element. * @see #getPreferenceStore() */ @@ -211,7 +210,7 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme /** * Constructor for GDBTracepointPropertyPage. - * + * */ public GDBTracepointPropertyPage() { super(GRID); @@ -231,24 +230,21 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme } private void createMainLabel(ICTracepoint tracepoint) { - addField(createLabelEditor(getFieldEditorParent(), - Messages.PropertyPage_Class, - getTracepointMainLabel(tracepoint))); + addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_Class, + getTracepointMainLabel(tracepoint))); } private void createTypeSpecificLabelFieldEditors(ICTracepoint tracepoint) { if (tracepoint instanceof ICFunctionBreakpoint) { - createFunctionEditor(getFieldEditorParent()); - } - else if (tracepoint instanceof ICAddressBreakpoint) { + createFunctionEditor(getFieldEditorParent()); + } else if (tracepoint instanceof ICAddressBreakpoint) { String address = getPreferenceStore().getString(ICLineBreakpoint.ADDRESS); if (address == null || address.trim().length() == 0) { address = Messages.PropertyPage_NotAvailable; } addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_Address, address)); - } - else { // LineTracepoint - String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); + } else { // LineTracepoint + String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); if (fileName != null) { addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_File, fileName)); } @@ -260,38 +256,39 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme } private String getTracepointMainLabel(ICTracepoint tracepoint) { - IWorkbenchAdapter labelProvider = getElement().getAdapter(IWorkbenchAdapter.class); - if (labelProvider != null) { - return labelProvider.getLabel(getElement()); - } - // default main label is the label of marker type for the tracepoint - return CDIDebugModel.calculateMarkerType(tracepoint); + IWorkbenchAdapter labelProvider = getElement().getAdapter(IWorkbenchAdapter.class); + if (labelProvider != null) { + return labelProvider.getLabel(getElement()); + } + // default main label is the label of marker type for the tracepoint + return CDIDebugModel.calculateMarkerType(tracepoint); } - - protected void createFunctionEditor(Composite parent) { - ICTracepoint tracepoint = getTracepoint(); - if (tracepoint == null || tracepoint.getMarker() == null) { - TracepointStringFieldEditor expressionEditor = new TracepointStringFieldEditor( - ICLineBreakpoint.FUNCTION, Messages.PropertyPage_FunctionName, parent); - expressionEditor.setErrorMessage(Messages.PropertyPage_function_value_errorMessage); - expressionEditor.setEmptyStringAllowed(false); - addField(expressionEditor); - } else { - String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION); - if (function == null) { - function = Messages.PropertyPage_NotAvailable; - } - addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_FunctionName, function)); - } - } + + protected void createFunctionEditor(Composite parent) { + ICTracepoint tracepoint = getTracepoint(); + if (tracepoint == null || tracepoint.getMarker() == null) { + TracepointStringFieldEditor expressionEditor = new TracepointStringFieldEditor(ICLineBreakpoint.FUNCTION, + Messages.PropertyPage_FunctionName, parent); + expressionEditor.setErrorMessage(Messages.PropertyPage_function_value_errorMessage); + expressionEditor.setEmptyStringAllowed(false); + addField(expressionEditor); + } else { + String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION); + if (function == null) { + function = Messages.PropertyPage_NotAvailable; + } + addField(createLabelEditor(getFieldEditorParent(), Messages.PropertyPage_FunctionName, function)); + } + } + protected void createLineNumberEditor(Composite parent) { - String title = Messages.PropertyPage_LineNumber; - fLineEditor = new TracepointIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent); - fLineEditor.setValidRange(1, Integer.MAX_VALUE); - fLineEditor.setErrorMessage(Messages.PropertyPage_lineNumber_errorMessage); - addField(fLineEditor); + String title = Messages.PropertyPage_LineNumber; + fLineEditor = new TracepointIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent); + fLineEditor.setValidRange(1, Integer.MAX_VALUE); + fLineEditor.setErrorMessage(Messages.PropertyPage_lineNumber_errorMessage); + addField(fLineEditor); } - + protected void createEnabledField(Composite parent) { fEnabled = new BooleanFieldEditor(ICBreakpoint.ENABLED, Messages.PropertyPage_Enabled, parent); addField(fEnabled); @@ -305,15 +302,17 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme } protected void createIgnoreCountEditor(Composite parent) { - fIgnoreCount = new TracepointIntegerFieldEditor(ICBreakpoint.IGNORE_COUNT, Messages.PropertyPage_IgnoreCount, parent); + fIgnoreCount = new TracepointIntegerFieldEditor(ICBreakpoint.IGNORE_COUNT, Messages.PropertyPage_IgnoreCount, + parent); fIgnoreCount.setValidRange(0, Integer.MAX_VALUE); fIgnoreCountTextControl = fIgnoreCount.getTextControl(parent); - fIgnoreCountTextControl.setEnabled( getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0 ); + fIgnoreCountTextControl.setEnabled(getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0); addField(fIgnoreCount); } protected void createPassCountEditor(Composite parent) { - fPassCount = new TracepointIntegerFieldEditor(ICTracepoint.PASS_COUNT, Messages.TracepointPropertyPage_PassCount, parent); + fPassCount = new TracepointIntegerFieldEditor(ICTracepoint.PASS_COUNT, + Messages.TracepointPropertyPage_PassCount, parent); fPassCount.setValidRange(0, Integer.MAX_VALUE); fPassCountTextControl = fPassCount.getTextControl(parent); fPassCountTextControl.setEnabled(getPreferenceStore().getInt(ICTracepoint.PASS_COUNT) >= 0); @@ -329,14 +328,13 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme // Don't allow to create a duplicate breakpoint return super.isValid() && !fDuplicateBreakpoint; } - + @Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); ICBreakpoint currentBp = getTracepoint(); - if (!(currentBp instanceof ICFunctionBreakpoint) && - !(currentBp instanceof ICAddressBreakpoint)) { + if (!(currentBp instanceof ICFunctionBreakpoint) && !(currentBp instanceof ICAddressBreakpoint)) { // Check for duplication of line tracepoints if (event.getProperty().equals(FieldEditor.VALUE)) { @@ -348,7 +346,8 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme fDuplicateBreakpoint = isDuplicateBreakpoint(); if (oldValue != fDuplicateBreakpoint) { if (fDuplicateBreakpoint) { - setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$ + setErrorMessage(BreakpointsMessages + .getString("CBreakpointPropertyPage.breakpoint_already_exists_errorMessage")); //$NON-NLS-1$ } else { setErrorMessage(null); } @@ -363,7 +362,7 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme } } } - + private boolean isDuplicateBreakpoint() { String source = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE); int line = fLineEditor.getIntValue(); @@ -389,17 +388,17 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme } return false; } - + protected ICTracepoint getTracepoint() { IAdaptable element = getElement(); if (element instanceof ICTracepoint) { - return (ICTracepoint)element; + return (ICTracepoint) element; } - + if (element instanceof ICBreakpointContext) { - ICBreakpoint breakpoint =((ICBreakpointContext)element).getBreakpoint(); + ICBreakpoint breakpoint = ((ICBreakpointContext) element).getBreakpoint(); if (breakpoint instanceof ICTracepoint) { - return (ICTracepoint)breakpoint; + return (ICTracepoint) breakpoint; } assert false : "Should always have a tracepoint"; //$NON-NLS-1$ } @@ -408,68 +407,66 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme } protected Object getDebugContext() { - IDebugContextProvider provider = getElement().getAdapter(IDebugContextProvider.class); - if (provider != null) { - ISelection selection = provider.getActiveContext(); - if (selection instanceof IStructuredSelection) { - return ((IStructuredSelection) selection).getFirstElement(); - } - return null; - } - return DebugUITools.getDebugContext(); + IDebugContextProvider provider = getElement().getAdapter(IDebugContextProvider.class); + if (provider != null) { + ISelection selection = provider.getActiveContext(); + if (selection instanceof IStructuredSelection) { + return ((IStructuredSelection) selection).getFirstElement(); + } + return null; + } + return DebugUITools.getDebugContext(); } - protected IResource getResource() { - IAdaptable element = getElement(); - if (element instanceof ICTracepoint) { - IMarker marker = ((ICTracepoint)element).getMarker(); - if (marker != null) { - return marker.getResource(); - } - } else if (element instanceof ICBreakpointContext) { - return ((ICBreakpointContext)element).getResource(); - } - return null; + IAdaptable element = getElement(); + if (element instanceof ICTracepoint) { + IMarker marker = ((ICTracepoint) element).getMarker(); + if (marker != null) { + return marker.getResource(); + } + } else if (element instanceof ICBreakpointContext) { + return ((ICBreakpointContext) element).getResource(); + } + return null; } @Override public IPreferenceStore getPreferenceStore() { - IAdaptable element = getElement(); - if (element instanceof ICBreakpointContext) { - return ((ICBreakpointContext)element).getPreferenceStore(); - } - - if (fTracepointPreferenceStore == null) { - CBreakpointContext bpContext = element instanceof CBreakpointContext ? - (CBreakpointContext)element : null; - fTracepointPreferenceStore = new CBreakpointPreferenceStore(bpContext, null); - } - return fTracepointPreferenceStore; + IAdaptable element = getElement(); + if (element instanceof ICBreakpointContext) { + return ((ICBreakpointContext) element).getPreferenceStore(); + } + + if (fTracepointPreferenceStore == null) { + CBreakpointContext bpContext = element instanceof CBreakpointContext ? (CBreakpointContext) element : null; + fTracepointPreferenceStore = new CBreakpointPreferenceStore(bpContext, null); + } + return fTracepointPreferenceStore; } @Override public boolean performCancel() { - IPreferenceStore store = getPreferenceStore(); - if (store instanceof CBreakpointPreferenceStore) { - ((CBreakpointPreferenceStore)store).setCanceled(true); - } - return super.performCancel(); + IPreferenceStore store = getPreferenceStore(); + if (store instanceof CBreakpointPreferenceStore) { + ((CBreakpointPreferenceStore) store).setCanceled(true); + } + return super.performCancel(); } @Override - public boolean performOk() { - IPreferenceStore store = getPreferenceStore(); - if (store instanceof CBreakpointPreferenceStore) { - ((CBreakpointPreferenceStore)store).setCanceled(false); - } - return super.performOk(); - } - + public boolean performOk() { + IPreferenceStore store = getPreferenceStore(); + if (store instanceof CBreakpointPreferenceStore) { + ((CBreakpointPreferenceStore) store).setCanceled(false); + } + return super.performOk(); + } + /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement() */ - @Override + @Override public IAdaptable getElement() { return fElement; } @@ -477,26 +474,25 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable) */ - @Override + @Override public void setElement(IAdaptable element) { - if (element instanceof ICBreakpoint) { - fElement = new CBreakpointContext((ICBreakpoint)element, null); - } - else { + if (element instanceof ICBreakpoint) { + fElement = new CBreakpointContext((ICBreakpoint) element, null); + } else { fElement = element; } } protected String[] getDebugModelIds() { - String[] debugModelIds = null; - Object debugContext = getDebugContext(); - IDebugModelProvider debugModelProvider = (IDebugModelProvider) - DebugPlugin.getAdapter(debugContext, IDebugModelProvider.class); - if (debugModelProvider != null) { - debugModelIds = debugModelProvider.getModelIdentifiers(); - } else if (debugContext instanceof IDebugElement) { - debugModelIds = new String[] { ((IDebugElement)debugContext).getModelIdentifier() }; - } - return debugModelIds; + String[] debugModelIds = null; + Object debugContext = getDebugContext(); + IDebugModelProvider debugModelProvider = (IDebugModelProvider) DebugPlugin.getAdapter(debugContext, + IDebugModelProvider.class); + if (debugModelProvider != null) { + debugModelIds = debugModelProvider.getModelIdentifiers(); + } else if (debugContext instanceof IDebugElement) { + debugModelIds = new String[] { ((IDebugElement) debugContext).getModelIdentifier() }; + } + return debugModelIds; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GdbThreadFilterEditor.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GdbThreadFilterEditor.java index 3110afef116..10e2e8663bd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GdbThreadFilterEditor.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GdbThreadFilterEditor.java @@ -65,498 +65,497 @@ import org.eclipse.swt.widgets.Label; public class GdbThreadFilterEditor { - public class CheckHandler implements ICheckStateListener { - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) - */ - @Override - public void checkStateChanged(CheckStateChangedEvent event) { - Object element = event.getElement(); - if (element instanceof IContainerDMContext) { - checkTarget((IContainerDMContext) element, event.getChecked()); - } else if (element instanceof IExecutionDMContext) { - checkThread((IExecutionDMContext) element, event.getChecked()); - } - } - - /** - * Check or uncheck a debug target in the tree viewer. When a debug - * target is checked, attempt to check all of the target's threads by - * default. When a debug target is unchecked, uncheck all its threads. - */ - protected void checkTarget(IContainerDMContext target, boolean checked) { - getThreadViewer().setChecked(target, checked); - getThreadViewer().setGrayed(target, false); - getThreadViewer().expandToLevel(target, AbstractTreeViewer.ALL_LEVELS); - IExecutionDMContext[] threads = syncGetThreads(target); - for (int i = 0; i < threads.length; i++) { - getThreadViewer().setChecked(threads[i], checked); - getThreadViewer().setGrayed(threads[i], false); - } - } - - /** - * Check or uncheck a thread. Update the thread's debug target. - */ - protected void checkThread(IExecutionDMContext thread, boolean checked) { - getThreadViewer().setChecked(thread, checked); - IContainerDMContext target = DMContexts.getAncestorOfType(thread, IContainerDMContext.class); - IExecutionDMContext[] threads = syncGetThreads(target); - int checkedNumber = 0; - for (int i = 0; i < threads.length; i++) { - if (getThreadViewer().getChecked(threads[i])) { - ++checkedNumber; - } - } - if (checkedNumber == 0) { - getThreadViewer().setChecked(target, false); - getThreadViewer().setGrayed(target, false); - } else if (checkedNumber == threads.length) { - getThreadViewer().setChecked(target, true); - getThreadViewer().setGrayed(target, false); - } else { - getThreadViewer().setGrayChecked(target, true); - } - } - } - - public class ThreadFilterContentProvider implements ITreeContentProvider { - - public ThreadFilterContentProvider() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ - @Override - public Object[] getChildren(Object parent) { - if (parent instanceof IContainerDMContext) { - return syncGetThreads((IContainerDMContext) parent); - } - - if (parent instanceof ILaunchManager) { - List<Object> children = new ArrayList<Object>(); - ILaunch[] launches = ((ILaunchManager) parent).getLaunches(); - IContainerDMContext[] targetArray; - for (int i = 0; i < launches.length; i++) { - if (launches[i] instanceof GdbLaunch) { - targetArray = syncGetContainers((GdbLaunch) launches[i]); - children.addAll(Arrays.asList(targetArray)); - } - } - return children.toArray(); - } - return new Object[0]; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) - */ - @Override - public Object getParent(Object element) { - if (element instanceof IContainerDMContext) { - return DebugPlugin.getDefault().getLaunchManager(); - } - if (element instanceof IExecutionDMContext) { - return DMContexts.getAncestorOfType((IExecutionDMContext) element, IContainerDMContext.class); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) - */ - @Override - public boolean hasChildren(Object element) { - return getChildren(element).length > 0; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - @Override - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - @Override - public void dispose() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - } - - public class ThreadFilterLabelProvider extends LabelProvider { - - @Override - public Image getImage(Object element) { - if (element instanceof IContainerDMContext) { - return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET); - } else { - return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING); - } - } - - @Override - public String getText(Object element) { - if (element instanceof IContainerDMContext) { - return syncGetContainerLabel((IContainerDMContext)element); - } else { - return syncGetThreadLabel((IExecutionDMContext)element); - } - } - } - - - private CBreakpointGdbThreadFilterPage fPage; - - private CheckboxTreeViewer fThreadViewer; - - private ThreadFilterContentProvider fContentProvider; - - private CheckHandler fCheckHandler; - - public GdbThreadFilterEditor(Composite parent, CBreakpointGdbThreadFilterPage page) { - fPage = page; - fContentProvider = new ThreadFilterContentProvider(); - fCheckHandler = new CheckHandler(); - createThreadViewer(parent); - } - - protected CBreakpointGdbThreadFilterPage getPage() { - return fPage; - } - - private void createThreadViewer(Composite parent) { - Label label = new Label(parent, SWT.NONE); - label.setText(Messages.GdbThreadFilterEditor_RestrictToSelected); - label.setFont(parent.getFont()); - label.setLayoutData(new GridData()); - GridData data = new GridData(GridData.FILL_BOTH); - data.heightHint = 100; - fThreadViewer = new CheckboxTreeViewer(parent, SWT.BORDER); - fThreadViewer.addCheckStateListener(fCheckHandler); - fThreadViewer.getTree().setLayoutData(data); - fThreadViewer.getTree().setFont(parent.getFont()); - fThreadViewer.setContentProvider(fContentProvider); - fThreadViewer.setLabelProvider(new ThreadFilterLabelProvider()); - fThreadViewer.setInput(DebugPlugin.getDefault().getLaunchManager()); - setInitialCheckedState(); - } - - /** - * Returns the debug targets that appear in the tree - */ - protected IContainerDMContext[] getDebugTargets() { - Object input = fThreadViewer.getInput(); - if (!(input instanceof ILaunchManager)) { - return new IContainerDMContext[0]; - } - List<Object> targets = new ArrayList<Object>(); - ILaunch[] launches = ((ILaunchManager) input).getLaunches(); - IContainerDMContext[] targetArray; - for (int i = 0; i < launches.length; i++) { - if (launches[i] instanceof GdbLaunch) { - targetArray = syncGetContainers((GdbLaunch) launches[i]); - targets.addAll(Arrays.asList(targetArray)); - } - } - return targets.toArray(new IContainerDMContext[targets.size()]); - } - - protected CheckboxTreeViewer getThreadViewer() { - return fThreadViewer; - } - - /** - * Sets the initial checked state of the tree viewer. The initial state - * should reflect the current state of the breakpoint. If the breakpoint has - * a thread filter in a given thread, that thread should be checked. - */ - protected void setInitialCheckedState() { - IDsfBreakpointExtension filterExtension = fPage.getFilterExtension(); - try { - IContainerDMContext[] targets = filterExtension.getTargetFilters(); - - for (int i = 0; i < targets.length; i++) { - IExecutionDMContext[] filteredThreads = filterExtension.getThreadFilters(targets[i]); - if (filteredThreads != null) { - for (int j = 0; j < filteredThreads.length; ++j) { - // Mark this thread as selected - fCheckHandler.checkThread(filteredThreads[j], true); - } - } else { - // Mark the entire process as selected - fCheckHandler.checkTarget(targets[i], true); - } - } - } catch (CoreException e) { - CDebugUIPlugin.log(e); - } - } - - protected void doStore() { - IDsfBreakpointExtension filterExtension = fPage.getFilterExtension(); - IContainerDMContext[] targets = getDebugTargets(); - for (int i = 0; i < targets.length; ++i) { - try { - if (getThreadViewer().getChecked(targets[i])) { - if (getThreadViewer().getGrayed(targets[i])) { - IExecutionDMContext[] threads = getTargetThreadFilters(targets[i]); - filterExtension.setThreadFilters(threads); - } else { - filterExtension.setTargetFilter(targets[i]); - } - } else { - filterExtension.removeTargetFilter(targets[i]); - } - DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged(fPage.getBreakpoint()); - } catch (CoreException e) { - CDebugUIPlugin.log(e); - } - } - } - - private IExecutionDMContext[] getTargetThreadFilters(IContainerDMContext target) { - Object[] threads = ((ITreeContentProvider) getThreadViewer().getContentProvider()).getChildren(target); - ArrayList<Object> list = new ArrayList<Object>(threads.length); - for (int i = 0; i < threads.length; ++i) { - if (getThreadViewer().getChecked(threads[i])) - list.add(threads[i]); - } - return list.toArray(new IExecutionDMContext[list.size()]); - } - - private IContainerDMContext[] syncGetContainers(final GdbLaunch launch) { - final DsfSession session = launch.getSession(); - - class ContainerQuery extends Query<IContainerDMContext[]> { - @Override - protected void execute(final DataRequestMonitor<IContainerDMContext[]> rm) { - if (!session.isActive()) { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Launch's session not active.")); //$NON-NLS-1$ - rm.done(); - return; - } - - DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - ICommandControlService commandControl = tracker.getService(ICommandControlService.class); - IMIProcesses procService = tracker.getService(IMIProcesses.class); - - if (commandControl != null && procService != null) { - procService.getProcessesBeingDebugged( - commandControl.getContext(), - new DataRequestMonitor<IDMContext[]>(session.getExecutor(), rm) { - @Override - protected void handleSuccess() { - if (getData() instanceof IContainerDMContext[]) { - IContainerDMContext[] containerDmcs = (IContainerDMContext[])getData(); - rm.setData(containerDmcs); - } else { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Wrong type of container contexts.")); //$NON-NLS-1$ - } - rm.done(); - } - }); - } else { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Control or Process service not accessible.")); //$NON-NLS-1$ - rm.done(); - } - tracker.dispose(); - } - } - - ContainerQuery query = new ContainerQuery(); - try { - session.getExecutor().execute(query); - return query.get(); - } catch (RejectedExecutionException e) { - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } - return new IContainerDMContext[0]; - } - - private IExecutionDMContext[] syncGetThreads(final IContainerDMContext container) { - final DsfSession session = DsfSession.getSession(container.getSessionId()); - if (session == null) { - return new IExecutionDMContext[0]; - } - - class ThreadsQuery extends Query<IExecutionDMContext[]> { - @Override - protected void execute(DataRequestMonitor<IExecutionDMContext[]> rm) { - if (!session.isActive()) { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$ - rm.done(); - return; - } - - DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - IRunControl runControl = tracker.getService(IRunControl.class); - if (runControl != null) { - runControl.getExecutionContexts(container, rm); - } else { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Control not accessible.")); //$NON-NLS-1$ - rm.done(); - } - tracker.dispose(); - } - } - - ThreadsQuery query = new ThreadsQuery(); - try { - session.getExecutor().execute(query); - return query.get(); - } catch (RejectedExecutionException e) { - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } - return new IExecutionDMContext[0]; - } - - private String syncGetContainerLabel(final IContainerDMContext container) { - final DsfSession session = DsfSession.getSession(container.getSessionId()); - if (session == null) { - return "Error reading data"; //$NON-NLS-1$ - } - - class ContainerLabelQuery extends Query<String> { - @Override - protected void execute(final DataRequestMonitor<String> rm) { - if (!session.isActive()) { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$ - rm.done(); - return; - } - - DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - IProcesses processService = tracker.getService(IProcesses.class); - IProcessDMContext procDmc = DMContexts.getAncestorOfType(container, IProcessDMContext.class); - if (processService != null && procDmc != null) { - processService.getExecutionData( - procDmc, - new ImmediateDataRequestMonitor<IThreadDMData>(rm) { - @Override - public void handleSuccess() { - final StringBuilder builder = new StringBuilder(getData().getName()); - String containerId = getData().getId(); - if (containerId != null) { - builder.append(" ["); //$NON-NLS-1$ - builder.append(containerId); - builder.append("]"); //$NON-NLS-1$ - } - - rm.setData(builder.toString()); - rm.done(); - } - }); - } else { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Processes service not accessible.")); //$NON-NLS-1$ - rm.done(); - } - tracker.dispose(); - } - } - - ContainerLabelQuery query = new ContainerLabelQuery(); - try { - session.getExecutor().execute(query); - return query.get(); - } catch (RejectedExecutionException e) { - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } - return "Error reading data"; //$NON-NLS-1$ - } - - private String syncGetThreadLabel(final IExecutionDMContext thread) { - final DsfSession session = DsfSession.getSession(thread.getSessionId()); - if (session == null) { - return "Error reading data"; //$NON-NLS-1$ - } - - class ThreadLabelQuery extends Query<String> { - @Override - protected void execute(final DataRequestMonitor<String> rm) { - if (!session.isActive()) { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$ - rm.done(); - return; - } - - DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - IProcesses procService = tracker.getService(IProcesses.class); - if (procService != null) { - IThreadDMContext threadDmc = DMContexts.getAncestorOfType(thread, IThreadDMContext.class); - procService.getExecutionData(threadDmc, new ImmediateDataRequestMonitor<IThreadDMData>(rm) { - @Override - protected void handleSuccess() { - final StringBuilder builder = new StringBuilder(Messages.GdbThreadFilterEditor_Thread); - builder.append(" #"); //$NON-NLS-1$ - builder.append(((IMIExecutionDMContext)thread).getThreadId()); - - String threadName = getData().getName(); - if (threadName != null) { - builder.append(" ["); //$NON-NLS-1$ - builder.append(threadName); - builder.append("] "); //$NON-NLS-1$ - } - - String threadId = getData().getId(); - if (threadId != null) { - builder.append(threadId); - } - - rm.setData(builder.toString()); - rm.done(); - } - }); - } else { - rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "IProcesses service not accessible.")); //$NON-NLS-1$ - rm.done(); - } - tracker.dispose(); - } - } - - ThreadLabelQuery query = new ThreadLabelQuery(); - try { - session.getExecutor().execute(query); - return query.get(); - } catch (RejectedExecutionException e) { - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } - return "Error reading data"; //$NON-NLS-1$ - } - - private Status getFailStatus(int code, String message) { - return new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, code, message, null); - } + public class CheckHandler implements ICheckStateListener { + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) + */ + @Override + public void checkStateChanged(CheckStateChangedEvent event) { + Object element = event.getElement(); + if (element instanceof IContainerDMContext) { + checkTarget((IContainerDMContext) element, event.getChecked()); + } else if (element instanceof IExecutionDMContext) { + checkThread((IExecutionDMContext) element, event.getChecked()); + } + } + + /** + * Check or uncheck a debug target in the tree viewer. When a debug + * target is checked, attempt to check all of the target's threads by + * default. When a debug target is unchecked, uncheck all its threads. + */ + protected void checkTarget(IContainerDMContext target, boolean checked) { + getThreadViewer().setChecked(target, checked); + getThreadViewer().setGrayed(target, false); + getThreadViewer().expandToLevel(target, AbstractTreeViewer.ALL_LEVELS); + IExecutionDMContext[] threads = syncGetThreads(target); + for (int i = 0; i < threads.length; i++) { + getThreadViewer().setChecked(threads[i], checked); + getThreadViewer().setGrayed(threads[i], false); + } + } + + /** + * Check or uncheck a thread. Update the thread's debug target. + */ + protected void checkThread(IExecutionDMContext thread, boolean checked) { + getThreadViewer().setChecked(thread, checked); + IContainerDMContext target = DMContexts.getAncestorOfType(thread, IContainerDMContext.class); + IExecutionDMContext[] threads = syncGetThreads(target); + int checkedNumber = 0; + for (int i = 0; i < threads.length; i++) { + if (getThreadViewer().getChecked(threads[i])) { + ++checkedNumber; + } + } + if (checkedNumber == 0) { + getThreadViewer().setChecked(target, false); + getThreadViewer().setGrayed(target, false); + } else if (checkedNumber == threads.length) { + getThreadViewer().setChecked(target, true); + getThreadViewer().setGrayed(target, false); + } else { + getThreadViewer().setGrayChecked(target, true); + } + } + } + + public class ThreadFilterContentProvider implements ITreeContentProvider { + + public ThreadFilterContentProvider() { + super(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ + @Override + public Object[] getChildren(Object parent) { + if (parent instanceof IContainerDMContext) { + return syncGetThreads((IContainerDMContext) parent); + } + + if (parent instanceof ILaunchManager) { + List<Object> children = new ArrayList<Object>(); + ILaunch[] launches = ((ILaunchManager) parent).getLaunches(); + IContainerDMContext[] targetArray; + for (int i = 0; i < launches.length; i++) { + if (launches[i] instanceof GdbLaunch) { + targetArray = syncGetContainers((GdbLaunch) launches[i]); + children.addAll(Arrays.asList(targetArray)); + } + } + return children.toArray(); + } + return new Object[0]; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ + @Override + public Object getParent(Object element) { + if (element instanceof IContainerDMContext) { + return DebugPlugin.getDefault().getLaunchManager(); + } + if (element instanceof IExecutionDMContext) { + return DMContexts.getAncestorOfType((IExecutionDMContext) element, IContainerDMContext.class); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + @Override + public boolean hasChildren(Object element) { + return getChildren(element).length > 0; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + @Override + public Object[] getElements(Object inputElement) { + return getChildren(inputElement); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + @Override + public void dispose() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, + * java.lang.Object, java.lang.Object) + */ + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + } + + public class ThreadFilterLabelProvider extends LabelProvider { + + @Override + public Image getImage(Object element) { + if (element instanceof IContainerDMContext) { + return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET); + } else { + return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING); + } + } + + @Override + public String getText(Object element) { + if (element instanceof IContainerDMContext) { + return syncGetContainerLabel((IContainerDMContext) element); + } else { + return syncGetThreadLabel((IExecutionDMContext) element); + } + } + } + + private CBreakpointGdbThreadFilterPage fPage; + + private CheckboxTreeViewer fThreadViewer; + + private ThreadFilterContentProvider fContentProvider; + + private CheckHandler fCheckHandler; + + public GdbThreadFilterEditor(Composite parent, CBreakpointGdbThreadFilterPage page) { + fPage = page; + fContentProvider = new ThreadFilterContentProvider(); + fCheckHandler = new CheckHandler(); + createThreadViewer(parent); + } + + protected CBreakpointGdbThreadFilterPage getPage() { + return fPage; + } + + private void createThreadViewer(Composite parent) { + Label label = new Label(parent, SWT.NONE); + label.setText(Messages.GdbThreadFilterEditor_RestrictToSelected); + label.setFont(parent.getFont()); + label.setLayoutData(new GridData()); + GridData data = new GridData(GridData.FILL_BOTH); + data.heightHint = 100; + fThreadViewer = new CheckboxTreeViewer(parent, SWT.BORDER); + fThreadViewer.addCheckStateListener(fCheckHandler); + fThreadViewer.getTree().setLayoutData(data); + fThreadViewer.getTree().setFont(parent.getFont()); + fThreadViewer.setContentProvider(fContentProvider); + fThreadViewer.setLabelProvider(new ThreadFilterLabelProvider()); + fThreadViewer.setInput(DebugPlugin.getDefault().getLaunchManager()); + setInitialCheckedState(); + } + + /** + * Returns the debug targets that appear in the tree + */ + protected IContainerDMContext[] getDebugTargets() { + Object input = fThreadViewer.getInput(); + if (!(input instanceof ILaunchManager)) { + return new IContainerDMContext[0]; + } + List<Object> targets = new ArrayList<Object>(); + ILaunch[] launches = ((ILaunchManager) input).getLaunches(); + IContainerDMContext[] targetArray; + for (int i = 0; i < launches.length; i++) { + if (launches[i] instanceof GdbLaunch) { + targetArray = syncGetContainers((GdbLaunch) launches[i]); + targets.addAll(Arrays.asList(targetArray)); + } + } + return targets.toArray(new IContainerDMContext[targets.size()]); + } + + protected CheckboxTreeViewer getThreadViewer() { + return fThreadViewer; + } + + /** + * Sets the initial checked state of the tree viewer. The initial state + * should reflect the current state of the breakpoint. If the breakpoint has + * a thread filter in a given thread, that thread should be checked. + */ + protected void setInitialCheckedState() { + IDsfBreakpointExtension filterExtension = fPage.getFilterExtension(); + try { + IContainerDMContext[] targets = filterExtension.getTargetFilters(); + + for (int i = 0; i < targets.length; i++) { + IExecutionDMContext[] filteredThreads = filterExtension.getThreadFilters(targets[i]); + if (filteredThreads != null) { + for (int j = 0; j < filteredThreads.length; ++j) { + // Mark this thread as selected + fCheckHandler.checkThread(filteredThreads[j], true); + } + } else { + // Mark the entire process as selected + fCheckHandler.checkTarget(targets[i], true); + } + } + } catch (CoreException e) { + CDebugUIPlugin.log(e); + } + } + + protected void doStore() { + IDsfBreakpointExtension filterExtension = fPage.getFilterExtension(); + IContainerDMContext[] targets = getDebugTargets(); + for (int i = 0; i < targets.length; ++i) { + try { + if (getThreadViewer().getChecked(targets[i])) { + if (getThreadViewer().getGrayed(targets[i])) { + IExecutionDMContext[] threads = getTargetThreadFilters(targets[i]); + filterExtension.setThreadFilters(threads); + } else { + filterExtension.setTargetFilter(targets[i]); + } + } else { + filterExtension.removeTargetFilter(targets[i]); + } + DebugPlugin.getDefault().getBreakpointManager().fireBreakpointChanged(fPage.getBreakpoint()); + } catch (CoreException e) { + CDebugUIPlugin.log(e); + } + } + } + + private IExecutionDMContext[] getTargetThreadFilters(IContainerDMContext target) { + Object[] threads = ((ITreeContentProvider) getThreadViewer().getContentProvider()).getChildren(target); + ArrayList<Object> list = new ArrayList<Object>(threads.length); + for (int i = 0; i < threads.length; ++i) { + if (getThreadViewer().getChecked(threads[i])) + list.add(threads[i]); + } + return list.toArray(new IExecutionDMContext[list.size()]); + } + + private IContainerDMContext[] syncGetContainers(final GdbLaunch launch) { + final DsfSession session = launch.getSession(); + + class ContainerQuery extends Query<IContainerDMContext[]> { + @Override + protected void execute(final DataRequestMonitor<IContainerDMContext[]> rm) { + if (!session.isActive()) { + rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Launch's session not active.")); //$NON-NLS-1$ + rm.done(); + return; + } + + DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + ICommandControlService commandControl = tracker.getService(ICommandControlService.class); + IMIProcesses procService = tracker.getService(IMIProcesses.class); + + if (commandControl != null && procService != null) { + procService.getProcessesBeingDebugged(commandControl.getContext(), + new DataRequestMonitor<IDMContext[]>(session.getExecutor(), rm) { + @Override + protected void handleSuccess() { + if (getData() instanceof IContainerDMContext[]) { + IContainerDMContext[] containerDmcs = (IContainerDMContext[]) getData(); + rm.setData(containerDmcs); + } else { + rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, + "Wrong type of container contexts.")); //$NON-NLS-1$ + } + rm.done(); + } + }); + } else { + rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, + "GDB Control or Process service not accessible.")); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + } + + ContainerQuery query = new ContainerQuery(); + try { + session.getExecutor().execute(query); + return query.get(); + } catch (RejectedExecutionException e) { + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } + return new IContainerDMContext[0]; + } + + private IExecutionDMContext[] syncGetThreads(final IContainerDMContext container) { + final DsfSession session = DsfSession.getSession(container.getSessionId()); + if (session == null) { + return new IExecutionDMContext[0]; + } + + class ThreadsQuery extends Query<IExecutionDMContext[]> { + @Override + protected void execute(DataRequestMonitor<IExecutionDMContext[]> rm) { + if (!session.isActive()) { + rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$ + rm.done(); + return; + } + + DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + IRunControl runControl = tracker.getService(IRunControl.class); + if (runControl != null) { + runControl.getExecutionContexts(container, rm); + } else { + rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Control not accessible.")); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + } + + ThreadsQuery query = new ThreadsQuery(); + try { + session.getExecutor().execute(query); + return query.get(); + } catch (RejectedExecutionException e) { + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } + return new IExecutionDMContext[0]; + } + + private String syncGetContainerLabel(final IContainerDMContext container) { + final DsfSession session = DsfSession.getSession(container.getSessionId()); + if (session == null) { + return "Error reading data"; //$NON-NLS-1$ + } + + class ContainerLabelQuery extends Query<String> { + @Override + protected void execute(final DataRequestMonitor<String> rm) { + if (!session.isActive()) { + rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$ + rm.done(); + return; + } + + DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + IProcesses processService = tracker.getService(IProcesses.class); + IProcessDMContext procDmc = DMContexts.getAncestorOfType(container, IProcessDMContext.class); + if (processService != null && procDmc != null) { + processService.getExecutionData(procDmc, new ImmediateDataRequestMonitor<IThreadDMData>(rm) { + @Override + public void handleSuccess() { + final StringBuilder builder = new StringBuilder(getData().getName()); + String containerId = getData().getId(); + if (containerId != null) { + builder.append(" ["); //$NON-NLS-1$ + builder.append(containerId); + builder.append("]"); //$NON-NLS-1$ + } + + rm.setData(builder.toString()); + rm.done(); + } + }); + } else { + rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Processes service not accessible.")); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + } + + ContainerLabelQuery query = new ContainerLabelQuery(); + try { + session.getExecutor().execute(query); + return query.get(); + } catch (RejectedExecutionException e) { + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } + return "Error reading data"; //$NON-NLS-1$ + } + + private String syncGetThreadLabel(final IExecutionDMContext thread) { + final DsfSession session = DsfSession.getSession(thread.getSessionId()); + if (session == null) { + return "Error reading data"; //$NON-NLS-1$ + } + + class ThreadLabelQuery extends Query<String> { + @Override + protected void execute(final DataRequestMonitor<String> rm) { + if (!session.isActive()) { + rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$ + rm.done(); + return; + } + + DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + IProcesses procService = tracker.getService(IProcesses.class); + if (procService != null) { + IThreadDMContext threadDmc = DMContexts.getAncestorOfType(thread, IThreadDMContext.class); + procService.getExecutionData(threadDmc, new ImmediateDataRequestMonitor<IThreadDMData>(rm) { + @Override + protected void handleSuccess() { + final StringBuilder builder = new StringBuilder(Messages.GdbThreadFilterEditor_Thread); + builder.append(" #"); //$NON-NLS-1$ + builder.append(((IMIExecutionDMContext) thread).getThreadId()); + + String threadName = getData().getName(); + if (threadName != null) { + builder.append(" ["); //$NON-NLS-1$ + builder.append(threadName); + builder.append("] "); //$NON-NLS-1$ + } + + String threadId = getData().getId(); + if (threadId != null) { + builder.append(threadId); + } + + rm.setData(builder.toString()); + rm.done(); + } + }); + } else { + rm.setStatus( + getFailStatus(IDsfStatusConstants.INVALID_STATE, "IProcesses service not accessible.")); //$NON-NLS-1$ + rm.done(); + } + tracker.dispose(); + } + } + + ThreadLabelQuery query = new ThreadLabelQuery(); + try { + session.getExecutor().execute(query); + return query.get(); + } catch (RejectedExecutionException e) { + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } + return "Error reading data"; //$NON-NLS-1$ + } + + private Status getFailStatus(int code, String message) { + return new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, code, message, null); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java index c999542996b..258672542f4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java @@ -43,7 +43,7 @@ public class Messages extends NLS { public static String GdbThreadFilterEditor_Thread; public static String GdbThreadFilterEditor_RestrictToSelected; - + static { // initialize resource bundle NLS.initializeMessages(Messages.class.getName(), Messages.class); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleDynamicPrintfTargetFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleDynamicPrintfTargetFactory.java index dbf705145dd..6a9f1193941 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleDynamicPrintfTargetFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleDynamicPrintfTargetFactory.java @@ -28,7 +28,7 @@ import org.eclipse.ui.IWorkbenchPart; * Toggle DynamicPrintf target factory for disassembly parts. * We use a separate factory because the tracepoint factory is controlled * through an action set, while the breakpoint factory is down in DSF (not DSF-GDB). - * + * * @since 2.4 */ public class ToggleDynamicPrintfTargetFactory implements IToggleBreakpointsTargetFactory { @@ -45,8 +45,9 @@ public class ToggleDynamicPrintfTargetFactory implements IToggleBreakpointsTarge * leaving <code>ToggleCDynamicPrintfTargetFactory</code> to return the same id * for the editor. */ - public static final String TOGGLE_C_DYNAMICPRINTF_TARGET_ID = CDebugUIPlugin.PLUGIN_ID + ".toggleCDynamicPrintfTarget"; //$NON-NLS-1$ - + public static final String TOGGLE_C_DYNAMICPRINTF_TARGET_ID = CDebugUIPlugin.PLUGIN_ID + + ".toggleCDynamicPrintfTarget"; //$NON-NLS-1$ + private static final Set<String> TOGGLE_TARGET_IDS_ALL = new HashSet<String>(1); static { TOGGLE_TARGET_IDS_ALL.add(TOGGLE_C_DYNAMICPRINTF_TARGET_ID); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java index 72935b52442..1a81de7abf5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java @@ -45,7 +45,7 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF * for the editor. */ public static final String TOGGLE_C_TRACEPOINT_TARGET_ID = CDebugUIPlugin.PLUGIN_ID + ".toggleCTracepointTarget"; //$NON-NLS-1$ - + private static final Set<String> TOGGLE_TARGET_IDS_ALL = new HashSet<String>(1); static { TOGGLE_TARGET_IDS_ALL.add(TOGGLE_C_TRACEPOINT_TARGET_ID); @@ -56,7 +56,7 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF public ToggleTracepointsTargetFactory() { } - @Override + @Override public IToggleBreakpointsTarget createToggleTarget(String targetID) { if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { return fgDisassemblyToggleTracepointsTarget; @@ -64,12 +64,12 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF return null; } - @Override + @Override public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) { return null; } - @Override + @Override public String getToggleTargetDescription(String targetID) { if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { return Messages.ToggleTracepointsTargetFactory_description; @@ -77,7 +77,7 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF return null; } - @Override + @Override public String getToggleTargetName(String targetID) { if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { return Messages.ToggleTracepointsTargetFactory_name; @@ -85,7 +85,7 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF return null; } - @Override + @Override public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) { if (part instanceof IDisassemblyPart) { return TOGGLE_TARGET_IDS_ALL; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/AddLocalsExpressionCommandHandler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/AddLocalsExpressionCommandHandler.java index ebcea69d60c..0f1129f2a5e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/AddLocalsExpressionCommandHandler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/AddLocalsExpressionCommandHandler.java @@ -21,7 +21,7 @@ import org.eclipse.debug.core.IExpressionManager; /** * Handling of adding group of locals into expression view - * + * * @since 2.4 */ public class AddLocalsExpressionCommandHandler extends AbstractHandler { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/AddRegistersExpressionCommandHandler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/AddRegistersExpressionCommandHandler.java index 2ec7390f257..467d776829c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/AddRegistersExpressionCommandHandler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/AddRegistersExpressionCommandHandler.java @@ -15,7 +15,7 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.commands; /** * Handling of adding group of registers into expression view - * + * * @since 2.4 */ public class AddRegistersExpressionCommandHandler extends AddLocalsExpressionCommandHandler { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbAbstractReverseStepCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbAbstractReverseStepCommand.java index 614a18ee4ce..eacb2c268f5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbAbstractReverseStepCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbAbstractReverseStepCommand.java @@ -7,13 +7,12 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.commands; - import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; @@ -39,7 +38,7 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; /** * Base class handling the work of a Reverse Step command. - * + * * @since 2.1 */ @Immutable @@ -49,66 +48,68 @@ public abstract class GdbAbstractReverseStepCommand extends AbstractDebugCommand private final DsfServicesTracker fTracker; private final DsfSteppingModeTarget fSteppingMode; - protected DsfSteppingModeTarget getSteppingMode() { return fSteppingMode; } + protected DsfSteppingModeTarget getSteppingMode() { + return fSteppingMode; + } public GdbAbstractReverseStepCommand(DsfSession session, DsfSteppingModeTarget steppingMode) { fExecutor = session.getExecutor(); fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); fSteppingMode = steppingMode; - } + } public void dispose() { fTracker.dispose(); } - @Override + @Override protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { - if (targets.length != 1) { - return; - } - - final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), IExecutionDMContext.class); - if (dmc == null) { - return; - } - - final StepType stepType = getStepType(); - Query<Object> reverseStepQuery = new Query<Object>() { - @Override - public void execute(DataRequestMonitor<Object> rm) { - IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); - - if (runControl != null) { - runControl.reverseStep(dmc, stepType, rm); - } else { - rm.done(); - } - } - }; - try { - fExecutor.execute(reverseStepQuery); - reverseStepQuery.get(); - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } - } - - @Override + if (targets.length != 1) { + return; + } + + final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + IExecutionDMContext.class); + if (dmc == null) { + return; + } + + final StepType stepType = getStepType(); + Query<Object> reverseStepQuery = new Query<Object>() { + @Override + public void execute(DataRequestMonitor<Object> rm) { + IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); + + if (runControl != null) { + runControl.reverseStep(dmc, stepType, rm); + } else { + rm.done(); + } + } + }; + try { + fExecutor.execute(reverseStepQuery); + reverseStepQuery.get(); + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } + } + + @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException - { - if (targets.length != 1) { - return false; - } - - final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), IExecutionDMContext.class); - if (dmc == null) { - return false; - } - - + throws CoreException { + if (targets.length != 1) { + return false; + } + + final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + IExecutionDMContext.class); + if (dmc == null) { + return false; + } + final StepType stepType = getStepType(); Query<Boolean> canReverseQuery = new Query<Boolean>() { @Override @@ -133,17 +134,17 @@ public abstract class GdbAbstractReverseStepCommand extends AbstractDebugCommand } return false; - } - - @Override + } + + @Override protected Object getTarget(Object element) { - if (element instanceof IDMVMContext) { - return element; - } - return null; - } - - @Override + if (element instanceof IDMVMContext) { + return element; + } + return null; + } + + @Override protected boolean isRemainEnabled(IDebugCommandRequest request) { return true; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java index b86826a70b9..f825dd5a1fa 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbConnectCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation * Marc Khouzam (Ericsson) - Add support for multi-attach (Bug 293679) @@ -80,264 +80,271 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne private final ILaunch fLaunch; private final DsfExecutor fExecutor; - private final DsfServicesTracker fTracker; - - // A map of processName to path, that allows us to remember the path to the binary file - // for a process with a particular name. We can then re-use the same binary for another - // process with the same name. This allows a user to connect to multiple processes - // with the same name without having to be prompted each time for a path. - // This map is associated to the current debug session only, therefore the user can - // reset it by using a new debug session. - // This map is only needed for remote sessions, since we don't need to specify - // the binary location for a local attach session. - private Map<String, String> fProcessNameToBinaryMap = new HashMap<String, String>(); - - public GdbConnectCommand(DsfSession session, ILaunch launch) { - fLaunch = launch; - fExecutor = session.getExecutor(); - fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } - - public void dispose() { - fTracker.dispose(); - } - - @Override + private final DsfServicesTracker fTracker; + + // A map of processName to path, that allows us to remember the path to the binary file + // for a process with a particular name. We can then re-use the same binary for another + // process with the same name. This allows a user to connect to multiple processes + // with the same name without having to be prompted each time for a path. + // This map is associated to the current debug session only, therefore the user can + // reset it by using a new debug session. + // This map is only needed for remote sessions, since we don't need to specify + // the binary location for a local attach session. + private Map<String, String> fProcessNameToBinaryMap = new HashMap<String, String>(); + + public GdbConnectCommand(DsfSession session, ILaunch launch) { + fLaunch = launch; + fExecutor = session.getExecutor(); + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + } + + public void dispose() { + fTracker.dispose(); + } + + @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException - { - return canConnect(); - } - - /* - * This method should not be called from the UI thread. - * (non-Javadoc) - * @see org.eclipse.cdt.dsf.gdb.actions.IConnect#canConnect() - */ + throws CoreException { + return canConnect(); + } + + /* + * This method should not be called from the UI thread. + * (non-Javadoc) + * @see org.eclipse.cdt.dsf.gdb.actions.IConnect#canConnect() + */ @Override public boolean canConnect() { - Query<Boolean> canConnectQuery = new Query<Boolean>() { - @Override - public void execute(DataRequestMonitor<Boolean> rm) { - IProcesses procService = fTracker.getService(IProcesses.class); - ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); - - if (procService != null && commandControl != null) { - procService.isDebuggerAttachSupported(commandControl.getContext(), rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; - try { - fExecutor.execute(canConnectQuery); + Query<Boolean> canConnectQuery = new Query<Boolean>() { + @Override + public void execute(DataRequestMonitor<Boolean> rm) { + IProcesses procService = fTracker.getService(IProcesses.class); + ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); + + if (procService != null && commandControl != null) { + procService.isDebuggerAttachSupported(commandControl.getContext(), rm); + } else { + rm.setData(false); + rm.done(); + } + } + }; + try { + fExecutor.execute(canConnectQuery); return canConnectQuery.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } return false; - } - - /** - * This job will prompt the user to select a set of processes - * to attach too. - * We need a job because the ProcessPrompter will block and - * we don't want to block the executor. - */ - protected class PromptForPidJob extends UIJob { - - // The list of processes used in the case of an ATTACH session - IProcessExtendedInfo[] fProcessList = null; - DataRequestMonitor<Object> fRequestMonitor; + } + + /** + * This job will prompt the user to select a set of processes + * to attach too. + * We need a job because the ProcessPrompter will block and + * we don't want to block the executor. + */ + protected class PromptForPidJob extends UIJob { + + // The list of processes used in the case of an ATTACH session + IProcessExtendedInfo[] fProcessList = null; + DataRequestMonitor<Object> fRequestMonitor; private List<String> fDebuggedProcesses; - public PromptForPidJob(String name, IProcessExtendedInfo[] procs, List<String> debuggedProcesses, DataRequestMonitor<Object> rm) { - super(name); - fProcessList = procs; - fRequestMonitor = rm; - fDebuggedProcesses = debuggedProcesses; - } - - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - final Status NO_PID_STATUS = new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, -1, - LaunchMessages.getString("LocalAttachLaunchDelegate.No_Process_ID_selected"), //$NON-NLS-1$ - null); - - try { - PrompterInfo info = new PrompterInfo(fProcessList, fDebuggedProcesses); - Object result = new ProcessPrompter().handleStatus(null, info); - if (result == null) { - fRequestMonitor.cancel(); - } else if (result instanceof IProcessExtendedInfo[]) { - fRequestMonitor.setData(result); - } else if (result instanceof Integer) { - // This is the case where the user typed in a pid number directly - fRequestMonitor.setData(new IProcessExtendedInfo[] { new ProcessInfo((Integer)result, "")}); //$NON-NLS-1$ - } else { - fRequestMonitor.setStatus(NO_PID_STATUS); - } - } catch (CoreException e) { - fRequestMonitor.setStatus(NO_PID_STATUS); - } - fRequestMonitor.done(); - - return Status.OK_STATUS; - } - }; - - /** - * This job will prompt the user for a path to the binary to use, - * and then will attach to the process. - * We need a job to free the executor while we prompt the user for - * a binary path. Bug 344892 - */ - private class PromptAndAttachToProcessJob extends UIJob { - private final String fPid; - private final RequestMonitor fRm; - private final String fTitle; - private final String fProcName; - - public PromptAndAttachToProcessJob(String pid, String title, String procName, RequestMonitor rm) { - super(""); //$NON-NLS-1$ - fPid = pid; - fTitle = title; - fProcName = procName; - fRm = rm; - } - - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - - // Have we already see the binary for a process with this name? - String binaryPath = fProcessNameToBinaryMap.get(fProcName); - - if (binaryPath == null) { - // prompt for the binary path - Shell shell = GdbUIPlugin.getShell(); - - if (shell != null) { - FileDialog fd = new FileDialog(shell, SWT.NONE); - fd.setText(fTitle); - binaryPath = fd.open(); - } - } - - if (binaryPath == null) { - // The user pressed the cancel button, so we cancel the attach gracefully - fRm.done(); - } else { - - final String finalBinaryPath = binaryPath; - fExecutor.execute(new DsfRunnable() { - @Override - public void run() { - IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); - ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); - - if (procService != null && commandControl != null) { - IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), fPid); - procService.attachDebuggerToProcess(procDmc, finalBinaryPath, new DataRequestMonitor<IDMContext>(fExecutor, fRm) { - @Override - protected void handleSuccess() { - // Store the path of the binary so we can use it again for another process - // with the same name. Only do this on success, to avoid being stuck with - // a path that is invalid. - if (fProcName != null && !fProcName.isEmpty()) { - fProcessNameToBinaryMap.put(fProcName, finalBinaryPath); - } - fRm.done(); - }; - }); - - } else { - fRm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot find services", null)); //$NON-NLS-1$ - fRm.done(); - } - } - }); - } - - return Status.OK_STATUS; - } - } - - @Override + public PromptForPidJob(String name, IProcessExtendedInfo[] procs, List<String> debuggedProcesses, + DataRequestMonitor<Object> rm) { + super(name); + fProcessList = procs; + fRequestMonitor = rm; + fDebuggedProcesses = debuggedProcesses; + } + + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + final Status NO_PID_STATUS = new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, -1, + LaunchMessages.getString("LocalAttachLaunchDelegate.No_Process_ID_selected"), //$NON-NLS-1$ + null); + + try { + PrompterInfo info = new PrompterInfo(fProcessList, fDebuggedProcesses); + Object result = new ProcessPrompter().handleStatus(null, info); + if (result == null) { + fRequestMonitor.cancel(); + } else if (result instanceof IProcessExtendedInfo[]) { + fRequestMonitor.setData(result); + } else if (result instanceof Integer) { + // This is the case where the user typed in a pid number directly + fRequestMonitor.setData(new IProcessExtendedInfo[] { new ProcessInfo((Integer) result, "") }); //$NON-NLS-1$ + } else { + fRequestMonitor.setStatus(NO_PID_STATUS); + } + } catch (CoreException e) { + fRequestMonitor.setStatus(NO_PID_STATUS); + } + fRequestMonitor.done(); + + return Status.OK_STATUS; + } + }; + + /** + * This job will prompt the user for a path to the binary to use, + * and then will attach to the process. + * We need a job to free the executor while we prompt the user for + * a binary path. Bug 344892 + */ + private class PromptAndAttachToProcessJob extends UIJob { + private final String fPid; + private final RequestMonitor fRm; + private final String fTitle; + private final String fProcName; + + public PromptAndAttachToProcessJob(String pid, String title, String procName, RequestMonitor rm) { + super(""); //$NON-NLS-1$ + fPid = pid; + fTitle = title; + fProcName = procName; + fRm = rm; + } + + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + + // Have we already see the binary for a process with this name? + String binaryPath = fProcessNameToBinaryMap.get(fProcName); + + if (binaryPath == null) { + // prompt for the binary path + Shell shell = GdbUIPlugin.getShell(); + + if (shell != null) { + FileDialog fd = new FileDialog(shell, SWT.NONE); + fd.setText(fTitle); + binaryPath = fd.open(); + } + } + + if (binaryPath == null) { + // The user pressed the cancel button, so we cancel the attach gracefully + fRm.done(); + } else { + + final String finalBinaryPath = binaryPath; + fExecutor.execute(new DsfRunnable() { + @Override + public void run() { + IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); + ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); + + if (procService != null && commandControl != null) { + IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), + fPid); + procService.attachDebuggerToProcess(procDmc, finalBinaryPath, + new DataRequestMonitor<IDMContext>(fExecutor, fRm) { + @Override + protected void handleSuccess() { + // Store the path of the binary so we can use it again for another process + // with the same name. Only do this on success, to avoid being stuck with + // a path that is invalid. + if (fProcName != null && !fProcName.isEmpty()) { + fProcessNameToBinaryMap.put(fProcName, finalBinaryPath); + } + fRm.done(); + }; + }); + + } else { + fRm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, + IDsfStatusConstants.INTERNAL_ERROR, "Cannot find services", null)); //$NON-NLS-1$ + fRm.done(); + } + } + }); + } + + return Status.OK_STATUS; + } + } + + @Override protected void doExecute(Object[] targets, IProgressMonitor monitor, final IRequest request) throws CoreException { - Query<Boolean> connectQuery = new Query<Boolean>() { - @Override - public void execute(final DataRequestMonitor<Boolean> rm) { - connect(new RequestMonitor(fExecutor, rm) { - @Override - protected void handleCompleted() { - // pass any error to the caller - if (!isSuccess()) { - request.setStatus(getStatus()); - } - rm.done(); - } - }); - } - }; - try { - fExecutor.execute(connectQuery); + Query<Boolean> connectQuery = new Query<Boolean>() { + @Override + public void execute(final DataRequestMonitor<Boolean> rm) { + connect(new RequestMonitor(fExecutor, rm) { + @Override + protected void handleCompleted() { + // pass any error to the caller + if (!isSuccess()) { + request.setStatus(getStatus()); + } + rm.done(); + } + }); + } + }; + try { + fExecutor.execute(connectQuery); connectQuery.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { } catch (CancellationException e) { // Nothing to do, just ignore the command since the user // cancelled it. - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } finally { - updateEnablement(); - } - } - - /** - * Get already debugged processes from all compatible sessions. - * "compatible" in current implementation means all sessions on local machine. - * - * @param currentCtx current session context - * @param allSessions true if all session to be queried, false to return result only for current execution session context - * @param drm where result to be returned - */ - private void getAllDebuggedProcesses(final IDMContext currentCtx, boolean allSessions, final DataRequestMonitor<List<String>> drm) { - SessionType sessionType = fTracker.getService(IGDBBackend.class).getSessionType(); - - final List<String> result = new LinkedList<>(); - final List<DsfSession> sessions = new LinkedList<>(); - // Only for local session types search in all debug sessions - if (allSessions && sessionType == SessionType.LOCAL) { - sessions.addAll(Arrays.asList(DsfSession.getActiveSessions())); - } else { - // For remote session just query current context. - // - // cannot reliably match two remote debug session that are connected to same target machine. - // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=486408#c7 - - sessions.add(DsfSession.getSession(currentCtx.getSessionId())); - } - - // Query each sessions for existing processes in a sequential fashion. - // We must do this as each session will require different executor. - final class ProcessRequestMonitor extends DataRequestMonitor<IDMContext[]> { - public ProcessRequestMonitor(Executor executor) { super(executor, null);} + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } finally { + updateEnablement(); + } + } + + /** + * Get already debugged processes from all compatible sessions. + * "compatible" in current implementation means all sessions on local machine. + * + * @param currentCtx current session context + * @param allSessions true if all session to be queried, false to return result only for current execution session context + * @param drm where result to be returned + */ + private void getAllDebuggedProcesses(final IDMContext currentCtx, boolean allSessions, + final DataRequestMonitor<List<String>> drm) { + SessionType sessionType = fTracker.getService(IGDBBackend.class).getSessionType(); + + final List<String> result = new LinkedList<>(); + final List<DsfSession> sessions = new LinkedList<>(); + // Only for local session types search in all debug sessions + if (allSessions && sessionType == SessionType.LOCAL) { + sessions.addAll(Arrays.asList(DsfSession.getActiveSessions())); + } else { + // For remote session just query current context. + // + // cannot reliably match two remote debug session that are connected to same target machine. + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=486408#c7 + + sessions.add(DsfSession.getSession(currentCtx.getSessionId())); + } + + // Query each sessions for existing processes in a sequential fashion. + // We must do this as each session will require different executor. + final class ProcessRequestMonitor extends DataRequestMonitor<IDMContext[]> { + public ProcessRequestMonitor(Executor executor) { + super(executor, null); + } + public ProcessRequestMonitor(DsfExecutor executor) { super(new ImmediateInDsfExecutor(executor), null); } + @Override protected void handleCompleted() { - // if succeeded and has data, add process ids to result, + // if succeeded and has data, add process ids to result, // otherwise proceed to next debug session (aka DsfSession) if (isSuccess() && getData() != null) { for (IDMContext dmc : getData()) { - IMIProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc, - IMIProcessDMContext.class); + IMIProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc, IMIProcessDMContext.class); if (procDmc != null) { result.add(procDmc.getProcId()); } @@ -349,95 +356,109 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne nextSession.getExecutor().execute(new DsfRunnable() { @Override public void run() { - DsfServicesTracker nextTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), nextSession.getId()); - IGDBBackend nextSessionBackend = nextTracker.getService(IGDBBackend.class); - if (sameSession || nextSessionBackend.getSessionType() == SessionType.LOCAL) { - ICommandControlService nextCommandControl = nextTracker.getService(ICommandControlService.class); - IProcesses nextProcService = nextTracker.getService(IProcesses.class); - nextProcService.getProcessesBeingDebugged( - nextCommandControl.getContext(), new ProcessRequestMonitor(nextSession.getExecutor())); - } else { - // proceed to next session context query passing an error (that will be ignored) - new ProcessRequestMonitor(nextSession.getExecutor()).done( - new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Only local session", null)); //$NON-NLS-1$ - } - nextTracker.dispose(); - } + DsfServicesTracker nextTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), + nextSession.getId()); + IGDBBackend nextSessionBackend = nextTracker.getService(IGDBBackend.class); + if (sameSession || nextSessionBackend.getSessionType() == SessionType.LOCAL) { + ICommandControlService nextCommandControl = nextTracker + .getService(ICommandControlService.class); + IProcesses nextProcService = nextTracker.getService(IProcesses.class); + nextProcService.getProcessesBeingDebugged(nextCommandControl.getContext(), + new ProcessRequestMonitor(nextSession.getExecutor())); + } else { + // proceed to next session context query passing an error (that will be ignored) + new ProcessRequestMonitor(nextSession.getExecutor()) + .done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, + IDsfStatusConstants.NOT_SUPPORTED, "Only local session", null)); //$NON-NLS-1$ + } + nextTracker.dispose(); + } }); } else { // done with querying all session. Copy the result drm.done(result); } } - }; - // Trigger the first query - new ProcessRequestMonitor(ImmediateExecutor.getInstance()).done(); - } - /* - * This method should not be called from the UI thread. - * (non-Javadoc) - * @see org.eclipse.cdt.dsf.gdb.actions.IConnect#canConnect() - */ - @Override - public void connect(final RequestMonitor rm) - { - fExecutor.execute(new DsfRunnable() { - @Override - public void run() { - final IProcesses procService = fTracker.getService(IProcesses.class); - ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); - IGDBBackend backend = fTracker.getService(IGDBBackend.class); - - if (procService != null && commandControl != null && backend != null) { - final ICommandControlDMContext controlCtx = commandControl.getContext(); - - // Now get the list of all processes - procService.getRunningProcesses( - controlCtx, - new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) { - @Override - protected void handleSuccess() { - - final List<IProcessExtendedInfo> procInfoList = new ArrayList<IProcessExtendedInfo>(); - - final CountingRequestMonitor countingRm = - new CountingRequestMonitor(fExecutor, rm) { + } + ; + // Trigger the first query + new ProcessRequestMonitor(ImmediateExecutor.getInstance()).done(); + } + + /* + * This method should not be called from the UI thread. + * (non-Javadoc) + * @see org.eclipse.cdt.dsf.gdb.actions.IConnect#canConnect() + */ + @Override + public void connect(final RequestMonitor rm) { + fExecutor.execute(new DsfRunnable() { + @Override + public void run() { + final IProcesses procService = fTracker.getService(IProcesses.class); + ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); + IGDBBackend backend = fTracker.getService(IGDBBackend.class); + + if (procService != null && commandControl != null && backend != null) { + final ICommandControlDMContext controlCtx = commandControl.getContext(); + + // Now get the list of all processes + procService.getRunningProcesses(controlCtx, + new DataRequestMonitor<IProcessDMContext[]>(fExecutor, rm) { + @Override + protected void handleSuccess() { + + final List<IProcessExtendedInfo> procInfoList = new ArrayList<IProcessExtendedInfo>(); + + final CountingRequestMonitor countingRm = new CountingRequestMonitor(fExecutor, + rm) { @Override protected void handleSuccess() { - getAllDebuggedProcesses(controlCtx, true, new ImmediateDataRequestMonitor<List<String>>(rm) { - @Override - protected void handleSuccess() { - List<String> dbgPids = getData(); - - // Prompt the user to choose one or more processes - new PromptForPidJob( - LaunchUIMessages.getString("ProcessPrompter.PromptJob"), //$NON-NLS-1$ - procInfoList.toArray(new IProcessExtendedInfo[procInfoList.size()]), - dbgPids, - new DataRequestMonitor<Object>(fExecutor, rm) { - @Override - protected void handleCancel() { - rm.cancel(); - rm.done(); - } - @Override - protected void handleSuccess() { - Object data = getData(); - if (data instanceof IProcessExtendedInfo[]) { - attachToProcesses(controlCtx, (IProcessExtendedInfo[])data, rm); - } else { - rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Invalid return type for process prompter", null)); //$NON-NLS-1$ - } - } - }).schedule(); - } - }); + getAllDebuggedProcesses(controlCtx, true, + new ImmediateDataRequestMonitor<List<String>>(rm) { + @Override + protected void handleSuccess() { + List<String> dbgPids = getData(); + + // Prompt the user to choose one or more processes + new PromptForPidJob( + LaunchUIMessages + .getString("ProcessPrompter.PromptJob"), //$NON-NLS-1$ + procInfoList.toArray( + new IProcessExtendedInfo[procInfoList + .size()]), + dbgPids, + new DataRequestMonitor<Object>(fExecutor, rm) { + @Override + protected void handleCancel() { + rm.cancel(); + rm.done(); + } + + @Override + protected void handleSuccess() { + Object data = getData(); + if (data instanceof IProcessExtendedInfo[]) { + attachToProcesses(controlCtx, + (IProcessExtendedInfo[]) data, + rm); + } else { + rm.done(new Status(IStatus.ERROR, + GdbUIPlugin.PLUGIN_ID, + IDsfStatusConstants.INTERNAL_ERROR, + "Invalid return type for process prompter", //$NON-NLS-1$ + null)); + } + } + }).schedule(); + } + }); } }; - if (getData().length > 0 && getData()[0] instanceof IThreadDMData) { - // The list of running processes also contains the name of the processes - // This is much more efficient. Let's use it. + if (getData().length > 0 && getData()[0] instanceof IThreadDMData) { + // The list of running processes also contains the name of the processes + // This is much more efficient. Let's use it. for (IProcessDMContext processCtx : getData()) { IThreadDMData processData = (IThreadDMData) processCtx; int pid = 0; @@ -448,198 +469,207 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne String[] cores = null; String owner = null; if (processData instanceof IGdbThreadDMData) { - cores = ((IGdbThreadDMData)processData).getCores(); - owner = ((IGdbThreadDMData)processData).getOwner(); + cores = ((IGdbThreadDMData) processData).getCores(); + owner = ((IGdbThreadDMData) processData).getOwner(); } String description = null; if (processData instanceof IGdbThreadDMData2) { - description = ((IGdbThreadDMData2)processData).getDescription(); + description = ((IGdbThreadDMData2) processData).getDescription(); } - procInfoList.add(new ProcessInfo(pid, processData.getName(), cores, owner, description)); + procInfoList.add(new ProcessInfo(pid, processData.getName(), cores, owner, + description)); } // Re-use the counting monitor and trigger it right away. // No need to call done() in this case. countingRm.setDoneCount(0); - } else { - // The list of running processes does not contain the names, so - // we must obtain it individually - - // For each process, obtain its name - // Once all the names are obtained, prompt the user for the pid to use - - // New cycle, look for service again - final IProcesses procService = fTracker.getService(IProcesses.class); - - if (procService != null) { - countingRm.setDoneCount(getData().length); - - for (IProcessDMContext processCtx : getData()) { - procService.getExecutionData( - processCtx, - new DataRequestMonitor<IThreadDMData> (fExecutor, countingRm) { - @Override - protected void handleSuccess() { - IThreadDMData processData = getData(); - int pid = 0; - try { - pid = Integer.parseInt(processData.getId()); - } catch (NumberFormatException e) { - } - String[] cores = null; - String owner = null; - if (processData instanceof IGdbThreadDMData) { - cores = ((IGdbThreadDMData)processData).getCores(); - owner = ((IGdbThreadDMData)processData).getOwner(); - } - String description = null; - if (processData instanceof IGdbThreadDMData2) { - description = ((IGdbThreadDMData2)processData).getDescription(); - } - procInfoList.add(new ProcessInfo(pid, processData.getName(), cores, owner, description)); - countingRm.done(); - } - }); - } - } else { - // Trigger right away. No need to call done() in this case. - countingRm.setDoneCount(0); - } - } - } - }); - } else { - rm.done(); - } - } - }); - } - - private void attachToProcesses(final ICommandControlDMContext controlDmc, IProcessExtendedInfo[] processes, final RequestMonitor rm) { - - // For a local attach, GDB can figure out the binary automatically, - // so we don't need to prompt for it. - final IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); - final IGDBBackend backend = fTracker.getService(IGDBBackend.class); - final StringBuilder errors = new StringBuilder(); - - if (procService != null && backend != null) { - // Attach to each process in a sequential fashion. We must do this - // to be able to check if we are allowed to attach to the next process. - // Attaching to all of them in parallel would assume that all attach are supported. - - // Create a list of all our processes so we can attach to one at a time. - // We need to create a new list so that we can remove elements from it. - final List<IProcessExtendedInfo> procList = new ArrayList<IProcessExtendedInfo>(Arrays.asList(processes)); - // Create a one element array to remember what process we are trying to attach to, so that we can - // use it in case of error. - final IProcessExtendedInfo[] previousProcAttempt = new IProcessExtendedInfo[1]; - - class AttachToProcessRequestMonitor extends ImmediateDataRequestMonitor<IDMContext> { - public AttachToProcessRequestMonitor() { - super(); - } - - @Override - protected void handleCompleted() { - // Failed to attach to a process. Remember the error message. - if (!isSuccess()) { - formatErrorMessage(errors, previousProcAttempt[0], getStatus().getMessage()); - } - - // Check that we have a process to attach to - if (!procList.isEmpty()) { - - // Check that we can actually attach to the process. - // This is because some backends may not support multi-process. - // If the backend does not support multi-process, we only attach to the first process. - procService.isDebuggerAttachSupported(controlDmc, new ImmediateDataRequestMonitor<Boolean>() { - @Override - protected void handleCompleted() { - if (isSuccess() && getData()) { - // Can attach to process - - // Remove process from list and attach to it. - IProcessExtendedInfo process = procList.remove(0); - // Store process in case of error - previousProcAttempt[0] = process; - String pidStr = Integer.toString(process.getPid()); - - if (backend.getSessionType() == SessionType.REMOTE) { - // For remote attach, we must set the binary first so we need to prompt the user. - - // If this is the very first attach of a remote session, check if the user - // specified the binary in the launch. If so, let's add it to our map to - // avoid having to prompt the user for that binary. - // This would be particularly annoying since we didn't use to have - // to do that before we supported multi-process. - // Must do this here to be in the executor - // Bug 350365 - if (fProcessNameToBinaryMap.isEmpty()) { - IPath binaryPath = backend.getProgramPath(); - if (binaryPath != null && !binaryPath.isEmpty()) { - fProcessNameToBinaryMap.put(binaryPath.lastSegment(), binaryPath.toOSString()); - } - } - - // Because the prompt is a very long operation, we need to run outside the - // executor, so we don't lock it. - // Bug 344892 - IPath processPath = new Path(process.getName()); - String processShortName = processPath.lastSegment(); - new PromptAndAttachToProcessJob(pidStr, - LaunchUIMessages.getString("ProcessPrompterDialog.TitlePrefix") + process.getName(), //$NON-NLS-1$ - processShortName, new AttachToProcessRequestMonitor()).schedule(); - } else { - // For a local attach, we can attach directly without looking for the binary - // since GDB will figure it out by itself - IProcessDMContext procDmc = procService.createProcessContext(controlDmc, pidStr); - procService.attachDebuggerToProcess(procDmc, null, new AttachToProcessRequestMonitor()); - } - } else { - // Not allowed to attach to another process. Just stop. - rm.done(); - } - } - }); - } else { - // If there were errors, pass them-on to the caller - if (errors.length() != 0) { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, errors.toString())); - } - // No other process to attach to - rm.done(); - } - } - }; - - // Trigger the first attach. - new AttachToProcessRequestMonitor().done(); - - } else { - rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot find service", null)); //$NON-NLS-1$ - } - - } - - @Override + } else { + // The list of running processes does not contain the names, so + // we must obtain it individually + + // For each process, obtain its name + // Once all the names are obtained, prompt the user for the pid to use + + // New cycle, look for service again + final IProcesses procService = fTracker.getService(IProcesses.class); + + if (procService != null) { + countingRm.setDoneCount(getData().length); + + for (IProcessDMContext processCtx : getData()) { + procService.getExecutionData(processCtx, + new DataRequestMonitor<IThreadDMData>(fExecutor, countingRm) { + @Override + protected void handleSuccess() { + IThreadDMData processData = getData(); + int pid = 0; + try { + pid = Integer.parseInt(processData.getId()); + } catch (NumberFormatException e) { + } + String[] cores = null; + String owner = null; + if (processData instanceof IGdbThreadDMData) { + cores = ((IGdbThreadDMData) processData).getCores(); + owner = ((IGdbThreadDMData) processData).getOwner(); + } + String description = null; + if (processData instanceof IGdbThreadDMData2) { + description = ((IGdbThreadDMData2) processData) + .getDescription(); + } + procInfoList + .add(new ProcessInfo(pid, processData.getName(), + cores, owner, description)); + countingRm.done(); + } + }); + } + } else { + // Trigger right away. No need to call done() in this case. + countingRm.setDoneCount(0); + } + } + } + }); + } else { + rm.done(); + } + } + }); + } + + private void attachToProcesses(final ICommandControlDMContext controlDmc, IProcessExtendedInfo[] processes, + final RequestMonitor rm) { + + // For a local attach, GDB can figure out the binary automatically, + // so we don't need to prompt for it. + final IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); + final IGDBBackend backend = fTracker.getService(IGDBBackend.class); + final StringBuilder errors = new StringBuilder(); + + if (procService != null && backend != null) { + // Attach to each process in a sequential fashion. We must do this + // to be able to check if we are allowed to attach to the next process. + // Attaching to all of them in parallel would assume that all attach are supported. + + // Create a list of all our processes so we can attach to one at a time. + // We need to create a new list so that we can remove elements from it. + final List<IProcessExtendedInfo> procList = new ArrayList<IProcessExtendedInfo>(Arrays.asList(processes)); + // Create a one element array to remember what process we are trying to attach to, so that we can + // use it in case of error. + final IProcessExtendedInfo[] previousProcAttempt = new IProcessExtendedInfo[1]; + + class AttachToProcessRequestMonitor extends ImmediateDataRequestMonitor<IDMContext> { + public AttachToProcessRequestMonitor() { + super(); + } + + @Override + protected void handleCompleted() { + // Failed to attach to a process. Remember the error message. + if (!isSuccess()) { + formatErrorMessage(errors, previousProcAttempt[0], getStatus().getMessage()); + } + + // Check that we have a process to attach to + if (!procList.isEmpty()) { + + // Check that we can actually attach to the process. + // This is because some backends may not support multi-process. + // If the backend does not support multi-process, we only attach to the first process. + procService.isDebuggerAttachSupported(controlDmc, new ImmediateDataRequestMonitor<Boolean>() { + @Override + protected void handleCompleted() { + if (isSuccess() && getData()) { + // Can attach to process + + // Remove process from list and attach to it. + IProcessExtendedInfo process = procList.remove(0); + // Store process in case of error + previousProcAttempt[0] = process; + String pidStr = Integer.toString(process.getPid()); + + if (backend.getSessionType() == SessionType.REMOTE) { + // For remote attach, we must set the binary first so we need to prompt the user. + + // If this is the very first attach of a remote session, check if the user + // specified the binary in the launch. If so, let's add it to our map to + // avoid having to prompt the user for that binary. + // This would be particularly annoying since we didn't use to have + // to do that before we supported multi-process. + // Must do this here to be in the executor + // Bug 350365 + if (fProcessNameToBinaryMap.isEmpty()) { + IPath binaryPath = backend.getProgramPath(); + if (binaryPath != null && !binaryPath.isEmpty()) { + fProcessNameToBinaryMap.put(binaryPath.lastSegment(), + binaryPath.toOSString()); + } + } + + // Because the prompt is a very long operation, we need to run outside the + // executor, so we don't lock it. + // Bug 344892 + IPath processPath = new Path(process.getName()); + String processShortName = processPath.lastSegment(); + new PromptAndAttachToProcessJob(pidStr, + LaunchUIMessages.getString("ProcessPrompterDialog.TitlePrefix") //$NON-NLS-1$ + + process.getName(), + processShortName, new AttachToProcessRequestMonitor()).schedule(); + } else { + // For a local attach, we can attach directly without looking for the binary + // since GDB will figure it out by itself + IProcessDMContext procDmc = procService.createProcessContext(controlDmc, + pidStr); + procService.attachDebuggerToProcess(procDmc, null, + new AttachToProcessRequestMonitor()); + } + } else { + // Not allowed to attach to another process. Just stop. + rm.done(); + } + } + }); + } else { + // If there were errors, pass them-on to the caller + if (errors.length() != 0) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, errors.toString())); + } + // No other process to attach to + rm.done(); + } + } + } + ; + + // Trigger the first attach. + new AttachToProcessRequestMonitor().done(); + + } else { + rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, + "Cannot find service", null)); //$NON-NLS-1$ + } + + } + + @Override protected Object getTarget(Object element) { - if (element instanceof GdbLaunch || - element instanceof IDMVMContext) { - return element; - } - return null; - } - - @Override + if (element instanceof GdbLaunch || element instanceof IDMVMContext) { + return element; + } + return null; + } + + @Override protected boolean isRemainEnabled(IDebugCommandRequest request) { return false; } - + private void formatErrorMessage(StringBuilder errors, IProcessExtendedInfo process, String errorMsg) { // Extract process name from full path. - // On windows host, paths of style "sendmail:", "udisk-daemon:" - // is treated as device id with no path segments + // On windows host, paths of style "sendmail:", "udisk-daemon:" + // is treated as device id with no path segments String name; IPath path = new Path(process.getName()); if (path.lastSegment() == null) { @@ -647,17 +677,14 @@ public class GdbConnectCommand extends RefreshableDebugCommand implements IConne } else { name = path.lastSegment(); } - + if (errors.length() != 0) { errors.append(System.lineSeparator()).append(System.lineSeparator()); } - + errors.append(Messages.GdbConnectCommand_FailureMessage).append(" ") //$NON-NLS-1$ - .append(name).append(" [").append(process.getPid()).append("]") //$NON-NLS-1$ //$NON-NLS-2$ - .append(System.lineSeparator()) - .append(Messages.GdbConnectCommand_Error) - .append(System.lineSeparator()) - .append(errorMsg); + .append(name).append(" [").append(process.getPid()).append("]") //$NON-NLS-1$ //$NON-NLS-2$ + .append(System.lineSeparator()).append(Messages.GdbConnectCommand_Error).append(System.lineSeparator()) + .append(errorMsg); } } - diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbDebugNewExecutableCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbDebugNewExecutableCommand.java index 6ff300885c9..ea1be6b6d12 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbDebugNewExecutableCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbDebugNewExecutableCommand.java @@ -55,29 +55,29 @@ public class GdbDebugNewExecutableCommand extends RefreshableDebugCommand implem private DataRequestMonitor<NewExecutableInfo> fRequestMonitor; final private SessionType fSessionType; - - private PromptJob( SessionType sessionType, DataRequestMonitor<NewExecutableInfo> rm ) { - super( Messages.GdbDebugNewExecutableCommand_New_Executable_Prompt_Job ); + + private PromptJob(SessionType sessionType, DataRequestMonitor<NewExecutableInfo> rm) { + super(Messages.GdbDebugNewExecutableCommand_New_Executable_Prompt_Job); fSessionType = sessionType; fRequestMonitor = rm; } @Override - public IStatus runInUIThread( IProgressMonitor monitor ) { + public IStatus runInUIThread(IProgressMonitor monitor) { final NewExecutableInfo info = new NewExecutableInfo(fSessionType); NewExecutableDialog dialog = new NewExecutableDialog(GdbUIPlugin.getShell(), info); final boolean canceled = dialog.open() == Window.CANCEL; - fExecutor.execute( new DsfRunnable() { - + fExecutor.execute(new DsfRunnable() { + @Override public void run() { - if ( canceled ) + if (canceled) fRequestMonitor.cancel(); else - fRequestMonitor.setData( info ); + fRequestMonitor.setData(info); fRequestMonitor.done(); } - } ); + }); return Status.OK_STATUS; } } @@ -86,99 +86,89 @@ public class GdbDebugNewExecutableCommand extends RefreshableDebugCommand implem private final DsfExecutor fExecutor; private final DsfServicesTracker fTracker; - public GdbDebugNewExecutableCommand( DsfSession session, ILaunch launch ) { + public GdbDebugNewExecutableCommand(DsfSession session, ILaunch launch) { super(); fLaunch = launch; fExecutor = session.getExecutor(); - fTracker = new DsfServicesTracker( GdbUIPlugin.getBundleContext(), session.getId() ); + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); } public boolean canDebugNewExecutable() { - - Query<Boolean> canDebugQuery = new Query<Boolean>() { - @Override - public void execute( DataRequestMonitor<Boolean> rm ) { - IProcesses procService = fTracker.getService( IProcesses.class ); - ICommandControlService commandControl = fTracker.getService( ICommandControlService.class ); - - if ( procService == null || commandControl == null ) { - rm.setData( false ); + + Query<Boolean> canDebugQuery = new Query<Boolean>() { + @Override + public void execute(DataRequestMonitor<Boolean> rm) { + IProcesses procService = fTracker.getService(IProcesses.class); + ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); + + if (procService == null || commandControl == null) { + rm.setData(false); rm.done(); return; } - procService.isDebugNewProcessSupported( commandControl.getContext(), rm ); - } - }; + procService.isDebugNewProcessSupported(commandControl.getContext(), rm); + } + }; try { - fExecutor.execute( canDebugQuery ); + fExecutor.execute(canDebugQuery); return canDebugQuery.get(); - } - catch( InterruptedException e ) { - } - catch( ExecutionException e ) { - } - catch( RejectedExecutionException e ) { + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } catch (RejectedExecutionException e) { // Can be thrown if the session is shutdown } return false; } - public void debugNewExecutable( final RequestMonitor rm ) { - IGDBBackend backend = fTracker.getService( IGDBBackend.class ); - final IProcesses procService = fTracker.getService( IProcesses.class ); - final ICommandControlService commandControl = fTracker.getService( ICommandControlService.class ); - if ( backend == null || procService == null || commandControl == null ) { - rm.setStatus( new Status( IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service is not available" ) ); //$NON-NLS-1$ + public void debugNewExecutable(final RequestMonitor rm) { + IGDBBackend backend = fTracker.getService(IGDBBackend.class); + final IProcesses procService = fTracker.getService(IProcesses.class); + final ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); + if (backend == null || procService == null || commandControl == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service is not available")); //$NON-NLS-1$ rm.done(); return; } - PromptJob job = new PromptJob( - backend.getSessionType(), - new DataRequestMonitor<NewExecutableInfo>( fExecutor, rm ){ - - @Override - protected void handleCancel() { - rm.cancel(); - rm.done(); - }; + PromptJob job = new PromptJob(backend.getSessionType(), + new DataRequestMonitor<NewExecutableInfo>(fExecutor, rm) { - @Override - protected void handleSuccess() { - try { - Map<String, Object> attributes = getLaunchConfiguration().getAttributes(); - attributes.putAll(getData().getAttributes()); - procService.debugNewProcess( - commandControl.getContext(), - getData().getHostPath(), - attributes, - new ImmediateDataRequestMonitor<IDMContext>( rm ) ); - } - catch( CoreException e ) { - rm.setStatus( e.getStatus() ); + @Override + protected void handleCancel() { + rm.cancel(); rm.done(); - } - }; - } ); + }; + + @Override + protected void handleSuccess() { + try { + Map<String, Object> attributes = getLaunchConfiguration().getAttributes(); + attributes.putAll(getData().getAttributes()); + procService.debugNewProcess(commandControl.getContext(), getData().getHostPath(), + attributes, new ImmediateDataRequestMonitor<IDMContext>(rm)); + } catch (CoreException e) { + rm.setStatus(e.getStatus()); + rm.done(); + } + }; + }); job.schedule(); } @Override - protected void doExecute( Object[] targets, IProgressMonitor monitor, IRequest request ) throws CoreException { + protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { Query<Boolean> query = new Query<Boolean>() { @Override - protected void execute( DataRequestMonitor<Boolean> rm ) { - debugNewExecutable( rm ); + protected void execute(DataRequestMonitor<Boolean> rm) { + debugNewExecutable(rm); } }; try { - fExecutor.execute( query ); + fExecutor.execute(query); query.get(); - } - catch( InterruptedException e ) { - } - catch( ExecutionException e ) { + } catch (InterruptedException e) { + } catch (ExecutionException e) { // There was an error. Propagate it to the user String errorMessage; if (e.getCause() != null) { @@ -186,13 +176,11 @@ public class GdbDebugNewExecutableCommand extends RefreshableDebugCommand implem } else { errorMessage = e.getMessage(); } - request.setStatus( new Status( IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, errorMessage ) ); - } - catch( CancellationException e ) { + request.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, errorMessage)); + } catch (CancellationException e) { // Nothing to do, just ignore the command since the user // cancelled it. - } - catch( RejectedExecutionException e ) { + } catch (RejectedExecutionException e) { // Can be thrown if the session is shutdown } finally { updateEnablement(); @@ -200,13 +188,14 @@ public class GdbDebugNewExecutableCommand extends RefreshableDebugCommand implem } @Override - protected boolean isExecutable( Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request ) throws CoreException { + protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) + throws CoreException { return canDebugNewExecutable(); } @Override - protected Object getTarget( Object element ) { - if ( element instanceof GdbLaunch || element instanceof IDMVMContext ) + protected Object getTarget(Object element) { + if (element instanceof GdbLaunch || element instanceof IDMVMContext) return element; return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbResumeWithoutSignalCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbResumeWithoutSignalCommand.java index 22d3e9eb370..80f2c0e05a5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbResumeWithoutSignalCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbResumeWithoutSignalCommand.java @@ -36,108 +36,109 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; /** * Command performing a resume without signal. - * + * * @since 2.1 */ public class GdbResumeWithoutSignalCommand extends AbstractDebugCommand implements IResumeWithoutSignalHandler { - private final DsfExecutor fExecutor; - private final DsfServicesTracker fTracker; - - public GdbResumeWithoutSignalCommand(DsfSession session) { - fExecutor = session.getExecutor(); - fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } - - public void dispose() { - fTracker.dispose(); - } - - @Override + private final DsfExecutor fExecutor; + private final DsfServicesTracker fTracker; + + public GdbResumeWithoutSignalCommand(DsfSession session) { + fExecutor = session.getExecutor(); + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + } + + public void dispose() { + fTracker.dispose(); + } + + @Override protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { - if (targets.length != 1) { - return; - } - - final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), IExecutionDMContext.class); - if (dmc == null) { - return; - } - - Query<Object> query = new Query<Object>() { - @Override - public void execute(DataRequestMonitor<Object> rm) { - IRunControl runControl = fTracker.getService(IRunControl.class); - - if (runControl != null) { - // This call must be replaced by a new 'resumeWithoutSignal' or even better - // resumeWithSignal(0) which does not exist in the runControl service yet. - // But this method is currently disabled anyway, until proper support is available. - rm.done(); - } else { - rm.done(); - } - } - }; - try { - fExecutor.execute(query); - query.get(); + if (targets.length != 1) { + return; + } + + final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + IExecutionDMContext.class); + if (dmc == null) { + return; + } + + Query<Object> query = new Query<Object>() { + @Override + public void execute(DataRequestMonitor<Object> rm) { + IRunControl runControl = fTracker.getService(IRunControl.class); + + if (runControl != null) { + // This call must be replaced by a new 'resumeWithoutSignal' or even better + // resumeWithSignal(0) which does not exist in the runControl service yet. + // But this method is currently disabled anyway, until proper support is available. + rm.done(); + } else { + rm.done(); + } + } + }; + try { + fExecutor.execute(query); + query.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } + } - @Override + @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException - { - if (targets.length != 1) { - return false; - } - - final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), IExecutionDMContext.class); - if (dmc == null) { - return false; - } - -// Currently, we don't properly support the handling of signal in DSF-GDB, so we cannot -// really enable this command - -// Query<Boolean> query = new Query<Boolean>() { -// @Override -// public void execute(DataRequestMonitor<Boolean> rm) { -// IRunControl runControl = fTracker.getService(IRunControl.class); -// -// if (runControl != null) { -// runControl.canResume(dmc, rm); -// } else { -// rm.setData(false); -// rm.done(); -// } -// } -// }; -// try { -// fExecutor.execute(query); -// return query.get(); -// } catch (InterruptedException e) { -// } catch (ExecutionException e) { -// } catch (RejectedExecutionException e) { -// // Can be thrown if the session is shutdown -// } + throws CoreException { + if (targets.length != 1) { + return false; + } + + final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + IExecutionDMContext.class); + if (dmc == null) { + return false; + } + + // Currently, we don't properly support the handling of signal in DSF-GDB, so we cannot + // really enable this command + + // Query<Boolean> query = new Query<Boolean>() { + // @Override + // public void execute(DataRequestMonitor<Boolean> rm) { + // IRunControl runControl = fTracker.getService(IRunControl.class); + // + // if (runControl != null) { + // runControl.canResume(dmc, rm); + // } else { + // rm.setData(false); + // rm.done(); + // } + // } + // }; + // try { + // fExecutor.execute(query); + // return query.get(); + // } catch (InterruptedException e) { + // } catch (ExecutionException e) { + // } catch (RejectedExecutionException e) { + // // Can be thrown if the session is shutdown + // } return false; - } - - @Override + } + + @Override protected Object getTarget(Object element) { - if (element instanceof IDMVMContext) { - return element; - } - return null; - } + if (element instanceof IDMVMContext) { + return element; + } + return null; + } - @Override + @Override protected boolean isRemainEnabled(IDebugCommandRequest request) { return false; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseResumeCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseResumeCommand.java index 3f66519840f..3a1a57092f8 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseResumeCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseResumeCommand.java @@ -36,102 +36,103 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; /** * Command performing a reverse resume. - * + * * @since 2.1 */ public class GdbReverseResumeCommand extends AbstractDebugCommand implements IReverseResumeHandler { - private final DsfExecutor fExecutor; - private final DsfServicesTracker fTracker; - - public GdbReverseResumeCommand(DsfSession session) { - fExecutor = session.getExecutor(); - fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } - - public void dispose() { - fTracker.dispose(); - } - - @Override + private final DsfExecutor fExecutor; + private final DsfServicesTracker fTracker; + + public GdbReverseResumeCommand(DsfSession session) { + fExecutor = session.getExecutor(); + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + } + + public void dispose() { + fTracker.dispose(); + } + + @Override protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { - if (targets.length != 1) { - return; - } - - final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), IExecutionDMContext.class); - if (dmc == null) { - return; - } - - Query<Object> reverseResume = new Query<Object>() { - @Override - public void execute(DataRequestMonitor<Object> rm) { - IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); - - if (runControl != null) { - runControl.reverseResume(dmc, rm); - } else { - rm.done(); - } - } - }; - try { - fExecutor.execute(reverseResume); - reverseResume.get(); + if (targets.length != 1) { + return; + } + + final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + IExecutionDMContext.class); + if (dmc == null) { + return; + } + + Query<Object> reverseResume = new Query<Object>() { + @Override + public void execute(DataRequestMonitor<Object> rm) { + IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); + + if (runControl != null) { + runControl.reverseResume(dmc, rm); + } else { + rm.done(); + } + } + }; + try { + fExecutor.execute(reverseResume); + reverseResume.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } + } - @Override + @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException - { - if (targets.length != 1) { - return false; - } - - final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), IExecutionDMContext.class); - if (dmc == null) { - return false; - } - - Query<Boolean> canReverseResume = new Query<Boolean>() { - @Override - public void execute(DataRequestMonitor<Boolean> rm) { - IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); - - if (runControl != null) { - runControl.canReverseResume(dmc, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; - try { - fExecutor.execute(canReverseResume); + throws CoreException { + if (targets.length != 1) { + return false; + } + + final IExecutionDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + IExecutionDMContext.class); + if (dmc == null) { + return false; + } + + Query<Boolean> canReverseResume = new Query<Boolean>() { + @Override + public void execute(DataRequestMonitor<Boolean> rm) { + IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); + + if (runControl != null) { + runControl.canReverseResume(dmc, rm); + } else { + rm.setData(false); + rm.done(); + } + } + }; + try { + fExecutor.execute(canReverseResume); return canReverseResume.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } return false; - } - - @Override + } + + @Override protected Object getTarget(Object element) { - if (element instanceof IDMVMContext) { - return element; - } - return null; - } + if (element instanceof IDMVMContext) { + return element; + } + return null; + } - @Override + @Override protected boolean isRemainEnabled(IDebugCommandRequest request) { return false; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseStepIntoCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseStepIntoCommand.java index ed94d4cdb5f..d16c1fc4a2d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseStepIntoCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseStepIntoCommand.java @@ -25,11 +25,12 @@ import org.eclipse.cdt.dsf.service.DsfSession; public class GdbReverseStepIntoCommand extends GdbAbstractReverseStepCommand implements IReverseStepIntoHandler { public GdbReverseStepIntoCommand(DsfSession session, DsfSteppingModeTarget steppingMode) { super(session, steppingMode); - } + } @Override protected final StepType getStepType() { - boolean instructionSteppingEnabled = getSteppingMode() != null && getSteppingMode().isInstructionSteppingEnabled(); + boolean instructionSteppingEnabled = getSteppingMode() != null + && getSteppingMode().isInstructionSteppingEnabled(); return instructionSteppingEnabled ? StepType.INSTRUCTION_STEP_INTO : StepType.STEP_INTO; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseStepOverCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseStepOverCommand.java index c8a8b231f3a..32b0b2600fb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseStepOverCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseStepOverCommand.java @@ -29,7 +29,8 @@ public class GdbReverseStepOverCommand extends GdbAbstractReverseStepCommand imp @Override protected final StepType getStepType() { - boolean instructionSteppingEnabled = getSteppingMode() != null && getSteppingMode().isInstructionSteppingEnabled(); + boolean instructionSteppingEnabled = getSteppingMode() != null + && getSteppingMode().isInstructionSteppingEnabled(); return instructionSteppingEnabled ? StepType.INSTRUCTION_STEP_OVER : StepType.STEP_OVER; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseToggleCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseToggleCommand.java index 3028e903a11..c69d5105bae 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseToggleCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseToggleCommand.java @@ -58,350 +58,357 @@ import org.eclipse.ui.services.IEvaluationService; /** * Command that toggles the Reverse Debugging feature - * + * * @since 2.1 */ public class GdbReverseToggleCommand extends AbstractDebugCommand implements IChangeReverseMethodHandler { - private final DsfExecutor fExecutor; - private final DsfServicesTracker fTracker; - private final DsfSession fSession; - - /** The reverse debugging method that was last returned by the service **/ - private ReverseDebugMethod fCurrentMethod; - /** The reverse debugging method that was used before the new method was selected **/ - private ReverseDebugMethod fPreviousMethod; - /** The reverse debugging method to be used when the toggle button is selected */ - private ReverseDebugMethod fNextMethod; - - public GdbReverseToggleCommand(DsfSession session) { - fExecutor = session.getExecutor(); - fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - fSession = session; - fCurrentMethod = ReverseDebugMethod.OFF; - fPreviousMethod = ReverseDebugMethod.OFF; - fNextMethod = ReverseDebugMethod.OFF; - - try { - fExecutor.execute(new DsfRunnable() { - @Override - public void run() { - fSession.addServiceEventListener(GdbReverseToggleCommand.this, null); - } - }); - } catch(RejectedExecutionException e) {} - } - - public void dispose() { - try { - fExecutor.execute(new DsfRunnable() { - @Override - public void run() { - fSession.removeServiceEventListener(GdbReverseToggleCommand.this); - } - }); - } catch (RejectedExecutionException e) { - // Session already gone. - } - fTracker.dispose(); - } - - @Override - protected void doExecute(Object[] targets, IProgressMonitor monitor, final IRequest request) throws CoreException { - if (targets.length != 1) { - return; - } - - IDMContext dmc = ((IDMVMContext)targets[0]).getDMContext(); - final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); - if (controlDmc == null) { - return; - } - - Query<Object> setReverseMode = new Query<Object>() { - @Override - public void execute(final DataRequestMonitor<Object> rm) { - final IReverseRunControl2 runControl = fTracker.getService(IReverseRunControl2.class); - - if (runControl != null) { - final ReverseDebugMethod newMethod; - if (fNextMethod == ReverseDebugMethod.HARDWARE) { - String defaultValue = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID, - IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_HARDWARE, - IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_GDB_TRACE, null); - - if (defaultValue.equals(IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_BRANCH_TRACE)) { - newMethod = ReverseDebugMethod.BRANCH_TRACE; - } else if (defaultValue.equals(IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_PROCESSOR_TRACE)) { - newMethod = ReverseDebugMethod.PROCESSOR_TRACE; - } else { - newMethod = ReverseDebugMethod.GDB_TRACE; - } - } else { - newMethod = fNextMethod; - } - runControl.enableReverseMode(controlDmc, newMethod, new RequestMonitor(fExecutor, rm) { - @Override - public void handleError() { - // Call the parent function - // Since otherwise the status is not updated - super.handleError(); - // Here we avoid setting any status other than OK, since we want to - // avoid the default dialog box from eclipse and we propagate the error - // with the plugin specific code of 1, here the ReverseToggleCommandHandler - // interprets it as, the selected trace method is not available - if (newMethod == ReverseDebugMethod.PROCESSOR_TRACE) { - request.setStatus(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, 1, Messages.GdbReverseDebugging_ProcessorTraceReverseDebugNotAvailable, null)); - } else if (newMethod == ReverseDebugMethod.BRANCH_TRACE || newMethod == ReverseDebugMethod.GDB_TRACE) { - request.setStatus(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, 1, Messages.GdbReverseDebugging_HardwareReverseDebugNotAvailable, null)); - } else { - request.setStatus(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, 1, Messages.GdbReverseDebugging_ReverseDebugNotAvailable, null)); - } - } - }); - } else { - final IReverseRunControl runControl_old = fTracker.getService(IReverseRunControl.class); - if (runControl_old != null) { - if (fCurrentMethod != ReverseDebugMethod.OFF && fCurrentMethod != ReverseDebugMethod.SOFTWARE) { - runControl_old.enableReverseMode(controlDmc, false, rm); // Switch Off tracing - request.setStatus(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, 1, Messages.GdbReverseDebugging_HardwareReverseDebugNotAvailable, null)); - return; - } - runControl_old.isReverseModeEnabled(controlDmc, new DataRequestMonitor<Boolean>(fExecutor, rm) { - @Override - public void handleSuccess() { - runControl_old.enableReverseMode(controlDmc, !getData(), rm); - } - }); - } else { - rm.done(); - } - } - } - }; - try { - fExecutor.execute(setReverseMode); - setReverseMode.get(); + private final DsfExecutor fExecutor; + private final DsfServicesTracker fTracker; + private final DsfSession fSession; + + /** The reverse debugging method that was last returned by the service **/ + private ReverseDebugMethod fCurrentMethod; + /** The reverse debugging method that was used before the new method was selected **/ + private ReverseDebugMethod fPreviousMethod; + /** The reverse debugging method to be used when the toggle button is selected */ + private ReverseDebugMethod fNextMethod; + + public GdbReverseToggleCommand(DsfSession session) { + fExecutor = session.getExecutor(); + fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); + fSession = session; + fCurrentMethod = ReverseDebugMethod.OFF; + fPreviousMethod = ReverseDebugMethod.OFF; + fNextMethod = ReverseDebugMethod.OFF; + + try { + fExecutor.execute(new DsfRunnable() { + @Override + public void run() { + fSession.addServiceEventListener(GdbReverseToggleCommand.this, null); + } + }); + } catch (RejectedExecutionException e) { + } + } + + public void dispose() { + try { + fExecutor.execute(new DsfRunnable() { + @Override + public void run() { + fSession.removeServiceEventListener(GdbReverseToggleCommand.this); + } + }); + } catch (RejectedExecutionException e) { + // Session already gone. + } + fTracker.dispose(); + } + + @Override + protected void doExecute(Object[] targets, IProgressMonitor monitor, final IRequest request) throws CoreException { + if (targets.length != 1) { + return; + } + + IDMContext dmc = ((IDMVMContext) targets[0]).getDMContext(); + final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); + if (controlDmc == null) { + return; + } + + Query<Object> setReverseMode = new Query<Object>() { + @Override + public void execute(final DataRequestMonitor<Object> rm) { + final IReverseRunControl2 runControl = fTracker.getService(IReverseRunControl2.class); + + if (runControl != null) { + final ReverseDebugMethod newMethod; + if (fNextMethod == ReverseDebugMethod.HARDWARE) { + String defaultValue = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID, + IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_HARDWARE, + IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_GDB_TRACE, null); + + if (defaultValue.equals(IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_BRANCH_TRACE)) { + newMethod = ReverseDebugMethod.BRANCH_TRACE; + } else if (defaultValue + .equals(IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_PROCESSOR_TRACE)) { + newMethod = ReverseDebugMethod.PROCESSOR_TRACE; + } else { + newMethod = ReverseDebugMethod.GDB_TRACE; + } + } else { + newMethod = fNextMethod; + } + runControl.enableReverseMode(controlDmc, newMethod, new RequestMonitor(fExecutor, rm) { + @Override + public void handleError() { + // Call the parent function + // Since otherwise the status is not updated + super.handleError(); + // Here we avoid setting any status other than OK, since we want to + // avoid the default dialog box from eclipse and we propagate the error + // with the plugin specific code of 1, here the ReverseToggleCommandHandler + // interprets it as, the selected trace method is not available + if (newMethod == ReverseDebugMethod.PROCESSOR_TRACE) { + request.setStatus(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, 1, + Messages.GdbReverseDebugging_ProcessorTraceReverseDebugNotAvailable, null)); + } else if (newMethod == ReverseDebugMethod.BRANCH_TRACE + || newMethod == ReverseDebugMethod.GDB_TRACE) { + request.setStatus(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, 1, + Messages.GdbReverseDebugging_HardwareReverseDebugNotAvailable, null)); + } else { + request.setStatus(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, 1, + Messages.GdbReverseDebugging_ReverseDebugNotAvailable, null)); + } + } + }); + } else { + final IReverseRunControl runControl_old = fTracker.getService(IReverseRunControl.class); + if (runControl_old != null) { + if (fCurrentMethod != ReverseDebugMethod.OFF && fCurrentMethod != ReverseDebugMethod.SOFTWARE) { + runControl_old.enableReverseMode(controlDmc, false, rm); // Switch Off tracing + request.setStatus(new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, 1, + Messages.GdbReverseDebugging_HardwareReverseDebugNotAvailable, null)); + return; + } + runControl_old.isReverseModeEnabled(controlDmc, new DataRequestMonitor<Boolean>(fExecutor, rm) { + @Override + public void handleSuccess() { + runControl_old.enableReverseMode(controlDmc, !getData(), rm); + } + }); + } else { + rm.done(); + } + } + } + }; + try { + fExecutor.execute(setReverseMode); + setReverseMode.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } + } - @Override + @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException - { - if (targets.length != 1) { - return false; - } - - IDMContext dmc = ((IDMVMContext)targets[0]).getDMContext(); - final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); - final IExecutionDMContext execDmc = DMContexts.getAncestorOfType(dmc, IExecutionDMContext.class); - if (controlDmc == null && execDmc == null) { - return false; - } - - Query<Boolean> canSetReverseMode = new Query<Boolean>() { - @Override - public void execute(DataRequestMonitor<Boolean> rm) { - IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); - - // Only allow to toggle reverse if the program is suspended. - // When the program is running, GDB will not answer our command - // in toggleReverse() and since it is blocking, it will hang the entire UI! - if (runControl != null && - runControl instanceof IRunControl && ((IRunControl)runControl).isSuspended(execDmc)) { - runControl.canEnableReverseMode(controlDmc, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; - try { - fExecutor.execute(canSetReverseMode); - return canSetReverseMode.get(); - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } + throws CoreException { + if (targets.length != 1) { + return false; + } + + IDMContext dmc = ((IDMVMContext) targets[0]).getDMContext(); + final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); + final IExecutionDMContext execDmc = DMContexts.getAncestorOfType(dmc, IExecutionDMContext.class); + if (controlDmc == null && execDmc == null) { + return false; + } + + Query<Boolean> canSetReverseMode = new Query<Boolean>() { + @Override + public void execute(DataRequestMonitor<Boolean> rm) { + IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); + + // Only allow to toggle reverse if the program is suspended. + // When the program is running, GDB will not answer our command + // in toggleReverse() and since it is blocking, it will hang the entire UI! + if (runControl != null && runControl instanceof IRunControl + && ((IRunControl) runControl).isSuspended(execDmc)) { + runControl.canEnableReverseMode(controlDmc, rm); + } else { + rm.setData(false); + rm.done(); + } + } + }; + try { + fExecutor.execute(canSetReverseMode); + return canSetReverseMode.get(); + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } return false; - } - - @Override + } + + @Override protected Object getTarget(Object element) { - if (element instanceof IDMVMContext) { - return element; - } - return null; - } + if (element instanceof IDMVMContext) { + return element; + } + return null; + } - @Override + @Override protected boolean isRemainEnabled(IDebugCommandRequest request) { return true; } - - @Override - public boolean toggleNeedsUpdating() { - return true; - } - - @Override - public boolean isReverseToggled(Object context) { - IDMContext dmc; - - if (context instanceof IDMContext) { - dmc = (IDMContext)context; - } else if (context instanceof IDMVMContext) { - dmc = ((IDMVMContext)context).getDMContext(); - } else { - return false; - } - - final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); - if (controlDmc == null) { - return false; - } - - Query<Boolean> isToggledQuery = new Query<Boolean>() { - @Override - public void execute(final DataRequestMonitor<Boolean> rm) { - final IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); - - if (runControl != null) { - runControl.isReverseModeEnabled(controlDmc, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; - try { - fExecutor.execute(isToggledQuery); - return isToggledQuery.get(500, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } catch (TimeoutException e) { - // If we timeout, we default to false. - // This is to avoid a deadlock - } - - return false; - } - - /** - * @noreference This method is not intended to be referenced by clients. - */ - @DsfServiceEventHandler - public void eventDispatched(IReverseModeChangedDMEvent e) { - new WorkbenchJob("") { //$NON-NLS-1$ + + @Override + public boolean toggleNeedsUpdating() { + return true; + } + + @Override + public boolean isReverseToggled(Object context) { + IDMContext dmc; + + if (context instanceof IDMContext) { + dmc = (IDMContext) context; + } else if (context instanceof IDMVMContext) { + dmc = ((IDMVMContext) context).getDMContext(); + } else { + return false; + } + + final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); + if (controlDmc == null) { + return false; + } + + Query<Boolean> isToggledQuery = new Query<Boolean>() { + @Override + public void execute(final DataRequestMonitor<Boolean> rm) { + final IReverseRunControl runControl = fTracker.getService(IReverseRunControl.class); + + if (runControl != null) { + runControl.isReverseModeEnabled(controlDmc, rm); + } else { + rm.setData(false); + rm.done(); + } + } + }; + try { + fExecutor.execute(isToggledQuery); + return isToggledQuery.get(500, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } catch (TimeoutException e) { + // If we timeout, we default to false. + // This is to avoid a deadlock + } + + return false; + } + + /** + * @noreference This method is not intended to be referenced by clients. + */ + @DsfServiceEventHandler + public void eventDispatched(IReverseModeChangedDMEvent e) { + new WorkbenchJob("") { //$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { - // Request re-evaluation of property "org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled" to update - // visibility of reverse stepping commands. - IEvaluationService exprService = PlatformUI.getWorkbench().getService(IEvaluationService.class); - if (exprService != null) { - exprService.requestEvaluation("org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled"); //$NON-NLS-1$ - } - // Refresh reverse toggle commands with the new state of reverse enabled. - // This is in order to keep multiple toggle actions in UI in sync. - ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); - if (commandService != null) { - commandService.refreshElements("org.eclipse.cdt.debug.ui.command.reverseToggle", null); //$NON-NLS-1$ - } - + // Request re-evaluation of property "org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled" to update + // visibility of reverse stepping commands. + IEvaluationService exprService = PlatformUI.getWorkbench().getService(IEvaluationService.class); + if (exprService != null) { + exprService.requestEvaluation("org.eclipse.cdt.debug.ui.isReverseDebuggingEnabled"); //$NON-NLS-1$ + } + // Refresh reverse toggle commands with the new state of reverse enabled. + // This is in order to keep multiple toggle actions in UI in sync. + ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); + if (commandService != null) { + commandService.refreshElements("org.eclipse.cdt.debug.ui.command.reverseToggle", null); //$NON-NLS-1$ + } + return Status.OK_STATUS; } }.schedule(); - } - - @Override - public void setReverseDebugMethod(ReverseDebugMethod traceMethod) { - fNextMethod = traceMethod; - } - - @Override - public ReverseDebugMethod getReverseDebugMethod(final Object context) { - IDMContext dmc; - - if (context instanceof IDMContext) { - dmc = (IDMContext)context; - } else if (context instanceof IDMVMContext) { - dmc = ((IDMVMContext)context).getDMContext(); - } else { - return ReverseDebugMethod.OFF; - } - - final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); - if (controlDmc == null) { - return ReverseDebugMethod.OFF; - } - - Query<ReverseDebugMethod> reverseMethodQuery = new Query<ReverseDebugMethod>() { - @Override - public void execute(DataRequestMonitor<ReverseDebugMethod> rm) { - IReverseRunControl2 runControl = fTracker.getService(IReverseRunControl2.class); - if (runControl != null) { - runControl.getReverseTraceMethod(controlDmc, new ImmediateDataRequestMonitor<ReverseDebugMethod>(rm) { - @Override - protected void handleCompleted() { - if (!isSuccess()) { - rm.done(ReverseDebugMethod.OFF); - } else { - ReverseDebugMethod method = getData(); - if (method == ReverseDebugMethod.BRANCH_TRACE || - method == ReverseDebugMethod.PROCESSOR_TRACE || - method == ReverseDebugMethod.GDB_TRACE) { - method = ReverseDebugMethod.HARDWARE; - } - rm.done(method); - } - } - }); - } else { - IReverseRunControl runControl_old = fTracker.getService(IReverseRunControl.class); - if (runControl_old != null) { - runControl_old.isReverseModeEnabled(controlDmc, new ImmediateDataRequestMonitor<Boolean>(rm) { - @Override - protected void handleCompleted() { - if (isSuccess() && getData()) { - rm.done(ReverseDebugMethod.SOFTWARE); - } else { - rm.done(ReverseDebugMethod.OFF); - } - } - }); - } else { - rm.done(ReverseDebugMethod.OFF); - } - } - } - }; - try { - fExecutor.execute(reverseMethodQuery); - ReverseDebugMethod currMethod = reverseMethodQuery.get(500, TimeUnit.MILLISECONDS); - - if (currMethod != fCurrentMethod) { - fPreviousMethod = fCurrentMethod; - fCurrentMethod = currMethod; - } - return fCurrentMethod; - } catch (InterruptedException e) { - } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - } catch (TimeoutException e) { - // If we timeout, we default to OFF. - // This is to avoid a deadlock - } - - return ReverseDebugMethod.OFF; - } + } + + @Override + public void setReverseDebugMethod(ReverseDebugMethod traceMethod) { + fNextMethod = traceMethod; + } + + @Override + public ReverseDebugMethod getReverseDebugMethod(final Object context) { + IDMContext dmc; + + if (context instanceof IDMContext) { + dmc = (IDMContext) context; + } else if (context instanceof IDMVMContext) { + dmc = ((IDMVMContext) context).getDMContext(); + } else { + return ReverseDebugMethod.OFF; + } + + final ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); + if (controlDmc == null) { + return ReverseDebugMethod.OFF; + } + + Query<ReverseDebugMethod> reverseMethodQuery = new Query<ReverseDebugMethod>() { + @Override + public void execute(DataRequestMonitor<ReverseDebugMethod> rm) { + IReverseRunControl2 runControl = fTracker.getService(IReverseRunControl2.class); + if (runControl != null) { + runControl.getReverseTraceMethod(controlDmc, + new ImmediateDataRequestMonitor<ReverseDebugMethod>(rm) { + @Override + protected void handleCompleted() { + if (!isSuccess()) { + rm.done(ReverseDebugMethod.OFF); + } else { + ReverseDebugMethod method = getData(); + if (method == ReverseDebugMethod.BRANCH_TRACE + || method == ReverseDebugMethod.PROCESSOR_TRACE + || method == ReverseDebugMethod.GDB_TRACE) { + method = ReverseDebugMethod.HARDWARE; + } + rm.done(method); + } + } + }); + } else { + IReverseRunControl runControl_old = fTracker.getService(IReverseRunControl.class); + if (runControl_old != null) { + runControl_old.isReverseModeEnabled(controlDmc, new ImmediateDataRequestMonitor<Boolean>(rm) { + @Override + protected void handleCompleted() { + if (isSuccess() && getData()) { + rm.done(ReverseDebugMethod.SOFTWARE); + } else { + rm.done(ReverseDebugMethod.OFF); + } + } + }); + } else { + rm.done(ReverseDebugMethod.OFF); + } + } + } + }; + try { + fExecutor.execute(reverseMethodQuery); + ReverseDebugMethod currMethod = reverseMethodQuery.get(500, TimeUnit.MILLISECONDS); + + if (currMethod != fCurrentMethod) { + fPreviousMethod = fCurrentMethod; + fCurrentMethod = currMethod; + } + return fCurrentMethod; + } catch (InterruptedException e) { + } catch (ExecutionException e) { + } catch (RejectedExecutionException e) { + } catch (TimeoutException e) { + // If we timeout, we default to OFF. + // This is to avoid a deadlock + } + + return ReverseDebugMethod.OFF; + } @Override public ReverseDebugMethod getPreviousReverseDebugMethod(Object context) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSaveTraceDataCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSaveTraceDataCommand.java index d29c6b1ffa5..a54f8528aea 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSaveTraceDataCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSaveTraceDataCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -41,43 +41,43 @@ import org.eclipse.ui.PlatformUI; /** * Command to save the trace data to file - * + * * @since 2.1 */ public class GdbSaveTraceDataCommand extends AbstractDebugCommand implements ISaveTraceDataHandler { - + private final DsfExecutor fExecutor; private final DsfServicesTracker fTracker; public GdbSaveTraceDataCommand(DsfSession session) { fExecutor = session.getExecutor(); fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } + } public void dispose() { fTracker.dispose(); } @Override - protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) - throws CoreException { + protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { if (targets.length != 1) { return; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return; } final String[] fileName = new String[1]; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - @Override + @Override public void run() { fileName[0] = promptForFileName(); }; }); - + if (fileName[0] != null) { Query<Object> saveTraceDataQuery = new Query<Object>() { @Override @@ -104,29 +104,30 @@ public class GdbSaveTraceDataCommand extends AbstractDebugCommand implements ISa @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException { + throws CoreException { if (targets.length != 1) { return false; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return false; } - Query<Boolean> canSaveQuery = new Query<Boolean>() { - @Override - public void execute(DataRequestMonitor<Boolean> rm) { - IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - - if (traceControl != null) { - traceControl.canSaveTraceData(dmc, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; + Query<Boolean> canSaveQuery = new Query<Boolean>() { + @Override + public void execute(DataRequestMonitor<Boolean> rm) { + IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + + if (traceControl != null) { + traceControl.canSaveTraceData(dmc, rm); + } else { + rm.setData(false); + rm.done(); + } + } + }; try { fExecutor.execute(canSaveQuery); return canSaveQuery.get(); @@ -151,7 +152,7 @@ public class GdbSaveTraceDataCommand extends AbstractDebugCommand implements ISa * Keep the command enabled since there is no automatic re-selection of the debug * context for this command. If not, it will remain disabled until something causes * the debug context to change. - * + * * (non-Javadoc) * @see org.eclipse.debug.core.commands.AbstractDebugCommand#isRemainEnabled(org.eclipse.debug.core.commands.IDebugCommandRequest) */ @@ -159,9 +160,9 @@ public class GdbSaveTraceDataCommand extends AbstractDebugCommand implements ISa protected boolean isRemainEnabled(IDebugCommandRequest request) { return true; } - + private String promptForFileName() { - Shell shell = Display.getDefault().getActiveShell(); + Shell shell = Display.getDefault().getActiveShell(); if (shell == null) { return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectNextTraceRecordCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectNextTraceRecordCommand.java index ed97eda5ef9..8adbe0769f4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectNextTraceRecordCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectNextTraceRecordCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -41,7 +41,7 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; /** * Command to select the next trace record - * + * * @since 2.1 */ public class GdbSelectNextTraceRecordCommand extends AbstractDebugCommand implements ISelectNextTraceRecordHandler { @@ -53,7 +53,7 @@ public class GdbSelectNextTraceRecordCommand extends AbstractDebugCommand implem fExecutor = session.getExecutor(); fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); fSession = session; - } + } public void dispose() { fTracker.dispose(); @@ -65,103 +65,105 @@ public class GdbSelectNextTraceRecordCommand extends AbstractDebugCommand implem return; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return; } - Query<Object> selectRecordQuery = new Query<Object>() { - @Override - public void execute(final DataRequestMonitor<Object> rm) { - final IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - - if (traceControl != null) { - traceControl.getCurrentTraceRecordContext( - dmc, - new DataRequestMonitor<ITraceRecordDMContext>(fExecutor, rm) { - @Override - protected void handleSuccess() { - final ITraceRecordDMContext previousDmc = getData(); - ITraceRecordDMContext nextDmc = traceControl.createNextRecordContext(previousDmc); - // Must send the event right away to tell the services we are starting visualization - // If we don't, the services won't behave accordingly soon enough - // Bug 347514 - fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(nextDmc), new Hashtable<String, String>()); - - traceControl.selectTraceRecord(nextDmc, new ImmediateRequestMonitor(rm) { - @Override - protected void handleError() { - // If we weren't able to select the next record, we must notify that we are still on the previous one - // since we have already sent a TraceRecordSelectedChangedEvent early, but it didn't happen. - fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(previousDmc), new Hashtable<String, String>()); - rm.done(); - } - }); - }; - }); - } else { - rm.done(); - } - } - }; - try { - fExecutor.execute(selectRecordQuery); - selectRecordQuery.get(); + Query<Object> selectRecordQuery = new Query<Object>() { + @Override + public void execute(final DataRequestMonitor<Object> rm) { + final IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + + if (traceControl != null) { + traceControl.getCurrentTraceRecordContext(dmc, + new DataRequestMonitor<ITraceRecordDMContext>(fExecutor, rm) { + @Override + protected void handleSuccess() { + final ITraceRecordDMContext previousDmc = getData(); + ITraceRecordDMContext nextDmc = traceControl.createNextRecordContext(previousDmc); + // Must send the event right away to tell the services we are starting visualization + // If we don't, the services won't behave accordingly soon enough + // Bug 347514 + fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(nextDmc), + new Hashtable<String, String>()); + + traceControl.selectTraceRecord(nextDmc, new ImmediateRequestMonitor(rm) { + @Override + protected void handleError() { + // If we weren't able to select the next record, we must notify that we are still on the previous one + // since we have already sent a TraceRecordSelectedChangedEvent early, but it didn't happen. + fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(previousDmc), + new Hashtable<String, String>()); + rm.done(); + } + }); + }; + }); + } else { + rm.done(); + } + } + }; + try { + fExecutor.execute(selectRecordQuery); + selectRecordQuery.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } } @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException - { + throws CoreException { if (targets.length != 1) { return false; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return false; } - Query<Boolean> canSelectRecordQuery = new Query<Boolean>() { - @Override - public void execute(final DataRequestMonitor<Boolean> rm) { - IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - - if (traceControl != null) { - traceControl.getTraceStatus(dmc, new DataRequestMonitor<ITraceStatusDMData>(fExecutor, rm) { - @Override - protected void handleSuccess() { - if (getData().getNumberOfCollectedFrame() > 0) { - IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - if (traceControl != null) { - traceControl.isTracing(dmc, new DataRequestMonitor<Boolean>(fExecutor, rm) { - @Override - protected void handleSuccess() { - rm.setData(!getData()); - rm.done(); - }; - }); - } else { - rm.setData(false); - rm.done(); - } - } else { - rm.setData(false); - rm.done(); - } - }; - }); - } else { - rm.setData(false); - rm.done(); - } - } - }; + Query<Boolean> canSelectRecordQuery = new Query<Boolean>() { + @Override + public void execute(final DataRequestMonitor<Boolean> rm) { + IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + + if (traceControl != null) { + traceControl.getTraceStatus(dmc, new DataRequestMonitor<ITraceStatusDMData>(fExecutor, rm) { + @Override + protected void handleSuccess() { + if (getData().getNumberOfCollectedFrame() > 0) { + IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + if (traceControl != null) { + traceControl.isTracing(dmc, new DataRequestMonitor<Boolean>(fExecutor, rm) { + @Override + protected void handleSuccess() { + rm.setData(!getData()); + rm.done(); + }; + }); + } else { + rm.setData(false); + rm.done(); + } + } else { + rm.setData(false); + rm.done(); + } + }; + }); + } else { + rm.setData(false); + rm.done(); + } + } + }; try { fExecutor.execute(canSelectRecordQuery); return canSelectRecordQuery.get(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectPrevTraceRecordCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectPrevTraceRecordCommand.java index 0fdc5232bc7..d5bf4b79c55 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectPrevTraceRecordCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectPrevTraceRecordCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation * Marc Khouzam (Ericsson) - Disable button when no trace record is selected @@ -43,7 +43,7 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; /** * Command to select the previous trace record - * + * * @since 2.1 */ public class GdbSelectPrevTraceRecordCommand extends AbstractDebugCommand implements ISelectPrevTraceRecordHandler { @@ -55,7 +55,7 @@ public class GdbSelectPrevTraceRecordCommand extends AbstractDebugCommand implem fExecutor = session.getExecutor(); fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); fSession = session; - } + } public void dispose() { fTracker.dispose(); @@ -67,97 +67,99 @@ public class GdbSelectPrevTraceRecordCommand extends AbstractDebugCommand implem return; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return; } - Query<Object> selectRecordQuery = new Query<Object>() { - @Override - public void execute(final DataRequestMonitor<Object> rm) { - final IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - - if (traceControl != null) { - traceControl.getCurrentTraceRecordContext( - dmc, - new DataRequestMonitor<ITraceRecordDMContext>(fExecutor, rm) { - @Override - protected void handleSuccess() { - final ITraceRecordDMContext prevDmc = traceControl.createPrevRecordContext(getData()); - traceControl.selectTraceRecord(prevDmc, new ImmediateRequestMonitor(rm) { - @Override - protected void handleSuccess() { - fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(prevDmc), new Hashtable<String, String>()); - rm.done(); - } - }); - }; - }); - } else { - rm.done(); - } - } - }; - try { - fExecutor.execute(selectRecordQuery); - selectRecordQuery.get(); + Query<Object> selectRecordQuery = new Query<Object>() { + @Override + public void execute(final DataRequestMonitor<Object> rm) { + final IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + + if (traceControl != null) { + traceControl.getCurrentTraceRecordContext(dmc, + new DataRequestMonitor<ITraceRecordDMContext>(fExecutor, rm) { + @Override + protected void handleSuccess() { + final ITraceRecordDMContext prevDmc = traceControl + .createPrevRecordContext(getData()); + traceControl.selectTraceRecord(prevDmc, new ImmediateRequestMonitor(rm) { + @Override + protected void handleSuccess() { + fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(prevDmc), + new Hashtable<String, String>()); + rm.done(); + } + }); + }; + }); + } else { + rm.done(); + } + } + }; + try { + fExecutor.execute(selectRecordQuery); + selectRecordQuery.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } } @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException - { + throws CoreException { if (targets.length != 1) { return false; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return false; } - Query<Boolean> canSelectRecordQuery = new Query<Boolean>() { - @Override - public void execute(final DataRequestMonitor<Boolean> rm) { - final IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - - if (traceControl != null) { - traceControl.getTraceStatus(dmc, new DataRequestMonitor<ITraceStatusDMData>(fExecutor, rm) { - @Override - protected void handleSuccess() { - if (getData().getNumberOfCollectedFrame() <= 0) { - // No frames to look at. - rm.done(false); - return; - } - - if (getData() instanceof ITraceStatusDMData2) { - if (((ITraceStatusDMData2)getData()).getCurrentTraceFrameId() == null) { - // Haven't started looking at frames, so don't enable the "Previous" button - rm.done(false); - return; - } - } - - traceControl.isTracing(dmc, new DataRequestMonitor<Boolean>(fExecutor, rm) { - @Override - protected void handleSuccess() { - // Can do visualization if we are tracing. - rm.done(!getData()); - }; - }); - }; - }); - } else { - rm.done(false); - } - } - }; + Query<Boolean> canSelectRecordQuery = new Query<Boolean>() { + @Override + public void execute(final DataRequestMonitor<Boolean> rm) { + final IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + + if (traceControl != null) { + traceControl.getTraceStatus(dmc, new DataRequestMonitor<ITraceStatusDMData>(fExecutor, rm) { + @Override + protected void handleSuccess() { + if (getData().getNumberOfCollectedFrame() <= 0) { + // No frames to look at. + rm.done(false); + return; + } + + if (getData() instanceof ITraceStatusDMData2) { + if (((ITraceStatusDMData2) getData()).getCurrentTraceFrameId() == null) { + // Haven't started looking at frames, so don't enable the "Previous" button + rm.done(false); + return; + } + } + + traceControl.isTracing(dmc, new DataRequestMonitor<Boolean>(fExecutor, rm) { + @Override + protected void handleSuccess() { + // Can do visualization if we are tracing. + rm.done(!getData()); + }; + }); + }; + }); + } else { + rm.done(false); + } + } + }; try { fExecutor.execute(canSelectRecordQuery); return canSelectRecordQuery.get(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbStartTracingCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbStartTracingCommand.java index f5af9d4ca87..2260aee8f77 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbStartTracingCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbStartTracingCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -38,7 +38,7 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; /** * Command to start the tracing experiment - * + * * @since 2.1 */ public class GdbStartTracingCommand extends AbstractDebugCommand implements IStartTracingHandler { @@ -48,80 +48,81 @@ public class GdbStartTracingCommand extends AbstractDebugCommand implements ISta public GdbStartTracingCommand(DsfSession session) { fExecutor = session.getExecutor(); fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } + } public void dispose() { fTracker.dispose(); } @Override - protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) - throws CoreException { + protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { if (targets.length != 1) { return; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return; } - Query<Object> startTracingQuery = new Query<Object>() { - @Override - public void execute(final DataRequestMonitor<Object> rm) { - final IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - if (traceControl != null) { - String user = System.getProperty("user.name"); //$NON-NLS-1$ - if (user != null && !user.isEmpty() && traceControl instanceof IGDBTraceControl2) { - ((IGDBTraceControl2)traceControl).setTraceUser(dmc, user, new ImmediateRequestMonitor() { - @Override - protected void handleCompleted() { - traceControl.startTracing(dmc, rm); - }; - }); - } else { - traceControl.startTracing(dmc, rm); - } - } else { - rm.done(); - } - } - }; - try { - fExecutor.execute(startTracingQuery); - startTracingQuery.get(); + Query<Object> startTracingQuery = new Query<Object>() { + @Override + public void execute(final DataRequestMonitor<Object> rm) { + final IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + if (traceControl != null) { + String user = System.getProperty("user.name"); //$NON-NLS-1$ + if (user != null && !user.isEmpty() && traceControl instanceof IGDBTraceControl2) { + ((IGDBTraceControl2) traceControl).setTraceUser(dmc, user, new ImmediateRequestMonitor() { + @Override + protected void handleCompleted() { + traceControl.startTracing(dmc, rm); + }; + }); + } else { + traceControl.startTracing(dmc, rm); + } + } else { + rm.done(); + } + } + }; + try { + fExecutor.execute(startTracingQuery); + startTracingQuery.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } } @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException { + throws CoreException { if (targets.length != 1) { return false; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return false; } - Query<Boolean> canStartTracingQuery = new Query<Boolean>() { - @Override - public void execute(DataRequestMonitor<Boolean> rm) { - IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + Query<Boolean> canStartTracingQuery = new Query<Boolean>() { + @Override + public void execute(DataRequestMonitor<Boolean> rm) { + IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - if (traceControl != null) { - traceControl.canStartTracing(dmc, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; + if (traceControl != null) { + traceControl.canStartTracing(dmc, rm); + } else { + rm.setData(false); + rm.done(); + } + } + }; try { fExecutor.execute(canStartTracingQuery); return canStartTracingQuery.get(); @@ -146,7 +147,7 @@ public class GdbStartTracingCommand extends AbstractDebugCommand implements ISta * Re-selection of the debug context will be forced by the Debug Model through a StartTracing event. * Therefore, the enablement of this command will be refreshed, so we don't need to keep it enabled. * In fact, it is better to have it disabled right after selection to avoid a double-click - * + * * (non-Javadoc) * @see org.eclipse.debug.core.commands.AbstractDebugCommand#isRemainEnabled(org.eclipse.debug.core.commands.IDebugCommandRequest) */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbStopTracingCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbStopTracingCommand.java index 4ce287e2d1f..b6c2de62f74 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbStopTracingCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbStopTracingCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -36,7 +36,7 @@ import org.eclipse.debug.core.commands.IEnabledStateRequest; /** * Command to stop the tracing experiment - * + * * @since 2.1 */ public class GdbStopTracingCommand extends AbstractDebugCommand implements IStopTracingHandler { @@ -46,71 +46,72 @@ public class GdbStopTracingCommand extends AbstractDebugCommand implements IStop public GdbStopTracingCommand(DsfSession session) { fExecutor = session.getExecutor(); fTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId()); - } + } public void dispose() { fTracker.dispose(); } @Override - protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) - throws CoreException { + protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException { if (targets.length != 1) { return; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return; } - Query<Object> stopTracingQuery = new Query<Object>() { - @Override - public void execute(final DataRequestMonitor<Object> rm) { - IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - - if (traceControl != null) { - traceControl.stopTracing(dmc, rm); - } else { - rm.done(); - } - } - }; - try { - fExecutor.execute(stopTracingQuery); - stopTracingQuery.get(); + Query<Object> stopTracingQuery = new Query<Object>() { + @Override + public void execute(final DataRequestMonitor<Object> rm) { + IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + + if (traceControl != null) { + traceControl.stopTracing(dmc, rm); + } else { + rm.done(); + } + } + }; + try { + fExecutor.execute(stopTracingQuery); + stopTracingQuery.get(); } catch (InterruptedException e) { } catch (ExecutionException e) { - } catch (RejectedExecutionException e) { - // Can be thrown if the session is shutdown - } + } catch (RejectedExecutionException e) { + // Can be thrown if the session is shutdown + } } @Override protected boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) - throws CoreException { + throws CoreException { if (targets.length != 1) { return false; } - final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext)targets[0]).getDMContext(), ITraceTargetDMContext.class); + final ITraceTargetDMContext dmc = DMContexts.getAncestorOfType(((IDMVMContext) targets[0]).getDMContext(), + ITraceTargetDMContext.class); if (dmc == null) { return false; } - Query<Boolean> canStopTracingQuery = new Query<Boolean>() { - @Override - public void execute(DataRequestMonitor<Boolean> rm) { - IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); - - if (traceControl != null) { - traceControl.canStopTracing(dmc, rm); - } else { - rm.setData(false); - rm.done(); - } - } - }; + Query<Boolean> canStopTracingQuery = new Query<Boolean>() { + @Override + public void execute(DataRequestMonitor<Boolean> rm) { + IGDBTraceControl traceControl = fTracker.getService(IGDBTraceControl.class); + + if (traceControl != null) { + traceControl.canStopTracing(dmc, rm); + } else { + rm.setData(false); + rm.done(); + } + } + }; try { fExecutor.execute(canStopTracingQuery); return canStopTracingQuery.get(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbUncallCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbUncallCommand.java index cd6cea889ef..be3fcaa7f31 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbUncallCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbUncallCommand.java @@ -24,12 +24,12 @@ import org.eclipse.cdt.dsf.service.DsfSession; * @since 2.1 */ public class GdbUncallCommand extends GdbAbstractReverseStepCommand implements IUncallHandler { - public GdbUncallCommand(DsfSession session, DsfSteppingModeTarget steppingMode) { + public GdbUncallCommand(DsfSession session, DsfSteppingModeTarget steppingMode) { super(session, steppingMode); - } - - @Override - protected final StepType getStepType() { - return StepType.STEP_RETURN; - } + } + + @Override + protected final StepType getStepType() { + return StepType.STEP_RETURN; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.java index f37189e05dd..71db50d4f20 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/Messages.java @@ -51,20 +51,20 @@ public class Messages extends NLS { public static String GdbDebugNewExecutableCommand_Select_Binary; public static String GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments; - + public static String GdbReverseDebugging_HardwareReverseDebugNotAvailable; public static String GdbReverseDebugging_ProcessorTraceReverseDebugNotAvailable; - + public static String GdbReverseDebugging_ReverseDebugNotAvailable; public static String GdbConnectCommand_Error; - + public static String GdbConnectCommand_FailureMessage; static { // initialize resource bundle - NLS.initializeMessages( Messages.class.getName(), Messages.class ); + NLS.initializeMessages(Messages.class.getName(), Messages.class); } private Messages() { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/RefreshableDebugCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/RefreshableDebugCommand.java index cd3c9ec7e42..ece6a62d4aa 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/RefreshableDebugCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/RefreshableDebugCommand.java @@ -28,8 +28,8 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.progress.UIJob; /** - * The enablement of a {@link AbstractDebugCommand} is updated only when the current - * debug context is changed. In some cases we need to force an update without changing + * The enablement of a {@link AbstractDebugCommand} is updated only when the current + * debug context is changed. In some cases we need to force an update without changing * the context. This class provides such a functionality. * The proper way is to modify {@link AbstractDebugCommand}. */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/SelectNextTraceRecordCommandHandler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/SelectNextTraceRecordCommandHandler.java index 87d0e71c280..f4401d478b8 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/SelectNextTraceRecordCommandHandler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/SelectNextTraceRecordCommandHandler.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -18,7 +18,7 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to select the next trace record - * + * * @since 2.1 */ public class SelectNextTraceRecordCommandHandler extends DebugCommandHandler { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/SelectPrevTraceRecordCommandHandler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/SelectPrevTraceRecordCommandHandler.java index 76a3a00c279..196475f7ae1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/SelectPrevTraceRecordCommandHandler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/SelectPrevTraceRecordCommandHandler.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -18,7 +18,7 @@ import org.eclipse.debug.ui.actions.DebugCommandHandler; /** * Command handler to select the previous trace record - * + * * @since 2.1 */ public class SelectPrevTraceRecordCommandHandler extends DebugCommandHandler { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsoleMessages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsoleMessages.java index 7c5cf30678f..5a2c7a21e08 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsoleMessages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsoleMessages.java @@ -36,13 +36,13 @@ public class ConsoleMessages extends NLS { public static String ConsoleScrollLockAction_name; public static String ConsoleScrollLockAction_description; - + public static String ConsoleCopyAction_name; public static String ConsoleCopyAction_description; - + public static String ConsolePasteAction_name; public static String ConsolePasteAction_description; - + public static String ConsoleSelectAllAction_name; public static String ConsoleSelectAllAction_description; @@ -50,12 +50,12 @@ public class ConsoleMessages extends NLS { public static String ConsoleAutoTerminateAction_description; public static String GdbConsolePreferences_name; - + static { // initialize resource bundle NLS.initializeMessages(ConsoleMessages.class.getName(), ConsoleMessages.class); } - + private ConsoleMessages() { } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsolePageParticipant.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsolePageParticipant.java index df3c92d8935..7be5b4b751e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsolePageParticipant.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsolePageParticipant.java @@ -41,26 +41,27 @@ import org.eclipse.ui.part.IPageBookViewPage; * It adds a save button to the gdb tracing console. * It also brings to the front the proper inferior console when an element of the * debug view is selected. - * + * * @since 2.1 */ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugContextListener { - - private IConsole fConsole; - private IPageBookViewPage fPage; - private IConsoleView fView; - @Override + private IConsole fConsole; + private IPageBookViewPage fPage; + private IConsoleView fView; + + @Override public void init(IPageBookViewPage page, IConsole console) { - fPage = page; - fConsole = console; - fView = (IConsoleView)fPage.getSite().getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW); + fPage = page; + fConsole = console; + fView = (IConsoleView) fPage.getSite().getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW); - if (isConsoleInferior(console)) { - // This console participant will affect all consoles, even those not for DSF-GDB. - // Only consoles for InferiorRuntimeProcess are what we care about for DSF-GDB - DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()).addDebugContextListener(this); - } + if (isConsoleInferior(console)) { + // This console participant will affect all consoles, even those not for DSF-GDB. + // Only consoles for InferiorRuntimeProcess are what we care about for DSF-GDB + DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()) + .addDebugContextListener(this); + } if (console instanceof TracingConsole) { TextConsole textConsole = (TextConsole) console; @@ -76,84 +77,85 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo /** * Checks if the the console is for an inferior. - * + * * @param console The console to check * @return true if the the console is for an inferior */ private boolean isConsoleInferior(IConsole console) { if (console instanceof org.eclipse.debug.ui.console.IConsole) { - org.eclipse.debug.ui.console.IConsole debugConsole = (org.eclipse.debug.ui.console.IConsole)console; + org.eclipse.debug.ui.console.IConsole debugConsole = (org.eclipse.debug.ui.console.IConsole) console; return (debugConsole.getProcess() instanceof InferiorRuntimeProcess); } return false; } - - @Override - public <T> T getAdapter(Class<T> adapter) { + + @Override + public <T> T getAdapter(Class<T> adapter) { return null; } - - @Override + + @Override public void dispose() { - if (isConsoleInferior(fConsole)) { - DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()).removeDebugContextListener(this); + if (isConsoleInferior(fConsole)) { + DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()) + .removeDebugContextListener(this); } fConsole = null; } - @Override + @Override public void activated() { } - @Override + @Override public void deactivated() { } - protected IProcess getConsoleProcess() { - if (fConsole instanceof org.eclipse.debug.ui.console.IConsole) { - return ((org.eclipse.debug.ui.console.IConsole)fConsole).getProcess(); - } - return null; - } - + protected IProcess getConsoleProcess() { + if (fConsole instanceof org.eclipse.debug.ui.console.IConsole) { + return ((org.eclipse.debug.ui.console.IConsole) fConsole).getProcess(); + } + return null; + } + protected IProcess getCurrentProcess() { IAdaptable context = DebugUITools.getDebugContext(); - + // If the launch is selected, we should choose the first inferior being debugged // If the GDB process is selected, and since the GDB console is not in the standard // console view, we should show a console that is part of the same launch as the // GDB process, so we can treat it the same as the launch selection case - if (context instanceof ILaunch || context instanceof GDBProcess) { - ILaunch launch; - if (context instanceof ILaunch) { - launch = (ILaunch)context; - } else { - launch = ((GDBProcess)context).getLaunch(); - } - - // Note that ProcessConsolePageParticipant also handles the case - // of ILaunch being selected. Usually, that class gets called - // after our current class, so the console it chooses wins in the - // case of ILaunch. - // So, for consistency, when GDBProcess is selected, we choose the - // same inferior chosen by ProcessConsolePageParticipant when - // ILaunch is selected, which is the last (not the first) inferior - // process. - // Note that we could ignore the ILaunch case in this class - // since it is already handled by ProcessConsolePageParticipant, - // but just to be safe and future-proof, we also handle it. - IProcess[] processes = launch.getProcesses(); - if (processes != null && processes.length > 0) { - for (int i = processes.length-1; i >= 0; i--) { - IProcess process = processes[i]; - if (process instanceof InferiorRuntimeProcess) { - return process; - } - } - } - - return null; - } + if (context instanceof ILaunch || context instanceof GDBProcess) { + ILaunch launch; + if (context instanceof ILaunch) { + launch = (ILaunch) context; + } else { + launch = ((GDBProcess) context).getLaunch(); + } + + // Note that ProcessConsolePageParticipant also handles the case + // of ILaunch being selected. Usually, that class gets called + // after our current class, so the console it chooses wins in the + // case of ILaunch. + // So, for consistency, when GDBProcess is selected, we choose the + // same inferior chosen by ProcessConsolePageParticipant when + // ILaunch is selected, which is the last (not the first) inferior + // process. + // Note that we could ignore the ILaunch case in this class + // since it is already handled by ProcessConsolePageParticipant, + // but just to be safe and future-proof, we also handle it. + IProcess[] processes = launch.getProcesses(); + if (processes != null && processes.length > 0) { + for (int i = processes.length - 1; i >= 0; i--) { + IProcess process = processes[i]; + if (process instanceof InferiorRuntimeProcess) { + return process; + } + } + } + + return null; + } if (context != null) { // Look for the process that this context refers to, so we can select its console @@ -162,42 +164,41 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo if (container != null) { ILaunch launch = context.getAdapter(ILaunch.class); if (launch != null) { - IProcess[] processes = launch.getProcesses(); - if (processes != null && processes.length > 0) { - for (IProcess process : processes) { - if (process instanceof InferiorRuntimeProcess) { - String groupId = process.getAttribute(IGdbDebugConstants.INFERIOR_GROUPID_ATTR); - - if (groupId == null || groupId.equals(MIProcesses.UNIQUE_GROUP_ID) || - container.getGroupId().equals(groupId)) { - // if the groupId is not set in the process we know we are dealing - // with single process debugging and we can just return the inferior. - // If the groupId is set, then we must find the proper inferior - return process; - } - } - } - - // No inferior? return the gdb process - if (processes[0] instanceof GDBProcess) { - return processes[0]; - } - } + IProcess[] processes = launch.getProcesses(); + if (processes != null && processes.length > 0) { + for (IProcess process : processes) { + if (process instanceof InferiorRuntimeProcess) { + String groupId = process.getAttribute(IGdbDebugConstants.INFERIOR_GROUPID_ATTR); + + if (groupId == null || groupId.equals(MIProcesses.UNIQUE_GROUP_ID) + || container.getGroupId().equals(groupId)) { + // if the groupId is not set in the process we know we are dealing + // with single process debugging and we can just return the inferior. + // If the groupId is set, then we must find the proper inferior + return process; + } + } + } + + // No inferior? return the gdb process + if (processes[0] instanceof GDBProcess) { + return processes[0]; + } + } } } } return null; } - - @Override + + @Override public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { IProcess consoleProcess = getConsoleProcess(); if (fView != null && consoleProcess != null && consoleProcess.equals(getCurrentProcess())) { - fView.display(fConsole); - } + fView.display(fConsole); + } } } } - diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbAbstractConsolePreferenceListener.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbAbstractConsolePreferenceListener.java index 109ef2fe08a..4d7a4c7ad0d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbAbstractConsolePreferenceListener.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbAbstractConsolePreferenceListener.java @@ -27,15 +27,21 @@ public abstract class GdbAbstractConsolePreferenceListener implements IPropertyC boolean terminate = terminateStr.equals(Boolean.FALSE.toString()) ? false : true; handleAutoTerminatePref(terminate); } else if (property.equals(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS)) { - boolean enabled = Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID, IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS, IGdbDebugPreferenceConstants.CONSOLE_INVERTED_COLORS_DEFAULT, null); + boolean enabled = Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID, + IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS, + IGdbDebugPreferenceConstants.CONSOLE_INVERTED_COLORS_DEFAULT, null); handleInvertColorsPref(enabled); } else if (property.equals(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES)) { - int bufferLines = Platform.getPreferencesService().getInt(GdbPlugin.PLUGIN_ID, IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES, IGdbDebugPreferenceConstants.CONSOLE_BUFFERLINES_DEFAULT, null); + int bufferLines = Platform.getPreferencesService().getInt(GdbPlugin.PLUGIN_ID, + IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES, + IGdbDebugPreferenceConstants.CONSOLE_BUFFERLINES_DEFAULT, null); handleBufferLinesPref(bufferLines); } } - + protected abstract void handleAutoTerminatePref(boolean enabled); + protected abstract void handleInvertColorsPref(boolean enabled); + protected abstract void handleBufferLinesPref(int bufferLines); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java index 4c4d2531237..0037eef758c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsole.java @@ -44,7 +44,7 @@ import org.eclipse.ui.part.IPageBookViewPage; public class GdbBasicCliConsole extends IOConsole implements IGDBDebuggerConsole { /** - * A conversion factor used to resolve number of characters from number of lines + * A conversion factor used to resolve number of characters from number of lines */ private final static int CHARS_PER_LINE_AVG = 80; private final static int HIGH_WATERMARK_OFFSET_CHARS = 8000; @@ -54,7 +54,7 @@ public class GdbBasicCliConsole extends IOConsole implements IGDBDebuggerConsole private final Process fProcess; private final IOConsoleOutputStream fOutputStream; private final IOConsoleOutputStream fErrorStream; - + private GdbAbstractConsolePreferenceListener fPreferenceListener = new GdbAbstractConsolePreferenceListener() { @Override @@ -76,21 +76,21 @@ public class GdbBasicCliConsole extends IOConsole implements IGDBDebuggerConsole public GdbBasicCliConsole(ILaunch launch, String label, Process process) { super("", "GdbBasicCliConsole", null, false); //$NON-NLS-1$ //$NON-NLS-2$ fLaunch = launch; - fLabel = label; - fProcess = process; - fOutputStream = newOutputStream(); - fErrorStream = newOutputStream(); - - assert(process != null); - - // Create a lifecycle listener to call init() and dispose() - new GdbConsoleLifecycleListener(this); - + fLabel = label; + fProcess = process; + fOutputStream = newOutputStream(); + fErrorStream = newOutputStream(); + + assert (process != null); + + // Create a lifecycle listener to call init() and dispose() + new GdbConsoleLifecycleListener(this); + GdbUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener); - resetName(); - setDefaults(); - + resetName(); + setDefaults(); + new InputReadJob().schedule(); new OutputReadJob().schedule(); new ErrorReadJob().schedule(); @@ -106,11 +106,11 @@ public class GdbBasicCliConsole extends IOConsole implements IGDBDebuggerConsole public void stop() { // Closing the streams will trigger the termination of the associated reading jobs try { - fOutputStream.close(); + fOutputStream.close(); } catch (IOException e) { } - try { - fErrorStream.close(); + try { + fErrorStream.close(); } catch (IOException e) { } @@ -135,177 +135,177 @@ public class GdbBasicCliConsole extends IOConsole implements IGDBDebuggerConsole if (inputStream != null) { inputStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN)); } - fErrorStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fErrorStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED)); - setInvertedColors(enabled); - setBufferLineLimit(bufferLines); - }); + setInvertedColors(enabled); + setBufferLineLimit(bufferLines); + }); } @Override public ILaunch getLaunch() { return fLaunch; } - - @Override + + @Override public void resetName() { - String newName = computeName(); - String name = getName(); - if (!name.equals(newName)) { - try { - PlatformUI.getWorkbench().getDisplay().asyncExec(() -> setName(newName)); + String newName = computeName(); + String name = getName(); + if (!name.equals(newName)) { + try { + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> setName(newName)); } catch (SWTException e) { // display may be disposed, so ignore the exception if (e.code != SWT.ERROR_WIDGET_DISPOSED) { throw e; } } - } - } - - protected String computeName() { - if (fLaunch == null) { - return ""; //$NON-NLS-1$ - } - - String label = fLabel; - - ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); - if (config != null && !DebugUITools.isPrivate(config)) { - String type = null; - try { - type = config.getType().getName(); - } catch (CoreException e) { - } - StringBuffer buffer = new StringBuffer(); - buffer.append(config.getName()); - if (type != null) { - buffer.append(" ["); //$NON-NLS-1$ - buffer.append(type); - buffer.append("] "); //$NON-NLS-1$ - } - buffer.append(label); - label = buffer.toString(); - } - - if (fLaunch.isTerminated()) { - return ConsoleMessages.ConsoleMessages_console_terminated + label; - } - - return label; - } - - @Override + } + } + + protected String computeName() { + if (fLaunch == null) { + return ""; //$NON-NLS-1$ + } + + String label = fLabel; + + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + if (config != null && !DebugUITools.isPrivate(config)) { + String type = null; + try { + type = config.getType().getName(); + } catch (CoreException e) { + } + StringBuffer buffer = new StringBuffer(); + buffer.append(config.getName()); + if (type != null) { + buffer.append(" ["); //$NON-NLS-1$ + buffer.append(type); + buffer.append("] "); //$NON-NLS-1$ + } + buffer.append(label); + label = buffer.toString(); + } + + if (fLaunch.isTerminated()) { + return ConsoleMessages.ConsoleMessages_console_terminated + label; + } + + return label; + } + + @Override public IPageBookViewPage createPage(IConsoleView view) { - return new GdbBasicCliConsolePage(this, view); - } + return new GdbBasicCliConsolePage(this, view); + } @Override public IPageBookViewPage createDebuggerPage(IDebuggerConsoleView view) { if (view instanceof IConsoleView) { - return createPage((IConsoleView)view); + return createPage((IConsoleView) view); } return null; } - + private void setInvertedColors(boolean enable) { if (enable) { setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fOutputStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); } else { - setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); + setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); fOutputStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); } } private void setBufferLineLimit(int bufferLines) { int chars = bufferLines * CHARS_PER_LINE_AVG; - // The buffer will be allowed to grow up-to the high watermark. + // The buffer will be allowed to grow up-to the high watermark. // When high watermark is passed, it will be trimmed-down to the low watermark. // So here add an extra buffer for high watermark. setWaterMarks(chars, chars + HIGH_WATERMARK_OFFSET_CHARS); } - - private class InputReadJob extends Job { - { - setSystem(true); - } - - InputReadJob() { - super("GDB CLI Input Job"); //$NON-NLS-1$ - } - - @Override + + private class InputReadJob extends Job { + { + setSystem(true); + } + + InputReadJob() { + super("GDB CLI Input Job"); //$NON-NLS-1$ + } + + @Override protected IStatus run(IProgressMonitor monitor) { - try { - byte[] b = new byte[1024]; - int read = 0; - do { - IOConsoleInputStream inputStream = getInputStream(); - if (inputStream == null) { - break; - } - read = inputStream.read(b); - if (read > 0) { - fProcess.getOutputStream().write(b, 0, read); - } - - } while (read >= 0); - } catch (IOException e) { - } - return Status.OK_STATUS; - } - } - - private class OutputReadJob extends Job { - { - setSystem(true); - } - - OutputReadJob() { - super("GDB CLI output Job"); //$NON-NLS-1$ - } - - @Override + try { + byte[] b = new byte[1024]; + int read = 0; + do { + IOConsoleInputStream inputStream = getInputStream(); + if (inputStream == null) { + break; + } + read = inputStream.read(b); + if (read > 0) { + fProcess.getOutputStream().write(b, 0, read); + } + + } while (read >= 0); + } catch (IOException e) { + } + return Status.OK_STATUS; + } + } + + private class OutputReadJob extends Job { + { + setSystem(true); + } + + OutputReadJob() { + super("GDB CLI output Job"); //$NON-NLS-1$ + } + + @Override protected IStatus run(IProgressMonitor monitor) { - try { - byte[] b = new byte[1024]; - int read = 0; - do { - read = fProcess.getInputStream().read(b); - if (read > 0) { - fOutputStream.write(b, 0, read); - } - } while (read >= 0); - } catch (IOException e) { - } - return Status.OK_STATUS; - } - } - - private class ErrorReadJob extends Job { - { - setSystem(true); - } - - ErrorReadJob() { - super("GDB CLI error output Job"); //$NON-NLS-1$ - } - - @Override + try { + byte[] b = new byte[1024]; + int read = 0; + do { + read = fProcess.getInputStream().read(b); + if (read > 0) { + fOutputStream.write(b, 0, read); + } + } while (read >= 0); + } catch (IOException e) { + } + return Status.OK_STATUS; + } + } + + private class ErrorReadJob extends Job { + { + setSystem(true); + } + + ErrorReadJob() { + super("GDB CLI error output Job"); //$NON-NLS-1$ + } + + @Override protected IStatus run(IProgressMonitor monitor) { - try { - byte[] b = new byte[1024]; - int read = 0; - do { - read = fProcess.getErrorStream().read(b); - if (read > 0) { - fErrorStream.write(b, 0, read); - } - } while (read >= 0); - } catch (IOException e) { - } - return Status.OK_STATUS; - } - } + try { + byte[] b = new byte[1024]; + int read = 0; + do { + read = fProcess.getErrorStream().read(b); + if (read > 0) { + fErrorStream.write(b, 0, read); + } + } while (read >= 0); + } catch (IOException e) { + } + return Status.OK_STATUS; + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsolePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsolePage.java index 3b124aeb2b0..99ea06a4770 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsolePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbBasicCliConsolePage.java @@ -30,7 +30,7 @@ import org.eclipse.ui.internal.console.IOConsolePage; /** * Page used for a basic GDB console. Each Debug session which uses the basic GDB console will * use its own instance of this page. The basic console is used for older GDB versions. - * + * * Contributions to this page's context menu can be done using id "GdbBasicCliConsole.#ContextMenu". * For example, using the extension point:<br> * <code> @@ -43,7 +43,7 @@ public class GdbBasicCliConsolePage extends IOConsolePage implements IDebugConte private final ILaunch fLaunch; private final IConsoleView fView; private final IDebuggerConsole fConsole; - + private GdbConsoleTerminateLaunchAction fTerminateLaunchAction; private GdbConsoleShowPreferencesAction fShowPreferencePageAction; @@ -57,13 +57,15 @@ public class GdbBasicCliConsolePage extends IOConsolePage implements IDebugConte @Override public void dispose() { super.dispose(); - DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()).removeDebugContextListener(this); + DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()) + .removeDebugContextListener(this); } - + @Override public void createControl(Composite parent) { super.createControl(parent); - DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()).addDebugContextListener(this); + DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()) + .addDebugContextListener(this); } @Override @@ -81,16 +83,16 @@ public class GdbBasicCliConsolePage extends IOConsolePage implements IDebugConte protected void contextMenuAboutToShow(IMenuManager menuManager) { menuManager.add(fTerminateLaunchAction); menuManager.add(new Separator()); - + // Other plug-ins can contribute their actions here menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); menuManager.add(fShowPreferencePageAction); } - + /** * Returns the launch to which the current selection belongs. - * + * * @return the launch to which the current selection belongs. */ protected ILaunch getCurrentLaunch() { @@ -100,7 +102,7 @@ public class GdbBasicCliConsolePage extends IOConsolePage implements IDebugConte } return null; } - + @Override public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbCliConsoleManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbCliConsoleManager.java index 00f6b3fdb12..c27f15f0ddd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbCliConsoleManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbCliConsoleManager.java @@ -35,7 +35,7 @@ import org.eclipse.debug.core.ILaunchesListener2; /** * A console manager for GDB sessions which adds and removes * gdb cli consoles. - * + * * There is a single such console per debug session. * This console interacts directly with the GDB process using * the standard GDB CLI interface. @@ -59,36 +59,36 @@ public class GdbCliConsoleManager implements ILaunchesListener2 { DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); } - @Override + @Override public void launchesAdded(ILaunch[] launches) { for (ILaunch launch : launches) { handleConsoleForLaunch(launch); } } - @Override + @Override public void launchesChanged(ILaunch[] launches) { } - @Override + @Override public void launchesRemoved(ILaunch[] launches) { for (ILaunch launch : launches) { removeConsole(launch); } } - - @Override + + @Override public void launchesTerminated(ILaunch[] launches) { for (ILaunch launch : launches) { renameConsole(launch); stopConsole(launch); } } - + protected void handleConsoleForLaunch(ILaunch launch) { // Full CLI GDB consoles are only added for GdbLaunches if (launch instanceof GdbLaunch) { - new GdbConsoleCreator((GdbLaunch)launch).init(); + new GdbConsoleCreator((GdbLaunch) launch).init(); } } @@ -111,11 +111,11 @@ public class GdbCliConsoleManager implements ILaunchesListener2 { IDebuggerConsole console = getConsole(launch); if (console != null) { console.resetName(); - } + } } private IDebuggerConsole getConsole(ILaunch launch) { - IDebuggerConsoleManager manager = CDebugUIPlugin.getDebuggerConsoleManager(); + IDebuggerConsoleManager manager = CDebugUIPlugin.getDebuggerConsoleManager(); for (IDebuggerConsole console : manager.getConsoles()) { if (console.getLaunch().equals(launch)) { return console; @@ -127,15 +127,15 @@ public class GdbCliConsoleManager implements ILaunchesListener2 { private void addConsole(IDebuggerConsole console) { getDebuggerConsoleManager().addConsole(console); } - + private void removeConsole(IDebuggerConsole console) { getDebuggerConsoleManager().removeConsole(console); } - + private IDebuggerConsoleManager getDebuggerConsoleManager() { return CDebugUIPlugin.getDebuggerConsoleManager(); } - + /** * Class that determines what type of console should be created * for this particular Gdblaunch. It figures this out by asking the @@ -145,41 +145,42 @@ public class GdbCliConsoleManager implements ILaunchesListener2 { private class GdbConsoleCreator { private GdbLaunch fLaunch; private DsfSession fSession; - + public GdbConsoleCreator(GdbLaunch launch) { fLaunch = launch; fSession = launch.getSession(); } - + public void init() { try { fSession.getExecutor().submit(new DsfRunnable() { - @Override - public void run() { - // Look for backend service right away. It probably - // won't be available yet but we must make sure. - DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); - // Use the lowest level service name in case those are created but don't implement - // the most specialized classes IGDBControl or IGDBBackend. - ICommandControlService control = tracker.getService(ICommandControlService.class); - IMIBackend backend = tracker.getService(IMIBackend.class); - tracker.dispose(); - - // If we use the old console we not only need the backend service but - // also the control service. For simplicity, always wait for both. - if (backend != null && control != null) { - // Backend and Control services already available, we can start! - verifyAndCreateCliConsole(); - } else { - // Backend service or Control service not available yet, let's wait for them to start. - new GdbServiceStartedListener(GdbConsoleCreator.this, fSession); - } - } - }); + @Override + public void run() { + // Look for backend service right away. It probably + // won't be available yet but we must make sure. + DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), + fSession.getId()); + // Use the lowest level service name in case those are created but don't implement + // the most specialized classes IGDBControl or IGDBBackend. + ICommandControlService control = tracker.getService(ICommandControlService.class); + IMIBackend backend = tracker.getService(IMIBackend.class); + tracker.dispose(); + + // If we use the old console we not only need the backend service but + // also the control service. For simplicity, always wait for both. + if (backend != null && control != null) { + // Backend and Control services already available, we can start! + verifyAndCreateCliConsole(); + } else { + // Backend service or Control service not available yet, let's wait for them to start. + new GdbServiceStartedListener(GdbConsoleCreator.this, fSession); + } + } + }); } catch (RejectedExecutionException e) { } } - + @ConfinedToDsfExecutor("fSession.getExecutor()") private void verifyAndCreateCliConsole() { String gdbVersion; @@ -189,14 +190,14 @@ public class GdbCliConsoleManager implements ILaunchesListener2 { gdbVersion = "???"; //$NON-NLS-1$ assert false : "Should not happen since the gdb version is cached"; //$NON-NLS-1$ } - String consoleTitle = fLaunch.getGDBPath().toOSString().trim() + " (" + gdbVersion +")"; //$NON-NLS-1$ //$NON-NLS-2$ + String consoleTitle = fLaunch.getGDBPath().toOSString().trim() + " (" + gdbVersion + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); - IGDBControl control = tracker.getService(IGDBControl.class); - IGDBBackend backend = tracker.getService(IGDBBackend.class); - tracker.dispose(); + DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); + IGDBControl control = tracker.getService(IGDBControl.class); + IGDBBackend backend = tracker.getService(IGDBBackend.class); + tracker.dispose(); - IDebuggerConsole console; + IDebuggerConsole console; if (backend != null && backend.isFullGdbConsoleSupported()) { // Create a full GDB cli console console = new GdbFullCliConsole(fLaunch, consoleTitle, backend.getProcess(), backend.getProcessPty()); @@ -208,18 +209,18 @@ public class GdbCliConsoleManager implements ILaunchesListener2 { assert false; return; } - + addConsole(console); - -// No need to open the view manually as it is associated with the Debug view -// and is handled through the automatic view management system. -// It will be opened by the platform. -// See http://eclip.se/509897 + + // No need to open the view manually as it is associated with the Debug view + // and is handled through the automatic view management system. + // It will be opened by the platform. + // See http://eclip.se/509897 // Make sure the Debugger Console view is visible but do not force it to the top // getDebuggerConsoleManager().openConsoleView(); } } - + /** * Class used to listen for started events for the services we need. * This class must be public to receive the event. @@ -227,13 +228,13 @@ public class GdbCliConsoleManager implements ILaunchesListener2 { public class GdbServiceStartedListener { private DsfSession fSession; private GdbConsoleCreator fCreator; - + public GdbServiceStartedListener(GdbConsoleCreator creator, DsfSession session) { - fCreator = creator; + fCreator = creator; fSession = session; fSession.addServiceEventListener(this, null); } - + @DsfServiceEventHandler public final void eventDispatched(ICommandControlInitializedDMEvent event) { // With the commandControl service started, we know the backend service diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbConsoleLifecycleListener.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbConsoleLifecycleListener.java index 1d1213f308c..c0c72221dae 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbConsoleLifecycleListener.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbConsoleLifecycleListener.java @@ -20,14 +20,14 @@ import org.eclipse.ui.console.IConsoleListener; * and <code>dispose()</code>. */ public class GdbConsoleLifecycleListener implements IConsoleListener { - + private final AbstractConsole fConsole; - + public GdbConsoleLifecycleListener(AbstractConsole console) { fConsole = console; CDebugUIPlugin.getDebuggerConsoleManager().addConsoleListener(this); } - + @Override public void consolesAdded(IConsole[] consoles) { for (IConsole console : consoles) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbFullCliConsole.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbFullCliConsole.java index 51ea26ba32b..1e3c392bd20 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbFullCliConsole.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbFullCliConsole.java @@ -25,7 +25,7 @@ import org.eclipse.ui.part.IPageBookViewPage; /** * A GDB CLI console. - * This console actually runs a GDB process in CLI mode to achieve a + * This console actually runs a GDB process in CLI mode to achieve a * full-featured CLI interface. This is only supported with GDB >= 7.12 * and if IGDBBackend.isFullGdbConsoleSupported() returns true. */ @@ -33,23 +33,23 @@ public class GdbFullCliConsole extends AbstractConsole implements IGDBDebuggerCo private final ILaunch fLaunch; private final String fLabel; private final PTY fGdbPty; - + private GdbFullCliConsolePage fConsolePage; - private final GdbTerminalConnector fTerminalConnector; + private final GdbTerminalConnector fTerminalConnector; public GdbFullCliConsole(ILaunch launch, String label, Process process, PTY pty) { super(label, null, false); fLaunch = launch; - fLabel = label; - fGdbPty = pty; - - // Create a lifecycle listener to call init() and dispose() - new GdbConsoleLifecycleListener(this); - fTerminalConnector = new GdbTerminalConnector(process); - - resetName(); + fLabel = label; + fGdbPty = pty; + + // Create a lifecycle listener to call init() and dispose() + new GdbConsoleLifecycleListener(this); + fTerminalConnector = new GdbTerminalConnector(process); + + resetName(); } - + @Override protected void dispose() { fTerminalConnector.dispose(); @@ -57,62 +57,64 @@ public class GdbFullCliConsole extends AbstractConsole implements IGDBDebuggerCo } @Override - public ILaunch getLaunch() { return fLaunch; } - - @Override + public ILaunch getLaunch() { + return fLaunch; + } + + @Override public void resetName() { - String newName = computeName(); - String name = getName(); - if (!name.equals(newName)) { - try { - PlatformUI.getWorkbench().getDisplay().asyncExec(() -> setName(newName)); - } catch (SWTException e) { - // display may be disposed, so ignore the exception - if (e.code != SWT.ERROR_WIDGET_DISPOSED && e.code != SWT.ERROR_DEVICE_DISPOSED) { - throw e; - } - } - } - } - - protected String computeName() { - if (fLaunch == null) { - return ""; //$NON-NLS-1$ - } - - String label = fLabel; - - ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); - if (config != null && !DebugUITools.isPrivate(config)) { - String type = null; - try { - type = config.getType().getName(); - } catch (CoreException e) { - } - StringBuffer buffer = new StringBuffer(); - buffer.append(config.getName()); - if (type != null) { - buffer.append(" ["); //$NON-NLS-1$ - buffer.append(type); - buffer.append("] "); //$NON-NLS-1$ - } - buffer.append(label); - label = buffer.toString(); - } - - if (fLaunch.isTerminated()) { - return ConsoleMessages.ConsoleMessages_console_terminated + label; - } - - return label; - } - + String newName = computeName(); + String name = getName(); + if (!name.equals(newName)) { + try { + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> setName(newName)); + } catch (SWTException e) { + // display may be disposed, so ignore the exception + if (e.code != SWT.ERROR_WIDGET_DISPOSED && e.code != SWT.ERROR_DEVICE_DISPOSED) { + throw e; + } + } + } + } + + protected String computeName() { + if (fLaunch == null) { + return ""; //$NON-NLS-1$ + } + + String label = fLabel; + + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + if (config != null && !DebugUITools.isPrivate(config)) { + String type = null; + try { + type = config.getType().getName(); + } catch (CoreException e) { + } + StringBuffer buffer = new StringBuffer(); + buffer.append(config.getName()); + if (type != null) { + buffer.append(" ["); //$NON-NLS-1$ + buffer.append(type); + buffer.append("] "); //$NON-NLS-1$ + } + buffer.append(label); + label = buffer.toString(); + } + + if (fLaunch.isTerminated()) { + return ConsoleMessages.ConsoleMessages_console_terminated + label; + } + + return label; + } + @Override public IPageBookViewPage createPage(IConsoleView view) { // This console is not meant for the standard console view return null; } - + @Override public IPageBookViewPage createDebuggerPage(IDebuggerConsoleView view) { view.setFocus(); @@ -123,5 +125,5 @@ public class GdbFullCliConsole extends AbstractConsole implements IGDBDebuggerCo public IGdbTerminalControlConnector getTerminalControlConnector() { return fTerminalConnector; } - + } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbFullCliConsolePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbFullCliConsolePage.java index 180bca9c283..9740bb409d1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbFullCliConsolePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbFullCliConsolePage.java @@ -55,7 +55,7 @@ import org.eclipse.ui.part.Page; /** * Page used for a full GDB console. Each Debug session which uses the full GDB console will * use its own instance of this page. GDB 7.12 is required to use the full GDB console. - * + * * Contributions to this page's context menu can be done using id "GdbFullCliConsole.#ContextMenu". * For example, using the extension point:<br> * <code> @@ -71,7 +71,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener private final IDebuggerConsoleView fView; private final IDebuggerConsole fConsole; private final IGdbTerminalControlConnector fGdbTerminalControlConnector; - + private MenuManager fMenuManager; private GdbConsoleTerminateLaunchAction fTerminateLaunchAction; @@ -114,28 +114,28 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener fView = view; fLaunch = gdbConsole.getLaunch(); fGdbPty = pty; - + GdbUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener); } @Override public void dispose() { super.dispose(); - DebugUITools.getDebugContextManager().getContextService( - getSite().getWorkbenchWindow()).removeDebugContextListener(this); + DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()) + .removeDebugContextListener(this); fTerminalControl.disposeTerminal(); fMenuManager.dispose(); GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); } - + @Override public void createControl(Composite parent) { fMainComposite = new Composite(parent, SWT.NONE); fMainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); fMainComposite.setLayout(new FillLayout()); - DebugUITools.getDebugContextManager().getContextService( - getSite().getWorkbenchWindow()).addDebugContextListener(this); + DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow()) + .addDebugContextListener(this); createTerminalControl(); createContextMenu(); @@ -152,27 +152,27 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener // Create the terminal control that will be used to interact with GDB // Don't use common terminal preferences as GDB consoles are having their own boolean useCommonPrefs = false; - fTerminalControl = TerminalViewControlFactory.makeControl( - new ITerminalListener() { - @Override public void setState(TerminalState state) {} - @Override public void setTerminalTitle(final String title) {} - }, - fMainComposite, - new ITerminalConnector[] {}, - useCommonPrefs); + fTerminalControl = TerminalViewControlFactory.makeControl(new ITerminalListener() { + @Override + public void setState(TerminalState state) { + } + + @Override + public void setTerminalTitle(final String title) { + } + }, fMainComposite, new ITerminalConnector[] {}, useCommonPrefs); fTerminalControl.setConnector(new GdbTerminalPageConnector(fGdbTerminalControlConnector, fGdbPty)); - + try { fTerminalControl.setEncoding(Charset.defaultCharset().name()); } catch (UnsupportedEncodingException e) { } if (fTerminalControl instanceof ITerminalControl) { - ((ITerminalControl)fTerminalControl).setConnectOnEnterIfClosed(false); - ((ITerminalControl)fTerminalControl).setVT100LineWrapping(true); + ((ITerminalControl) fTerminalControl).setConnectOnEnterIfClosed(false); + ((ITerminalControl) fTerminalControl).setVT100LineWrapping(true); } - // Must use syncExec because the logic within must complete before the rest // of the class methods (specifically getProcess()) is called fMainComposite.getDisplay().syncExec(new Runnable() { @@ -181,7 +181,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener if (fTerminalControl != null && !fTerminalControl.isDisposed()) { fTerminalControl.clearTerminal(); fTerminalControl.connectTerminal(); - + // The actual terminal widget initializes its defaults in the line above, // lets override them with our application defaults right after. setDefaults(); @@ -191,12 +191,14 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener } protected void createContextMenu() { - // Choose the id to be similar in format to what + // Choose the id to be similar in format to what // the GdbBasicCliConsole has as id, for consistency String id = "GdbFullCliConsole.#ContextMenu"; //$NON-NLS-1$ fMenuManager = new MenuManager(id, id); fMenuManager.setRemoveAllWhenShown(true); - fMenuManager.addMenuListener((menuManager) -> { contextMenuAboutToShow(menuManager); }); + fMenuManager.addMenuListener((menuManager) -> { + contextMenuAboutToShow(menuManager); + }); Menu menu = fMenuManager.createContextMenu(fTerminalControl.getControl()); fTerminalControl.getControl().setMenu(menu); @@ -230,17 +232,17 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener menuManager.add(fClearAction); menuManager.add(new Separator()); - + menuManager.add(fScrollLockAction); menuManager.add(new Separator()); - + menuManager.add(fTerminateLaunchAction); menuManager.add(fAutoTerminateAction); menuManager.add(new Separator()); - + // Other plug-ins can contribute their actions here menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - + menuManager.add(fShowPreferencePageAction); } @@ -253,11 +255,10 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener public void setFocus() { fTerminalControl.setFocus(); } - /** * Returns the launch to which the current selection belongs. - * + * * @return the launch to which the current selection belongs. */ protected ILaunch getCurrentLaunch() { @@ -267,7 +268,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener } return null; } - + @Override public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { @@ -290,7 +291,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener fTerminalControl.setBufferLineLimit(bufferLines); } } - + public ITerminalViewControl getTerminalViewControl() { return fTerminalControl; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalConnector.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalConnector.java index 93411d24305..78999c893b3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalConnector.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalConnector.java @@ -33,9 +33,9 @@ import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; * This class will read from the GDB process output and error streams and will write it to any registered * ITerminalControl. It must continue reading from the streams, even if there are no ITerminalControl to write * to. This is important to prevent GDB's output buffer from getting full and then completely stopping. - * - * In addition this class manages a history buffer which will be used to populate a new console with history - * information already collected for the same session. Used for example when closing an re-opening a console. + * + * In addition this class manages a history buffer which will be used to populate a new console with history + * information already collected for the same session. Used for example when closing an re-opening a console. */ public class GdbTerminalConnector implements IGdbTerminalControlConnector { /** @@ -58,25 +58,24 @@ public class GdbTerminalConnector implements IGdbTerminalControlConnector { public GdbTerminalConnector(Process process) { fProcess = process; - // Using a history buffer size aligned with the preferences for console buffering + // Using a history buffer size aligned with the preferences for console buffering // but not exceeding the internal maximum - // We cap the history buffer to an internal maximum in order to prevent excessive use + // We cap the history buffer to an internal maximum in order to prevent excessive use // of memory, the preference value applies to the console (not the history buffer) and can be specified // to billions of lines. - // Handling billion of lines for the history buffer would require a completely different approach + // Handling billion of lines for the history buffer would require a completely different approach // to this implementation, possibly making use of the hard disk instead of in memory. IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); int prefBufferLines = store.getInt(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES); - int history_buffer_size = prefBufferLines < HIST_BUFFER_MAX_SIZE ? prefBufferLines - : HIST_BUFFER_MAX_SIZE; + int history_buffer_size = prefBufferLines < HIST_BUFFER_MAX_SIZE ? prefBufferLines : HIST_BUFFER_MAX_SIZE; fHistoryBuffer = new ConsoleHistoryLinesBuffer(history_buffer_size); - + // Start the jobs that read the GDB process output streams String jobSuffix = ""; //$NON-NLS-1$ fOutputStreamJob = new OutputReadJob(process.getInputStream(), jobSuffix); fOutputStreamJob.schedule(); - + jobSuffix = "-Error"; //$NON-NLS-1$ fErrorStreamJob = new OutputReadJob(process.getErrorStream(), jobSuffix); fErrorStreamJob.schedule(); @@ -87,7 +86,7 @@ public class GdbTerminalConnector implements IGdbTerminalControlConnector { * the maximum is being exceeded.</br> * It also keeps track of partial text at the end of the receiving input i.e. not yet forming a complete * line, once it forms a complete line it gets integrated in the queue - * + * * In addition the API used in this implementation are synchronized to allow consistent information among * the Jobs using it */ @@ -111,13 +110,14 @@ public class GdbTerminalConnector implements IGdbTerminalControlConnector { */ private class HistorySnapShot { private final String[] fHistoryLinesSnapShot; - private final String fHistoryRemainderSnapShot; + private final String fHistoryRemainderSnapShot; + private HistorySnapShot(String[] historyLines, String historyRemainder) { fHistoryLinesSnapShot = historyLines; fHistoryRemainderSnapShot = historyRemainder; } } - + @Override public synchronized int size() { return super.size(); @@ -150,7 +150,7 @@ public class GdbTerminalConnector implements IGdbTerminalControlConnector { /** * Writes complete lines to the history buffer, and accumulates incomplete lines "remainder" until * they form a full line. - * + * * Adding complete lines to the buffer is needed to respect a specified maximum number of buffered * lines */ @@ -191,7 +191,7 @@ public class GdbTerminalConnector implements IGdbTerminalControlConnector { } @Override - public synchronized String[] toArray() { + public synchronized String[] toArray() { return super.toArray(new String[size()]); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalPageConnector.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalPageConnector.java index e121e474862..c6e43fb43ed 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalPageConnector.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalPageConnector.java @@ -24,24 +24,24 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; */ public class GdbTerminalPageConnector extends PlatformObject implements ITerminalConnector { - private int fTerminalWidth, fTerminalHeight; - private ITerminalControl fControl; - private final PTY fPty; - private final IGdbTerminalControlConnector fGdbTerminalCtrlConnector; - - public GdbTerminalPageConnector(IGdbTerminalControlConnector gdbTerminalCtrlConnector, PTY pty) { - fPty = pty; - fGdbTerminalCtrlConnector = gdbTerminalCtrlConnector; + private int fTerminalWidth, fTerminalHeight; + private ITerminalControl fControl; + private final PTY fPty; + private final IGdbTerminalControlConnector fGdbTerminalCtrlConnector; + + public GdbTerminalPageConnector(IGdbTerminalControlConnector gdbTerminalCtrlConnector, PTY pty) { + fPty = pty; + fGdbTerminalCtrlConnector = gdbTerminalCtrlConnector; } - - @Override + + @Override public void disconnect() { - fGdbTerminalCtrlConnector.removePageTerminalControl(fControl); + fGdbTerminalCtrlConnector.removePageTerminalControl(fControl); - if (fControl != null) { - fControl.setState(TerminalState.CLOSED); - } - } + if (fControl != null) { + fControl.setState(TerminalState.CLOSED); + } + } @Override public OutputStream getTerminalToRemoteStream() { @@ -50,9 +50,9 @@ public class GdbTerminalPageConnector extends PlatformObject implements ITermina @Override public void connect(ITerminalControl control) { - if (control == null) { - throw new IllegalArgumentException("Invalid ITerminalControl"); //$NON-NLS-1$ - } + if (control == null) { + throw new IllegalArgumentException("Invalid ITerminalControl"); //$NON-NLS-1$ + } fControl = control; fGdbTerminalCtrlConnector.addPageTerminalControl(fControl); @@ -61,69 +61,68 @@ public class GdbTerminalPageConnector extends PlatformObject implements ITermina fControl.setState(TerminalState.CONNECTED); } + @Override + public void setTerminalSize(int newWidth, int newHeight) { + if (newWidth != fTerminalWidth || newHeight != fTerminalHeight) { + fTerminalWidth = newWidth; + fTerminalHeight = newHeight; + if (fPty != null) { + fPty.setTerminalSize(newWidth, newHeight); + } + } + } + + @Override + public String getId() { + // No need for an id, as we're are just used locally + return null; + } + + @Override + public String getName() { + // No name + return null; + } + + @Override + public boolean isHidden() { + // in case we do leak into the TM world, we shouldn't be visible + return true; + } + + @Override + public boolean isInitialized() { + return true; + } + + @Override + public String getInitializationErrorMessage() { + return null; + } + + @Override + public boolean isLocalEcho() { + return false; + } + + @Override + public void setDefaultSettings() { + // we don't do settings + } - @Override - public void setTerminalSize(int newWidth, int newHeight) { - if (newWidth != fTerminalWidth || newHeight != fTerminalHeight) { - fTerminalWidth = newWidth; - fTerminalHeight = newHeight; - if (fPty != null) { - fPty.setTerminalSize(newWidth, newHeight); - } - } - } - - @Override - public String getId() { - // No need for an id, as we're are just used locally - return null; - } - - @Override - public String getName() { - // No name - return null; - } - - @Override - public boolean isHidden() { - // in case we do leak into the TM world, we shouldn't be visible - return true; - } - - @Override - public boolean isInitialized() { - return true; - } - - @Override - public String getInitializationErrorMessage() { - return null; - } - - @Override - public boolean isLocalEcho() { - return false; - } - - @Override - public void setDefaultSettings() { - // we don't do settings - } - - @Override - public String getSettingsSummary() { - // we don't do settings - return null; - } - - @Override - public void load(ISettingsStore arg0) { - // we don't do settings - } - - @Override - public void save(ISettingsStore arg0) { - // we don't do settings - } + @Override + public String getSettingsSummary() { + // we don't do settings + return null; + } + + @Override + public void load(ISettingsStore arg0) { + // we don't do settings + } + + @Override + public void save(ISettingsStore arg0) { + // we don't do settings + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/IGDBDebuggerConsole.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/IGDBDebuggerConsole.java index 0e235a8d58f..424010227c3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/IGDBDebuggerConsole.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/IGDBDebuggerConsole.java @@ -27,19 +27,21 @@ import org.eclipse.debug.ui.DebugUITools; public interface IGDBDebuggerConsole extends IDebuggerConsole { /* * (non-Javadoc) - * + * * @see org.eclipse.cdt.debug.ui.debuggerconsole.IDebuggerConsole#consoleSelected() */ @Override public default void consoleSelected() { - DsfSession session = ((GdbLaunch)getLaunch()).getSession(); - if (!session.isActive()) {return;} + DsfSession session = ((GdbLaunch) getLaunch()).getSession(); + if (!session.isActive()) { + return; + } // only trigger the DV selection if the current selection is in // a different session IAdaptable context = DebugUITools.getDebugContext(); if (context != null) { - ILaunch selectedLaunch = context.getAdapter(ILaunch.class); + ILaunch selectedLaunch = context.getAdapter(ILaunch.class); if (getLaunch().equals(selectedLaunch)) { return; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/IGdbTerminalControlConnector.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/IGdbTerminalControlConnector.java index 5f883051630..fafd9dfbcd7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/IGdbTerminalControlConnector.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/IGdbTerminalControlConnector.java @@ -21,14 +21,14 @@ public interface IGdbTerminalControlConnector { /** * Adds a terminal control which is ready to receive the process output - * + * * @param terminalControl */ void addPageTerminalControl(ITerminalControl terminalControl); /** * Removes a registered terminal control - * + * * @param terminalControl */ void removePageTerminalControl(ITerminalControl terminalControl); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsole.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsole.java index 0f93f7dbac1..56569b929e4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsole.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsole.java @@ -43,7 +43,7 @@ import org.eclipse.ui.console.IOConsole; * Any input to this console is read and discarded, since this console should be * read-only. We don't actually make the console read-only because it is nice * for the user to be able to add delimiters such as empty lines within the traces. - * + * * @since 2.1 * This class was moved from package org.eclipse.cdt.dsf.gdb.internal.ui.tracing */ @@ -56,148 +56,151 @@ public class TracingConsole extends IOConsole { public TracingConsole(ILaunch launch, String label) { super("", null, null, false); //$NON-NLS-1$ fLaunch = launch; - fTracingStream = newOutputStream(); - fSession = ((GdbLaunch)launch).getSession(); - fLabel = label; + fTracingStream = newOutputStream(); + fSession = ((GdbLaunch) launch).getSession(); + fLabel = label; resetName(); - // Start a job to swallow all the input from the user + // Start a job to swallow all the input from the user new InputReadJob().schedule(); - // This is needed if the service has already been created. - // For example, if we turn on tracing after a launch is started. - setStreamInService(); + // This is needed if the service has already been created. + // For example, if we turn on tracing after a launch is started. + setStreamInService(); } - - @Override + + @Override protected void init() { - super.init(); - fSession.getExecutor().submit(new DsfRunnable() { - @Override - public void run() { - fSession.addServiceEventListener(TracingConsole.this, null); - } - }); - } - + super.init(); + fSession.getExecutor().submit(new DsfRunnable() { + @Override + public void run() { + fSession.addServiceEventListener(TracingConsole.this, null); + } + }); + } + @Override protected void dispose() { - try { + try { fTracingStream.close(); } catch (IOException e) { } - try { - fSession.getExecutor().submit(new DsfRunnable() { - @Override - public void run() { - fSession.removeServiceEventListener(TracingConsole.this); - } - }); + try { + fSession.getExecutor().submit(new DsfRunnable() { + @Override + public void run() { + fSession.removeServiceEventListener(TracingConsole.this); + } + }); } catch (RejectedExecutionException e) { // Session already disposed } super.dispose(); } - - public ILaunch getLaunch() { return fLaunch; } - - private void setStreamInService() { - try { - fSession.getExecutor().submit(new DsfRunnable() { - @Override - public void run() { - DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); - IGDBControl control = tracker.getService(IGDBControl.class); - tracker.dispose(); - if (control != null) { - // Special method that need not be called on the executor - control.setTracingStream(fTracingStream); - } - } - }); - } catch (RejectedExecutionException e) { - } + + public ILaunch getLaunch() { + return fLaunch; + } + + private void setStreamInService() { + try { + fSession.getExecutor().submit(new DsfRunnable() { + @Override + public void run() { + DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), + fSession.getId()); + IGDBControl control = tracker.getService(IGDBControl.class); + tracker.dispose(); + if (control != null) { + // Special method that need not be called on the executor + control.setTracingStream(fTracingStream); + } + } + }); + } catch (RejectedExecutionException e) { + } + } + + protected String computeName() { + String label = fLabel; + + ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); + if (config != null && !DebugUITools.isPrivate(config)) { + String type = null; + try { + type = config.getType().getName(); + } catch (CoreException e) { + } + StringBuilder buffer = new StringBuilder(); + buffer.append(config.getName()); + if (type != null) { + buffer.append(" ["); //$NON-NLS-1$ + buffer.append(type); + buffer.append("] "); //$NON-NLS-1$ + } + buffer.append(label); + label = buffer.toString(); + } + + if (fLaunch.isTerminated()) { + return ConsoleMessages.ConsoleMessages_console_terminated + label; + } + + return label; + } + + public void resetName() { + final String newName = computeName(); + String name = getName(); + if (!name.equals(newName)) { + Display display = PlatformUI.getWorkbench().getDisplay(); + if (!display.isDisposed()) { + display.asyncExec(() -> setName(newName)); + } + } + } + + @DsfServiceEventHandler + public final void eventDispatched(ICommandControlInitializedDMEvent event) { + // Now that the service is started, we can set the stream. + // We won't receive this event if we enable tracing after a launch + // has been started. + setStreamInService(); } - - protected String computeName() { - String label = fLabel; - - ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); - if (config != null && !DebugUITools.isPrivate(config)) { - String type = null; - try { - type = config.getType().getName(); - } catch (CoreException e) { - } - StringBuilder buffer = new StringBuilder(); - buffer.append(config.getName()); - if (type != null) { - buffer.append(" ["); //$NON-NLS-1$ - buffer.append(type); - buffer.append("] "); //$NON-NLS-1$ - } - buffer.append(label); - label = buffer.toString(); - } - - if (fLaunch.isTerminated()) { - return ConsoleMessages.ConsoleMessages_console_terminated + label; - } - - return label; - } - - public void resetName() { - final String newName = computeName(); - String name = getName(); - if (!name.equals(newName)) { - Display display = PlatformUI.getWorkbench().getDisplay(); - if (!display.isDisposed()) { - display.asyncExec(() -> setName(newName)); - } - } - } - - @DsfServiceEventHandler - public final void eventDispatched(ICommandControlInitializedDMEvent event) { - // Now that the service is started, we can set the stream. - // We won't receive this event if we enable tracing after a launch - // has been started. - setStreamInService(); - } /** * A reading Job which will prevent the input stream * from filling up. We don't actually do anything with * the data we read, since the Trace console should not * accept input. - * + * * But instead of making the console read-only, we allow * the user to type things to allow for comments to be * inserted within the traces. */ - private class InputReadJob extends Job { - { - setSystem(true); - } - - InputReadJob() { - super("Traces Input Job"); //$NON-NLS-1$ - } - - @Override + private class InputReadJob extends Job { + { + setSystem(true); + } + + InputReadJob() { + super("Traces Input Job"); //$NON-NLS-1$ + } + + @Override protected IStatus run(IProgressMonitor monitor) { - try { - byte[] b = new byte[1024]; - int read = 0; - while (getInputStream() != null && read >= 0) { - // Read the input and swallow it. - read = getInputStream().read(b); - } - } catch (IOException e) { - } - return Status.OK_STATUS; - } - } + try { + byte[] b = new byte[1024]; + int read = 0; + while (getInputStream() != null && read >= 0) { + // Read the input and swallow it. + read = getInputStream().read(b); + } + } catch (IOException e) { + } + return Status.OK_STATUS; + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java index 2955fbafe44..5bfb10771e8 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java @@ -32,7 +32,7 @@ import org.eclipse.ui.console.IConsole; * based on launch events and preference events. * TracingConsoles are always running but are only shown in the console * view if enabled by the user preference. - * + * * @since 2.1 * This class was moved from package org.eclipse.cdt.dsf.gdb.internal.ui.tracing */ @@ -46,7 +46,7 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang /** * The minimum number of characters that should be kept when truncating - * the console output. + * the console output. */ private static final int MIN_NUMBER_OF_CHARS_TO_KEEP = 5000; @@ -55,37 +55,37 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang * We keep it up-to-date by registering as an IPropertyChangeListener */ private boolean fTracingEnabled = false; - + /** * The maximum number of characters that are allowed per console */ private int fMaxNumCharacters = 500000; - + /** * The number of characters that will be kept in the console once we * go over fMaxNumCharacters and that we must remove some characters */ private int fMinNumCharacters = fMaxNumCharacters - NUMBER_OF_CHARS_TO_DELETE; - + /** * A map of all TracingConsoles for their corresponding launch. * We keep this list because TracingConsoles may not be registered * with the ConsoleManager, so we need another way to find them. */ private HashMap<ITracedLaunch, TracingConsole> fTracingConsoles = new HashMap<>(); - + /** * Start the tracing console. We don't do this in a constructor, because * we need to use <code>this</code>. */ public void startup() { IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); - + store.addPropertyChangeListener(this); fTracingEnabled = store.getBoolean(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE); int maxChars = store.getInt(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES); setWaterMarks(maxChars); - + DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); } @@ -97,14 +97,14 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang protected void toggleTracingVisibility(boolean visible) { if (visible) { - ConsolePlugin.getDefault().getConsoleManager().addConsoles( - fTracingConsoles.values().toArray(new IConsole[fTracingConsoles.size()])); + ConsolePlugin.getDefault().getConsoleManager() + .addConsoles(fTracingConsoles.values().toArray(new IConsole[fTracingConsoles.size()])); } else { - ConsolePlugin.getDefault().getConsoleManager().removeConsoles( - fTracingConsoles.values().toArray(new IConsole[fTracingConsoles.size()])); + ConsolePlugin.getDefault().getConsoleManager() + .removeConsoles(fTracingConsoles.values().toArray(new IConsole[fTracingConsoles.size()])); } } - + protected void removeAllConsoles() { ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); for (ILaunch launch : launches) { @@ -112,25 +112,25 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang } } - @Override + @Override public void launchesAdded(ILaunch[] launches) { for (ILaunch launch : launches) { addConsole(launch); } } - @Override + @Override public void launchesChanged(ILaunch[] launches) { } - @Override + @Override public void launchesRemoved(ILaunch[] launches) { for (ILaunch launch : launches) { removeConsole(launch); } } - - @Override + + @Override public void launchesTerminated(ILaunch[] launches) { for (ILaunch launch : launches) { // Since we already had a console, don't get rid of it @@ -138,14 +138,14 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang renameConsole(launch); } } - - @Override + + @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE)) { - fTracingEnabled = (Boolean)event.getNewValue(); + fTracingEnabled = (Boolean) event.getNewValue(); toggleTracingVisibility(fTracingEnabled); } else if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES)) { - int maxChars = (Integer)event.getNewValue(); + int maxChars = (Integer) event.getNewValue(); updateAllConsoleWaterMarks(maxChars); } } @@ -157,13 +157,14 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang if (getConsole(launch) == null) { if (!launch.isTerminated()) { // Create a new tracing console. - TracingConsole console = new TracingConsole(launch, ConsoleMessages.ConsoleMessages_trace_console_name); + TracingConsole console = new TracingConsole(launch, + ConsoleMessages.ConsoleMessages_trace_console_name); console.initialize(); console.setWaterMarks(fMinNumCharacters, fMaxNumCharacters); - - fTracingConsoles.put((ITracedLaunch)launch, console); + + fTracingConsoles.put((ITracedLaunch) launch, console); if (fTracingEnabled) { - ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{console}); + ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console }); } } // else we don't display a new console for a terminated launch } @@ -175,7 +176,7 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang if (console != null) { console.destroy(); if (fTracingEnabled) { - ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{console}); + ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[] { console }); } } } @@ -186,24 +187,25 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang console.resetName(); } } - + private TracingConsole getConsole(ILaunch launch) { return fTracingConsoles.get(launch); } - + /** @since 2.2 */ protected void setWaterMarks(int maxChars) { if (maxChars < (MIN_NUMBER_OF_CHARS_TO_KEEP * 2)) { maxChars = MIN_NUMBER_OF_CHARS_TO_KEEP * 2; } - + fMaxNumCharacters = maxChars; // If the max number of chars is anything below the number of chars we are going to delete // (plus our minimum buffer), we only keep the minimum. // If the max number of chars is bigger than the number of chars we are going to delete (plus // the minimum buffer), we truncate a fixed amount chars. - fMinNumCharacters = maxChars < (NUMBER_OF_CHARS_TO_DELETE + MIN_NUMBER_OF_CHARS_TO_KEEP) - ? MIN_NUMBER_OF_CHARS_TO_KEEP : maxChars - NUMBER_OF_CHARS_TO_DELETE; + fMinNumCharacters = maxChars < (NUMBER_OF_CHARS_TO_DELETE + MIN_NUMBER_OF_CHARS_TO_KEEP) + ? MIN_NUMBER_OF_CHARS_TO_KEEP + : maxChars - NUMBER_OF_CHARS_TO_DELETE; } /** @since 2.2 */ @@ -214,12 +216,12 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang updateConsoleWaterMarks(launch); } } - + /** @since 2.2 */ protected void updateConsoleWaterMarks(ILaunch launch) { TracingConsole console = getConsole(launch); if (console != null) { console.setWaterMarks(fMinNumCharacters, fMaxNumCharacters); - } + } } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/ConsoleSaveAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/ConsoleSaveAction.java index 072103a7a15..60b5392eea2 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/ConsoleSaveAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/ConsoleSaveAction.java @@ -31,59 +31,60 @@ import org.eclipse.ui.console.TextConsole; /** * An action to save the gdb traces. Inspired by MiConsoleSaveAction - * + * * @since 2.1 */ -public class ConsoleSaveAction extends Action{ +public class ConsoleSaveAction extends Action { private TextConsole fConsole; - + public ConsoleSaveAction(TextConsole console) { - super(); - setToolTipText( ConsoleMessages.ConsoleMessages_save_action_tooltip); - setImageDescriptor(GdbUIPlugin.imageDescriptorFromPlugin(GdbUIPlugin.PLUGIN_ID,IConsoleImagesConst.IMG_SAVE_CONSOLE)); - fConsole = console; + super(); + setToolTipText(ConsoleMessages.ConsoleMessages_save_action_tooltip); + setImageDescriptor( + GdbUIPlugin.imageDescriptorFromPlugin(GdbUIPlugin.PLUGIN_ID, IConsoleImagesConst.IMG_SAVE_CONSOLE)); + fConsole = console; } - + @Override public void run() { FileDialog fileDialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE); final String fileName = fileDialog.open(); - if(fileName==null) { + if (fileName == null) { return; } Runnable saveJob = new Runnable() { - @Override + @Override public void run() { saveContent(fileName); } }; BusyIndicator.showWhile(Display.getCurrent(), saveJob); } - + /** * Save the content from the tracing console to a file - * + * * @param fileName The fileName of the File to save to */ - protected void saveContent(String fileName) { + protected void saveContent(String fileName) { try { boolean confirmed = true; - + File file = new File(fileName); - if(file.exists()) { - confirmed = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), - ConsoleMessages.ConsoleMessages_save_confirm_overwrite_title, + if (file.exists()) { + confirmed = MessageDialog.openQuestion(Display.getCurrent().getActiveShell(), + ConsoleMessages.ConsoleMessages_save_confirm_overwrite_title, ConsoleMessages.ConsoleMessages_save_confirm_overwrite_desc); } - if(confirmed) { + if (confirmed) { BufferedWriter out = new BufferedWriter(new FileWriter(fileName)); out.write(fConsole.getDocument().get()); out.close(); } } catch (IOException e) { MessageDialog.openError(Display.getCurrent().getActiveShell(), - ConsoleMessages.ConsoleMessages_save_info_io_error_title, + ConsoleMessages.ConsoleMessages_save_info_io_error_title, ConsoleMessages.ConsoleMessages_save_info_io_error_desc); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbAutoTerminateAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbAutoTerminateAction.java index 1f9aa1285ea..6dbc1683928 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbAutoTerminateAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbAutoTerminateAction.java @@ -35,8 +35,7 @@ public class GdbAutoTerminateAction extends Action { private boolean readState() { return Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID, - IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, - true, null); + IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true, null); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleClearAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleClearAction.java index b1532602cfa..5dc3f9e2ae5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleClearAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleClearAction.java @@ -22,6 +22,7 @@ import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; public class GdbConsoleClearAction extends Action { private final ITerminalViewControl fTerminalCtrl; + public GdbConsoleClearAction(ITerminalViewControl terminalControl) { fTerminalCtrl = terminalControl; if (fTerminalCtrl == null || fTerminalCtrl.isDisposed()) { @@ -31,7 +32,8 @@ public class GdbConsoleClearAction extends Action { setText(ConsoleMessages.ConsoleClearAction_name); setToolTipText(ConsoleMessages.ConsoleClearAction_description); setImageDescriptor(GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_CLEAR_ACTIVE_COLOR)); - setDisabledImageDescriptor(GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_CLEAR_DISABLED_COLOR)); + setDisabledImageDescriptor( + GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_CLEAR_DISABLED_COLOR)); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsolePasteAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsolePasteAction.java index 049969d30e4..5274b98696e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsolePasteAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsolePasteAction.java @@ -22,6 +22,7 @@ import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; public class GdbConsolePasteAction extends Action { private final ITerminalViewControl fTerminalCtrl; + public GdbConsolePasteAction(ITerminalViewControl terminalControl) { fTerminalCtrl = terminalControl; if (fTerminalCtrl == null || fTerminalCtrl.isDisposed()) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleScrollLockAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleScrollLockAction.java index 7adabc6c36e..17138f04ebc 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleScrollLockAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleScrollLockAction.java @@ -24,10 +24,10 @@ public class GdbConsoleScrollLockAction extends Action { private final ITerminalViewControl fTerminalCtrl; private Boolean fScrollLocked = false; - + public GdbConsoleScrollLockAction(ITerminalViewControl terminalControl) { super(ConsoleMessages.ConsoleScrollLockAction_name, IAction.AS_CHECK_BOX); - + fTerminalCtrl = terminalControl; if (fTerminalCtrl == null || fTerminalCtrl.isDisposed()) { setEnabled(false); @@ -37,7 +37,8 @@ public class GdbConsoleScrollLockAction extends Action { setToolTipText(ConsoleMessages.ConsoleScrollLockAction_description); setImageDescriptor(GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_SCROLL_LOCK_ACTIVE_COLOR)); - setDisabledImageDescriptor(GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_SCROLL_LOCK_DISABLED_COLOR)); + setDisabledImageDescriptor( + GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_SCROLL_LOCK_DISABLED_COLOR)); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleTerminateLaunchAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleTerminateLaunchAction.java index c2e9fb16963..364d009d7f3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleTerminateLaunchAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/actions/GdbConsoleTerminateLaunchAction.java @@ -22,15 +22,16 @@ import org.eclipse.debug.core.ILaunchesListener2; import org.eclipse.jface.action.Action; public class GdbConsoleTerminateLaunchAction extends Action implements ILaunchesListener2 { - + private final ILaunch fLaunch; - + public GdbConsoleTerminateLaunchAction(ILaunch launch) { fLaunch = launch; setText(ConsoleMessages.ConsoleTerminateLaunchAction_name); setToolTipText(ConsoleMessages.ConsoleTerminateLaunchAction_description); setImageDescriptor(GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_TERMINATE_ACTIVE_COLOR)); - setDisabledImageDescriptor(GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_TERMINATE_DISABLED_COLOR)); + setDisabledImageDescriptor( + GdbUIPlugin.getImageDescriptor(IConsoleImagesConst.IMG_CONSOLE_TERMINATE_DISABLED_COLOR)); if (fLaunch.isTerminated()) { // Launch already terminated @@ -62,7 +63,7 @@ public class GdbConsoleTerminateLaunchAction extends Action implements ILaunches } } } - + @Override public void launchesRemoved(ILaunch[] launches) { } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/disassembly/AddDynamicPrintfRulerAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/disassembly/AddDynamicPrintfRulerAction.java index 2e59cbacff8..3bf36bb3800 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/disassembly/AddDynamicPrintfRulerAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/disassembly/AddDynamicPrintfRulerAction.java @@ -44,14 +44,14 @@ import org.eclipse.ui.IWorkbenchPart; * Ruler action to add dynamic printf with a dialog properties. */ public class AddDynamicPrintfRulerAction extends AbstractDisassemblyBreakpointRulerAction { - + private IToggleBreakpointsTargetCExtension fDynamicPrintfBreakpointsTarget; protected AddDynamicPrintfRulerAction(IDisassemblyPart disassemblyPart, IVerticalRulerInfo rulerInfo) { super(disassemblyPart, rulerInfo); setText(DisassemblyMessages.Disassembly_action_AddDynamicPrintf_label); } - + /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AbstractDisassemblyAction#run() */ @@ -60,107 +60,106 @@ public class AddDynamicPrintfRulerAction extends AbstractDisassemblyBreakpointRu if (fDynamicPrintfBreakpointsTarget != null) { IWorkbenchPart part = getDisassemblyPart(); ISelection selection = getSelection(); - try { - if (fDynamicPrintfBreakpointsTarget.canCreateLineBreakpointsInteractive(part, selection)) { - fDynamicPrintfBreakpointsTarget.createLineBreakpointsInteractive(part, selection); - } - } catch (CoreException e) { - reportException(e); - } - } + try { + if (fDynamicPrintfBreakpointsTarget.canCreateLineBreakpointsInteractive(part, selection)) { + fDynamicPrintfBreakpointsTarget.createLineBreakpointsInteractive(part, selection); + } + } catch (CoreException e) { + reportException(e); + } + } } @Override public void update() { - IDisassemblyPart part = getDisassemblyPart(); - if (part != null && part.isConnected()) { - ISelection selection = getSelection(); + IDisassemblyPart part = getDisassemblyPart(); + if (part != null && part.isConnected()) { + ISelection selection = getSelection(); if (fDynamicPrintfBreakpointsTarget == null) { fDynamicPrintfBreakpointsTarget = fetchDynamicPrintfBreakpointsTarget(selection); } - if (fDynamicPrintfBreakpointsTarget == null) { - setEnabled(false); - return; - } - if (fDynamicPrintfBreakpointsTarget.canCreateLineBreakpointsInteractive(part, selection)) { - setEnabled(true); - return; - } - } - setEnabled(false); + if (fDynamicPrintfBreakpointsTarget == null) { + setEnabled(false); + return; + } + if (fDynamicPrintfBreakpointsTarget.canCreateLineBreakpointsInteractive(part, selection)) { + setEnabled(true); + return; + } + } + setEnabled(false); } - /** - * Report an error to the user. - * - * @param e underlying exception - */ - private void reportException(Exception e) { - IStatus status= new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Error creating dynamic printf: ", e); //$NON-NLS-1$ - ErrorDialog.openError( - getDisassemblyPart().getSite().getShell(), - DisassemblyMessages.Disassembly_action_AddDynamicPrintf_errorTitle, - DisassemblyMessages.Disassembly_action_AddDynamicPrintf_errorMessage, - status); - CDebugUIPlugin.log(status); - } + * Report an error to the user. + * + * @param e underlying exception + */ + private void reportException(Exception e) { + IStatus status = new Status(IStatus.ERROR, CDebugUIPlugin.PLUGIN_ID, "Error creating dynamic printf: ", e); //$NON-NLS-1$ + ErrorDialog.openError(getDisassemblyPart().getSite().getShell(), + DisassemblyMessages.Disassembly_action_AddDynamicPrintf_errorTitle, + DisassemblyMessages.Disassembly_action_AddDynamicPrintf_errorMessage, status); + CDebugUIPlugin.log(status); + } /** - * Determines the text selection for the breakpoint action. If clicking on the ruler inside - * the highlighted text, return the text selection for the highlighted text. Otherwise, - * return a text selection representing the start of the line. - * - * @return An ISelection as described. - * @throws BadLocationException If underlying operations throw. - */ - private ISelection getSelection() { - IDocument document = getDocument(); - if (document != null) { - int line = getRulerInfo().getLineOfLastMouseButtonActivity(); - - try { - IRegion region = getDocument().getLineInformation(line); - ITextSelection textSelection = new TextSelection(document, region.getOffset(), 0); - ISelectionProvider provider = getDisassemblyPart().getSite().getSelectionProvider(); - if (provider != null){ - ISelection selection = provider.getSelection(); - if (selection instanceof ITextSelection - && ((ITextSelection) selection).getStartLine() <= line - && ((ITextSelection) selection).getEndLine() >= line) { - textSelection = (ITextSelection) selection; - } - } - return textSelection; - } catch (BadLocationException e) { - } - } - return StructuredSelection.EMPTY; - } + * Determines the text selection for the breakpoint action. If clicking on the ruler inside + * the highlighted text, return the text selection for the highlighted text. Otherwise, + * return a text selection representing the start of the line. + * + * @return An ISelection as described. + * @throws BadLocationException If underlying operations throw. + */ + private ISelection getSelection() { + IDocument document = getDocument(); + if (document != null) { + int line = getRulerInfo().getLineOfLastMouseButtonActivity(); + + try { + IRegion region = getDocument().getLineInformation(line); + ITextSelection textSelection = new TextSelection(document, region.getOffset(), 0); + ISelectionProvider provider = getDisassemblyPart().getSite().getSelectionProvider(); + if (provider != null) { + ISelection selection = provider.getSelection(); + if (selection instanceof ITextSelection && ((ITextSelection) selection).getStartLine() <= line + && ((ITextSelection) selection).getEndLine() >= line) { + textSelection = (ITextSelection) selection; + } + } + return textSelection; + } catch (BadLocationException e) { + } + } + return StructuredSelection.EMPTY; + } private IToggleBreakpointsTargetCExtension fetchDynamicPrintfBreakpointsTarget(ISelection selection) { - if (fDynamicPrintfBreakpointsTarget == null){ - IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.EXTENSION_POINT_TOGGLE_BREAKPOINTS_TARGET_FACTORIES); + if (fDynamicPrintfBreakpointsTarget == null) { + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(IDebugUIConstants.PLUGIN_ID, + IDebugUIConstants.EXTENSION_POINT_TOGGLE_BREAKPOINTS_TARGET_FACTORIES); IConfigurationElement[] elements = ep.getConfigurationElements(); - for (int i= 0; i < elements.length; i++) { - String id = elements[i].getAttribute("id"); //$NON-NLS-1$ + for (int i = 0; i < elements.length; i++) { + String id = elements[i].getAttribute("id"); //$NON-NLS-1$ if (id != null && id.equals("org.eclipse.cdt.dsf.gdb.ui.ToggleDynamicPrintfTargetFactory")) { //$NON-NLS-1$ - try{ + try { Object obj = elements[i].createExecutableExtension("class"); //$NON-NLS-1$ - if(obj instanceof IToggleBreakpointsTargetFactory) { - IToggleBreakpointsTarget target = ((IToggleBreakpointsTargetFactory)obj).createToggleTarget(ToggleDynamicPrintfTargetFactory.TOGGLE_C_DYNAMICPRINTF_TARGET_ID); + if (obj instanceof IToggleBreakpointsTargetFactory) { + IToggleBreakpointsTarget target = ((IToggleBreakpointsTargetFactory) obj) + .createToggleTarget( + ToggleDynamicPrintfTargetFactory.TOGGLE_C_DYNAMICPRINTF_TARGET_ID); if (target instanceof IToggleBreakpointsTargetCExtension) { - fDynamicPrintfBreakpointsTarget = (IToggleBreakpointsTargetCExtension)target; + fDynamicPrintfBreakpointsTarget = (IToggleBreakpointsTargetCExtension) target; } - } - } catch (CoreException e){ + } + } catch (CoreException e) { } break; } } } return fDynamicPrintfBreakpointsTarget; - } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/disassembly/DisassemblyMessages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/disassembly/DisassemblyMessages.java index b6dbb119ada..059b179186a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/disassembly/DisassemblyMessages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/disassembly/DisassemblyMessages.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Marc Khouzam (Ericsson) - Support for dynamic printf (Bug 400628) *******************************************************************************/ @@ -16,11 +16,11 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.disassembly; import org.eclipse.osgi.util.NLS; public final class DisassemblyMessages extends NLS { - public static String Disassembly_action_AddDynamicPrintf_label; - public static String Disassembly_action_AddDynamicPrintf_errorMessage; - public static String Disassembly_action_AddDynamicPrintf_errorTitle; - public static String Disassembly_action_AddDynamicPrintf_accelerator; - + public static String Disassembly_action_AddDynamicPrintf_label; + public static String Disassembly_action_AddDynamicPrintf_errorMessage; + public static String Disassembly_action_AddDynamicPrintf_errorTitle; + public static String Disassembly_action_AddDynamicPrintf_accelerator; + static { NLS.initializeMessages(DisassemblyMessages.class.getName(), DisassemblyMessages.class); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/AttachCDebuggerTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/AttachCDebuggerTab.java index 1176da21ac6..1a80d7054f9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/AttachCDebuggerTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/AttachCDebuggerTab.java @@ -7,22 +7,21 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.launching; - /** * Debugger tab to use for an attach launch configuration. - * + * * @since 2.0 */ public class AttachCDebuggerTab extends CDebuggerTab { - public AttachCDebuggerTab() { - // We don't know yet if we are going to do a remote or local session - super(null, true); - } + public AttachCDebuggerTab() { + // We don't know yet if we are going to do a remote or local session + super(null, true); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CArgumentsTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CArgumentsTab.java index a5f726ad635..9efcea5f2a1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CArgumentsTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CArgumentsTab.java @@ -49,82 +49,82 @@ import org.eclipse.swt.widgets.Text; * </p> */ public class CArgumentsTab extends CLaunchConfigurationTab { - /** - * Tab identifier used for ordering of tabs added using the - * <code>org.eclipse.debug.ui.launchConfigurationTabs</code> - * extension point. - * - * @since 2.0 - */ - public static final String TAB_ID = "org.eclipse.cdt.dsf.gdb.launch.argumentsTab"; //$NON-NLS-1$ - + /** + * Tab identifier used for ordering of tabs added using the + * <code>org.eclipse.debug.ui.launchConfigurationTabs</code> + * extension point. + * + * @since 2.0 + */ + public static final String TAB_ID = "org.eclipse.cdt.dsf.gdb.launch.argumentsTab"; //$NON-NLS-1$ + // Program arguments UI widgets protected Label fPrgmArgumentsLabel; protected Text fPrgmArgumentsText; protected Button fArgumentVariablesButton; - + // Working directory protected WorkingDirectoryBlock fWorkingDirectoryBlock = new WorkingDirectoryBlock(); - @Override + @Override public void createControl(Composite parent) { - Font font = parent.getFont(); - Composite comp = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(1, true); - comp.setLayout(layout); - comp.setFont(font); - - GridData gd = new GridData(GridData.FILL_BOTH); - comp.setLayoutData(gd); - setControl(comp); - - GdbUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB); - + Font font = parent.getFont(); + Composite comp = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(1, true); + comp.setLayout(layout); + comp.setFont(font); + + GridData gd = new GridData(GridData.FILL_BOTH); + comp.setLayoutData(gd); + setControl(comp); + + GdbUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), + ICDTLaunchHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB); + createArgumentComponent(comp, 1); fWorkingDirectoryBlock.createControl(comp); } - protected void createArgumentComponent(Composite comp, int horizontalSpan) { - Font font = comp.getFont(); - Group group = new Group(comp, SWT.NONE); - group.setFont(font); - group.setLayout(new GridLayout()); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = horizontalSpan; - group.setLayoutData(gd); + protected void createArgumentComponent(Composite comp, int horizontalSpan) { + Font font = comp.getFont(); + Group group = new Group(comp, SWT.NONE); + group.setFont(font); + group.setLayout(new GridLayout()); + GridData gd = new GridData(GridData.FILL_BOTH); + gd.horizontalSpan = horizontalSpan; + group.setLayoutData(gd); - group.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$ - fPrgmArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); - fPrgmArgumentsText.getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments"); //$NON-NLS-1$ - } - }); - gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = 40; - gd.widthHint = 100; - fPrgmArgumentsText.setLayoutData(gd); - fPrgmArgumentsText.setFont(font); - fPrgmArgumentsText.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - fArgumentVariablesButton= createPushButton(group, LaunchMessages.getString("CArgumentsTab.Variables"), null); //$NON-NLS-1$ - gd = new GridData(GridData.HORIZONTAL_ALIGN_END); - fArgumentVariablesButton.setLayoutData(gd); - fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent arg0) { - handleVariablesButtonSelected(fPrgmArgumentsText); - } - }); - addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons - } + group.setText(LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments")); //$NON-NLS-1$ + fPrgmArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); + fPrgmArgumentsText.getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = LaunchMessages.getString("CArgumentsTab.C/C++_Program_Arguments"); //$NON-NLS-1$ + } + }); + gd = new GridData(GridData.FILL_BOTH); + gd.heightHint = 40; + gd.widthHint = 100; + fPrgmArgumentsText.setLayoutData(gd); + fPrgmArgumentsText.setFont(font); + fPrgmArgumentsText.addModifyListener(new ModifyListener() { + @Override + public void modifyText(ModifyEvent evt) { + updateLaunchConfigurationDialog(); + } + }); + fArgumentVariablesButton = createPushButton(group, LaunchMessages.getString("CArgumentsTab.Variables"), null); //$NON-NLS-1$ + gd = new GridData(GridData.HORIZONTAL_ALIGN_END); + fArgumentVariablesButton.setLayoutData(gd); + fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent arg0) { + handleVariablesButtonSelected(fPrgmArgumentsText); + } + }); + addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons + } /** * A variable entry button has been pressed for the given text @@ -147,7 +147,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { dialog.open(); return dialog.getVariableExpression(); } - + public void addControlAccessibleListener(Control control, String controlName) { // Strip mnemonic (&) String[] strs = controlName.split("&"); //$NON-NLS-1$ @@ -157,7 +157,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { } control.getAccessible().addAccessibleListener(new ControlAccessibleListener(stripped.toString())); } - + private class ControlAccessibleListener extends AccessibleAdapter { private String controlName; @@ -170,59 +170,59 @@ public class CArgumentsTab extends CLaunchConfigurationTab { e.result = controlName; } } - + @Override public boolean isValid(ILaunchConfiguration config) { return fWorkingDirectoryBlock.isValid(config); } - @Override + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); } - @Override + @Override public void initializeFrom(ILaunchConfiguration configuration) { try { - fPrgmArgumentsText.setText(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "")); //$NON-NLS-1$ + fPrgmArgumentsText + .setText(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "")); //$NON-NLS-1$ fWorkingDirectoryBlock.initializeFrom(configuration); - } - catch (CoreException e) { - setErrorMessage(LaunchMessages.getFormattedString("Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ + } catch (CoreException e) { + setErrorMessage(LaunchMessages.getFormattedString( + "Launch.common.Exception_occurred_reading_configuration_EXCEPTION", e.getStatus().getMessage())); //$NON-NLS-1$ GdbUIPlugin.log(e); } } - @Override + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute( - ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, - getAttributeValueFrom(fPrgmArgumentsText)); + configuration.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, + getAttributeValueFrom(fPrgmArgumentsText)); fWorkingDirectoryBlock.performApply(configuration); } /** * Returns the string in the text widget, or <code>null</code> if empty. - * + * * @return text or <code>null</code> */ protected String getAttributeValueFrom(Text text) { String content = text.getText().trim(); // Bug #131513 - eliminate Windows \r line delimiter - content = content.replaceAll("\r\n", "\n"); //$NON-NLS-1$//$NON-NLS-2$ + content = content.replaceAll("\r\n", "\n"); //$NON-NLS-1$//$NON-NLS-2$ if (!content.isEmpty()) { return content; } return null; } - @Override - public String getId() { - return TAB_ID; - } - - @Override + @Override + public String getId() { + return TAB_ID; + } + + @Override public String getName() { return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CDebuggerTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CDebuggerTab.java index b61108dd836..84a9499f1b9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CDebuggerTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CDebuggerTab.java @@ -56,14 +56,14 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class CDebuggerTab extends CLaunchConfigurationTab { - /** - * Tab identifier used for ordering of tabs added using - * the <code>org.eclipse.debug.ui.launchConfigurationTabs</code> - * extension point. - * - * @since 2.0 - */ - public static final String TAB_ID = "org.eclipse.cdt.dsf.gdb.launch.debuggerTab"; //$NON-NLS-1$ + /** + * Tab identifier used for ordering of tabs added using + * the <code>org.eclipse.debug.ui.launchConfigurationTabs</code> + * extension point. + * + * @since 2.0 + */ + public static final String TAB_ID = "org.eclipse.cdt.dsf.gdb.launch.debuggerTab"; //$NON-NLS-1$ private final static String LOCAL_DEBUGGER_ID = "gdb";//$NON-NLS-1$ private final static String REMOTE_DEBUGGER_ID = "gdbserver";//$NON-NLS-1$ @@ -90,12 +90,12 @@ public class CDebuggerTab extends CLaunchConfigurationTab { private Composite fContents; - private IContentChangeListener fContentListener = new IContentChangeListener() { - @Override - public void contentChanged() { - contentsChanged(); - } - }; + private IContentChangeListener fContentListener = new IContentChangeListener() { + @Override + public void contentChanged() { + contentsChanged(); + } + }; public CDebuggerTab(SessionType sessionType, boolean attach) { if (sessionType == SessionType.REMOTE) { @@ -108,10 +108,10 @@ public class CDebuggerTab extends CLaunchConfigurationTab { @Override public String getId() { - return TAB_ID; + return TAB_ID; } - @Override + @Override public void createControl(Composite parent) { fContainer = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); fContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -158,7 +158,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { } } - @Override + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { setLaunchConfigurationWorkingCopy(config); ICDebuggerPage dynamicTab = getDynamicTab(); @@ -177,9 +177,9 @@ public class CDebuggerTab extends CLaunchConfigurationTab { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, LOCAL_DEBUGGER_ID); } else if (fRemoteMode) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); + IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, REMOTE_DEBUGGER_ID); - } else if (fCoreMode){ + } else if (fCoreMode) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, LOCAL_DEBUGGER_ID); @@ -198,7 +198,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { } } - @Override + @Override public void initializeFrom(ILaunchConfiguration config) { setInitializing(true); @@ -217,14 +217,13 @@ public class CDebuggerTab extends CLaunchConfigurationTab { setInitializing(false); } - @Override + @Override public void performApply(ILaunchConfigurationWorkingCopy config) { if (getDebuggerId() != null) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebuggerId()); ICDebuggerPage dynamicTab = getDynamicTab(); if (dynamicTab == null) { - config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, - (Map)null); + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null); } else { dynamicTab.performApply(config); } @@ -238,8 +237,8 @@ public class CDebuggerTab extends CLaunchConfigurationTab { ICDTLaunchConfigurationConstants.DEBUGGER_MODE_ATTACH); } else if (fRemoteMode) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - } else if (fCoreMode){ + IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); + } else if (fCoreMode) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE); } else { @@ -250,7 +249,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, fStopInMain.getSelection()); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, - fStopInMainSymbol.getText()); + fStopInMainSymbol.getText()); } } @@ -310,7 +309,8 @@ public class CDebuggerTab extends CLaunchConfigurationTab { optionsComp.setLayout(layout); optionsComp.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false, 1, 1)); if (!fAttachMode && !fCoreMode) { - fStopInMain = createCheckButton(optionsComp, LaunchMessages.getString("CDebuggerTab.Stop_at_main_on_startup")); //$NON-NLS-1$ + fStopInMain = createCheckButton(optionsComp, + LaunchMessages.getString("CDebuggerTab.Stop_at_main_on_startup")); //$NON-NLS-1$ fStopInMain.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -323,19 +323,17 @@ public class CDebuggerTab extends CLaunchConfigurationTab { gridData.widthHint = 100; fStopInMainSymbol.setLayoutData(gridData); fStopInMainSymbol.addModifyListener(new ModifyListener() { - @Override + @Override public void modifyText(ModifyEvent evt) { update(); } }); - fStopInMainSymbol.getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = LaunchMessages.getString("CDebuggerTab.Stop_at_main_on_startup"); //$NON-NLS-1$ - } + fStopInMainSymbol.getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = LaunchMessages.getString("CDebuggerTab.Stop_at_main_on_startup"); //$NON-NLS-1$ } - ); + }); } } @@ -361,10 +359,12 @@ public class CDebuggerTab extends CLaunchConfigurationTab { try { if (!fAttachMode && !fCoreMode) { IPreferenceStore preferences = GdbUIPlugin.getDefault().getPreferenceStore(); - fStopInMain.setSelection(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, - preferences.getBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN))); - fStopInMainSymbol.setText(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, - preferences.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL))); + fStopInMain + .setSelection(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, + preferences.getBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN))); + fStopInMainSymbol + .setText(config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, + preferences.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL))); fStopInMainSymbol.setEnabled(fStopInMain.getSelection()); } else if (fAttachMode) { // In attach mode, figure out if we are doing a remote connect based on @@ -434,11 +434,11 @@ public class CDebuggerTab extends CLaunchConfigurationTab { } protected void setDynamicTab(ICDebuggerPage tab) { - if (fDynamicTab instanceof ICDebuggerPageExtension) - ((ICDebuggerPageExtension) fDynamicTab).removeContentChangeListener(fContentListener); - fDynamicTab = tab; - if (fDynamicTab instanceof ICDebuggerPageExtension) - ((ICDebuggerPageExtension) fDynamicTab).addContentChangeListener(fContentListener); + if (fDynamicTab instanceof ICDebuggerPageExtension) + ((ICDebuggerPageExtension) fDynamicTab).removeContentChangeListener(fContentListener); + fDynamicTab = tab; + if (fDynamicTab instanceof ICDebuggerPageExtension) + ((ICDebuggerPageExtension) fDynamicTab).addContentChangeListener(fContentListener); } protected Composite getDynamicTabHolder() { @@ -497,8 +497,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { } } if (wc != null) { - wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, - (Map) null); + wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_SPECIFIC_ATTRS_MAP, (Map) null); } } else { if (wc == null) { @@ -538,7 +537,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { return LaunchImages.get(LaunchImages.IMG_VIEW_DEBUGGER_TAB); } - @Override + @Override public String getName() { return LaunchMessages.getString("AbstractCDebuggerTab.Debugger"); //$NON-NLS-1$ } @@ -554,17 +553,17 @@ public class CDebuggerTab extends CLaunchConfigurationTab { fDCombo = new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN); fDCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDCombo.addSelectionListener(new SelectionListener() { - @Override - public void widgetSelected(SelectionEvent e) { - if (!isInitializing()) { - setInitializeDefault(true); - updateComboFromSelection(); - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } + @Override + public void widgetSelected(SelectionEvent e) { + if (!isInitializing()) { + setInitializeDefault(true); + updateComboFromSelection(); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } }); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CLaunchConfigurationTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CLaunchConfigurationTab.java index 3c7655f6645..106cca5e000 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CLaunchConfigurationTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CLaunchConfigurationTab.java @@ -46,7 +46,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio * settings, or <code>null</code> if none. Note, if possible we will * return the IBinary based on config entry as this may be more usefull then * just the project. - * + * * @return C element context. */ protected ICElement getContext(ILaunchConfiguration config, String platform) { @@ -57,9 +57,10 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio try { projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null); programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null); - if (programName != null) { - programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName); - } + if (programName != null) { + programName = VariablesPlugin.getDefault().getStringVariableManager() + .performStringSubstitution(programName); + } } catch (CoreException e) { } @@ -73,7 +74,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio if (page != null) { ISelection selection = page.getSelection(); if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection)selection; + IStructuredSelection ss = (IStructuredSelection) selection; if (!ss.isEmpty()) { obj = ss.getFirstElement(); } @@ -81,9 +82,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio } } if (obj instanceof IResource) { - ICElement ce = CoreModel.getDefault().create((IResource)obj); + ICElement ce = CoreModel.getDefault().create((IResource) obj); if (ce == null) { - IProject pro = ((IResource)obj).getProject(); + IProject pro = ((IResource) obj).getProject(); ce = CoreModel.getDefault().create(pro); } obj = ce; @@ -92,8 +93,8 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio if (platform != null && !platform.equals("*")) { //$NON-NLS-1$ ICDescriptor descriptor; try { - descriptor = CCorePlugin.getDefault().getCProjectDescription( ((ICElement)obj).getCProject().getProject(), - false); + descriptor = CCorePlugin.getDefault() + .getCProjectDescription(((ICElement) obj).getCProject().getProject(), false); if (descriptor != null) { String projectPlatform = descriptor.getPlatform(); if (!projectPlatform.equals(platform) && !projectPlatform.equals("*")) { //$NON-NLS-1$ @@ -105,17 +106,17 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio } if (obj != null) { if (programName == null || programName.isEmpty()) { - return (ICElement)obj; + return (ICElement) obj; } - ICElement ce = (ICElement)obj; + ICElement ce = (ICElement) obj; IProject project; - project = (IProject)ce.getCProject().getResource(); + project = (IProject) ce.getCProject().getResource(); IPath programFile = project.getFile(programName).getLocation(); ce = CCorePlugin.getDefault().getCoreModel().create(programFile); if (ce != null && ce.exists()) { return ce; } - return (ICElement)obj; + return (ICElement) obj; } } if (page != null) { @@ -123,7 +124,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio if (part != null) { IEditorInput input = part.getEditorInput(); if (input instanceof IFileEditorInput) { - IFile file = ((IFileEditorInput)input).getFile(); + IFile file = ((IFileEditorInput) input).getFile(); if (file != null) { ICElement ce = CoreModel.getDefault().create(file); if (ce == null) { @@ -146,7 +147,7 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio String name = null; if (cProject != null && cProject.exists()) { name = cProject.getElementName(); - config.setMappedResources(new IResource[] {cProject.getProject()}); + config.setMappedResources(new IResource[] { cProject.getProject() }); ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(cProject.getProject()); String buildConfigID = projDes.getActiveConfiguration().getId(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainAttachTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainAttachTab.java index d1461f216a5..1f098a007c1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainAttachTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainAttachTab.java @@ -7,20 +7,19 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.launching; - /** * Main tab to use for an attach launch configuration. - * + * * @since 2.0 */ public class CMainAttachTab extends CMainTab { - public CMainAttachTab() { - super(CMainTab.DONT_CHECK_PROGRAM | CMainTab.INCLUDE_BUILD_SETTINGS); - } + public CMainAttachTab() { + super(CMainTab.DONT_CHECK_PROGRAM | CMainTab.INCLUDE_BUILD_SETTINGS); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainCoreTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainCoreTab.java index 30736cdb9e5..991c704376c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainCoreTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainCoreTab.java @@ -7,20 +7,19 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.launching; - /** * Main tab to use for an attach launch configuration. - * + * * @since 2.0 */ public class CMainCoreTab extends CMainTab { - public CMainCoreTab() { - super(CMainTab.SPECIFY_CORE_FILE | CMainTab.INCLUDE_BUILD_SETTINGS); - } + public CMainCoreTab() { + super(CMainTab.SPECIFY_CORE_FILE | CMainTab.INCLUDE_BUILD_SETTINGS); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java index 7ce8bc49c76..3417b8bbf87 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java @@ -14,10 +14,11 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.launching; import org.eclipse.cdt.launch.ui.CMainTab2; + /** * A launch configuration tab that displays and edits project and main type name launch * configuration attributes. - * + * * @deprecated Replaced with org.eclipse.cdt.launch.ui.CMainTab2 */ @Deprecated @@ -30,9 +31,9 @@ public class CMainTab extends CMainTab2 { super(flags); } - @Override - public String getId() { - // Return the old id as to be backwards compatible - return "org.eclipse.cdt.dsf.gdb.launch.mainTab"; //$NON-NLS-1$ - } + @Override + public String getId() { + // Return the old id as to be backwards compatible + return "org.eclipse.cdt.dsf.gdb.launch.mainTab"; //$NON-NLS-1$ + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFileDebuggerTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFileDebuggerTab.java index e7f488d3437..8adfa95150c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFileDebuggerTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFileDebuggerTab.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -19,7 +19,7 @@ import org.eclipse.cdt.dsf.gdb.service.SessionType; * @since 2.0 */ public class CoreFileDebuggerTab extends CDebuggerTab { - public CoreFileDebuggerTab() { - super(SessionType.CORE, false); - } + public CoreFileDebuggerTab() { + super(SessionType.CORE, false); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFilePrompter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFilePrompter.java index ce878e2b4b9..92a573653e7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFilePrompter.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFilePrompter.java @@ -34,11 +34,11 @@ public class CoreFilePrompter implements IStatusHandler { /* * (non-Javadoc) - * + * * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, * java.lang.Object) */ - @Override + @Override public Object handleStatus(IStatus status, Object params) throws CoreException { final Shell shell = GdbUIPlugin.getShell(); if (shell == null) { @@ -47,20 +47,21 @@ public class CoreFilePrompter implements IStatusHandler { LaunchMessages.getString("CoreFileLaunchDelegate.No_Shell_available_in_Launch"), null); //$NON-NLS-1$ throw new CoreException(error); } - + FileDialog dialog = new FileDialog(shell); dialog.setText(LaunchMessages.getString("CoreFileLaunchDelegate.Select_Corefile")); //$NON-NLS-1$ - String initialPath = (String)params; + String initialPath = (String) params; if (initialPath != null && initialPath.length() != 0) { dialog.setFilterPath(initialPath); } - + String res = dialog.open(); if (res != null) { File file = new File(res); if (!file.exists() || !file.canRead()) { - ErrorDialog.openError(shell, LaunchMessages.getString("CoreFileLaunchDelegate.postmortem_debugging_failed"), //$NON-NLS-1$ + ErrorDialog.openError(shell, + LaunchMessages.getString("CoreFileLaunchDelegate.postmortem_debugging_failed"), //$NON-NLS-1$ LaunchMessages.getString("CoreFileLaunchDelegate.Corefile_not_accessible"), //$NON-NLS-1$ new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(), ICDTLaunchConfigurationConstants.ERR_NO_COREFILE, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GDBSolibBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GDBSolibBlock.java index 8c4bcef1d55..023be02689d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GDBSolibBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GDBSolibBlock.java @@ -41,9 +41,9 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC private Button fAutoSoLibButton; private Button fUseSolibForAppButton; - + private Composite fControl; - + private boolean fAutoSolib = false; // Bug 314536 and Bug 314554 @@ -51,104 +51,112 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC // Since this option was added for multi-process but it has not been completed for Linux yet, just hide it completely for now private boolean fUseSolibForApp = false; - public GDBSolibBlock( IMILaunchConfigurationComponent solibSearchBlock, boolean autoSolib, boolean stopOnSolibEvents ) { + public GDBSolibBlock(IMILaunchConfigurationComponent solibSearchBlock, boolean autoSolib, + boolean stopOnSolibEvents) { super(); fSolibSearchPathBlock = solibSearchBlock; fAutoSolib = autoSolib; } - @Override - public void createControl( Composite parent ) { - Composite subComp = ControlFactory.createCompositeEx( parent, 1, GridData.FILL_HORIZONTAL ); - ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; - ((GridLayout)subComp.getLayout()).marginHeight = 0; - ((GridLayout)subComp.getLayout()).marginWidth = 0; - if ( fSolibSearchPathBlock != null ) { - fSolibSearchPathBlock.createControl( subComp ); - if ( fSolibSearchPathBlock instanceof Observable ) - ((Observable)fSolibSearchPathBlock).addObserver( this ); + @Override + public void createControl(Composite parent) { + Composite subComp = ControlFactory.createCompositeEx(parent, 1, GridData.FILL_HORIZONTAL); + ((GridLayout) subComp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout) subComp.getLayout()).marginHeight = 0; + ((GridLayout) subComp.getLayout()).marginWidth = 0; + if (fSolibSearchPathBlock != null) { + fSolibSearchPathBlock.createControl(subComp); + if (fSolibSearchPathBlock instanceof Observable) + ((Observable) fSolibSearchPathBlock).addObserver(this); } - if ( fAutoSolib ) { - fAutoSoLibButton = ControlFactory.createCheckBox( subComp, LaunchUIMessages.getString( "GDBSolibBlock.0" ) ); //$NON-NLS-1$ - fAutoSoLibButton.addSelectionListener( new SelectionAdapter() { + if (fAutoSolib) { + fAutoSoLibButton = ControlFactory.createCheckBox(subComp, LaunchUIMessages.getString("GDBSolibBlock.0")); //$NON-NLS-1$ + fAutoSoLibButton.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { + public void widgetSelected(SelectionEvent e) { updateButtons(); changed(); } - } ); + }); } - if ( fUseSolibForApp ) { - fUseSolibForAppButton = ControlFactory.createCheckBox( subComp, LaunchUIMessages.getString( "GDBSolibBlock.2" ) ); //$NON-NLS-1$ - fUseSolibForAppButton.addSelectionListener( new SelectionAdapter() { + if (fUseSolibForApp) { + fUseSolibForAppButton = ControlFactory.createCheckBox(subComp, + LaunchUIMessages.getString("GDBSolibBlock.2")); //$NON-NLS-1$ + fUseSolibForAppButton.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { + public void widgetSelected(SelectionEvent e) { updateButtons(); changed(); } - } ); + }); } fControl = subComp; } - @Override - public void initializeFrom( ILaunchConfiguration configuration ) { - if ( fSolibSearchPathBlock != null ) - fSolibSearchPathBlock.initializeFrom( configuration ); + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + if (fSolibSearchPathBlock != null) + fSolibSearchPathBlock.initializeFrom(configuration); try { - if ( fAutoSoLibButton != null ) - fAutoSoLibButton.setSelection( configuration.getAttribute( IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IGDBLaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT ) ); - if ( fUseSolibForAppButton != null ) - fUseSolibForAppButton.setSelection( configuration.getAttribute( IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP, IGDBLaunchConfigurationConstants.DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP_DEFAULT ) ); - initializeButtons( configuration ); + if (fAutoSoLibButton != null) + fAutoSoLibButton.setSelection( + configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, + IGDBLaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT)); + if (fUseSolibForAppButton != null) + fUseSolibForAppButton.setSelection(configuration.getAttribute( + IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP, + IGDBLaunchConfigurationConstants.DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP_DEFAULT)); + initializeButtons(configuration); updateButtons(); - } - catch( CoreException e ) { + } catch (CoreException e) { } } - @Override - public void performApply( ILaunchConfigurationWorkingCopy configuration ) { - if ( fSolibSearchPathBlock != null ) - fSolibSearchPathBlock.performApply( configuration ); + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + if (fSolibSearchPathBlock != null) + fSolibSearchPathBlock.performApply(configuration); try { Map attrs = configuration.getAttributes(); - - if ( fAutoSoLibButton != null ) - attrs.put( IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, Boolean.valueOf( fAutoSoLibButton.getSelection() ) ); - if ( fUseSolibForAppButton != null ) - attrs.put( IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP, Boolean.valueOf( fUseSolibForAppButton.getSelection() ) ); - configuration.setAttributes( attrs ); - } - catch( CoreException e ) { + + if (fAutoSoLibButton != null) + attrs.put(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, + Boolean.valueOf(fAutoSoLibButton.getSelection())); + if (fUseSolibForAppButton != null) + attrs.put(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP, + Boolean.valueOf(fUseSolibForAppButton.getSelection())); + configuration.setAttributes(attrs); + } catch (CoreException e) { } } - @Override - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { - if ( fSolibSearchPathBlock != null ) - fSolibSearchPathBlock.setDefaults( configuration ); - configuration.setAttribute( IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, IGDBLaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT ); - configuration.setAttribute( IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP, IGDBLaunchConfigurationConstants.DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP_DEFAULT ); + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { + if (fSolibSearchPathBlock != null) + fSolibSearchPathBlock.setDefaults(configuration); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, + IGDBLaunchConfigurationConstants.DEBUGGER_AUTO_SOLIB_DEFAULT); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP, + IGDBLaunchConfigurationConstants.DEBUGGER_USE_SOLIB_SYMBOLS_FOR_APP_DEFAULT); } protected void updateButtons() { } - @Override + @Override public void dispose() { deleteObservers(); - if ( fSolibSearchPathBlock != null ) { - if ( fSolibSearchPathBlock instanceof Observable ) - ((Observable)fSolibSearchPathBlock).deleteObserver( this ); + if (fSolibSearchPathBlock != null) { + if (fSolibSearchPathBlock instanceof Observable) + ((Observable) fSolibSearchPathBlock).deleteObserver(this); fSolibSearchPathBlock.dispose(); } } - @Override - public void update( Observable o, Object arg ) { + @Override + public void update(Observable o, Object arg) { changed(); } @@ -157,25 +165,25 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC notifyObservers(); } - protected void initializeButtons( ILaunchConfiguration configuration ) { + protected void initializeButtons(ILaunchConfiguration configuration) { try { - boolean enable = !ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE.equals( configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, "" ) ); //$NON-NLS-1$ - if ( fAutoSoLibButton != null ) - fAutoSoLibButton.setEnabled( enable ); - if ( fUseSolibForAppButton != null ) - fUseSolibForAppButton.setEnabled( enable ); - } - catch( CoreException e ) { + boolean enable = !ICDTLaunchConfigurationConstants.DEBUGGER_MODE_CORE + .equals(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, "")); //$NON-NLS-1$ + if (fAutoSoLibButton != null) + fAutoSoLibButton.setEnabled(enable); + if (fUseSolibForAppButton != null) + fUseSolibForAppButton.setEnabled(enable); + } catch (CoreException e) { } } - @Override + @Override public Control getControl() { return fControl; } - @Override - public boolean isValid( ILaunchConfiguration launchConfig ) { + @Override + public boolean isValid(ILaunchConfiguration launchConfig) { // TODO Auto-generated method stub return false; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java index f7cee54548a..34fb813539f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java @@ -56,7 +56,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ private IMILaunchConfigurationComponent fSolibBlock; private boolean fIsInitializing = false; - @Override + @Override public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); @@ -68,7 +68,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ setControl(parent); } - @Override + @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore(); String defaultGdbCommand = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND); @@ -93,45 +93,44 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ return valid; } - @Override + @Override public void initializeFrom(ILaunchConfiguration configuration) { setInitializing(true); IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore(); String defaultGdbCommand = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND); String defaultGdbInit = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT); - + String gdbCommand = defaultGdbCommand; String gdbInit = defaultGdbInit; - + try { - gdbCommand = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, defaultGdbCommand); - } catch(CoreException e) { + gdbCommand = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, + defaultGdbCommand); + } catch (CoreException e) { } try { gdbInit = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, defaultGdbInit); - } catch(CoreException e) { + } catch (CoreException e) { } if (fSolibBlock != null) fSolibBlock.initializeFrom(configuration); fGDBCommandText.setText(gdbCommand); fGDBInitText.setText(gdbInit); - - setInitializing(false); + + setInitializing(false); } - @Override + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, - fGDBCommandText.getText().trim()); - configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, - fGDBInitText.getText().trim()); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, fGDBCommandText.getText().trim()); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, fGDBInitText.getText().trim()); if (fSolibBlock != null) fSolibBlock.performApply(configuration); } - @Override + @Override public String getName() { return LaunchUIMessages.getString("GDBDebuggerPage.tab_name"); //$NON-NLS-1$ } @@ -154,17 +153,17 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ /* * (non-Javadoc) - * + * * @see java.util.Observer#update(java.util.Observable, java.lang.Object) */ - @Override + @Override public void update(Observable o, Object arg) { if (!isInitializing()) updateLaunchConfigurationDialog(); } public IMILaunchConfigurationComponent createSolibBlock(Composite parent) { - IMILaunchConfigurationComponent block = new GDBSolibBlock( new SolibSearchPathBlock(), true, true); + IMILaunchConfigurationComponent block = new GDBSolibBlock(new SolibSearchPathBlock(), true, true); block.createControl(parent); return block; } @@ -178,11 +177,11 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ TabItem tabItem = new TabItem(tabFolder, SWT.NONE); tabItem.setText(LaunchUIMessages.getString("GDBDebuggerPage.main_tab_name")); //$NON-NLS-1$ Composite comp = ControlFactory.createCompositeEx(tabFolder, 1, GridData.FILL_BOTH); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; comp.setFont(tabFolder.getFont()); tabItem.setControl(comp); Composite subComp = ControlFactory.createCompositeEx(comp, 3, GridData.FILL_HORIZONTAL); - ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout) subComp.getLayout()).makeColumnsEqualWidth = false; subComp.setFont(tabFolder.getFont()); Label label = ControlFactory.createLabel(subComp, LaunchUIMessages.getString("GDBDebuggerPage.gdb_debugger")); //$NON-NLS-1$ GridData gd = new GridData(); @@ -190,7 +189,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ label.setLayoutData(gd); fGDBCommandText = ControlFactory.createTextField(subComp, SWT.SINGLE | SWT.BORDER); fGDBCommandText.addModifyListener(new ModifyListener() { - @Override + @Override public void modifyText(ModifyEvent evt) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -211,16 +210,16 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { String cmd = gdbCommand.substring(0, lastSeparatorIndex); - // remove double quotes, since they interfere with + // remove double quotes, since they interfere with // "setFilterPath()" below - cmd = cmd.replaceAll("\\\"", ""); //$NON-NLS-1$//$NON-NLS-2$ + cmd = cmd.replaceAll("\\\"", ""); //$NON-NLS-1$//$NON-NLS-2$ dialog.setFilterPath(cmd); } String res = dialog.open(); if (res == null) { return; } - // path contains space(s)? + // path contains space(s)? if (res.contains(" ")) { //$NON-NLS-1$ // surround it in double quotes res = '"' + res + '"'; @@ -236,7 +235,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ gd = new GridData(GridData.FILL_HORIZONTAL); fGDBInitText.setLayoutData(gd); fGDBInitText.addModifyListener(new ModifyListener() { - @Override + @Override public void modifyText(ModifyEvent evt) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -272,7 +271,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; gd.widthHint = 200; - label.setLayoutData(gd); + label.setLayoutData(gd); } public void createSolibTab(TabFolder tabFolder) { @@ -283,19 +282,19 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ tabItem.setControl(comp); fSolibBlock = createSolibBlock(comp); if (fSolibBlock instanceof Observable) - ((Observable)fSolibBlock).addObserver(this); + ((Observable) fSolibBlock).addObserver(this); } /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() */ @Override public void dispose() { if (fSolibBlock != null) { if (fSolibBlock instanceof Observable) - ((Observable)fSolibBlock).deleteObserver(this); + ((Observable) fSolibBlock).deleteObserver(this); fSolibBlock.dispose(); } super.dispose(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java index 8c480420152..b6ae17ac6c6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java @@ -56,19 +56,21 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { protected Text fGDBCommandText; protected Text fGDBInitText; protected Button fNonStopCheckBox; - + protected Button fReverseCheckBox; protected Combo fReverseDebugMode; - protected static final String HW_REVERSE_MODE = LaunchUIMessages.getString("GDBDebuggerPage.reverse_Debuggingmodehard"); //$NON-NLS-1$ - protected static final String SW_REVERSE_MODE = LaunchUIMessages.getString("GDBDebuggerPage.reverse_Debuggingmodesoft"); //$NON-NLS-1$ - + protected static final String HW_REVERSE_MODE = LaunchUIMessages + .getString("GDBDebuggerPage.reverse_Debuggingmodehard"); //$NON-NLS-1$ + protected static final String SW_REVERSE_MODE = LaunchUIMessages + .getString("GDBDebuggerPage.reverse_Debuggingmodesoft"); //$NON-NLS-1$ + protected Button fUpdateThreadlistOnSuspend; protected Button fDebugOnFork; /** * Checkbox for using GDB's new-console -- only displayed on Windows. Will be null if unsupported. */ private Button fExternalConsole; - + /** * A combo box to let the user choose if fast tracepoints should be used or not. */ @@ -80,7 +82,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { private IMILaunchConfigurationComponent fSolibBlock; private boolean fIsInitializing = false; - @Override + @Override public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); @@ -92,7 +94,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { setControl(parent); } - @Override + @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore(); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, @@ -113,7 +115,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { preferenceStore.getBoolean(IGdbDebugPreferenceConstants.PREF_EXTERNAL_CONSOLE)); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT); - + if (fSolibBlock != null) fSolibBlock.setDefaults(configuration); } @@ -139,6 +141,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { return defaultValue; } } + /** utility method to cut down on clutter */ private boolean getBooleanAttr(ILaunchConfiguration config, String attributeName, boolean defaultValue) { try { @@ -148,7 +151,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { } } - @Override + @Override public void initializeFrom(ILaunchConfiguration configuration) { setInitializing(true); IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore(); @@ -163,11 +166,14 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { updateReverseDebugModeFromConfig(configuration); - boolean updateThreadsOnSuspend = getBooleanAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND, + boolean updateThreadsOnSuspend = getBooleanAttr(configuration, + IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND, IGDBLaunchConfigurationConstants.DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND_DEFAULT); - boolean debugOnFork = getBooleanAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK, + boolean debugOnFork = getBooleanAttr(configuration, + IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK, IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_ON_FORK_DEFAULT); - boolean externalConsole = getBooleanAttr(configuration, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_EXTERNAL_CONSOLE, + boolean externalConsole = getBooleanAttr(configuration, + IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_EXTERNAL_CONSOLE, preferenceStore.getBoolean(IGdbDebugPreferenceConstants.PREF_EXTERNAL_CONSOLE)); if (fSolibBlock != null) @@ -181,16 +187,17 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { if (fExternalConsole != null) { fExternalConsole.setSelection(externalConsole); } - + updateTracepointModeFromConfig(configuration); - + setInitializing(false); } protected void updateTracepointModeFromConfig(ILaunchConfiguration config) { if (fTracepointModeCombo != null) { - String tracepointMode = getStringAttr(config, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT); + String tracepointMode = getStringAttr(config, + IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, + IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT); if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_NORMAL_ONLY)) { fTracepointModeCombo.setText(TP_NORMAL_ONLY); @@ -205,12 +212,12 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { // Bug 375256 // // assert false : "Unknown Tracepoint Mode: " + tracepointMode; //$NON-NLS-1$ - fTracepointModeCombo.setText(TP_NORMAL_ONLY); + fTracepointModeCombo.setText(TP_NORMAL_ONLY); } } } - protected void updateReverseDebugModeFromConfig(ILaunchConfiguration config){ + protected void updateReverseDebugModeFromConfig(ILaunchConfiguration config) { if (fReverseDebugMode != null) { String debugMode = getStringAttr(config, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE_MODE, IGDBLaunchConfigurationConstants.DEBUGGER_REVERSE_MODE_DEFAULT); @@ -253,40 +260,38 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { return IGDBLaunchConfigurationConstants.DEBUGGER_REVERSE_MODE_DEFAULT; } - @Override + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { - configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, - fGDBCommandText.getText().trim()); - configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, - fGDBInitText.getText().trim()); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, fGDBCommandText.getText().trim()); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, fGDBInitText.getText().trim()); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_NON_STOP, fNonStopCheckBox.getSelection()); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE, - fReverseCheckBox.getSelection()); + fReverseCheckBox.getSelection()); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_UPDATE_THREADLIST_ON_SUSPEND, - fUpdateThreadlistOnSuspend.getSelection()); + fUpdateThreadlistOnSuspend.getSelection()); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_DEBUG_ON_FORK, fDebugOnFork.getSelection()); if (fExternalConsole != null) { configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_EXTERNAL_CONSOLE, fExternalConsole.getSelection()); } - + if (fTracepointModeCombo != null) { configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, - getSelectedTracepointMode()); + getSelectedTracepointMode()); } if (fReverseDebugMode != null) { configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE_MODE, - getSelectedReverseDebugMode()); + getSelectedReverseDebugMode()); } if (fSolibBlock != null) fSolibBlock.performApply(configuration); } - @Override + @Override public String getName() { return LaunchUIMessages.getString("GDBDebuggerPage.tab_name"); //$NON-NLS-1$ } @@ -312,14 +317,14 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { * * @see java.util.Observer#update(java.util.Observable, java.lang.Object) */ - @Override + @Override public void update(Observable o, Object arg) { if (!isInitializing()) updateLaunchConfigurationDialog(); } public IMILaunchConfigurationComponent createSolibBlock(Composite parent) { - IMILaunchConfigurationComponent block = new GDBSolibBlock( new SolibSearchPathBlock(), true, true); + IMILaunchConfigurationComponent block = new GDBSolibBlock(new SolibSearchPathBlock(), true, true); block.createControl(parent); return block; } @@ -335,9 +340,9 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { Composite comp = ControlFactory.createCompositeEx(tabFolder, 1, GridData.FILL_BOTH); ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; tabItem.setControl(comp); - + createGdbContent(comp); - + ControlFactory.createLabel(comp, LaunchUIMessages.getString("GDBDebuggerPage.cmdfile_warning"), //$NON-NLS-1$ 200, SWT.DEFAULT, SWT.WRAP); @@ -347,15 +352,19 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { createReverseDebugModeCombo(comp); - fUpdateThreadlistOnSuspend = addCheckbox(comp, LaunchUIMessages.getString("GDBDebuggerPage.update_thread_list_on_suspend")); //$NON-NLS-1$ + fUpdateThreadlistOnSuspend = addCheckbox(comp, + LaunchUIMessages.getString("GDBDebuggerPage.update_thread_list_on_suspend")); //$NON-NLS-1$ // This checkbox needs an explanation. Attach context help to it. - PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpdateThreadlistOnSuspend, GdbUIPlugin.PLUGIN_ID + ".update_threadlist_button_context"); //$NON-NLS-1$ + PlatformUI.getWorkbench().getHelpSystem().setHelp(fUpdateThreadlistOnSuspend, + GdbUIPlugin.PLUGIN_ID + ".update_threadlist_button_context"); //$NON-NLS-1$ + + fDebugOnFork = addCheckbox(comp, + LaunchUIMessages.getString("GDBDebuggerPage.Automatically_debug_forked_processes")); //$NON-NLS-1$ + if (Platform.getOS().startsWith("win")) { //$NON-NLS-1$ + fExternalConsole = addCheckbox(comp, + LaunchUIMessages.getString("GDBDebuggerPage.use_new_console_for_process")); //$NON-NLS-1$ + } - fDebugOnFork = addCheckbox(comp, LaunchUIMessages.getString("GDBDebuggerPage.Automatically_debug_forked_processes")); //$NON-NLS-1$ - if (Platform.getOS().startsWith("win")) { //$NON-NLS-1$ - fExternalConsole = addCheckbox(comp, LaunchUIMessages.getString("GDBDebuggerPage.use_new_console_for_process")); //$NON-NLS-1$ - } - createTracepointModeCombo(comp); } @@ -367,7 +376,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { ControlFactory.createLabel(subComp, LaunchUIMessages.getString("GDBDebuggerPage.gdb_debugger")); //$NON-NLS-1$ fGDBCommandText = ControlFactory.createTextField(subComp, SWT.SINGLE | SWT.BORDER); fGDBCommandText.addModifyListener(new ModifyListener() { - @Override + @Override public void modifyText(ModifyEvent evt) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -388,16 +397,16 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { int lastSeparatorIndex = gdbCommand.lastIndexOf(File.separator); if (lastSeparatorIndex != -1) { String cmd = gdbCommand.substring(0, lastSeparatorIndex); - // remove double quotes, since they interfere with + // remove double quotes, since they interfere with // "setFilterPath()" below - cmd = cmd.replaceAll("\\\"", ""); //$NON-NLS-1$//$NON-NLS-2$ + cmd = cmd.replaceAll("\\\"", ""); //$NON-NLS-1$//$NON-NLS-2$ dialog.setFilterPath(cmd); } String res = dialog.open(); if (res == null) { return; } - // path contains space(s)? + // path contains space(s)? if (res.contains(" ")) { //$NON-NLS-1$ // surround it in double quotes res = '"' + res + '"'; @@ -405,11 +414,11 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { fGDBCommandText.setText(res); } }); - + ControlFactory.createLabel(subComp, LaunchUIMessages.getString("GDBDebuggerPage.gdb_command_file")); //$NON-NLS-1$ fGDBInitText = ControlFactory.createTextField(subComp, SWT.SINGLE | SWT.BORDER); fGDBInitText.addModifyListener(new ModifyListener() { - @Override + @Override public void modifyText(ModifyEvent evt) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -455,7 +464,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { fTracepointModeCombo.add(TP_AUTOMATIC); fTracepointModeCombo.addSelectionListener(new SelectionAdapter() { - @Override + @Override public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); } @@ -474,11 +483,11 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { fReverseCheckBox = addCheckbox(subComp, LaunchUIMessages.getString("GDBDebuggerPage.reverse_Debugging")); //$NON-NLS-1$ - fReverseDebugMode = new Combo(subComp, SWT.READ_ONLY | SWT.DROP_DOWN ); + fReverseDebugMode = new Combo(subComp, SWT.READ_ONLY | SWT.DROP_DOWN); fReverseDebugMode.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); fReverseDebugMode.add(HW_REVERSE_MODE); fReverseDebugMode.add(SW_REVERSE_MODE); - + fReverseDebugMode.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -502,7 +511,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { /** Used to add a checkbox to the tab. Each checkbox has its own line. */ private Button addCheckbox(Composite parent, String label) { Button button = ControlFactory.createCheckBox(parent, label); - button .addSelectionListener(new SelectionAdapter() { + button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbServerDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbServerDebuggerPage.java index a9cb610432e..05c6e415fab 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbServerDebuggerPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbServerDebuggerPage.java @@ -51,7 +51,7 @@ public class GdbServerDebuggerPage extends GdbDebuggerPage { protected StringDialogField fRemoteTimeoutValueField; - private String[] fConnections = new String[]{ CONNECTION_TCP, CONNECTION_SERIAL }; + private String[] fConnections = new String[] { CONNECTION_TCP, CONNECTION_SERIAL }; private TCPSettingsBlock fTCPBlock; @@ -75,28 +75,33 @@ public class GdbServerDebuggerPage extends GdbDebuggerPage { TabItem tabItem = new TabItem(tabFolder, SWT.NONE); tabItem.setText(LaunchUIMessages.getString("GDBServerDebuggerPage.10")); //$NON-NLS-1$ Composite comp1 = ControlFactory.createCompositeEx(tabFolder, 1, GridData.FILL_BOTH); - ((GridLayout)comp1.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout) comp1.getLayout()).makeColumnsEqualWidth = false; comp1.setFont(tabFolder.getFont()); tabItem.setControl(comp1); Composite comp = ControlFactory.createCompositeEx(comp1, 3, GridData.FILL_BOTH); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; comp.setFont(comp1.getFont()); fConnectionField.doFillIntoGrid(comp, 3); - ((GridData)fConnectionField.getComboControl(null).getLayoutData()).horizontalAlignment = GridData.BEGINNING; + ((GridData) fConnectionField.getComboControl(null).getLayoutData()).horizontalAlignment = GridData.BEGINNING; fRemoteTimeoutEnabledField.doFillIntoGrid(comp, 1); - fRemoteTimeoutEnabledField.getSelectionButton(comp).setToolTipText(LaunchUIMessages.getString("GDBServerDebuggerPage.12")); //$NON-NLS-1$ + fRemoteTimeoutEnabledField.getSelectionButton(comp) + .setToolTipText(LaunchUIMessages.getString("GDBServerDebuggerPage.12")); //$NON-NLS-1$ fRemoteTimeoutValueField.doFillIntoGrid(comp, 2); - ((GridData)fRemoteTimeoutValueField.getTextControl(null).getLayoutData()).horizontalAlignment = GridData.BEGINNING; + ((GridData) fRemoteTimeoutValueField.getTextControl(null) + .getLayoutData()).horizontalAlignment = GridData.BEGINNING; PixelConverter converter = new PixelConverter(comp); - LayoutUtil.setWidthHint(fRemoteTimeoutValueField.getTextControl(null), converter.convertWidthInCharsToPixels(10)); - fRemoteTimeoutValueField.getLabelControl(comp).setToolTipText(LaunchUIMessages.getString("GDBServerDebuggerPage.12")); //$NON-NLS-1$ - fRemoteTimeoutValueField.getTextControl(comp).setToolTipText(LaunchUIMessages.getString("GDBServerDebuggerPage.12")); //$NON-NLS-1$ + LayoutUtil.setWidthHint(fRemoteTimeoutValueField.getTextControl(null), + converter.convertWidthInCharsToPixels(10)); + fRemoteTimeoutValueField.getLabelControl(comp) + .setToolTipText(LaunchUIMessages.getString("GDBServerDebuggerPage.12")); //$NON-NLS-1$ + fRemoteTimeoutValueField.getTextControl(comp) + .setToolTipText(LaunchUIMessages.getString("GDBServerDebuggerPage.12")); //$NON-NLS-1$ fConnectionStack = ControlFactory.createCompositeEx(comp, 1, GridData.FILL_BOTH); StackLayout stackLayout = new StackLayout(); fConnectionStack.setLayout(stackLayout); - ((GridData)fConnectionStack.getLayoutData()).horizontalSpan = 3; + ((GridData) fConnectionStack.getLayoutData()).horizontalSpan = 3; fTCPBlock.createBlock(fConnectionStack); - fSerialBlock.createBlock(fConnectionStack); + fSerialBlock.createBlock(fConnectionStack); } private ComboDialogField createConnectionField() { @@ -133,7 +138,7 @@ public class GdbServerDebuggerPage extends GdbDebuggerPage { } }); fRemoteTimeoutEnabledField.attachDialogField(fRemoteTimeoutValueField); - } + } protected void connectionTypeChanged() { connectionTypeChanged0(); @@ -141,14 +146,14 @@ public class GdbServerDebuggerPage extends GdbDebuggerPage { } private void connectionTypeChanged0() { - ((StackLayout)fConnectionStack.getLayout()).topControl = null; + ((StackLayout) fConnectionStack.getLayout()).topControl = null; int index = fConnectionField.getSelectionIndex(); if (index >= 0 && index < fConnections.length) { String[] connTypes = fConnectionField.getItems(); if (CONNECTION_TCP.equals(connTypes[index])) - ((StackLayout)fConnectionStack.getLayout()).topControl = fTCPBlock.getControl(); + ((StackLayout) fConnectionStack.getLayout()).topControl = fTCPBlock.getControl(); else if (CONNECTION_SERIAL.equals(connTypes[index])) - ((StackLayout)fConnectionStack.getLayout()).topControl = fSerialBlock.getControl(); + ((StackLayout) fConnectionStack.getLayout()).topControl = fSerialBlock.getControl(); } fConnectionStack.layout(); } @@ -166,8 +171,7 @@ public class GdbServerDebuggerPage extends GdbDebuggerPage { setErrorMessage(fTCPBlock.getErrorMessage()); return false; } - } - else if (CONNECTION_SERIAL.equals(connTypes[index])) { + } else if (CONNECTION_SERIAL.equals(connTypes[index])) { if (!fSerialBlock.isValid(launchConfig)) { setErrorMessage(fSerialBlock.getErrorMessage()); return false; @@ -194,8 +198,7 @@ public class GdbServerDebuggerPage extends GdbDebuggerPage { boolean isTcp = true; try { isTcp = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, true); - } - catch(CoreException e) { + } catch (CoreException e) { } fTCPBlock.initializeFrom(configuration); fSerialBlock.initializeFrom(configuration); @@ -223,13 +226,16 @@ public class GdbServerDebuggerPage extends GdbDebuggerPage { public void performApply(ILaunchConfigurationWorkingCopy configuration) { super.performApply(configuration); if (fConnectionField != null) - configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, fConnectionField.getSelectionIndex() == 0); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, + fConnectionField.getSelectionIndex() == 0); fTCPBlock.performApply(configuration); fSerialBlock.performApply(configuration); if (fRemoteTimeoutEnabledField != null) - configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_TIMEOUT_ENABLED, fRemoteTimeoutEnabledField.isSelected()); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_TIMEOUT_ENABLED, + fRemoteTimeoutEnabledField.isSelected()); if (fRemoteTimeoutValueField != null) - configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_TIMEOUT_VALUE, fRemoteTimeoutValueField.getText().trim()); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_TIMEOUT_VALUE, + fRemoteTimeoutValueField.getText().trim()); } @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ICDTLaunchHelpContextIds.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ICDTLaunchHelpContextIds.java index 2d410219065..3c7da303a85 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ICDTLaunchHelpContextIds.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ICDTLaunchHelpContextIds.java @@ -20,10 +20,14 @@ public interface ICDTLaunchHelpContextIds { public static final String PREFIX = GdbUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$ // Launch configuration dialog pages - public static final String LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB = PREFIX + "launch_configuration_dialog_main_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB = PREFIX + "launch_configuration_dialog_arguments_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB = PREFIX + "launch_configuration_dialog_environment_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB = PREFIX + "launch_configuration_dialog_debugger_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_SOURCELOOKUP_TAB = PREFIX + "launch_configuration_dialog_source_tab"; //$NON-NLS-1$ + public static final String LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB = PREFIX + "launch_configuration_dialog_main_tab"; //$NON-NLS-1$ + public static final String LAUNCH_CONFIGURATION_DIALOG_ARGUMNETS_TAB = PREFIX + + "launch_configuration_dialog_arguments_tab"; //$NON-NLS-1$ + public static final String LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB = PREFIX + + "launch_configuration_dialog_environment_tab"; //$NON-NLS-1$ + public static final String LAUNCH_CONFIGURATION_DIALOG_DEBBUGER_TAB = PREFIX + + "launch_configuration_dialog_debugger_tab"; //$NON-NLS-1$ + public static final String LAUNCH_CONFIGURATION_DIALOG_SOURCELOOKUP_TAB = PREFIX + + "launch_configuration_dialog_source_tab"; //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/IMILaunchConfigurationComponent.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/IMILaunchConfigurationComponent.java index 917dd2f44ed..7b2e248906a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/IMILaunchConfigurationComponent.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/IMILaunchConfigurationComponent.java @@ -28,56 +28,56 @@ public interface IMILaunchConfigurationComponent { * <p> * Implementors are responsible for ensuring that the created control can be accessed via <code>getControl</code> * </p> - * + * * @param parent the parent composite */ - public void createControl( Composite parent ); + public void createControl(Composite parent); /** * Returns the top level control for this component. * <p> * May return <code>null</code> if the control has not been created yet. * </p> - * + * * @return the top level control or <code>null</code> */ public Control getControl(); /** - * Initializes the given component with default values. + * Initializes the given component with default values. * This method may be called before this tab's control is created. - * + * * @param configuration launch configuration */ - public void setDefaults( ILaunchConfigurationWorkingCopy configuration ); + public void setDefaults(ILaunchConfigurationWorkingCopy configuration); /** - * Initializes this component's controls with values from the given + * Initializes this component's controls with values from the given * launch configuration. - * + * * @param configuration launch configuration */ - public void initializeFrom( ILaunchConfiguration configuration ); + public void initializeFrom(ILaunchConfiguration configuration); /** - * Notifies this component that it has been disposed. - * Marks the end of this component's lifecycle, allowing + * Notifies this component that it has been disposed. + * Marks the end of this component's lifecycle, allowing * to perform any cleanup required. */ public void dispose(); /** * Copies values from this component into the given launch configuration. - * + * * @param configuration launch configuration */ - public void performApply( ILaunchConfigurationWorkingCopy configuration ); + public void performApply(ILaunchConfigurationWorkingCopy configuration); /** - * Returns whether this component is in a valid state in the context + * Returns whether this component is in a valid state in the context * of the specified launch configuration. * - * @param launchConfig launch configuration which provides context + * @param launchConfig launch configuration which provides context * for validating this component. * This value must not be <code>null</code>. * diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchImages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchImages.java index f1448ce76c3..3102a08e011 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchImages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchImages.java @@ -24,17 +24,17 @@ import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; public class LaunchImages { - private static final String NAME_PREFIX= GdbUIPlugin.PLUGIN_ID + '.'; - private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length(); - + private static final String NAME_PREFIX = GdbUIPlugin.PLUGIN_ID + '.'; + private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length(); + // The plugin registry private static ImageRegistry imageRegistry = new ImageRegistry(); // Subdirectory (under the package containing this class) where 16 color images are private static URL fgIconBaseURL; static { - fgIconBaseURL= Platform.getBundle(GdbUIPlugin.PLUGIN_ID).getEntry("/icons/"); //$NON-NLS-1$ - } + fgIconBaseURL = Platform.getBundle(GdbUIPlugin.PLUGIN_ID).getEntry("/icons/"); //$NON-NLS-1$ + } private static final String T_TABS = "full/view16/"; //$NON-NLS-1$ private static final String T_OBJS = "full/obj16/"; //$NON-NLS-1$ @@ -43,33 +43,33 @@ public class LaunchImages { public static String IMG_VIEW_ARGUMENTS_TAB = NAME_PREFIX + "arguments_tab.gif"; //$NON-NLS-1$ public static String IMG_VIEW_DEBUGGER_TAB = NAME_PREFIX + "debugger_tab.gif"; //$NON-NLS-1$ - public static final ImageDescriptor DESC_TAB_MAIN= createManaged(T_TABS, IMG_VIEW_MAIN_TAB); + public static final ImageDescriptor DESC_TAB_MAIN = createManaged(T_TABS, IMG_VIEW_MAIN_TAB); public static final ImageDescriptor DESC_TAB_ARGUMENTS = createManaged(T_TABS, IMG_VIEW_ARGUMENTS_TAB); public static final ImageDescriptor DESC_TAB_DEBUGGER = createManaged(T_TABS, IMG_VIEW_DEBUGGER_TAB); - public static String IMG_OBJS_EXEC= NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$ + public static String IMG_OBJS_EXEC = NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$ public static final ImageDescriptor DESC_OBJS_EXEC = createManaged(T_OBJS, IMG_OBJS_EXEC); public static void initialize() { } - + private static ImageDescriptor createManaged(String prefix, String name) { return createManaged(imageRegistry, prefix, name); } - + private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) { - ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); + ImageDescriptor result = ImageDescriptor + .createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH))); registry.put(name, result); return result; } - + public static Image get(String key) { return imageRegistry.get(key); } - private static URL makeIconFileURL(String prefix, String name) { - StringBuilder buffer= new StringBuilder(prefix); + StringBuilder buffer = new StringBuilder(prefix); buffer.append(name); try { return new URL(fgIconBaseURL, buffer.toString()); @@ -78,7 +78,7 @@ public class LaunchImages { return null; } } - + /** * Helper method to access the image registry from the JavaPlugin class. */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.java index a2ed94adfe9..da7d91e0d97 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.java @@ -25,25 +25,26 @@ public class LaunchUIMessages { private static ResourceBundle RESOURCE_BUNDLE = null; static { - try { - RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - } - catch (MissingResourceException x) { - } + try { + RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + } catch (MissingResourceException x) { + } } - private LaunchUIMessages() {} + private LaunchUIMessages() { + } public static String getFormattedString(String key, String arg) { - return MessageFormat.format(getString(key), new Object[]{arg}); + return MessageFormat.format(getString(key), new Object[] { arg }); } public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getString(key), (Object[])args); + return MessageFormat.format(getString(key), (Object[]) args); } public static String getString(String key) { - if (RESOURCE_BUNDLE == null) return '!' + key + '!'; + if (RESOURCE_BUNDLE == null) + return '!' + key + '!'; return RESOURCE_BUNDLE.getString(key); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LocalApplicationCDebuggerTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LocalApplicationCDebuggerTab.java index 15553c79bb6..6a02c7804bd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LocalApplicationCDebuggerTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LocalApplicationCDebuggerTab.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -20,7 +20,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; /** * Debugger tab to use for a local application launch configuration. - * + * * @since 2.0 */ public class LocalApplicationCDebuggerTab extends CDebuggerTab { @@ -38,30 +38,30 @@ public class LocalApplicationCDebuggerTab extends CDebuggerTab { * Bug 281970 */ private final static String DEFAULTS_SET = "org.eclipse.cdt.dsf.gdb.internal.ui.launching.LocalApplicationCDebuggerTab.DEFAULTS_SET"; //$NON-NLS-1$ - - public LocalApplicationCDebuggerTab() { - super(SessionType.LOCAL, false); - } - - @Override - public void setDefaults(ILaunchConfigurationWorkingCopy config) { + + public LocalApplicationCDebuggerTab() { + super(SessionType.LOCAL, false); + } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy config) { config.setAttribute(DEFAULTS_SET, true); - - super.setDefaults(config); - } - - @Override - public void initializeFrom(ILaunchConfiguration config) { - try { - if (config.hasAttribute(DEFAULTS_SET) == false) { - ILaunchConfigurationWorkingCopy wc; - wc = config.getWorkingCopy(); - setDefaults(wc); - wc.doSave(); - } - } catch (CoreException e) { - } + + super.setDefaults(config); + } + + @Override + public void initializeFrom(ILaunchConfiguration config) { + try { + if (config.hasAttribute(DEFAULTS_SET) == false) { + ILaunchConfigurationWorkingCopy wc; + wc = config.getWorkingCopy(); + setDefaults(wc); + wc.doSave(); + } + } catch (CoreException e) { + } super.initializeFrom(config); - } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableDialog.java index ba0d999cc8f..aece4365ef5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableDialog.java @@ -44,7 +44,7 @@ import org.eclipse.swt.widgets.Text; public class NewExecutableDialog extends TitleAreaDialog { private NewExecutableInfo fInfo = null; - + private Text fHostBinaryText; private Text fTargetBinaryText; private Text fArgumentsText; @@ -52,82 +52,82 @@ public class NewExecutableDialog extends TitleAreaDialog { private Button fStopInMain; private Text fStopInMainSymbol; - public NewExecutableDialog( Shell parentShell, NewExecutableInfo info ) { - super( parentShell ); + public NewExecutableDialog(Shell parentShell, NewExecutableInfo info) { + super(parentShell); assert info != null; - setShellStyle( getShellStyle() | SWT.RESIZE ); + setShellStyle(getShellStyle() | SWT.RESIZE); fInfo = info; } @Override - protected Control createContents( Composite parent ) { - Control control = super.createContents( parent ); + protected Control createContents(Composite parent) { + Control control = super.createContents(parent); initialize(); validate(); return control; } @Override - protected Control createDialogArea( Composite parent ) { + protected Control createDialogArea(Composite parent) { boolean remote = fInfo.getSessionType() == SessionType.REMOTE; - getShell().setText( Messages.GdbDebugNewExecutableCommand_Debug_New_Executable ); - setTitle( Messages.GdbDebugNewExecutableCommand_Select_Binary ); - String message = ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target : - Messages.GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments; - setMessage( message ); - - Composite control = (Composite)super.createDialogArea( parent ); - Composite comp = new Composite( control, SWT.NONE ); - GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); - GridLayout layout = new GridLayout( 3, false ); - comp.setLayout( layout ); - comp.setLayoutData( gd ); - - new Label( comp, SWT.None ).setText( remote ? Messages.GdbDebugNewExecutableCommand_Binary_on_host : Messages.GdbDebugNewExecutableCommand_Binary ); - fHostBinaryText = new Text( comp, SWT.BORDER ); - fHostBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) ); - fHostBinaryText.addModifyListener( new ModifyListener() { - + getShell().setText(Messages.GdbDebugNewExecutableCommand_Debug_New_Executable); + setTitle(Messages.GdbDebugNewExecutableCommand_Select_Binary); + String message = (remote) ? Messages.GdbDebugNewExecutableCommand_Select_binaries_on_host_and_target + : Messages.GdbDebugNewExecutableCommand_Select_binary_and_specify_arguments; + setMessage(message); + + Composite control = (Composite) super.createDialogArea(parent); + Composite comp = new Composite(control, SWT.NONE); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + GridLayout layout = new GridLayout(3, false); + comp.setLayout(layout); + comp.setLayoutData(gd); + + new Label(comp, SWT.None).setText(remote ? Messages.GdbDebugNewExecutableCommand_Binary_on_host + : Messages.GdbDebugNewExecutableCommand_Binary); + fHostBinaryText = new Text(comp, SWT.BORDER); + fHostBinaryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + fHostBinaryText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); - Button browseButton = new Button( comp, SWT.PUSH ); - browseButton.setText( Messages.GdbDebugNewExecutableCommand_Browse ); - browseButton.setFont( JFaceResources.getDialogFont() ); - setButtonLayoutData( browseButton ); - browseButton.addSelectionListener( new SelectionAdapter() { + }); + Button browseButton = new Button(comp, SWT.PUSH); + browseButton.setText(Messages.GdbDebugNewExecutableCommand_Browse); + browseButton.setFont(JFaceResources.getDialogFont()); + setButtonLayoutData(browseButton); + browseButton.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { - FileDialog dialog = new FileDialog( getShell() ); - dialog.setFileName( fHostBinaryText.getText() ); + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getShell()); + dialog.setFileName(fHostBinaryText.getText()); String result = dialog.open(); - if ( result != null ) { - fHostBinaryText.setText( result ); + if (result != null) { + fHostBinaryText.setText(result); } } - } ); - - if ( remote ) { - new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Binary_on_target ); - fTargetBinaryText = new Text( comp, SWT.BORDER ); - fTargetBinaryText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); - fTargetBinaryText.addModifyListener( new ModifyListener() { - + }); + + if (remote) { + new Label(comp, SWT.None).setText(Messages.GdbDebugNewExecutableCommand_Binary_on_target); + fTargetBinaryText = new Text(comp, SWT.BORDER); + fTargetBinaryText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + fTargetBinaryText.addModifyListener(new ModifyListener() { + @Override - public void modifyText( ModifyEvent e ) { + public void modifyText(ModifyEvent e) { validate(); } - } ); + }); } - new Label( comp, SWT.None ).setText( Messages.GdbDebugNewExecutableCommand_Arguments ); - fArgumentsText = new Text( comp, SWT.BORDER ); - fArgumentsText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, 2, 1 ) ); + new Label(comp, SWT.None).setText(Messages.GdbDebugNewExecutableCommand_Arguments); + fArgumentsText = new Text(comp, SWT.BORDER); + fArgumentsText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); createOptionsArea(comp); @@ -160,15 +160,13 @@ public class NewExecutableDialog extends TitleAreaDialog { validate(); } }); - fStopInMainSymbol.getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = LaunchMessages.getString("CDebuggerTab.Stop_at_main_on_startup"); //$NON-NLS-1$ - } + fStopInMainSymbol.getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = LaunchMessages.getString("CDebuggerTab.Stop_at_main_on_startup"); //$NON-NLS-1$ } - ); - + }); + } @Override @@ -190,8 +188,10 @@ public class NewExecutableDialog extends TitleAreaDialog { } fArgumentsText.setText(fInfo.getArguments()); if (fStopInMain != null && fStopInMainSymbol != null) { - fStopInMain.setSelection((Boolean)fInfo.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN)); - fStopInMainSymbol.setText((String)fInfo.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL)); + fStopInMain.setSelection( + (Boolean) fInfo.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN)); + fStopInMainSymbol.setText( + (String) fInfo.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL)); } } @@ -199,30 +199,25 @@ public class NewExecutableDialog extends TitleAreaDialog { boolean remote = fInfo.getSessionType() == SessionType.REMOTE; StringBuilder sb = new StringBuilder(); String hostBinary = fHostBinaryText.getText().trim(); - if ( hostBinary.isEmpty() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Host_binary_must_be_specified : - Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified ); - } - else { - File file = new File( hostBinary ); - if ( !file.exists() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist : - Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist ); - } - else if ( file.isDirectory() ) { - sb.append( ( remote ) ? - Messages.GdbDebugNewExecutableCommand_Invalid_host_binary : - Messages.GdbDebugNewExecutableCommand_Invalid_binary ); + if (hostBinary.isEmpty()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Host_binary_must_be_specified + : Messages.GdbDebugNewExecutableCommand_Binary_must_be_specified); + } else { + File file = new File(hostBinary); + if (!file.exists()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Host_binary_file_does_not_exist + : Messages.GdbDebugNewExecutableCommand_Binary_file_does_not_exist); + } else if (file.isDirectory()) { + sb.append((remote) ? Messages.GdbDebugNewExecutableCommand_Invalid_host_binary + : Messages.GdbDebugNewExecutableCommand_Invalid_binary); } } - if ( fTargetBinaryText != null ) { - if ( fTargetBinaryText.getText().trim().length() == 0 ) { - if ( sb.length() != 0 ) { - sb.append( "\n " ); //$NON-NLS-1$ + if (fTargetBinaryText != null) { + if (fTargetBinaryText.getText().trim().length() == 0) { + if (sb.length() != 0) { + sb.append("\n "); //$NON-NLS-1$ } - sb.append( Messages.GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified ); + sb.append(Messages.GdbDebugNewExecutableCommand_Binary_on_target_must_be_specified); } } if (fStopInMain != null && fStopInMainSymbol != null) { @@ -236,14 +231,16 @@ public class NewExecutableDialog extends TitleAreaDialog { } } - setErrorMessage( ( sb.length() != 0 ) ? sb.toString() : null ); - getButton( IDialogConstants.OK_ID ).setEnabled( getErrorMessage() == null ); + setErrorMessage((sb.length() != 0) ? sb.toString() : null); + getButton(IDialogConstants.OK_ID).setEnabled(getErrorMessage() == null); } - + protected void saveOptions() { if (fStopInMain != null && fStopInMainSymbol != null) { - fInfo.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, Boolean.valueOf(fStopInMain.getSelection())); - fInfo.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, fStopInMainSymbol.getText().trim()); + fInfo.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, + Boolean.valueOf(fStopInMain.getSelection())); + fInfo.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, + fStopInMainSymbol.getText().trim()); } } }
\ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableInfo.java index f8b77f37299..cc5ae917434 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/NewExecutableInfo.java @@ -25,30 +25,30 @@ import org.eclipse.cdt.dsf.gdb.service.SessionType; import org.eclipse.jface.preference.IPreferenceStore; /** - * This class provides information required to start - * debugging an executable. + * This class provides information required to start + * debugging an executable. */ public class NewExecutableInfo { - + public static final String ATTR_SESSION_TYPE = "sessionType"; //$NON-NLS-1$ - final private SessionType fSessionType; + final private SessionType fSessionType; private String fHostPath = ""; //$NON-NLS-1$ private Map<String, Object> fAttributes = new HashMap<String, Object>(); - public NewExecutableInfo(SessionType sessionType) { + public NewExecutableInfo(SessionType sessionType) { super(); fSessionType = sessionType; setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY, ""); //$NON-NLS-1$ setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$ IPreferenceStore preferences = GdbUIPlugin.getDefault().getPreferenceStore(); setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, - preferences.getBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN)); + preferences.getBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN)); setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, - preferences.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL)); + preferences.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL)); } - + /** * Returns the path of the executable on the host */ @@ -64,20 +64,20 @@ public class NewExecutableInfo { } /** - * For remote sessions returns the path of the executable + * For remote sessions returns the path of the executable * on the target. Otherwise returns null. */ public String getTargetPath() { - return (String)fAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY); + return (String) fAttributes.get(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REMOTE_BINARY); } - + /** * Returns the arguments to pass to the executable, or null */ public String getArguments() { - return (String)fAttributes.get(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS); + return (String) fAttributes.get(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS); } - + /** * Returns the attribute map */ @@ -95,7 +95,7 @@ public class NewExecutableInfo { public Object getAttribute(String name) { return fAttributes.get(name); } - + public void setAttribute(String name, Object value) { fAttributes.put(name, value); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java index 01a7a2d3b21..770db858d63 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java @@ -43,14 +43,14 @@ public class ProcessPrompter implements IStatusHandler { public static class PrompterInfo { public IProcessExtendedInfo[] processList; public List<String> debuggedProcesses; - + public PrompterInfo(IProcessExtendedInfo[] list, List<String> debuggedProcs) { processList = list; debuggedProcesses = debuggedProcs; } } - - @Override + + @Override public Object handleStatus(IStatus status, Object info) throws CoreException { Shell shell = GdbUIPlugin.getShell(); if (shell == null) { @@ -61,20 +61,19 @@ public class ProcessPrompter implements IStatusHandler { } final PrompterInfo prompterInfo = (PrompterInfo) info; - IProcessExtendedInfo[] plist = prompterInfo.processList; + IProcessExtendedInfo[] plist = prompterInfo.processList; if (plist == null) { - MessageDialog.openError( - shell, - LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), LaunchMessages.getString("LocalAttachLaunchDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ //$NON-NLS-2$ + MessageDialog.openError(shell, LaunchMessages.getString("LocalAttachLaunchDelegate.CDT_Launch_Error"), //$NON-NLS-1$ + LaunchMessages.getString("LocalAttachLaunchDelegate.Platform_cannot_list_processes")); //$NON-NLS-1$ return null; } - + if (plist.length == 0) { // No list available, just let the user put in a pid directly - InputDialog dialog = new InputDialog(shell, - LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process"), //$NON-NLS-1$ - LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to"), //$NON-NLS-1$ - null, null); + InputDialog dialog = new InputDialog(shell, + LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process"), //$NON-NLS-1$ + LaunchMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to"), //$NON-NLS-1$ + null, null); if (dialog.open() == Window.OK) { String pidStr = dialog.getValue(); @@ -87,7 +86,7 @@ public class ProcessPrompter implements IStatusHandler { ILabelProvider provider = new LabelProvider() { @Override public String getText(Object element) { - IProcessExtendedInfo info = (IProcessExtendedInfo)element; + IProcessExtendedInfo info = (IProcessExtendedInfo) element; // Sometimes, if we are not getting the list of processes from GDB, // we use CCorePlugin.getDefault().getProcessList(); which returns // the process and its arguments. If the arguments contain a / @@ -99,44 +98,44 @@ public class ProcessPrompter implements IStatusHandler { // Bug 374823 return null; } - + name = name.split("\\s", 2)[0]; //$NON-NLS-1$ - - // on windows host, paths of style "sendmail:", "udisk-daemon:" - // would be treated as device id with no path segments + + // on windows host, paths of style "sendmail:", "udisk-daemon:" + // would be treated as device id with no path segments IPath path = new Path(name); StringBuilder text = new StringBuilder(); - if (path.lastSegment() == null ) { + if (path.lastSegment() == null) { text.append(name); } else { text.append(path.lastSegment()); } - + String owner = info.getOwner(); if (owner != null && !owner.isEmpty()) { - text.append(" (").append(owner).append(")"); //$NON-NLS-1$//$NON-NLS-2$ + text.append(" (").append(owner).append(")"); //$NON-NLS-1$//$NON-NLS-2$ } - + text.append(" - ").append(info.getPid()); //$NON-NLS-1$ String[] cores = info.getCores(); if (cores != null && cores.length > 0) { String coreStr; if (cores.length == 1) { - coreStr = LaunchUIMessages.getString("ProcessPrompter.Core"); //$NON-NLS-1$ + coreStr = LaunchUIMessages.getString("ProcessPrompter.Core"); //$NON-NLS-1$ } else { - coreStr = LaunchUIMessages.getString("ProcessPrompter.Cores"); //$NON-NLS-1$ + coreStr = LaunchUIMessages.getString("ProcessPrompter.Cores"); //$NON-NLS-1$ } - text.append(" [").append(coreStr).append(": "); //$NON-NLS-1$//$NON-NLS-2$ - + text.append(" [").append(coreStr).append(": "); //$NON-NLS-1$//$NON-NLS-2$ + for (String core : cores) { text.append(core).append(", "); //$NON-NLS-1$ } // Remove the last comma and space - text.replace(text.length()-2, text.length(), "]"); //$NON-NLS-1$ + text.replace(text.length() - 2, text.length(), "]"); //$NON-NLS-1$ } - - String description = info.getDescription(); + + String description = info.getDescription(); if (description != null) { text.append(" : " + description); //$NON-NLS-1$ } @@ -152,8 +151,8 @@ public class ProcessPrompter implements IStatusHandler { ILabelProvider qprovider = new LabelProvider() { @Override public String getText(Object element) { - IProcessExtendedInfo info = (IProcessExtendedInfo)element; - String description = info.getDescription(); + IProcessExtendedInfo info = (IProcessExtendedInfo) element; + String description = info.getDescription(); if (description != null) { return description; } @@ -167,23 +166,23 @@ public class ProcessPrompter implements IStatusHandler { }; // Display the list of processes and have the user choose - ProcessPrompterDialog dialog = - new ProcessPrompterDialog(shell, provider, qprovider); + ProcessPrompterDialog dialog = new ProcessPrompterDialog(shell, provider, qprovider); dialog.setTitle(LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process")); //$NON-NLS-1$ - dialog.setMessage(LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$ + dialog.setMessage( + LaunchUIMessages.getString("LocalAttachLaunchDelegate.Select_Process_to_attach_debugger_to")); //$NON-NLS-1$ // Allow for multiple selection dialog.setMultipleSelection(true); dialog.setStatusLineAboveButtons(true); - + dialog.setValidator(new ISelectionStatusValidator() { @Override public IStatus validate(Object[] selection) { for (Object sel : selection) { - String pid = Integer.toString(((IProcessExtendedInfo)sel).getPid(), 10); + String pid = Integer.toString(((IProcessExtendedInfo) sel).getPid(), 10); if (prompterInfo.debuggedProcesses.contains(pid)) { - return new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(), - MessageFormat.format(LaunchUIMessages.getString("ProcessPrompter.ErrProcessConected"), pid)); //$NON-NLS-1$ + return new Status(IStatus.ERROR, GdbUIPlugin.getUniqueIdentifier(), MessageFormat + .format(LaunchUIMessages.getString("ProcessPrompter.ErrProcessConected"), pid)); //$NON-NLS-1$ } } return new Status(IStatus.OK, GdbUIPlugin.getUniqueIdentifier(), ""); //$NON-NLS-1$ @@ -194,14 +193,14 @@ public class ProcessPrompter implements IStatusHandler { Object[] results = dialog.getResult(); if (results != null) { IProcessExtendedInfo[] processes = new IProcessExtendedInfo[results.length]; - for (int i=0; i<processes.length; i++) { - processes[i] = (IProcessExtendedInfo)results[i]; + for (int i = 0; i < processes.length; i++) { + processes[i] = (IProcessExtendedInfo) results[i]; } return processes; } } } - + return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java index a11e22f424f..7cfeabb43ff 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java @@ -50,14 +50,13 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector { private final ILabelProvider elementRenderer; - public ProcessPrompterDialog(Shell parent, ILabelProvider elementRenderer, - ILabelProvider qualifierRenderer) { + public ProcessPrompterDialog(Shell parent, ILabelProvider elementRenderer, ILabelProvider qualifierRenderer) { super(parent, elementRenderer, qualifierRenderer); this.elementRenderer = elementRenderer; setDialogBoundsSettings(getDialogBoundsSettings(), Dialog.DIALOG_PERSISTSIZE); setFilter(getFilterFromDialogSetting()); } - + @Override protected FilteredList createFilteredList(Composite parent) { FilteredList list = super.createFilteredList(parent); @@ -72,16 +71,16 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector { pattern = ""; //$NON-NLS-1$ } - if (! pattern.startsWith("*")) { //$NON-NLS-1$ + if (!pattern.startsWith("*")) { //$NON-NLS-1$ pattern = "*" + pattern; //$NON-NLS-1$ } int rules = SearchPattern.RULE_BLANK_MATCH | SearchPattern.RULE_PREFIX_MATCH; - if (! ignoreCase) { + if (!ignoreCase) { rules |= SearchPattern.RULE_CASE_SENSITIVE; } - if (! ignoreWildCards) { + if (!ignoreWildCards) { rules |= SearchPattern.RULE_PATTERN_MATCH; } matcher = new SearchPattern(rules); @@ -100,59 +99,59 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector { /* * The result should be every selected element. */ - @Override - protected void computeResult() { - setResult(Arrays.asList(getSelectedElements())); - } - - /* - * Disable the ability to select items in the bottom pane. - */ - @Override - protected Table createLowerList(Composite parent) { - final Table list = super.createLowerList(parent); - - // First remove listeners such as the double click. - // We don't want the user to trigger the action by - // double-clicking on the bottom pane. - int[] events = { SWT.Selection, SWT.MouseDoubleClick }; - for (int event : events) { - Listener[] selectionListeners = list.getListeners(event); - for (Listener listener : selectionListeners) { - list.removeListener(event, listener); - } - } - - // Now add a listener to prevent selection - list.addListener(SWT.EraseItem, new Listener() { - @Override - public void handleEvent(Event event) { - if ((event.detail & SWT.SELECTED) != 0) { - event.detail &= ~SWT.SELECTED; - // Removing the SELECTED event did not work properly. - // The foreground text became invisible. - // Let's simply deselect everything - list.deselectAll(); - } - } - }); - return list; - } - - /* - * Allow a double-click to work without any selection - * in the bottom list. - */ - @Override + @Override + protected void computeResult() { + setResult(Arrays.asList(getSelectedElements())); + } + + /* + * Disable the ability to select items in the bottom pane. + */ + @Override + protected Table createLowerList(Composite parent) { + final Table list = super.createLowerList(parent); + + // First remove listeners such as the double click. + // We don't want the user to trigger the action by + // double-clicking on the bottom pane. + int[] events = { SWT.Selection, SWT.MouseDoubleClick }; + for (int event : events) { + Listener[] selectionListeners = list.getListeners(event); + for (Listener listener : selectionListeners) { + list.removeListener(event, listener); + } + } + + // Now add a listener to prevent selection + list.addListener(SWT.EraseItem, new Listener() { + @Override + public void handleEvent(Event event) { + if ((event.detail & SWT.SELECTED) != 0) { + event.detail &= ~SWT.SELECTED; + // Removing the SELECTED event did not work properly. + // The foreground text became invisible. + // Let's simply deselect everything + list.deselectAll(); + } + } + }); + return list; + } + + /* + * Allow a double-click to work without any selection + * in the bottom list. + */ + @Override protected void handleDefaultSelected() { - if (validateCurrentSelection()) { + if (validateCurrentSelection()) { buttonPressed(IDialogConstants.OK_ID); } - } - + } + /** * Validate only upper selected elements. Lower list is always disabled. - * + * * @see #createLowerList(Composite) */ @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/RemoteApplicationCDebuggerTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/RemoteApplicationCDebuggerTab.java index d929a541351..f8eef0aa0b1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/RemoteApplicationCDebuggerTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/RemoteApplicationCDebuggerTab.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -20,7 +20,7 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; /** * Debugger tab to use for a remote application launch configuration. - * + * * @since 2.0 */ public class RemoteApplicationCDebuggerTab extends CDebuggerTab { @@ -38,30 +38,30 @@ public class RemoteApplicationCDebuggerTab extends CDebuggerTab { * Bug 281970 */ private final static String DEFAULTS_SET = "org.eclipse.cdt.dsf.gdb.internal.ui.launching.RemoteApplicationCDebuggerTab.DEFAULTS_SET"; //$NON-NLS-1$ - - public RemoteApplicationCDebuggerTab() { - super(SessionType.REMOTE, false); - } - - @Override - public void setDefaults(ILaunchConfigurationWorkingCopy config) { + + public RemoteApplicationCDebuggerTab() { + super(SessionType.REMOTE, false); + } + + @Override + public void setDefaults(ILaunchConfigurationWorkingCopy config) { config.setAttribute(DEFAULTS_SET, true); - - super.setDefaults(config); - } - - @Override - public void initializeFrom(ILaunchConfiguration config) { - try { - if (config.hasAttribute(DEFAULTS_SET) == false) { - ILaunchConfigurationWorkingCopy wc; - wc = config.getWorkingCopy(); - setDefaults(wc); - wc.doSave(); - } - } catch (CoreException e) { - } + + super.setDefaults(config); + } + + @Override + public void initializeFrom(ILaunchConfiguration config) { + try { + if (config.hasAttribute(DEFAULTS_SET) == false) { + ILaunchConfigurationWorkingCopy wc; + wc = config.getWorkingCopy(); + setDefaults(wc); + wc.doSave(); + } + } catch (CoreException e) { + } super.initializeFrom(config); - } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SerialPortSettingsBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SerialPortSettingsBlock.java index 2ea8e8b34fe..d6872e5562e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SerialPortSettingsBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SerialPortSettingsBlock.java @@ -46,11 +46,10 @@ public class SerialPortSettingsBlock extends Observable { private ComboDialogField fSpeedField; - private String fSpeedChoices[] = { - "9600", "19200", "38400", "57600", "115200", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - "230400", "460800", "921600", "1000000", "1152000", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - "1500000", "2000000", "2500000", "3000000", "3500000", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - "4000000" //$NON-NLS-1$ + private String fSpeedChoices[] = { "9600", "19200", "38400", "57600", "115200", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + "230400", "460800", "921600", "1000000", "1152000", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + "1500000", "2000000", "2500000", "3000000", "3500000", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + "4000000" //$NON-NLS-1$ }; private Control fControl; @@ -65,15 +64,15 @@ public class SerialPortSettingsBlock extends Observable { public void createBlock(Composite parent) { fShell = parent.getShell(); Composite comp = ControlFactory.createCompositeEx(parent, 2, GridData.FILL_BOTH); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - ((GridLayout)comp.getLayout()).marginHeight = 0; - ((GridLayout)comp.getLayout()).marginWidth = 0; + ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout) comp.getLayout()).marginHeight = 0; + ((GridLayout) comp.getLayout()).marginWidth = 0; comp.setFont(parent.getFont()); PixelConverter converter = new PixelConverter(comp); fDeviceField.doFillIntoGrid(comp, 2); LayoutUtil.setWidthHint(fDeviceField.getTextControl(null), converter.convertWidthInCharsToPixels(20)); fSpeedField.doFillIntoGrid(comp, 2); - ((GridData)fSpeedField.getComboControl(null).getLayoutData()).horizontalAlignment = GridData.BEGINNING; + ((GridData) fSpeedField.getComboControl(null).getLayoutData()).horizontalAlignment = GridData.BEGINNING; setControl(comp); } @@ -146,9 +145,9 @@ public class SerialPortSettingsBlock extends Observable { private void initializeDevice(ILaunchConfiguration configuration) { if (fDeviceField != null) { try { - fDeviceField.setText(configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV, DEFAULT_ASYNC_DEVICE)); - } - catch(CoreException e) { + fDeviceField.setText( + configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV, DEFAULT_ASYNC_DEVICE)); + } catch (CoreException e) { } } } @@ -157,9 +156,9 @@ public class SerialPortSettingsBlock extends Observable { if (fSpeedField != null) { int index = 0; try { - index = getSpeedItemIndex(configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV_SPEED, DEFAULT_ASYNC_DEVICE_SPEED)); - } - catch(CoreException e) { + index = getSpeedItemIndex(configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEV_SPEED, + DEFAULT_ASYNC_DEVICE_SPEED)); + } catch (CoreException e) { } fSpeedField.selectItem(index); } @@ -170,7 +169,7 @@ public class SerialPortSettingsBlock extends Observable { } private int getSpeedItemIndex(String item) { - for(int i = 0; i < fSpeedChoices.length; ++i) + for (int i = 0; i < fSpeedChoices.length; ++i) if (fSpeedChoices[i].equals(item)) return i; return 0; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SolibSearchPathBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SolibSearchPathBlock.java index cf3f66e80da..965e4f943d7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SolibSearchPathBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SolibSearchPathBlock.java @@ -84,13 +84,13 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu class AddDirectoryDialog extends Dialog { protected Text fText; - + private Button fBrowseButton; private IPath fValue; - /** - * Constructor for AddDirectoryDialog. + /** + * Constructor for AddDirectoryDialog. */ public AddDirectoryDialog(Shell parentShell) { super(parentShell); @@ -98,11 +98,12 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu @Override protected Control createDialogArea(Composite parent) { - Composite composite = (Composite)super.createDialogArea(parent); + Composite composite = (Composite) super.createDialogArea(parent); Composite subComp = ControlFactory.createCompositeEx(composite, 2, GridData.FILL_HORIZONTAL); - ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; - GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); + ((GridLayout) subComp.getLayout()).makeColumnsEqualWidth = false; + GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL + | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); subComp.setLayoutData(data); subComp.setFont(parent.getFont()); @@ -117,7 +118,8 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu } }); - fBrowseButton = ControlFactory.createPushButton(subComp, LaunchUIMessages.getString("GDBServerDebuggerPage.7")); //$NON-NLS-1$ + fBrowseButton = ControlFactory.createPushButton(subComp, + LaunchUIMessages.getString("GDBServerDebuggerPage.7")); //$NON-NLS-1$ data = new GridData(); data.horizontalAlignment = GridData.FILL; fBrowseButton.setLayoutData(data); @@ -156,8 +158,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { setValue(fText.getText()); - } - else { + } else { setValue(null); } super.buttonPressed(buttonId); @@ -211,14 +212,13 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu } } - private static String[] fgStaticButtonLabels = new String[] { - LaunchUIMessages.getString("SolibSearchPathBlock.0"), //$NON-NLS-1$ + private static String[] fgStaticButtonLabels = new String[] { LaunchUIMessages.getString("SolibSearchPathBlock.0"), //$NON-NLS-1$ LaunchUIMessages.getString("SolibSearchPathBlock.1"), //$NON-NLS-1$ LaunchUIMessages.getString("SolibSearchPathBlock.2"), //$NON-NLS-1$ LaunchUIMessages.getString("SolibSearchPathBlock.3"), //$NON-NLS-1$ LaunchUIMessages.getString("SolibSearchPathBlock.6"), //$NON-NLS-1$ null, // separator - }; + }; private IProject fProject; @@ -229,7 +229,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu private IListAdapter fCustomListAdapter; private File[] fAutoSolibs = new File[0]; - + public SolibSearchPathBlock() { this(new String[0], null); } @@ -251,6 +251,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu public void customButtonPressed(DialogField field, int index) { buttonPressed(index); } + @Override public void selectionChanged(DialogField field) { } @@ -259,7 +260,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu @Override public String getText(Object element) { if (element instanceof IPath) - return ((IPath)element).toOSString(); + return ((IPath) element).toOSString(); return super.getText(element); } }; @@ -268,20 +269,20 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu fDirList.setUpButtonIndex(1); fDirList.setDownButtonIndex(2); fDirList.setRemoveButtonIndex(3); - + fDirList.setDialogFieldListener(this); } /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#createControl(org.eclipse.swt.widgets.Composite) */ - @Override + @Override public void createControl(Composite parent) { fShell = parent.getShell(); Composite comp = ControlFactory.createCompositeEx(parent, 2, GridData.FILL_BOTH); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - ((GridLayout)comp.getLayout()).marginHeight = 0; - ((GridLayout)comp.getLayout()).marginWidth = 0; + ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout) comp.getLayout()).marginHeight = 0; + ((GridLayout) comp.getLayout()).marginWidth = 0; comp.setFont(parent.getFont()); PixelConverter converter = new PixelConverter(comp); fDirList.doFillIntoGrid(comp, 3); @@ -294,52 +295,51 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ - @Override + @Override public void initializeFrom(ILaunchConfiguration configuration) { IProject project = null; try { - String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null); + String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, + (String) null); if (projectName != null) { projectName = projectName.trim(); if (!projectName.isEmpty()) { project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); } } - } - catch(CoreException e) { + } catch (CoreException e) { } setProject(project); if (fDirList != null) { try { @SuppressWarnings("unchecked") - List<String> values = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, - Collections.EMPTY_LIST); + List<String> values = configuration.getAttribute( + IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST); ArrayList<Path> paths = new ArrayList<Path>(values.size()); Iterator<String> it = values.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { paths.add(new Path(it.next())); } fDirList.addElements(paths); - } - catch(CoreException e) { + } catch (CoreException e) { } } try { fAutoSolibs = getAutoSolibs(configuration); - } - catch(CoreException e) { + } catch (CoreException e) { } } public static File[] getAutoSolibs(ILaunchConfiguration configuration) throws CoreException { @SuppressWarnings("unchecked") - List<String> autoSolibs = configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB_LIST, Collections.EMPTY_LIST ); + List<String> autoSolibs = configuration + .getAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB_LIST, Collections.EMPTY_LIST); List<File> list = new ArrayList<File>(autoSolibs.size()); Iterator<String> it = autoSolibs.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { list.add(new File(it.next())); } return list.toArray(new File[list.size()]); @@ -348,7 +348,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ - @Override + @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST); } @@ -356,16 +356,16 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ - @Override + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { if (fDirList != null) { - + @SuppressWarnings("unchecked") List<IPath> elements = fDirList.getElements(); - + ArrayList<String> values = new ArrayList<String>(elements.size()); Iterator<IPath> it = elements.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { values.add((it.next()).toOSString()); } configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, values); @@ -373,18 +373,16 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu ArrayList<String> autoLibs = new ArrayList<String>(fAutoSolibs.length); for (int i = 0; i < fAutoSolibs.length; ++i) autoLibs.add(fAutoSolibs[i].getPath()); - configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB_LIST, autoLibs); + configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB_LIST, autoLibs); } protected void buttonPressed(int index) { - boolean changed = false; + boolean changed = false; if (index == 0) { // Add button changed = addDirectory(); - } - else if (index == 4) { //Select from list + } else if (index == 4) { //Select from list changed = selectFromList(); - } - else if (index >= fgStaticButtonLabels.length && fCustomListAdapter != null) { + } else if (index >= fgStaticButtonLabels.length && fCustomListAdapter != null) { fCustomListAdapter.customButtonPressed(fDirList, index); changed = true; } @@ -412,7 +410,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu IPath result = dialog.getValue(); if (result != null && !contains(result)) { fDirList.addElement(result); - changed = true; + changed = true; } return changed; } @@ -420,7 +418,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#dispose() */ - @Override + @Override public void dispose() { deleteObservers(); } @@ -428,7 +426,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#getControl() */ - @Override + @Override public Control getControl() { return fControl; } @@ -436,7 +434,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#isValid(org.eclipse.debug.core.ILaunchConfiguration) */ - @Override + @Override public boolean isValid(ILaunchConfiguration launchConfig) { // TODO Auto-generated method stub return false; @@ -445,9 +443,9 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu private boolean contains(IPath path) { @SuppressWarnings("unchecked") List<IPath> list = fDirList.getElements(); - + Iterator<IPath> it = list.iterator(); - while(it.hasNext()) { + while (it.hasNext()) { IPath p = it.next(); if (p.toFile().equals(path.toFile())) return true; @@ -465,48 +463,53 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu protected boolean selectFromList() { boolean changed = false; - + @SuppressWarnings("unchecked") List<IPath> dirList = fDirList.getSelectedElements(); - + final HashSet<IPath> libs = new HashSet<IPath>(10); if (generateLibraryList(dirList.toArray(new IPath[dirList.size()]), libs)) { ITreeContentProvider cp = new ITreeContentProvider() { - @Override + @Override public Object[] getChildren(Object parentElement) { return getElements(parentElement); } - @Override + + @Override public Object getParent(Object element) { if (libs.contains(element)) return libs; return null; } - @Override + + @Override public boolean hasChildren(Object element) { return false; } - @Override + + @Override public Object[] getElements(Object inputElement) { if (inputElement instanceof Set) { - return ((Set)inputElement).toArray(); + return ((Set) inputElement).toArray(); } return new Object[0]; } - @Override + + @Override public void dispose() { } - @Override + + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } + } }; - + LabelProvider lp = new LabelProvider() { - + @Override public String getText(Object element) { if (element instanceof File) - return ((File)element).getName(); + return ((File) element).getName(); return super.getText(element); } }; @@ -530,7 +533,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu boolean result = true; IRunnableWithProgress runnable = new IRunnableWithProgress() { - @Override + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { for (int i = 0; i < paths.length; ++i) { @@ -551,13 +554,11 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu } } }; - try { - IRunnableContext context = new ProgressMonitorDialog(getShell()); + try { + IRunnableContext context = new ProgressMonitorDialog(getShell()); context.run(true, true, runnable); - } - catch(InvocationTargetException e) { - } - catch(InterruptedException e) { + } catch (InvocationTargetException e) { + } catch (InterruptedException e) { result = false; } return result; @@ -570,21 +571,20 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu if (project != null) { IPath fullPath = new Path(file.getPath()); try { - ICConfigExtensionReference[] binaryParsersExt = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project); - for(int i = 0; i < binaryParsersExt.length; i++) { + ICConfigExtensionReference[] binaryParsersExt = CCorePlugin.getDefault() + .getDefaultBinaryParserExtensions(project); + for (int i = 0; i < binaryParsersExt.length; i++) { IBinaryParser parser = CoreModelUtil.getBinaryParser(binaryParsersExt[i]); try { IBinaryFile bin = parser.getBinary(fullPath); if (bin instanceof IBinaryShared) { - String soname = ((IBinaryShared)bin).getSoName(); + String soname = ((IBinaryShared) bin).getSoName(); return (soname.length() != 0) ? soname : file.getName(); } - } - catch(IOException e) { + } catch (IOException e) { } } - } - catch(CoreException e) { + } catch (CoreException e) { } return null; } @@ -604,18 +604,17 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu if (project != null) { IPath fullPath = new Path(file.getPath()); try { - ICConfigExtensionReference[] binaryParsersExt = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(project); - for(int i = 0; i < binaryParsersExt.length; i++) { + ICConfigExtensionReference[] binaryParsersExt = CCorePlugin.getDefault() + .getDefaultBinaryParserExtensions(project); + for (int i = 0; i < binaryParsersExt.length; i++) { IBinaryParser parser = CoreModelUtil.getBinaryParser(binaryParsersExt[i]); try { IBinaryFile bin = parser.getBinary(fullPath); return (bin instanceof IBinaryShared); - } - catch(IOException e) { + } catch (IOException e) { } } - } - catch(CoreException e) { + } catch (CoreException e) { } return false; } @@ -628,7 +627,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu return (name.indexOf(".so.") >= 0); //$NON-NLS-1$ } - @Override + @Override public void dialogFieldChanged(DialogField field) { setChanged(); notifyObservers(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/TCPSettingsBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/TCPSettingsBlock.java index 4b04774ff22..5bf5d2ac9ff 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/TCPSettingsBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/TCPSettingsBlock.java @@ -57,15 +57,15 @@ public class TCPSettingsBlock extends Observable { public void createBlock(Composite parent) { fShell = parent.getShell(); Composite comp = ControlFactory.createCompositeEx(parent, 2, GridData.FILL_BOTH); - ((GridLayout)comp.getLayout()).makeColumnsEqualWidth = false; - ((GridLayout)comp.getLayout()).marginHeight = 0; - ((GridLayout)comp.getLayout()).marginWidth = 0; + ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false; + ((GridLayout) comp.getLayout()).marginHeight = 0; + ((GridLayout) comp.getLayout()).marginWidth = 0; comp.setFont(parent.getFont()); PixelConverter converter = new PixelConverter(comp); fHostNameField.doFillIntoGrid(comp, 2); LayoutUtil.setWidthHint(fHostNameField.getTextControl(null), converter.convertWidthInCharsToPixels(20)); fPortNumberField.doFillIntoGrid(comp, 2); - ((GridData)fPortNumberField.getTextControl(null).getLayoutData()).horizontalAlignment = GridData.BEGINNING; + ((GridData) fPortNumberField.getTextControl(null).getLayoutData()).horizontalAlignment = GridData.BEGINNING; LayoutUtil.setWidthHint(fPortNumberField.getTextControl(null), converter.convertWidthInCharsToPixels(10)); setControl(comp); } @@ -136,9 +136,9 @@ public class TCPSettingsBlock extends Observable { private void initializeHostName(ILaunchConfiguration configuration) { if (fHostNameField != null) { try { - fHostNameField.setText(configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_HOST, DEFAULT_HOST_NAME)); - } - catch(CoreException e) { + fHostNameField.setText( + configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_HOST, DEFAULT_HOST_NAME)); + } catch (CoreException e) { } } } @@ -146,9 +146,9 @@ public class TCPSettingsBlock extends Observable { private void initializePortNumber(ILaunchConfiguration configuration) { if (fPortNumberField != null) { try { - fPortNumberField.setText(configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, DEFAULT_PORT_NUMBER)); - } - catch(CoreException e) { + fPortNumberField.setText( + configuration.getAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, DEFAULT_PORT_NUMBER)); + } catch (CoreException e) { } } } @@ -196,8 +196,7 @@ public class TCPSettingsBlock extends Observable { try { int port = Integer.parseInt(portNumber); return (port > 0 && port <= 0xFFFF); - } - catch(NumberFormatException e) { + } catch (NumberFormatException e) { return false; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/WorkingDirectoryBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/WorkingDirectoryBlock.java index e981c4d25da..3910400655a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/WorkingDirectoryBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/WorkingDirectoryBlock.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * Ericsson - Updated for DSF @@ -48,7 +48,6 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.ContainerSelectionDialog; - /** * A control for setting the working directory associated with a launch * configuration. @@ -74,7 +73,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { */ private class WidgetListener extends SelectionAdapter implements ModifyListener { - @Override + @Override public void modifyText(ModifyEvent e) { updateLaunchConfigurationDialog(); } @@ -98,14 +97,14 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) */ - @Override + @Override public void createControl(Composite parent) { Font font = parent.getFont(); - Group group = new Group(parent, SWT.NONE); + Group group = new Group(parent, SWT.NONE); // WorkbenchHelp.setHelp(group, // IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK); GridLayout workingDirLayout = new GridLayout(); @@ -116,17 +115,15 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { group.setFont(font); setControl(group); - group.setText(LaunchUIMessages.getString("WorkingDirectoryBlock.Working_directory")); //$NON-NLS-1$ - - fWorkingDirText = new Text(group, SWT.SINGLE | SWT.BORDER); - fWorkingDirText.getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = LaunchUIMessages.getString("WorkingDirectoryBlock.Working_directory"); //$NON-NLS-1$ - } - } - ); + group.setText(LaunchUIMessages.getString("WorkingDirectoryBlock.Working_directory")); //$NON-NLS-1$ + + fWorkingDirText = new Text(group, SWT.SINGLE | SWT.BORDER); + fWorkingDirText.getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = LaunchUIMessages.getString("WorkingDirectoryBlock.Working_directory"); //$NON-NLS-1$ + } + }); gd = new GridData(GridData.FILL_HORIZONTAL); fWorkingDirText.setLayoutData(gd); fWorkingDirText.setFont(font); @@ -159,7 +156,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() */ @Override @@ -191,13 +188,13 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { * workspace */ protected void handleWorkspaceDirBrowseButtonSelected() { - ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, - LaunchUIMessages.getString("WorkingDirectoryBlock.4")); //$NON-NLS-1$ + ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), + ResourcesPlugin.getWorkspace().getRoot(), false, LaunchUIMessages.getString("WorkingDirectoryBlock.4")); //$NON-NLS-1$ IContainer currentContainer = getContainer(); if (currentContainer != null) { IPath path = currentContainer.getFullPath(); - dialog.setInitialSelections(new Object[] { path}); + dialog.setInitialSelections(new Object[] { path }); } dialog.showClosedProjects(false); @@ -272,7 +269,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) */ @Override @@ -307,10 +304,10 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { /** * Defaults are empty. - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ - @Override + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { // config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, // (String)null); @@ -318,14 +315,15 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ - @Override + @Override public void initializeFrom(ILaunchConfiguration configuration) { setLaunchConfiguration(configuration); try { - String wd = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); + String wd = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, + (String) null); fWorkingDirText.setText(""); //$NON-NLS-1$ if (wd == null) { fUseDefaultWorkingDirButton.setSelection(true); @@ -335,17 +333,19 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { } handleUseDefaultWorkingDirButtonSelected(); } catch (CoreException e) { - setErrorMessage(LaunchUIMessages.getString("WorkingDirectoryBlock.Exception_occurred_reading_configuration___15") + e.getStatus().getMessage()); //$NON-NLS-1$ + setErrorMessage( + LaunchUIMessages.getString("WorkingDirectoryBlock.Exception_occurred_reading_configuration___15") //$NON-NLS-1$ + + e.getStatus().getMessage()); GdbUIPlugin.log(e); } } /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ - @Override + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { String wd = null; if (!isDefaultWorkingDirectory()) { @@ -356,7 +356,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { /** * Retuns the string in the text widget, or <code>null</code> if empty. - * + * * @return text or <code>null</code> */ protected String getAttributeValueFrom(Text text) { @@ -369,10 +369,10 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { /* * (non-Javadoc) - * + * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ - @Override + @Override public String getName() { return LaunchUIMessages.getString("WorkingDirectoryBlock.Working_Directory_8"); //$NON-NLS-1$ } @@ -400,4 +400,3 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { } } - diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/memory/GdbMemoryBlockAddressInfoRetrieval.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/memory/GdbMemoryBlockAddressInfoRetrieval.java index e806ee48dc5..bfd23622594 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/memory/GdbMemoryBlockAddressInfoRetrieval.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/memory/GdbMemoryBlockAddressInfoRetrieval.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -37,137 +37,139 @@ import org.eclipse.debug.core.model.IMemoryBlock; public class GdbMemoryBlockAddressInfoRetrieval implements IMemoryBlockAddressInfoRetrieval { - private final DsfSession fSession; - private final Set<IAddressInfoUpdateListener> fListeners = new HashSet<>(); - - public GdbMemoryBlockAddressInfoRetrieval(DsfSession session) { - fSession = session; - fSession.getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - fSession.addServiceEventListener(GdbMemoryBlockAddressInfoRetrieval.this, null); - } - }); - } - - protected IGdbMemoryAddressInfoTypeRetrieval[] resolveMemoryAddressInfoProviders() { - return new IGdbMemoryAddressInfoTypeRetrieval[] {new GdbMemoryAddressInfoVariablesRetrieval(fSession), new GdbMemoryAddressInfoRegistersRetrieval(fSession)}; - } - - @Override - public void getMemoryBlockAddressInfo(Object selection, final IMemoryBlock memBlock, - final IGetMemoryBlockAddressInfoReq request) { - IDMContext memBlockContext = null; - if (memBlock instanceof DsfMemoryBlock) { - memBlockContext = ((DsfMemoryBlock) memBlock).getContext(); - - if (selection instanceof IDMVMContext) { - IDMContext context = ((IDMVMContext) selection).getDMContext(); - final IFrameDMContext frameCtx = DMContexts.getAncestorOfType(context, IFrameDMContext.class); - if (frameCtx != null) { - // Resolve container context of selection - IContainerDMContext selectedContainerCtx = DMContexts.getAncestorOfType(frameCtx, - IContainerDMContext.class); - - // Resolve container context of memory block - IContainerDMContext memoryContainerCtx = DMContexts.getAncestorOfType(memBlockContext, - IContainerDMContext.class); - - // Continue if the selected container matches the container for the memory context - if (memoryContainerCtx != null && memoryContainerCtx.equals(selectedContainerCtx)) { - fSession.getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - // Resolve the memory address info providers - IGdbMemoryAddressInfoTypeRetrieval[] infoTypeProviders = resolveMemoryAddressInfoProviders(); - if (infoTypeProviders == null || infoTypeProviders.length == 0) { - // No providers available - request.done(); - return; - } - - final CountingRequestMonitor crm = new CountingRequestMonitor(fSession.getExecutor(), - null) { - // mark the request done when all available infoTypeProviders have - // returned its information - @Override - protected void handleCompleted() { - request.done(); - }; - }; - - for (final IGdbMemoryAddressInfoTypeRetrieval infoProvider : infoTypeProviders) { - infoProvider.itemsRequest(frameCtx, memBlock, - new DataRequestMonitor<IMemoryBlockAddressInfoItem[]>( - fSession.getExecutor(), crm) { - @Override - protected void handleCompleted() { - if (isSuccess()) { - // Load the information from this provider - request.setAddressInfoItems(infoProvider.getInfoType(), getData()); - } else { - request.setStatus(getStatus()); - } - crm.done(); - } - }); - } - - crm.setDoneCount(infoTypeProviders.length); - } - - }); - } else { - request.done(); - } - } else { - // The selection context does not match the block memory context, - // Simply close the request - request.done(); - } - } else { - request.done(); - } - } else { - request.done(); - } - } - - // The GdbSessionAdapters class will call this method automatically when it cleans up - public void dispose() { - fListeners.clear(); - } - - @Override - public void addAddressInfoUpdateListener(IAddressInfoUpdateListener listener) { - synchronized(fListeners) { - fListeners.add(listener); - } - } - - @Override - public void removeAddressInfoUpdateListener(IAddressInfoUpdateListener listener) { - synchronized(fListeners) { - fListeners.remove(listener); - } - } - - @DsfServiceEventHandler - public void eventDispatched(IRegisterChangedDMEvent e) { - synchronized(fListeners) { - for (IAddressInfoUpdateListener listener : fListeners) { - listener.handleAddressInfoUpdate(EventType.VALUE_CHANGED, null); - } - } - - } - - @DsfServiceEventHandler - public void eventDispatched(IExpressionChangedDMEvent e) { - synchronized(fListeners) { - for (IAddressInfoUpdateListener listener : fListeners) { - listener.handleAddressInfoUpdate(EventType.VALUE_CHANGED, null); - } - } - } + private final DsfSession fSession; + private final Set<IAddressInfoUpdateListener> fListeners = new HashSet<>(); + + public GdbMemoryBlockAddressInfoRetrieval(DsfSession session) { + fSession = session; + fSession.getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + fSession.addServiceEventListener(GdbMemoryBlockAddressInfoRetrieval.this, null); + } + }); + } + + protected IGdbMemoryAddressInfoTypeRetrieval[] resolveMemoryAddressInfoProviders() { + return new IGdbMemoryAddressInfoTypeRetrieval[] { new GdbMemoryAddressInfoVariablesRetrieval(fSession), + new GdbMemoryAddressInfoRegistersRetrieval(fSession) }; + } + + @Override + public void getMemoryBlockAddressInfo(Object selection, final IMemoryBlock memBlock, + final IGetMemoryBlockAddressInfoReq request) { + IDMContext memBlockContext = null; + if (memBlock instanceof DsfMemoryBlock) { + memBlockContext = ((DsfMemoryBlock) memBlock).getContext(); + + if (selection instanceof IDMVMContext) { + IDMContext context = ((IDMVMContext) selection).getDMContext(); + final IFrameDMContext frameCtx = DMContexts.getAncestorOfType(context, IFrameDMContext.class); + if (frameCtx != null) { + // Resolve container context of selection + IContainerDMContext selectedContainerCtx = DMContexts.getAncestorOfType(frameCtx, + IContainerDMContext.class); + + // Resolve container context of memory block + IContainerDMContext memoryContainerCtx = DMContexts.getAncestorOfType(memBlockContext, + IContainerDMContext.class); + + // Continue if the selected container matches the container for the memory context + if (memoryContainerCtx != null && memoryContainerCtx.equals(selectedContainerCtx)) { + fSession.getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + // Resolve the memory address info providers + IGdbMemoryAddressInfoTypeRetrieval[] infoTypeProviders = resolveMemoryAddressInfoProviders(); + if (infoTypeProviders == null || infoTypeProviders.length == 0) { + // No providers available + request.done(); + return; + } + + final CountingRequestMonitor crm = new CountingRequestMonitor(fSession.getExecutor(), + null) { + // mark the request done when all available infoTypeProviders have + // returned its information + @Override + protected void handleCompleted() { + request.done(); + }; + }; + + for (final IGdbMemoryAddressInfoTypeRetrieval infoProvider : infoTypeProviders) { + infoProvider.itemsRequest(frameCtx, memBlock, + new DataRequestMonitor<IMemoryBlockAddressInfoItem[]>( + fSession.getExecutor(), crm) { + @Override + protected void handleCompleted() { + if (isSuccess()) { + // Load the information from this provider + request.setAddressInfoItems(infoProvider.getInfoType(), + getData()); + } else { + request.setStatus(getStatus()); + } + crm.done(); + } + }); + } + + crm.setDoneCount(infoTypeProviders.length); + } + + }); + } else { + request.done(); + } + } else { + // The selection context does not match the block memory context, + // Simply close the request + request.done(); + } + } else { + request.done(); + } + } else { + request.done(); + } + } + + // The GdbSessionAdapters class will call this method automatically when it cleans up + public void dispose() { + fListeners.clear(); + } + + @Override + public void addAddressInfoUpdateListener(IAddressInfoUpdateListener listener) { + synchronized (fListeners) { + fListeners.add(listener); + } + } + + @Override + public void removeAddressInfoUpdateListener(IAddressInfoUpdateListener listener) { + synchronized (fListeners) { + fListeners.remove(listener); + } + } + + @DsfServiceEventHandler + public void eventDispatched(IRegisterChangedDMEvent e) { + synchronized (fListeners) { + for (IAddressInfoUpdateListener listener : fListeners) { + listener.handleAddressInfoUpdate(EventType.VALUE_CHANGED, null); + } + } + + } + + @DsfServiceEventHandler + public void eventDispatched(IExpressionChangedDMEvent e) { + synchronized (fListeners) { + for (IAddressInfoUpdateListener listener : fListeners) { + listener.handleAddressInfoUpdate(EventType.VALUE_CHANGED, null); + } + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/AttachProcessHandler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/AttachProcessHandler.java index 404d086a319..a6d78b9f6ba 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/AttachProcessHandler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/AttachProcessHandler.java @@ -119,7 +119,7 @@ public class AttachProcessHandler extends AbstractHandler implements IHandler { /* * (non-Javadoc) - * + * * @see * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. * ExecutionEvent) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ColumnLayout.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ColumnLayout.java index 459ed90b724..097c760b3ac 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ColumnLayout.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ColumnLayout.java @@ -23,8 +23,7 @@ import org.eclipse.jface.dialogs.IDialogSettings; /* Hold information about which columns in a table are visible, and what * width they have. Stores that information inside preferences store. */ -class ColumnLayout -{ +class ColumnLayout { private String fResourceClass; private Map<String, Boolean> fVisible = new HashMap<String, Boolean>(); private Map<String, Integer> fWidth = new HashMap<String, Integer>(); @@ -32,8 +31,8 @@ class ColumnLayout private Integer fSortDirection = null; private static IDialogSettings settings; - private static IDialogSettings getDialogSettings() - { + + private static IDialogSettings getDialogSettings() { if (settings != null) return settings; @@ -45,31 +44,26 @@ class ColumnLayout return settings; } - private static void setDefaultSetting(String key, boolean value) - { + private static void setDefaultSetting(String key, boolean value) { IDialogSettings s = getDialogSettings(); if (s.get(key) == null) s.put(key, value); } - private static void setDefaultSetting(String key, int value) - { + private static void setDefaultSetting(String key, int value) { IDialogSettings s = getDialogSettings(); if (s.get(key) == null) s.put(key, value); } - public ColumnLayout(String resourceClass) - { + public ColumnLayout(String resourceClass) { fResourceClass = resourceClass; } - public boolean getVisible(String column) - { + public boolean getVisible(String column) { if (fVisible.containsKey(column)) return fVisible.get(column); - else - { + else { setDefaultSetting(columnKey(column, "v"), true); //$NON-NLS-1$ boolean b = getDialogSettings().getBoolean(columnKey(column, "v")); //$NON-NLS-1$ fVisible.put(column, b); @@ -77,18 +71,15 @@ class ColumnLayout } } - public void setVisible(String column, boolean visible) - { + public void setVisible(String column, boolean visible) { fVisible.put(column, visible); getDialogSettings().put(columnKey(column, "v"), visible); //$NON-NLS-1$ } - public int getWidth(String column) - { + public int getWidth(String column) { if (fWidth.containsKey(column)) return fWidth.get(column); - else - { + else { setDefaultSetting(columnKey(column, "w"), -1); //$NON-NLS-1$ int w = getDialogSettings().getInt(columnKey(column, "w")); //$NON-NLS-1$ fWidth.put(column, w); @@ -96,51 +87,42 @@ class ColumnLayout } } - public void setWidth(String column, int width) - { + public void setWidth(String column, int width) { fWidth.put(column, width); getDialogSettings().put(columnKey(column, "w"), width); //$NON-NLS-1$ } - public int getSortColumn() - { - if (fSortColumn == null) - { + public int getSortColumn() { + if (fSortColumn == null) { setDefaultSetting(globalKey("sortColumn"), 0); //$NON-NLS-1$ - fSortColumn = getDialogSettings().getInt(globalKey("sortColumn")); //$NON-NLS-1$ + fSortColumn = getDialogSettings().getInt(globalKey("sortColumn")); //$NON-NLS-1$ } return fSortColumn; } - public void setSortColumn(int column) - { + public void setSortColumn(int column) { fSortColumn = column; getDialogSettings().put(globalKey("sortColumn"), fSortColumn); //$NON-NLS-1$ } - public int getSortDirection() - { - if (fSortDirection == null) - { + public int getSortDirection() { + if (fSortDirection == null) { setDefaultSetting(globalKey("sortDirection"), 1); //$NON-NLS-1$ fSortDirection = getDialogSettings().getInt(globalKey("sortDirection")); //$NON-NLS-1$ } return fSortDirection; } - public void setSortDirection(int direction) - { + public void setSortDirection(int direction) { fSortDirection = direction; getDialogSettings().put(globalKey("sortDirection"), fSortDirection); //$NON-NLS-1$ } - private String columnKey(String column, String what) - { + private String columnKey(String column, String what) { return "columnLayout." + fResourceClass + "." + column + "." + what; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - private String globalKey(String what) - { + private String globalKey(String what) { return "columnLayout." + fResourceClass + "." + what; //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ContentLabelProviderWrapper.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ContentLabelProviderWrapper.java index 6ee3577af03..289fae64221 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ContentLabelProviderWrapper.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ContentLabelProviderWrapper.java @@ -30,25 +30,21 @@ import org.eclipse.swt.graphics.Image; * * This class is wrapping our real content provider, and can be retargeted in one call -- after which * refresh of TreeViewer sees consistent data. - * + * * @since 2.4 * */ public class ContentLabelProviderWrapper<U extends ITableLabelProvider & IStructuredContentProvider> -implements ITableLabelProvider, IStructuredContentProvider -{ + implements ITableLabelProvider, IStructuredContentProvider { - public ContentLabelProviderWrapper(U realProvider) - { + public ContentLabelProviderWrapper(U realProvider) { this.realProvider = realProvider; } - public void setData(U realProvider) - { + public void setData(U realProvider) { this.realProvider = realProvider; } - public U getData() - { + public U getData() { return realProvider; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/OSData.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/OSData.java index 0993de21581..4ab8142f4b6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/OSData.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/OSData.java @@ -29,10 +29,7 @@ import org.eclipse.swt.graphics.Image; * of specific class. Constructed from MI output. Once constructed, * this class is immutable. */ -class OSData -extends LabelProvider -implements ITableLabelProvider, IStructuredContentProvider -{ +class OSData extends LabelProvider implements ITableLabelProvider, IStructuredContentProvider { private IResourcesInformation data; private boolean[] columnIsInteger; private List<Integer> remap; @@ -45,19 +42,18 @@ implements ITableLabelProvider, IStructuredContentProvider for (int i = 0; i < data.getColumnNames().length; ++i) remap.add(i); - if (resourceClass.equals("processes")) //$NON-NLS-1$ - sendToEnd("Command"); //$NON-NLS-1$ + if (resourceClass.equals("processes")) //$NON-NLS-1$ + sendToEnd("Command"); //$NON-NLS-1$ - if (resourceClass.equals("threads")) //$NON-NLS-1$ - sendToEnd("Command"); //$NON-NLS-1$ + if (resourceClass.equals("threads")) //$NON-NLS-1$ + sendToEnd("Command"); //$NON-NLS-1$ - if (resourceClass.equals("modules")) //$NON-NLS-1$ - sendToEnd("Dependencies"); //$NON-NLS-1$ + if (resourceClass.equals("modules")) //$NON-NLS-1$ + sendToEnd("Dependencies"); //$NON-NLS-1$ } // Determine column types, for the purpose of proper sorting - private void determineColumnTypes() - { + private void determineColumnTypes() { String[] columnNames = data.getColumnNames(); String[][] content = data.getContent(); @@ -67,22 +63,19 @@ implements ITableLabelProvider, IStructuredContentProvider boolean[] columnHasOther = new boolean[columnNames.length]; for (int i = 0; i < content.length; ++i) { - for (int j = 0; j < content[i].length; ++j) { - if (!columnHasOther[j]) - { - try { - Integer.parseInt(content[i][j]); - columnHasInteger[j] = true; - } - catch(NumberFormatException e) { - columnHasOther[j] = true; - } - catch(Throwable e) { - e.printStackTrace(); - } + for (int j = 0; j < content[i].length; ++j) { + if (!columnHasOther[j]) { + try { + Integer.parseInt(content[i][j]); + columnHasInteger[j] = true; + } catch (NumberFormatException e) { + columnHasOther[j] = true; + } catch (Throwable e) { + e.printStackTrace(); } - } + + } } for (int j = 0; j < data.getColumnNames().length; ++j) { @@ -91,8 +84,7 @@ implements ITableLabelProvider, IStructuredContentProvider } /* Make column named 'column' appear last in UI. */ - private void sendToEnd(String column) - { + private void sendToEnd(String column) { // Find index in the remap array (which is equal to index in UI) // at which column named 'column' is found. int index = -1; @@ -108,13 +100,11 @@ implements ITableLabelProvider, IStructuredContentProvider remap.add(remap.remove(index)); } - public int getColumnCount() - { + public int getColumnCount() { return remap.size(); } - public String getColumnName(int i) - { + public String getColumnName(int i) { return data.getColumnNames()[remap.get(i)]; } @@ -150,14 +140,15 @@ implements ITableLabelProvider, IStructuredContentProvider // split into array of resource information for each raw String[][] content = data.getContent(); IResourcesInformation[] split_ri = new IResourcesInformation[content.length]; - for (int i = 0; i< content.length; ++i) { + for (int i = 0; i < content.length; ++i) { final String[][] row_content = new String[1][content[i].length]; row_content[0] = content[i]; - split_ri[i]=new IResourcesInformation() { + split_ri[i] = new IResourcesInformation() { @Override public String[] getColumnNames() { return data.getColumnNames(); } + @Override public String[][] getContent() { return row_content; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/OSResourcesView.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/OSResourcesView.java index 86d5312e6c7..a6d7a98415c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/OSResourcesView.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/OSResourcesView.java @@ -92,18 +92,17 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded // selected. private SessionOSData fSessionData; private Map<String, SessionOSData> fSessionDataCache = new HashMap<String, SessionOSData>(); - // The data presently shown by table viewer. + // The data presently shown by table viewer. private OSData fTableShownData = null; // The data which was used to populate column selector menu private OSData fMenuShownData = null; private String fResourceClass = null; - + // Indicates that we've selected objects from different debug sessions. boolean fMultiple = false; // Indicates that we have selected object with a wrong type boolean fWrongType = false; - // UI objects private TableViewer fViewer; private Comparator fComparator; @@ -128,8 +127,7 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded topLayout.marginHeight = 0; parent.setLayout(topLayout); - fViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL - | SWT.V_SCROLL); + fViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); GridData viewerData = new GridData(GridData.FILL_BOTH); viewerData.exclude = true; fViewer.getControl().setLayoutData(viewerData); @@ -150,9 +148,8 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded fNothingLabel = new Link(fNothingLabelContainer, SWT.BORDER); fNothingLabel.setText(Messages.OSView_4); - fNothingLabel.setBackground(fNothingLabel.getDisplay().getSystemColor( - SWT.COLOR_LIST_BACKGROUND)); - fNothingLabel.addListener (SWT.Selection, new Listener () { + fNothingLabel.setBackground(fNothingLabel.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); + fNothingLabel.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { if (event.text.equals("fetch")) //$NON-NLS-1$ @@ -189,34 +186,32 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded }; fRefreshAction.setText(Messages.OSView_3); fRefreshAction.setToolTipText(Messages.OSView_3); - try { - Bundle bundle= Platform.getBundle("org.eclipse.ui"); //$NON-NLS-1$ - URL url = bundle.getEntry("/"); //$NON-NLS-1$ - url = new URL(url, "icons/full/elcl16/refresh_nav.png"); //$NON-NLS-1$ - ImageDescriptor candidate = ImageDescriptor.createFromURL(url); - if (candidate != null && candidate.getImageData() != null) { - fRefreshAction.setImageDescriptor(candidate); - } - } catch (Exception e) { - } - bars.getToolBarManager().add(fRefreshAction); - bars.setGlobalActionHandler(ActionFactory.COPY.getId(), new CopyAction()); - bars.updateActionBars(); - - createContextMenu(); + try { + Bundle bundle = Platform.getBundle("org.eclipse.ui"); //$NON-NLS-1$ + URL url = bundle.getEntry("/"); //$NON-NLS-1$ + url = new URL(url, "icons/full/elcl16/refresh_nav.png"); //$NON-NLS-1$ + ImageDescriptor candidate = ImageDescriptor.createFromURL(url); + if (candidate != null && candidate.getImageData() != null) { + fRefreshAction.setImageDescriptor(candidate); + } + } catch (Exception e) { + } + bars.getToolBarManager().add(fRefreshAction); + bars.setGlobalActionHandler(ActionFactory.COPY.getId(), new CopyAction()); + bars.updateActionBars(); + + createContextMenu(); getSite().setSelectionProvider(fViewer); - - setResourceClass(fResourceClassEditor.getResourceClassId()); + setResourceClass(fResourceClassEditor.getResourceClassId()); setupContextListener(); DsfSession.addSessionEndedListener(this); - } private void createContextMenu() { - MenuManager menuMgr= new MenuManager("#PopUp"); //$NON-NLS-1$ + MenuManager menuMgr = new MenuManager("#PopUp"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @Override @@ -225,7 +220,7 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } }); - Menu menu= menuMgr.createContextMenu(fViewer.getControl()); + Menu menu = menuMgr.createContextMenu(fViewer.getControl()); fViewer.getControl().setMenu(menu); // register the context menu such that other plug-ins may contribute to it @@ -234,8 +229,7 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded private void setupContextListener() { IDebugContextManager contextManager = DebugUITools.getDebugContextManager(); - IDebugContextService contextService = contextManager - .getContextService(getSite().getWorkbenchWindow()); + IDebugContextService contextService = contextManager.getContextService(getSite().getWorkbenchWindow()); fDebugContextListener = new IDebugContextListener() { @@ -251,22 +245,21 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded contextService.addDebugContextListener(fDebugContextListener); setDebugContext(contextService.getActiveContext()); } - + @Override public void dispose() { super.dispose(); IDebugContextManager contextManager = DebugUITools.getDebugContextManager(); - IDebugContextService contextService = contextManager - .getContextService(getSite().getWorkbenchWindow()); + IDebugContextService contextService = contextManager.getContextService(getSite().getWorkbenchWindow()); contextService.removeDebugContextListener(fDebugContextListener); - setDebugContext((ICommandControlDMContext)null); + setDebugContext((ICommandControlDMContext) null); DsfSession.removeSessionEndedListener(this); } private void setDebugContext(ISelection s) { - + ICommandControlDMContext context = null; fMultiple = false; fWrongType = false; @@ -278,15 +271,13 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded context = getCommandControlContext(i.next()); if (context == null) fWrongType = true; - + while (i.hasNext()) { ICommandControlDMContext nextContext = getCommandControlContext(i.next()); if (nextContext == null) fWrongType = true; - if (nextContext == null && context != null - || nextContext != null && context == null - || nextContext != null && context != null && !nextContext.equals(context)) - { + if (nextContext == null && context != null || nextContext != null && context == null + || nextContext != null && context != null && !nextContext.equals(context)) { context = null; fMultiple = true; break; @@ -294,24 +285,24 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded } } } - + setDebugContext(context); } private ICommandControlDMContext getCommandControlContext(Object obj) { IDMContext context = null; if (obj instanceof IDMVMContext) - context = ((IDMVMContext)obj).getDMContext(); + context = ((IDMVMContext) obj).getDMContext(); else if (obj instanceof GdbLaunch) { - GdbLaunch l = (GdbLaunch)obj; - final DsfServicesTracker tracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), l.getSession().getId()); + GdbLaunch l = (GdbLaunch) obj; + final DsfServicesTracker tracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), + l.getSession().getId()); Query<IDMContext> contextQuery = new Query<IDMContext>() { @Override protected void execute(DataRequestMonitor<IDMContext> rm) { ICommandControlService commandControl = tracker.getService(ICommandControlService.class); tracker.dispose(); - if (commandControl != null) - { + if (commandControl != null) { rm.setData(commandControl.getContext()); } rm.done(); @@ -326,21 +317,17 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded return DMContexts.getAncestorOfType(context, ICommandControlDMContext.class); } - private void setDebugContext(ICommandControlDMContext context) - { + private void setDebugContext(ICommandControlDMContext context) { DsfSession newSession = null; SessionOSData newSessionData = null; - - if (context != null) - { + + if (context != null) { newSession = DsfSession.getSession(context.getSessionId()); } - - if (newSession != null) - { + + if (newSession != null) { newSessionData = fSessionDataCache.get(newSession.getId()); - if (newSessionData == null) - { + if (newSessionData == null) { newSessionData = new SessionOSData(newSession, context); fSessionDataCache.put(newSession.getId(), newSessionData); @@ -370,58 +357,56 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded // Update UI to showing new session data. If this session data is already // shown, does nothing. - private void update(SessionOSData newSessionData) - { + private void update(SessionOSData newSessionData) { if (fViewer == null || fViewer.getControl() == null) return; if (fViewer.getControl().isDisposed()) return; - - if (newSessionData == null) - { + + if (newSessionData == null) { fSessionData = null; if (fMultiple) hideTable(Messages.OSView_14); else if (fWrongType) hideTable(Messages.OSView_4); - else + else hideTable(Messages.OSView_15); fResourceClassEditor.setEnabled(false); fRefreshAction.setEnabled(false); return; } - + if (newSessionData != fSessionData) { fSessionData = newSessionData; updateSessionDataContents(); } } - + // Update the UI according to actual content of fSessionData, // which must be not null. private void updateSessionDataContents() { if (fSessionData == null) return; - + if (fViewer == null || fViewer.getControl() == null) return; if (fViewer.getControl().isDisposed()) return; - boolean enable = fSessionData.canFetchData(); + boolean enable = fSessionData.canFetchData(); fRefreshAction.setEnabled(enable); setResourceClass(fResourceClassEditor.updateClasses(fSessionData.getResourceClasses())); fResourceClassEditor.setEnabled(enable); - + if (!fSessionData.osResourcesSupported()) { fRefreshAction.setEnabled(false); fResourceClassEditor.setEnabled(false); hideTable(Messages.OSView_10); return; } - + if (fSessionData.waitingForSessionInitialization()) { fRefreshAction.setEnabled(false); fResourceClassEditor.setEnabled(false); @@ -436,38 +421,30 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded return; } - if (getResourceClass() == null) - { + if (getResourceClass() == null) { fRefreshAction.setEnabled(false); fResourceClassEditor.setEnabled(true); hideTable(Messages.OSView_5); return; } - final OSData data = fSessionData.existingData(getResourceClass()); - if (fSessionData.fetchingContent()) - { + if (fSessionData.fetchingContent()) { hideTable(Messages.OSView_6); - } - else if (data == null) - { + } else if (data == null) { if (fSessionData.canFetchData()) hideTable(NLS.bind(Messages.OSView_7, FETCH_LINK_TAG)); else hideTable(Messages.OSView_12); - } - else - { + } else { SimpleDateFormat format = new SimpleDateFormat(Messages.OSView_8); fRefreshAction.setToolTipText(format.format(fSessionData.timestamp(getResourceClass()))); - if (data != fTableShownData) - { + if (data != fTableShownData) { Job job = new UIJob(Messages.OSView_9) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { - fTableShownData = data; + fTableShownData = data; populateTable(data); showTable(); return Status.OK_STATUS; @@ -476,9 +453,7 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded }; job.setPriority(Job.INTERACTIVE); job.schedule(); - } - else - { + } else { assert fViewer.getTable().getColumnCount() == data.getColumnCount(); showTable(); } @@ -511,7 +486,7 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded private void showTable() { assert fTableShownData != null; - + fViewer.getControl().setVisible(true); ((GridData) fViewer.getControl().getLayoutData()).exclude = false; fNothingLabelContainer.setVisible(false); @@ -521,20 +496,18 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded populateViewMenu(fTableShownData); } - private void populateTable(final OSData data) - { + private void populateTable(final OSData data) { final Table table = fViewer.getTable(); while (table.getColumnCount() > 0) table.getColumns()[0].dispose(); fColumnLayout = fColumnLayouts.get(getResourceClass()); - if (fColumnLayout == null) - { + if (fColumnLayout == null) { fColumnLayout = new ColumnLayout(getResourceClass()); fColumnLayouts.put(getResourceClass(), fColumnLayout); } - + for (int i = 0; i < data.getColumnCount(); ++i) { final String cn = data.getColumnName(i); final TableColumn c = new TableColumn(table, SWT.LEFT); @@ -572,35 +545,29 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded populateViewMenu(data); int sortColumn = fColumnLayout.getSortColumn(); - if (sortColumn < data.getColumnCount()) - { + if (sortColumn < data.getColumnCount()) { fComparator.configure(sortColumn, data); } fComparator.setDirection(fColumnLayout.getSortDirection()); fViewer.getTable().setEnabled(true); - - if (fViewer.getContentProvider() == null) - { - ContentLabelProviderWrapper<OSData> wrapper = - new ContentLabelProviderWrapper<OSData>(data); + if (fViewer.getContentProvider() == null) { + ContentLabelProviderWrapper<OSData> wrapper = new ContentLabelProviderWrapper<OSData>(data); fViewer.setContentProvider(wrapper); fViewer.setLabelProvider(wrapper); - } - else - { + } else { // Retarget current content/label providers in atomic fashion. See comments // on ContentLabelProviderWrapper. @SuppressWarnings("unchecked") - ContentLabelProviderWrapper<OSData> wrapper = (ContentLabelProviderWrapper<OSData>)fViewer.getContentProvider(); + ContentLabelProviderWrapper<OSData> wrapper = (ContentLabelProviderWrapper<OSData>) fViewer + .getContentProvider(); wrapper.setData(data); } fViewer.setInput(getViewSite()); fViewer.getControl().setVisible(true); - for (int i = 0; i < fViewer.getTable().getColumnCount(); ++i) - { + for (int i = 0; i < fViewer.getTable().getColumnCount(); ++i) { TableColumn col = fViewer.getTable().getColumns()[i]; String cn = col.getText(); @@ -609,16 +576,13 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded table.setSortColumn(col); } - if (fColumnLayout.getVisible(cn)) - { + if (fColumnLayout.getVisible(cn)) { int w = fColumnLayout.getWidth(cn); if (w > 0) col.setWidth(w); else col.pack(); - } - else - { + } else { col.setWidth(0); col.setResizable(false); } @@ -628,10 +592,10 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded private void populateViewMenu(final OSData data) { assert data.getColumnCount() == fViewer.getTable().getColumnCount(); - + if (data == fMenuShownData) return; - + IActionBars bars = getViewSite().getActionBars(); bars.getMenuManager().setVisible(true); bars.getMenuManager().removeAll(); @@ -666,26 +630,23 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded bars.getMenuManager().add(a); } bars.updateActionBars(); - + fMenuShownData = data; } - class Comparator extends ViewerComparator - { + class Comparator extends ViewerComparator { private int fColumn = 0; private OSData fData; private boolean fInteger = false; private int fDirection = 1; - public void configure(int column, OSData data) - { + public void configure(int column, OSData data) { fColumn = column; fData = data; fInteger = data.getColumnIsInteger(column); } - public void setDirection(int direction) - { + public void setDirection(int direction) { assert direction == 1 || direction == -1; fDirection = direction; } @@ -694,13 +655,13 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded public int compare(Viewer viewer, Object xe1, Object xe2) { String v1 = fData.getColumnText(xe1, fColumn); - String v2 = fData.getColumnText(xe2, fColumn); + String v2 = fData.getColumnText(xe2, fColumn); if (fInteger) { Integer i1 = Integer.parseInt(v1); Integer i2 = Integer.parseInt(v2); - return fDirection*(i1 - i2); + return fDirection * (i1 - i2); } else { - return fDirection*(v1.compareTo(v2)); + return fDirection * (v1.compareTo(v2)); } } }; @@ -723,7 +684,7 @@ public class OSResourcesView extends ViewPart implements DsfSession.SessionEnded private void setResourceClass(String resourceClass) { fResourceClass = resourceClass; } - + /** * @return currently debug context for which resources are displayed */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ResourceClassContributionItem.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ResourceClassContributionItem.java index f32663093c8..4a3760e67d9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ResourceClassContributionItem.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/ResourceClassContributionItem.java @@ -36,8 +36,7 @@ public class ResourceClassContributionItem extends ContributionItem { // the combobox itself is adding. This constant is our guess. private static final int COMBO_TRIM_WIDTH = 64; - interface Listener - { + interface Listener { void resourceClassChanged(String newClass); } @@ -52,8 +51,8 @@ public class ResourceClassContributionItem extends ContributionItem { private boolean enabled = true; private static IDialogSettings settings; - private static IDialogSettings getDialogSettings() - { + + private static IDialogSettings getDialogSettings() { if (settings != null) return settings; @@ -80,24 +79,24 @@ public class ResourceClassContributionItem extends ContributionItem { } public String updateClasses(IResourceClass[] resourceClasses) { - + boolean different = false; if (this.resourceClasses.length != resourceClasses.length) different = true; - else for (int i = 0; i < this.resourceClasses.length; ++i) { - if (!this.resourceClasses[i].getId().equals(resourceClasses[i].getId()) - || !this.resourceClasses[i].getHumanDescription().equals(resourceClasses[i].getHumanDescription())) - { - different = true; - break; + else + for (int i = 0; i < this.resourceClasses.length; ++i) { + if (!this.resourceClasses[i].getId().equals(resourceClasses[i].getId()) || !this.resourceClasses[i] + .getHumanDescription().equals(resourceClasses[i].getHumanDescription())) { + different = true; + break; + } } - } if (!different) return fResourceClassId; this.resourceClasses = resourceClasses; - + fResourceClassCombo.removeAll(); final int width = populateCombo(); // Now change the width. Call to setWidth causes relayout automatically. @@ -106,14 +105,14 @@ public class ResourceClassContributionItem extends ContributionItem { // is not shown. The bug manifests by 100% CPU consumption inside event loop, and // it further blocks asyncExec runnables from ever executing. I suppose it might // be specific to relayout of invisible toolbar. - + // If we're invisible, we don't arrange for relayout to happen when the view becomes // available, because it is not exactly trivial (we need to events on the right control) - // and it only matters when we start a new session and it has a different set of + // and it only matters when we start a new session and it has a different set of // resource classes and that requires longer combobox. if (toolItem.getParent().isVisible()) toolItem.setWidth(width); - + return fResourceClassId; } @@ -122,7 +121,7 @@ public class ResourceClassContributionItem extends ContributionItem { * returns some reasonable default width. */ private int populateCombo() { - + int width = 0; String lastResourceClassId = getDialogSettings().get("resourceClass"); //$NON-NLS-1$ int index = -1; @@ -135,8 +134,6 @@ public class ResourceClassContributionItem extends ContributionItem { if (resourceClasses[i].getId().equals(lastResourceClassId)) index = i; } - - if (index != -1) { fResourceClassId = lastResourceClassId; @@ -144,22 +141,21 @@ public class ResourceClassContributionItem extends ContributionItem { fResourceClassCombo.select(index); blockListener = false; } - + if (width == 0) { // We have some hints what the longest element in combo will be. Even if it's different // in new GDB version, no problem -- the combo will be resized when it's populated. - width = gc.textExtent("Shared memory regions").x; //$NON-NLS-1$ + width = gc.textExtent("Shared memory regions").x; //$NON-NLS-1$ } // Because there's no way whatsoever to set the width // of the combobox list, only complete length, we just add // random padding. width = width + COMBO_TRIM_WIDTH; - + return width; } - public String getResourceClassId() { return fResourceClassId; } @@ -185,8 +181,7 @@ public class ResourceClassContributionItem extends ContributionItem { // id is never null here, unless we messed up our data structures. assert id != null; - if (id != null && !id.equals(fResourceClassId)) - { + if (id != null && !id.equals(fResourceClassId)) { fResourceClassId = id; getDialogSettings().put("resourceClass", id); //$NON-NLS-1$ if (fListener != null && !blockListener) @@ -199,7 +194,6 @@ public class ResourceClassContributionItem extends ContributionItem { } }); - toolItem = new ToolItem(parent, SWT.SEPARATOR); toolItem.setControl(fResourceClassCombo); toolItem.setWidth(width); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/SessionOSData.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/SessionOSData.java index 3cdd4e9eaba..fcb235617c0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/SessionOSData.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/osview/SessionOSData.java @@ -66,10 +66,8 @@ public class SessionOSData { private boolean fAcceptingCommands = false; private boolean fFetchingClasses = false; private boolean fFetchingContent = false; - - public SessionOSData(DsfSession session, final ICommandControlDMContext executionContext) - { + public SessionOSData(DsfSession session, final ICommandControlDMContext executionContext) { fSession = session; BundleContext c = GdbUIPlugin.getDefault().getBundle().getBundleContext(); fTracker = new DsfServicesTracker(c, fSession.getId()); @@ -80,7 +78,7 @@ public class SessionOSData { @Override public void run() { - + IMIRunControl runControl = fTracker.getService(IMIRunControl.class); fAcceptingCommands = runControl.isTargetAcceptingCommands(); @@ -93,41 +91,38 @@ public class SessionOSData { notifyUI(); return; } - + if (fHardwareOs.isAvailable()) { - fetchClasses(); + fetchClasses(); } } }); } - + @ConfinedToDsfExecutor("") - private void fetchClasses() - { + private void fetchClasses() { fWaitingForSession = false; fFetchingClasses = true; - fHardwareOs.getResourceClasses(fContext, new DataRequestMonitor<IResourceClass[]>(fSession.getExecutor(), null) { - @Override - @ConfinedToDsfExecutor("fExecutor") - protected void handleCompleted() { - - if (isSuccess()) - { - fResourceClasses = getData(); - if (fResourceClasses.length == 0) - fSupported = false; - } - else - { - fSupported = false; - } - fFetchingClasses = false; - notifyUI(); - } - }); + fHardwareOs.getResourceClasses(fContext, + new DataRequestMonitor<IResourceClass[]>(fSession.getExecutor(), null) { + @Override + @ConfinedToDsfExecutor("fExecutor") + protected void handleCompleted() { + + if (isSuccess()) { + fResourceClasses = getData(); + if (fResourceClasses.length == 0) + fSupported = false; + } else { + fSupported = false; + } + fFetchingClasses = false; + notifyUI(); + } + }); } - - @DsfServiceEventHandler + + @DsfServiceEventHandler public void eventDispatched(DataModelInitializedEvent e) { // If we see this event, it necessary means that by the time we've set event listener, // isAvailable() was returning false, so we need to fetch classes now. @@ -135,32 +130,27 @@ public class SessionOSData { fetchClasses(); } - public boolean waitingForSessionInitialization() - { + public boolean waitingForSessionInitialization() { return fWaitingForSession; } - public boolean osResourcesSupported() - { + public boolean osResourcesSupported() { return fSupported; } - public void dispose() - { + public void dispose() { fSession.removeServiceEventListener(SessionOSData.this); fTracker.dispose(); } - public IResourceClass[] getResourceClasses() - { + public IResourceClass[] getResourceClasses() { return fResourceClasses; } /** Returns OS awareness data for given resource class that * was previously fetched, or null if none was ever fetched. */ - public OSData existingData(String resourceClass) - { + public OSData existingData(String resourceClass) { return fExistingData.get(resourceClass); } @@ -168,8 +158,7 @@ public class SessionOSData { * been obtained. * @pre existingData(resourceClass) != null */ - public Date timestamp(String resourceClass) - { + public Date timestamp(String resourceClass) { return fTimestamp.get(resourceClass); } @@ -178,28 +167,24 @@ public class SessionOSData { * and if GDB is accepting commands right now. * */ - public boolean canFetchData() - { + public boolean canFetchData() { return fAcceptingCommands && !fFetchingContent; } - public boolean fetchingClasses() - { + public boolean fetchingClasses() { return fFetchingClasses; } /** Returns true if we're presently fetching data. This can * be used to provide some feedback to the user. */ - public boolean fetchingContent() - { + public boolean fetchingContent() { return fFetchingContent; } /** Fetches up-to-date data for resourceClass. Listeners will be * informed when the new data is available. */ - public void fetchData(final String resourceClass) - { + public void fetchData(final String resourceClass) { fFetchingContent = true; notifyUI(); @@ -208,35 +193,31 @@ public class SessionOSData { @Override public void run() { - fHardwareOs.getResourcesInformation(fContext, resourceClass, new DataRequestMonitor<IResourcesInformation>(executor, null) { - - @Override - @ConfinedToDsfExecutor("fExecutor") - protected void handleCompleted() { - - fFetchingContent = false; - - if (isSuccess()) - { - OSData data = new OSData(resourceClass, getData()); - fExistingData.put(resourceClass, data); - fTimestamp.put(resourceClass, new Date()); - } - else - { - StatusManager.getManager().handle(getStatus(), StatusManager.SHOW); - } - notifyUI(); - } - }); + fHardwareOs.getResourcesInformation(fContext, resourceClass, + new DataRequestMonitor<IResourcesInformation>(executor, null) { + + @Override + @ConfinedToDsfExecutor("fExecutor") + protected void handleCompleted() { + + fFetchingContent = false; + + if (isSuccess()) { + OSData data = new OSData(resourceClass, getData()); + fExistingData.put(resourceClass, data); + fTimestamp.put(resourceClass, new Date()); + } else { + StatusManager.getManager().handle(getStatus(), StatusManager.SHOW); + } + notifyUI(); + } + }); } }); - } - public interface Listener - { + public interface Listener { void update(); } @@ -246,55 +227,53 @@ public class SessionOSData { * the listener. The listener will not be called if the control * is disposed. */ - public void setUIListener(Listener listener, Control control) - { + public void setUIListener(Listener listener, Control control) { fUIListener = listener; fUIControl = control; } - private void notifyUI() - { - + private void notifyUI() { + final Control c = fUIControl; if (c != null && !c.isDisposed()) // There be dragons: if you try to use c.getDisplay() below, then this Runnable will not // run until resource view is actually visible. And it will also block other interesting // async/job runnables, like perspective switch runnable using during debug launch, // causing launch to be stuck at random point. - // + // Display.getDefault().asyncExec(new Runnable() { @Override public void run() { - + if (!c.isDisposed()) fUIListener.update(); } }); - + + } + + @DsfServiceEventHandler + public void eventDispatched(IResumedDMEvent e) { + if (e instanceof IContainerResumedDMEvent) { + // This event is raised only in all-stop. It does not + // seem to be possible to issue -info-os in all-stop, + // regardless of whether target-async is in effect, and + // according to DSF folks, all-stop+target-async will + // not work anyway. So, we assume that no commands + // can be issued right now. + fAcceptingCommands = false; + notifyUI(); + } } - @DsfServiceEventHandler - public void eventDispatched(IResumedDMEvent e) { - if (e instanceof IContainerResumedDMEvent) { - // This event is raised only in all-stop. It does not - // seem to be possible to issue -info-os in all-stop, - // regardless of whether target-async is in effect, and - // according to DSF folks, all-stop+target-async will - // not work anyway. So, we assume that no commands - // can be issued right now. - fAcceptingCommands = false; - notifyUI(); - } - } - - @DsfServiceEventHandler - public void eventDispatched(ISuspendedDMEvent e) { - if (e instanceof IContainerSuspendedDMEvent) { - fAcceptingCommands = true; - notifyUI(); - } - } + @DsfServiceEventHandler + public void eventDispatched(ISuspendedDMEvent e) { + if (e instanceof IContainerSuspendedDMEvent) { + fAcceptingCommands = true; + notifyUI(); + } + } /** * @return the fContext diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbConsolePreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbConsolePreferencePage.java index fe5a4bbdcee..188a15f8028 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbConsolePreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbConsolePreferencePage.java @@ -23,13 +23,13 @@ import org.eclipse.ui.IWorkbenchPreferencePage; /** * GDB CLI Console Preference Page. - * + * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. * @noreference This class is not intended to be referenced by clients. */ public class GdbConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - private static final int MIN_BUFFER_LINES = 16; /* minimum of ~1000 chars */ + private static final int MIN_BUFFER_LINES = 16; /* minimum of ~1000 chars */ // Instead of using a maximum of Integer.MAX_VALUE (which is some obscure number), // let's use a well defined limit e.g. 2 billion lines, which is readable. private static final int MAX_BUFFER_LINES = 2000000000; @@ -58,9 +58,11 @@ public class GdbConsolePreferencePage extends FieldEditorPreferencePage implemen } private void setupEditors() { - BooleanFieldEditor invertColors = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS, + BooleanFieldEditor invertColors = new BooleanFieldEditor( + IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS, MessagesForPreferences.GdbConsolePreferencePage_InvertColors, getFieldEditorParent()); - IntegerFieldEditor editorBufferSize = new IntegerFieldEditor(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES, + IntegerFieldEditor editorBufferSize = new IntegerFieldEditor( + IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES, MessagesForPreferences.GdbConsolePreferencePage_BufferLines, getFieldEditorParent()); editorBufferSize.setValidRange(MIN_BUFFER_LINES, MAX_BUFFER_LINES); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java index a031d2e91cc..6298aac88fd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java @@ -84,7 +84,7 @@ import org.eclipse.ui.PlatformUI; * A preference page for settings that are currently only supported in GDB. */ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - + private static final int DEFAULT_GDB_COMMAND_LABEL_WIDTH_HINT = 300; /** @@ -93,8 +93,7 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements */ private class ListenableBooleanFieldEditor extends BooleanFieldEditor { - public ListenableBooleanFieldEditor(String name, String labelText, int style, - Composite parent) { + public ListenableBooleanFieldEditor(String name, String labelText, int style, Composite parent) { super(name, labelText, style, parent); } @@ -107,88 +106,87 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements class AdvancedTimeoutSettingsDialog extends TitleAreaDialog { class CommandTimeoutEntry { - + String fCommand; Integer fTimeout; - - CommandTimeoutEntry( String command, Integer timeout ) { + + CommandTimeoutEntry(String command, Integer timeout) { fCommand = command; fTimeout = timeout; } } class CellEditorListener implements ICellEditorListener { - + CellEditor fEditor; - - public CellEditorListener( CellEditor editor ) { + + public CellEditorListener(CellEditor editor) { super(); fEditor = editor; } @Override - public void editorValueChanged( boolean oldValidState, boolean newValidState ) { - if ( newValidState ) { - setErrorMessage( null ); - } - else { - setErrorMessage( fEditor.getErrorMessage() ); + public void editorValueChanged(boolean oldValidState, boolean newValidState) { + if (newValidState) { + setErrorMessage(null); + } else { + setErrorMessage(fEditor.getErrorMessage()); } updateDialogButtons(); } - + @Override public void cancelEditor() { } - + @Override public void applyEditorValue() { validate(); updateDialogButtons(); } }; - + abstract class AbstractEditingSupport extends EditingSupport { - public AbstractEditingSupport( ColumnViewer viewer ) { - super( viewer ); + public AbstractEditingSupport(ColumnViewer viewer) { + super(viewer); } @Override - protected void setValue( Object element, Object value ) { - if ( element instanceof CommandTimeoutEntry && value instanceof String ) { - if ( processValue( (CommandTimeoutEntry)element, (String)value ) ) { - fViewer.refresh( element ); + protected void setValue(Object element, Object value) { + if (element instanceof CommandTimeoutEntry && value instanceof String) { + if (processValue((CommandTimeoutEntry) element, (String) value)) { + fViewer.refresh(element); validate(); updateDialogButtons(); } } } - + @Override - protected Object getValue( Object element ) { - if ( element instanceof CommandTimeoutEntry ) { - return doGetValue( (CommandTimeoutEntry)element ); + protected Object getValue(Object element) { + if (element instanceof CommandTimeoutEntry) { + return doGetValue((CommandTimeoutEntry) element); } return null; } - + @Override - protected CellEditor getCellEditor( Object element ) { - final CellEditor editor = new TextCellEditor( (Composite)getViewer().getControl() ); - editor.setValidator( getValidator() ); - editor.addListener( new CellEditorListener( editor ) ); + protected CellEditor getCellEditor(Object element) { + final CellEditor editor = new TextCellEditor((Composite) getViewer().getControl()); + editor.setValidator(getValidator()); + editor.addListener(new CellEditorListener(editor)); return editor; } - + @Override - protected boolean canEdit( Object element ) { - return ( element instanceof CommandTimeoutEntry ); + protected boolean canEdit(Object element) { + return (element instanceof CommandTimeoutEntry); } - - abstract boolean processValue( CommandTimeoutEntry entry, String value ); - abstract Object doGetValue( CommandTimeoutEntry entry ); + abstract boolean processValue(CommandTimeoutEntry entry, String value); + + abstract Object doGetValue(CommandTimeoutEntry entry); abstract ICellEditorValidator getValidator(); }; @@ -196,14 +194,14 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements private TableViewer fViewer; private Button fAddButton; private Button fDeleteButton; - + private List<CommandTimeoutEntry> fEntries; - + final private ICellEditorValidator fCommandValidator = new ICellEditorValidator() { - + @Override - public String isValid( Object value ) { - if ( value instanceof String && ((String)value).trim().length() == 0 ) { + public String isValid(Object value) { + if (value instanceof String && ((String) value).trim().length() == 0) { return MessagesForPreferences.GdbDebugPreferencePage_Command_field_can_not_be_empty; } return null; @@ -211,16 +209,15 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements }; final private ICellEditorValidator fTimeoutValidator = new ICellEditorValidator() { - + @Override - public String isValid( Object value ) { - if ( value instanceof String ) { + public String isValid(Object value) { + if (value instanceof String) { try { - int intValue = Integer.decode( (String)value ).intValue(); - if ( intValue < 0 ) + int intValue = Integer.decode((String) value).intValue(); + if (intValue < 0) return MessagesForPreferences.GdbDebugPreferencePage_Timeout_value_can_not_be_negative; - } - catch( NumberFormatException e ) { + } catch (NumberFormatException e) { return MessagesForPreferences.GdbDebugPreferencePage_Invalid_timeout_value; } } @@ -228,116 +225,115 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements } }; - AdvancedTimeoutSettingsDialog( Shell parentShell, Set<Map.Entry<String, Integer>> entries ) { - super( parentShell ); + AdvancedTimeoutSettingsDialog(Shell parentShell, Set<Map.Entry<String, Integer>> entries) { + super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE); fEntries = new LinkedList<CommandTimeoutEntry>(); - for ( Map.Entry<String, Integer> entry : entries ) { - fEntries.add( new CommandTimeoutEntry( entry.getKey(), entry.getValue() ) ); + for (Map.Entry<String, Integer> entry : entries) { + fEntries.add(new CommandTimeoutEntry(entry.getKey(), entry.getValue())); } } @Override - protected Control createDialogArea( Composite parent ) { - getShell().setText( MessagesForPreferences.GdbDebugPreferencePage_Advanced_Timeout_Settings ); - setTitle( MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_title ); - setTitleImage( GdbUIPlugin.getImage( IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS ) ); - setMessage( MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_message ); - - Composite control = (Composite)super.createDialogArea( parent ); - Composite comp = new Composite( control, SWT.NONE ); - GridData gd = new GridData( SWT.FILL, SWT.FILL, true, true ); - GridLayout layout = new GridLayout( 2, false ); + protected Control createDialogArea(Composite parent) { + getShell().setText(MessagesForPreferences.GdbDebugPreferencePage_Advanced_Timeout_Settings); + setTitle(MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_title); + setTitleImage(GdbUIPlugin.getImage(IGdbUIConstants.IMG_WIZBAN_ADVANCED_TIMEOUT_SETTINGS)); + setMessage(MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_dialog_message); + + Composite control = (Composite) super.createDialogArea(parent); + Composite comp = new Composite(control, SWT.NONE); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + GridLayout layout = new GridLayout(2, false); layout.marginLeft = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); - comp.setLayout( layout ); - comp.setLayoutData( gd ); - - fViewer = new TableViewer( comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER ); + comp.setLayout(layout); + comp.setLayoutData(gd); + + fViewer = new TableViewer(comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); final Table table = fViewer.getTable(); - gd = new GridData( SWT.FILL, SWT.FILL, true, true ); + gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); - table.setLayoutData( gd ); - - ControlDecoration decoration = new ControlDecoration( table, SWT.TOP | SWT.LEFT, control ); - decoration.setImage( - FieldDecorationRegistry.getDefault().getFieldDecoration( - FieldDecorationRegistry.DEC_INFORMATION ).getImage() ); - decoration.setDescriptionText( - MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip ); - fViewer.addDoubleClickListener( new IDoubleClickListener() { + table.setLayoutData(gd); + + ControlDecoration decoration = new ControlDecoration(table, SWT.TOP | SWT.LEFT, control); + decoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); + decoration.setDescriptionText( + MessagesForPreferences.GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip); + fViewer.addDoubleClickListener(new IDoubleClickListener() { @Override - public void doubleClick( DoubleClickEvent event ) { + public void doubleClick(DoubleClickEvent event) { okPressed(); } - } ); + }); + + fViewer.addSelectionChangedListener(new ISelectionChangedListener() { - fViewer.addSelectionChangedListener( new ISelectionChangedListener() { - @Override - public void selectionChanged( SelectionChangedEvent event ) { + public void selectionChanged(SelectionChangedEvent event) { updateDialogButtons(); } - } ); - - Composite btnComp = new Composite( comp, SWT.NONE ); - btnComp.setLayout( new GridLayout() ); - btnComp.setLayoutData( new GridData( SWT.RIGHT, SWT.TOP, false, false ) ); - - fAddButton = new Button( btnComp, SWT.PUSH ); - fAddButton.setText( MessagesForPreferences.GdbDebugPreferencePage_Add_button ); - fAddButton.setFont( JFaceResources.getDialogFont() ); - setButtonLayoutData( fAddButton ); - fAddButton.addSelectionListener( new SelectionAdapter() { + }); + + Composite btnComp = new Composite(comp, SWT.NONE); + btnComp.setLayout(new GridLayout()); + btnComp.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); + + fAddButton = new Button(btnComp, SWT.PUSH); + fAddButton.setText(MessagesForPreferences.GdbDebugPreferencePage_Add_button); + fAddButton.setFont(JFaceResources.getDialogFont()); + setButtonLayoutData(fAddButton); + fAddButton.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { + public void widgetSelected(SelectionEvent e) { addNewEntry(); } - } ); - - fDeleteButton = new Button( btnComp, SWT.PUSH ); - fDeleteButton.setText( MessagesForPreferences.GdbDebugPreferencePage_Delete_button ); - fDeleteButton.setFont( JFaceResources.getDialogFont() ); - setButtonLayoutData( fDeleteButton ); - fDeleteButton.addSelectionListener( new SelectionAdapter() { + }); + + fDeleteButton = new Button(btnComp, SWT.PUSH); + fDeleteButton.setText(MessagesForPreferences.GdbDebugPreferencePage_Delete_button); + fDeleteButton.setFont(JFaceResources.getDialogFont()); + setButtonLayoutData(fDeleteButton); + fDeleteButton.addSelectionListener(new SelectionAdapter() { @Override - public void widgetSelected( SelectionEvent e ) { + public void widgetSelected(SelectionEvent e) { deleteEntries(); } - } ); - - table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); - table.setHeaderVisible( true ); - table.setLinesVisible( true ); - - TableViewerColumn commandColumn = new TableViewerColumn( fViewer, SWT.LEFT ); - commandColumn.getColumn().setText( MessagesForPreferences.GdbDebugPreferencePage_Command_column_name ); - commandColumn.setLabelProvider( createCommandLabelProvider() ); - commandColumn.setEditingSupport( createCommandEditingSupport( fViewer ) ); - - TableViewerColumn timeoutColumn = new TableViewerColumn( fViewer, SWT.LEFT ); - timeoutColumn.getColumn().setText( MessagesForPreferences.GdbDebugPreferencePage_Timeout_column_name ); - timeoutColumn.setLabelProvider( createTimeoutLabelProvider() ); - timeoutColumn.setEditingSupport( createTimeoutEditingSupport( fViewer ) ); - - fViewer.setContentProvider( createCustomTimeoutsContentProvider() ); - - table.addControlListener( new ControlAdapter() { - + }); + + table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + TableViewerColumn commandColumn = new TableViewerColumn(fViewer, SWT.LEFT); + commandColumn.getColumn().setText(MessagesForPreferences.GdbDebugPreferencePage_Command_column_name); + commandColumn.setLabelProvider(createCommandLabelProvider()); + commandColumn.setEditingSupport(createCommandEditingSupport(fViewer)); + + TableViewerColumn timeoutColumn = new TableViewerColumn(fViewer, SWT.LEFT); + timeoutColumn.getColumn().setText(MessagesForPreferences.GdbDebugPreferencePage_Timeout_column_name); + timeoutColumn.setLabelProvider(createTimeoutLabelProvider()); + timeoutColumn.setEditingSupport(createTimeoutEditingSupport(fViewer)); + + fViewer.setContentProvider(createCustomTimeoutsContentProvider()); + + table.addControlListener(new ControlAdapter() { + @Override - public void controlResized( ControlEvent e ) { + public void controlResized(ControlEvent e) { Rectangle area = table.getClientArea(); - if ( area.width > 0 ) { + if (area.width > 0) { TableColumn[] cols = table.getColumns(); - cols[0].setWidth( area.width * 50 / 100 ); - cols[1].setWidth( area.width * 50 / 100 ); - table.removeControlListener( this ); + cols[0].setWidth(area.width * 50 / 100); + cols[1].setWidth(area.width * 50 / 100); + table.removeControlListener(this); } } - } ); + }); - fViewer.setInput( fEntries ); + fViewer.setInput(fEntries); updateDialogButtons(); @@ -345,28 +341,28 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements } void updateDialogButtons() { - if ( fViewer != null && fDeleteButton != null ) { - fDeleteButton.setEnabled( !fViewer.getSelection().isEmpty() ); + if (fViewer != null && fDeleteButton != null) { + fDeleteButton.setEnabled(!fViewer.getSelection().isEmpty()); } - Button okButton = getButton( IDialogConstants.OK_ID ); - if ( okButton != null ) - okButton.setEnabled( getErrorMessage() == null ); + Button okButton = getButton(IDialogConstants.OK_ID); + if (okButton != null) + okButton.setEnabled(getErrorMessage() == null); } void addNewEntry() { - CommandTimeoutEntry newEntry = new CommandTimeoutEntry( "", Integer.valueOf( 0 ) ); //$NON-NLS-1$ - fEntries.add( newEntry ); + CommandTimeoutEntry newEntry = new CommandTimeoutEntry("", Integer.valueOf(0)); //$NON-NLS-1$ + fEntries.add(newEntry); fViewer.refresh(); - fViewer.setSelection( new StructuredSelection( newEntry ) ); - validateEntry( newEntry ); + fViewer.setSelection(new StructuredSelection(newEntry)); + validateEntry(newEntry); updateDialogButtons(); - fViewer.editElement( newEntry, 0 ); + fViewer.editElement(newEntry, 0); } void deleteEntries() { - IStructuredSelection sel = (IStructuredSelection)fViewer.getSelection(); - if ( !sel.isEmpty() ) - fEntries.removeAll( sel.toList() ); + IStructuredSelection sel = (IStructuredSelection) fViewer.getSelection(); + if (!sel.isEmpty()) + fEntries.removeAll(sel.toList()); fViewer.refresh(); validate(); updateDialogButtons(); @@ -374,41 +370,41 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements CustomTimeoutsMap getResult() { CustomTimeoutsMap map = new CustomTimeoutsMap(); - for ( CommandTimeoutEntry entry : fEntries ) { - map.put( entry.fCommand, entry.fTimeout ); + for (CommandTimeoutEntry entry : fEntries) { + map.put(entry.fCommand, entry.fTimeout); } return map; } void validate() { - for ( CommandTimeoutEntry entry : fEntries ) { - validateEntry( entry ); + for (CommandTimeoutEntry entry : fEntries) { + validateEntry(entry); } } - void validateEntry( CommandTimeoutEntry entry ) { - String errorMessage = fCommandValidator.isValid( entry.fCommand ); - setErrorMessage( ( errorMessage != null ) ? - errorMessage : fTimeoutValidator.isValid( entry.fTimeout.toString() ) ); + void validateEntry(CommandTimeoutEntry entry) { + String errorMessage = fCommandValidator.isValid(entry.fCommand); + setErrorMessage( + (errorMessage != null) ? errorMessage : fTimeoutValidator.isValid(entry.fTimeout.toString())); } IStructuredContentProvider createCustomTimeoutsContentProvider() { return new IStructuredContentProvider() { - + @Override - public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) { + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } - + @Override public void dispose() { } - + @Override - public Object[] getElements( Object inputElement ) { - if ( inputElement instanceof List<?> ) { - @SuppressWarnings( "unchecked" ) - List<CommandTimeoutEntry> list = (List<CommandTimeoutEntry>)inputElement; - return list.toArray( new Object[list.size()] ); + public Object[] getElements(Object inputElement) { + if (inputElement instanceof List<?>) { + @SuppressWarnings("unchecked") + List<CommandTimeoutEntry> list = (List<CommandTimeoutEntry>) inputElement; + return list.toArray(new Object[list.size()]); } return null; } @@ -422,11 +418,11 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object) */ @Override - public String getText( Object element ) { - if ( element instanceof CommandTimeoutEntry ) { - return ((CommandTimeoutEntry)element).fCommand; + public String getText(Object element) { + if (element instanceof CommandTimeoutEntry) { + return ((CommandTimeoutEntry) element).fCommand; } - return super.getText( element ); + return super.getText(element); } }; } @@ -438,26 +434,26 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object) */ @Override - public String getText( Object element ) { - if ( element instanceof CommandTimeoutEntry ) { - return ((CommandTimeoutEntry)element).fTimeout.toString(); + public String getText(Object element) { + if (element instanceof CommandTimeoutEntry) { + return ((CommandTimeoutEntry) element).fTimeout.toString(); } - return super.getText( element ); + return super.getText(element); } }; } - EditingSupport createCommandEditingSupport( ColumnViewer viewer ) { - return new AbstractEditingSupport( viewer ) { - + EditingSupport createCommandEditingSupport(ColumnViewer viewer) { + return new AbstractEditingSupport(viewer) { + @Override - boolean processValue( CommandTimeoutEntry entry, String value ) { + boolean processValue(CommandTimeoutEntry entry, String value) { entry.fCommand = value; return true; } @Override - Object doGetValue( CommandTimeoutEntry entry ) { + Object doGetValue(CommandTimeoutEntry entry) { return entry.fCommand; } @@ -468,23 +464,22 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements }; } - EditingSupport createTimeoutEditingSupport( ColumnViewer viewer ) { - return new AbstractEditingSupport( viewer ) { + EditingSupport createTimeoutEditingSupport(ColumnViewer viewer) { + return new AbstractEditingSupport(viewer) { @Override - boolean processValue( CommandTimeoutEntry entry, String value ) { + boolean processValue(CommandTimeoutEntry entry, String value) { try { - entry.fTimeout = Integer.decode( value ); + entry.fTimeout = Integer.decode(value); return true; - } - catch( NumberFormatException e ) { + } catch (NumberFormatException e) { // Shouldn't happen, validator takes care of this case. } return false; } @Override - Object doGetValue( CommandTimeoutEntry entry ) { + Object doGetValue(CommandTimeoutEntry entry) { return entry.fTimeout.toString(); } @@ -500,16 +495,16 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements private Button fTimeoutAdvancedButton; private CustomTimeoutsMap fCustomTimeouts; - + public GdbDebugPreferencePage() { super(FLAT); - IPreferenceStore store= GdbUIPlugin.getDefault().getPreferenceStore(); + IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); setPreferenceStore(store); setDescription(MessagesForPreferences.GdbDebugPreferencePage_description); fCustomTimeouts = new CustomTimeoutsMap(); } - @Override + @Override public void init(IWorkbench workbench) { } @@ -529,9 +524,9 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements @Override protected void createFieldEditors() { - final Composite parent= getFieldEditorParent(); - final GridLayout layout= new GridLayout(); - layout.marginWidth= 0; + final Composite parent = getFieldEditorParent(); + final GridLayout layout = new GridLayout(); + layout.marginWidth = 0; parent.setLayout(layout); final Group group1 = new Group(parent, SWT.NONE); @@ -542,8 +537,7 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements final StringFieldEditor stringFieldEditorCommand = new StringFieldEditor( IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, - MessagesForPreferences.GdbDebugPreferencePage_GDB_debugger, - group1); + MessagesForPreferences.GdbDebugPreferencePage_GDB_debugger, group1); stringFieldEditorCommand.fillIntoGrid(group1, 2); GridData stringFieldLayoutData = (GridData) stringFieldEditorCommand.getTextControl(group1).getLayoutData(); @@ -559,12 +553,11 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements stringFieldEditorCommand); } }); - setButtonLayoutData( browsebutton ); + setButtonLayoutData(browsebutton); final StringFieldEditor stringFieldEditorGdbInit = new StringFieldEditor( IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_INIT, - MessagesForPreferences.GdbDebugPreferencePage_GDB_command_file, - group1); + MessagesForPreferences.GdbDebugPreferencePage_GDB_command_file, group1); stringFieldEditorGdbInit.fillIntoGrid(group1, 2); addField(stringFieldEditorGdbInit); @@ -577,116 +570,100 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements stringFieldEditorGdbInit); } }); - setButtonLayoutData( browsebutton ); + setButtonLayoutData(browsebutton); final StringWithBooleanFieldEditor enableStopAtMain = new StringWithBooleanFieldEditor( IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN, IGdbDebugPreferenceConstants.PREF_DEFAULT_STOP_AT_MAIN_SYMBOL, - MessagesForPreferences.GdbDebugPreferencePage_Stop_on_startup_at, - group1); + MessagesForPreferences.GdbDebugPreferencePage_Stop_on_startup_at, group1); enableStopAtMain.fillIntoGrid(group1, 3); addField(enableStopAtMain); - - fCommandTimeoutField = new IntegerWithBooleanFieldEditor( - IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, - IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, - MessagesForPreferences.GdbDebugPreferencePage_Command_timeout, - group1); + + fCommandTimeoutField = new IntegerWithBooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, + IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, + MessagesForPreferences.GdbDebugPreferencePage_Command_timeout, group1); fCommandTimeoutField.setValidRange(0, Integer.MAX_VALUE); fCommandTimeoutField.fillIntoGrid(group1, 2); addField(fCommandTimeoutField); - + fTimeoutAdvancedButton = new Button(group1, SWT.PUSH); fTimeoutAdvancedButton.setText(MessagesForPreferences.GdbDebugPreferencePage_Advanced_button); fTimeoutAdvancedButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - handleAdvancedButtonSelected( - MessagesForPreferences.GdbDebugPreferencePage_GDB_debugger_dialog_title); + handleAdvancedButtonSelected(MessagesForPreferences.GdbDebugPreferencePage_GDB_debugger_dialog_title); } }); - setButtonLayoutData( fTimeoutAdvancedButton ); + setButtonLayoutData(fTimeoutAdvancedButton); - final ListenableBooleanFieldEditor enableNonStop= new ListenableBooleanFieldEditor( + final ListenableBooleanFieldEditor enableNonStop = new ListenableBooleanFieldEditor( IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, - MessagesForPreferences.GdbDebugPreferencePage_Non_stop_mode, - SWT.NONE, group1); + MessagesForPreferences.GdbDebugPreferencePage_Non_stop_mode, SWT.NONE, group1); enableNonStop.fillIntoGrid(group1, 3); addField(enableNonStop); - if (Platform.getOS().startsWith("win")) { //$NON-NLS-1$ + if (Platform.getOS().startsWith("win")) { //$NON-NLS-1$ BooleanFieldEditor externalConsoleField = new BooleanFieldEditor( IGdbDebugPreferenceConstants.PREF_EXTERNAL_CONSOLE, - MessagesForPreferences.GdbDebugPreferencePage_external_console, - group1); - + MessagesForPreferences.GdbDebugPreferencePage_external_console, group1); + externalConsoleField.fillIntoGrid(group1, 3); addField(externalConsoleField); - } + } final StringWithBooleanFieldEditor remoteTimeout = new StringWithBooleanFieldEditor( IGdbDebugPreferenceConstants.PREF_DEFAULT_REMOTE_TIMEOUT_ENABLED, IGdbDebugPreferenceConstants.PREF_DEFAULT_REMOTE_TIMEOUT_VALUE, - MessagesForPreferences.GdbDebugPreferencePage_remoteTimeout_label, - group1); - remoteTimeout.getCheckboxControl(group1).setToolTipText(MessagesForPreferences.GdbDebugPreferencePage_remoteTimeout_tooltip); - remoteTimeout.getTextControl(group1).setToolTipText(MessagesForPreferences.GdbDebugPreferencePage_remoteTimeout_tooltip); + MessagesForPreferences.GdbDebugPreferencePage_remoteTimeout_label, group1); + remoteTimeout.getCheckboxControl(group1) + .setToolTipText(MessagesForPreferences.GdbDebugPreferencePage_remoteTimeout_tooltip); + remoteTimeout.getTextControl(group1) + .setToolTipText(MessagesForPreferences.GdbDebugPreferencePage_remoteTimeout_tooltip); remoteTimeout.fillIntoGrid(group1, 3); addField(remoteTimeout); - group1.setLayout(groupLayout); - final Group group2= new Group(parent, SWT.NONE); + final Group group2 = new Group(parent, SWT.NONE); group2.setText(MessagesForPreferences.GdbDebugPreferencePage_general_behavior_label); - groupLayout= new GridLayout(3, false); + groupLayout = new GridLayout(3, false); group2.setLayout(groupLayout); group2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - BooleanFieldEditor boolField= new BooleanFieldEditor( - IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, - MessagesForPreferences.GdbDebugPreferencePage_autoTerminateGdb_label, - group2); + BooleanFieldEditor boolField = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, + MessagesForPreferences.GdbDebugPreferencePage_autoTerminateGdb_label, group2); boolField.fillIntoGrid(group2, 3); addField(boolField); // Need to set layout again. group2.setLayout(groupLayout); - boolField= new BooleanFieldEditor( - IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, - MessagesForPreferences.GdbDebugPreferencePage_useInspectorHover_label, - group2); + boolField = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, + MessagesForPreferences.GdbDebugPreferencePage_useInspectorHover_label, group2); boolField.fillIntoGrid(group2, 3); addField(boolField); // need to set layout again group2.setLayout(groupLayout); - boolField= new BooleanFieldEditor( - IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS, - MessagesForPreferences.GdbDebugPreferencePage_hideRunningThreads, - group2); + boolField = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS, + MessagesForPreferences.GdbDebugPreferencePage_hideRunningThreads, group2); boolField.fillIntoGrid(group2, 3); addField(boolField); // Need to set layout again. group2.setLayout(groupLayout); - boolField= new BooleanFieldEditor( - IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, - MessagesForPreferences.GdbDebugPreferencePage_useAggressiveBpFilter, - group2); + boolField = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, + MessagesForPreferences.GdbDebugPreferencePage_useAggressiveBpFilter, group2); boolField.fillIntoGrid(group2, 3); addField(boolField); // Need to set layout again. group2.setLayout(groupLayout); - - boolField= new BooleanFieldEditor( - IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, - MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label, - group2); + + boolField = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, + MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label, group2); boolField.fillIntoGrid(group2, 1); addField(boolField); @@ -698,12 +675,11 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements // couple the two fields using IntegerWithBooleanFieldEditor because // we want the gdb traces limit to stay enabled even when the gdb traces // are not actually shown (when the above preference is not selected). - // The reason is that since the gdb traces record even when they are not + // The reason is that since the gdb traces record even when they are not // shown, we want the user to be able to set the limit on those consoles, // even if they are not currently shown. final IntegerFieldEditor gdbTracesLimit = new IntegerFieldEditor( - IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, - "", // Empty title as we reuse the string of the previous field //$NON-NLS-1$ + IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, "", // Empty title as we reuse the string of the previous field //$NON-NLS-1$ group2); // Instead of using Integer.MAX_VALUE which is some obscure number, @@ -714,10 +690,9 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements // Need to set layout again. group2.setLayout(groupLayout); - boolField= new BooleanFieldEditor( - IGdbDebugPreferenceConstants.PREF_USE_RTTI, + boolField = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_USE_RTTI, MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label1 + " \n" //$NON-NLS-1$ - + MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label2, + + MessagesForPreferences.GdbDebugPreferencePage_use_rtti_label2, group2); boolField.fillIntoGrid(group2, 3); @@ -734,7 +709,7 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements final ListenableBooleanFieldEditor enablePrettyPrintingField = new ListenableBooleanFieldEditor( IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING, MessagesForPreferences.GdbDebugPreferencePage_enablePrettyPrinting_label1 + " \n" //$NON-NLS-1$ - + MessagesForPreferences.GdbDebugPreferencePage_enablePrettyPrinting_label2, + + MessagesForPreferences.GdbDebugPreferencePage_enablePrettyPrinting_label2, SWT.NONE, group); enablePrettyPrintingField.fillIntoGrid(group, 3); @@ -749,14 +724,13 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements final IntegerFieldEditor childCountLimitField = new IntegerFieldEditor( IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, - MessagesForPreferences.GdbDebugPreferencePage_initialChildCountLimitForCollections_label, - indentHelper); + MessagesForPreferences.GdbDebugPreferencePage_initialChildCountLimitForCollections_label, indentHelper); childCountLimitField.setValidRange(1, 10000); childCountLimitField.fillIntoGrid(indentHelper, 3); - boolean prettyPrintingEnabled = - getPreferenceStore().getBoolean(IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING); + boolean prettyPrintingEnabled = getPreferenceStore() + .getBoolean(IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING); childCountLimitField.setEnabled(prettyPrintingEnabled, indentHelper); addField(childCountLimitField); @@ -790,9 +764,9 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements } private void handleAdvancedButtonSelected(String dialogTitle) { - AdvancedTimeoutSettingsDialog dialog = - new AdvancedTimeoutSettingsDialog( getShell(), fCustomTimeouts.entrySet() ); - if ( dialog.open() == Window.OK ) { + AdvancedTimeoutSettingsDialog dialog = new AdvancedTimeoutSettingsDialog(getShell(), + fCustomTimeouts.entrySet()); + if (dialog.open() == Window.OK) { fCustomTimeouts = dialog.getResult(); } } @@ -803,19 +777,19 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements } @Override - public void propertyChange( PropertyChangeEvent event ) { - if ( event.getSource().equals( fCommandTimeoutField ) && event.getNewValue() instanceof Boolean ) { - fTimeoutAdvancedButton.setEnabled( ((Boolean)event.getNewValue()).booleanValue() ); + public void propertyChange(PropertyChangeEvent event) { + if (event.getSource().equals(fCommandTimeoutField) && event.getNewValue() instanceof Boolean) { + fTimeoutAdvancedButton.setEnabled(((Boolean) event.getNewValue()).booleanValue()); } - super.propertyChange( event ); + super.propertyChange(event); } @Override protected void performDefaults() { IPreferenceStore store = getPreferenceStore(); - if ( store != null ) { - String memento = store.getDefaultString( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS ); - fCustomTimeouts.initializeFromMemento( memento ); + if (store != null) { + String memento = store.getDefaultString(IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS); + fCustomTimeouts.initializeFromMemento(memento); } super.performDefaults(); updateTimeoutButtons(); @@ -823,19 +797,20 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements @Override public boolean performOk() { - getPreferenceStore().setValue( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS, fCustomTimeouts.getMemento() ); + getPreferenceStore().setValue(IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS, + fCustomTimeouts.getMemento()); return super.performOk(); } private void updateTimeoutButtons() { - fTimeoutAdvancedButton.setEnabled( fCommandTimeoutField.getBooleanValue() ); + fTimeoutAdvancedButton.setEnabled(fCommandTimeoutField.getBooleanValue()); } private void initializeCustomTimeouts() { IPreferenceStore store = getPreferenceStore(); - if ( store != null ) { - String memento = store.getString( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS ); - fCustomTimeouts.initializeFromMemento( memento ); + if (store != null) { + String memento = store.getString(IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS); + fCustomTimeouts.initializeFromMemento(memento); } } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java index 6a148e96ba1..1cfb06ae6e4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java @@ -81,7 +81,7 @@ class MessagesForPreferences extends NLS { public static String GdbConsolePreferencePage_BufferLines; public static String GdbDebugPreferencePage_remoteTimeout_label; public static String GdbDebugPreferencePage_remoteTimeout_tooltip; - + static { // initialize resource bundle NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/ReverseDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/ReverseDebugPreferencePage.java index 77cce5bc7bf..e37b76780c1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/ReverseDebugPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/ReverseDebugPreferencePage.java @@ -25,30 +25,30 @@ import org.eclipse.ui.IWorkbenchPreferencePage; public class ReverseDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public ReverseDebugPreferencePage() { - super( GRID ); + super(GRID); IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); - setPreferenceStore( store ); + setPreferenceStore(store); } @Override protected void createFieldEditors() { - FieldEditor edit = new RadioGroupFieldEditor( - IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_HARDWARE, - MessagesForPreferences.ReverseDebugPreferencePage_SelectHardwareTracingMethod, - 1, + FieldEditor edit = new RadioGroupFieldEditor(IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_HARDWARE, + MessagesForPreferences.ReverseDebugPreferencePage_SelectHardwareTracingMethod, 1, new String[][] { - {MessagesForPreferences.ReverseDebugPreferencePage_GDBPreference, IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_GDB_TRACE}, - {MessagesForPreferences.ReverseDebugPreferencePage_BranchTrace, IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_BRANCH_TRACE}, - {MessagesForPreferences.ReverseDebugPreferencePage_ProcessorTrace, IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_PROCESSOR_TRACE} - }, - getFieldEditorParent() ); - edit.fillIntoGrid( getFieldEditorParent(), 1 ); - getPreferenceStore().setDefault( IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_HARDWARE, - IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_GDB_TRACE ); - addField( edit ); + { MessagesForPreferences.ReverseDebugPreferencePage_GDBPreference, + IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_GDB_TRACE }, + { MessagesForPreferences.ReverseDebugPreferencePage_BranchTrace, + IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_BRANCH_TRACE }, + { MessagesForPreferences.ReverseDebugPreferencePage_ProcessorTrace, + IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_PROCESSOR_TRACE } }, + getFieldEditorParent()); + edit.fillIntoGrid(getFieldEditorParent(), 1); + getPreferenceStore().setDefault(IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_HARDWARE, + IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_GDB_TRACE); + addField(edit); } @Override - public void init( IWorkbench workbench ) { + public void init(IWorkbench workbench) { } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/sync/GdbDebugContextSyncManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/sync/GdbDebugContextSyncManager.java index 5adb8456672..58beed0fc57 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/sync/GdbDebugContextSyncManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/sync/GdbDebugContextSyncManager.java @@ -50,9 +50,8 @@ public class GdbDebugContextSyncManager implements IDebugContextListener { if (context != null) { final IDMContext dmc = context.getAdapter(IDMContext.class); - if (dmc instanceof IMIContainerDMContext || - dmc instanceof IMIExecutionDMContext || - dmc instanceof IFrameDMContext) { + if (dmc instanceof IMIContainerDMContext || dmc instanceof IMIExecutionDMContext + || dmc instanceof IFrameDMContext) { // A process, thread or stack frame was selected. In each case, have GDB switch to the new // corresponding thread, if required. @@ -72,9 +71,9 @@ public class GdbDebugContextSyncManager implements IDebugContextListener { eventSessionId); IGDBFocusSynchronizer gdbSync = tracker.getService(IGDBFocusSynchronizer.class); tracker.dispose(); - + if (gdbSync != null) { - gdbSync.setFocus(new IDMContext[] {dmc}, new ImmediateRequestMonitor() { + gdbSync.setFocus(new IDMContext[] { dmc }, new ImmediateRequestMonitor() { @Override protected void handleFailure() { // do not set error - it's normal in some cases to fail to switch thread diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/CollectActionPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/CollectActionPage.java index f26c50ae600..c98e563ef1a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/CollectActionPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/CollectActionPage.java @@ -42,11 +42,12 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi */ private class IllegalCollectStringLimitException extends Exception { private static final long serialVersionUID = -2087722354642237691L; + public IllegalCollectStringLimitException(String message) { super(message); } } - + private Text fCollectString; private Button fTreatCharPtrAsStrings; private Text fTreatCharPtrAsStringsLimit; @@ -69,7 +70,7 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi fCollectString = new Text(composite, SWT.BORDER); fCollectString.setText(fCollectAction.getCollectString()); fCollectString.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); - + // An option to collect character pointers as strings fTreatCharPtrAsStrings = new Button(composite, SWT.CHECK); GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1); @@ -85,14 +86,15 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi // Disable/enable the limit field fTreatCharPtrAsStringsLimit.setEnabled(fTreatCharPtrAsStrings.getSelection()); } + @Override public void widgetDefaultSelected(SelectionEvent e) { // Disable/enable the limit field fTreatCharPtrAsStringsLimit.setEnabled(fTreatCharPtrAsStrings.getSelection()); } }); - - // A label asking for an optional limit of bytes of collected strings + + // A label asking for an optional limit of bytes of collected strings final Label limitLabel = new Label(composite, SWT.NONE); gd = new GridData(SWT.CENTER, SWT.CENTER, false, false); gd.horizontalIndent = buttonWidth; @@ -103,12 +105,13 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi fTreatCharPtrAsStringsLimit = new Text(composite, SWT.BORDER); fTreatCharPtrAsStringsLimit.setText(getCharPtrAsStringLimit(fCollectAction.getCharPtrAsStringsLimit())); - gd = new GridData(SWT.FILL, SWT.CENTER, false, false); - gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); + gd = new GridData(SWT.FILL, SWT.CENTER, false, false); + gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); fTreatCharPtrAsStringsLimit.setLayoutData(gd); fTreatCharPtrAsStringsLimit.setEnabled(fTreatCharPtrAsStrings.getSelection()); - final ControlDecoration decoration = new ControlDecoration(fTreatCharPtrAsStringsLimit, SWT.TOP | SWT.LEFT, composite ); + final ControlDecoration decoration = new ControlDecoration(fTreatCharPtrAsStringsLimit, SWT.TOP | SWT.LEFT, + composite); decoration.hide(); fTreatCharPtrAsStringsLimit.addModifyListener(new ModifyListener() { @Override @@ -117,16 +120,14 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi getCharPtrAsStringLimit(fTreatCharPtrAsStringsLimit.getText()); decoration.hide(); } catch (IllegalCollectStringLimitException exception) { - decoration.setImage( - FieldDecorationRegistry.getDefault().getFieldDecoration( - FieldDecorationRegistry.DEC_ERROR).getImage()); + decoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoration.setDescriptionText(exception.getMessage()); decoration.show(); - } + } } }); - return composite; } @@ -134,15 +135,15 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi return fCollectAction; } - @Override + @Override public void actionDialogCanceled() { } - @Override + @Override public void actionDialogOK() { fCollectAction.setCollectString(fCollectString.getText()); fCollectAction.setCharPtrAsStrings(fTreatCharPtrAsStrings.getSelection()); - + try { Integer limit = getCharPtrAsStringLimit(fTreatCharPtrAsStringsLimit.getText()); fCollectAction.setCharPtrAsStringsLimit(limit); @@ -151,43 +152,46 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi } } - @Override + @Override public Composite createComposite(IBreakpointAction action, Composite composite, int style) { fCollectAction = (CollectAction) action; return createCollectActionComposite(composite, style); } - /** - * Convert the user-specified string into an integer. - * If the string is not valid, disable the limit by using null. - * @param limitStr The string provided by the user - * @return An non-negative integer limit, or null for no limit. - */ - private Integer getCharPtrAsStringLimit(String limitStr) throws IllegalCollectStringLimitException { - limitStr = limitStr.trim(); - Integer limit = null; + /** + * Convert the user-specified string into an integer. + * If the string is not valid, disable the limit by using null. + * @param limitStr The string provided by the user + * @return An non-negative integer limit, or null for no limit. + */ + private Integer getCharPtrAsStringLimit(String limitStr) throws IllegalCollectStringLimitException { + limitStr = limitStr.trim(); + Integer limit = null; try { limit = Integer.parseInt(limitStr); if (limit < 0) { - throw new IllegalCollectStringLimitException(MessagesForTracepointActions.TracepointActions_Collect_Strings_Limit_Error); + throw new IllegalCollectStringLimitException( + MessagesForTracepointActions.TracepointActions_Collect_Strings_Limit_Error); } } catch (NumberFormatException e) { if (!limitStr.isEmpty()) { // We only accept an empty string, which means no limit - throw new IllegalCollectStringLimitException(MessagesForTracepointActions.TracepointActions_Collect_Strings_Limit_Error); + throw new IllegalCollectStringLimitException( + MessagesForTracepointActions.TracepointActions_Collect_Strings_Limit_Error); } } return limit; - } - - /** - * Convert the integer limit into a string. - * If the string is not valid, disable the limit by using null. - * @param limit The integer limit to convert. Can be null for no limit. - * @return The limit as a string, where no limit or a negative limit is the empty string. - */ - private String getCharPtrAsStringLimit(Integer limit) { - if (limit == null || limit < 0) return ""; //$NON-NLS-1$ + } + + /** + * Convert the integer limit into a string. + * If the string is not valid, disable the limit by using null. + * @param limit The integer limit to convert. Can be null for no limit. + * @return The limit as a string, where no limit or a negative limit is the empty string. + */ + private String getCharPtrAsStringLimit(Integer limit) { + if (limit == null || limit < 0) + return ""; //$NON-NLS-1$ return Integer.toString(limit); - } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/EvaluateActionPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/EvaluateActionPage.java index 5defe9f1a7e..330c9d6c687 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/EvaluateActionPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/EvaluateActionPage.java @@ -46,25 +46,24 @@ public class EvaluateActionPage extends PlatformObject implements IBreakpointAct fEvalString = new Text(composite, SWT.BORDER); fEvalString.setText(fEvalAction.getEvalString()); fEvalString.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + return composite; } - public EvaluateAction getEvalAction() { return fEvalAction; } - @Override + @Override public void actionDialogCanceled() { } - @Override + @Override public void actionDialogOK() { fEvalAction.setEvalString(fEvalString.getText()); } - @Override + @Override public Composite createComposite(IBreakpointAction action, Composite composite, int style) { fEvalAction = (EvaluateAction) action; return createEvaluateActionComposite(composite, style); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/MessagesForTracepointActions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/MessagesForTracepointActions.java index 13a0910fea5..510f0aef1e6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/MessagesForTracepointActions.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/MessagesForTracepointActions.java @@ -21,7 +21,7 @@ import org.eclipse.osgi.util.NLS; * @since 2.1 */ class MessagesForTracepointActions extends NLS { - private static final String BUNDLE_NAME= "org.eclipse.cdt.dsf.gdb.internal.ui.tracepointactions.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.eclipse.cdt.dsf.gdb.internal.ui.tracepointactions.messages"; //$NON-NLS-1$ public static String TracepointActions_Actions_for_this_tracepoint; public static String TracepointActions_Available_actions; @@ -46,7 +46,7 @@ class MessagesForTracepointActions extends NLS { public static String TracepointActions_Collect_Strings_Label; public static String TracepointActions_Collect_Strings_Limit_Label; public static String TracepointActions_Collect_Strings_Limit_Error; - + static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, MessagesForTracepointActions.class); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionDialog.java index 71dd27a68f0..09ec33f5b62 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionDialog.java @@ -63,8 +63,8 @@ public class TracepointActionDialog extends Dialog { private static final String TRACEPOINT_ACTION_DIALOG_LAST_SELECTED = "TracepointActionDialog.lastSelectedAction"; //$NON-NLS-1$ private static final int TRACEPOINT_ACTIONS_COUNT = 3; - - private Composite actionArea; + + private Composite actionArea; private Composite[] actionComposites; private ITracepointAction tracepointAction; private IBreakpointActionPage actionPage; @@ -77,20 +77,20 @@ public class TracepointActionDialog extends Dialog { private int lastSelectedActionTypeIndex; private IBreakpointAction originalAction; private boolean isSubAction; - + // If this dialog is for a "while-stepping" action, we keep track // of the parent global list, so that it can be updated. private TracepointGlobalActionsList parentGlobalList; private IExtension[] breakpointActionPageExtensions; - + private static final Point MINIMUM_SIZE = new Point(440, 540); /** * Create the dialog */ - public TracepointActionDialog(Shell parentShell, ITracepointAction action, - TracepointGlobalActionsList parentList, boolean isSub) { + public TracepointActionDialog(Shell parentShell, ITracepointAction action, TracepointGlobalActionsList parentList, + boolean isSub) { super(parentShell); setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE); originalAction = action; @@ -161,14 +161,16 @@ public class TracepointActionDialog extends Dialog { tracepointActions.add(new CollectAction()); tracepointActions.add(new EvaluateAction()); // Sub actions of whileStepping cannot be whileStepping - if (!isSubAction) tracepointActions.add(new WhileSteppingAction()); - + if (!isSubAction) + tracepointActions.add(new WhileSteppingAction()); + actionPages = new IBreakpointActionPage[TRACEPOINT_ACTIONS_COUNT]; actionComposites = new Composite[TRACEPOINT_ACTIONS_COUNT]; if (!tracepointActions.isEmpty()) { - String lastTypeName = GdbUIPlugin.getDefault().getPreferenceStore().getString(TRACEPOINT_ACTION_DIALOG_LAST_SELECTED); + String lastTypeName = GdbUIPlugin.getDefault().getPreferenceStore() + .getString(TRACEPOINT_ACTION_DIALOG_LAST_SELECTED); if (tracepointAction != null) { lastTypeName = tracepointAction.getTypeName(); @@ -177,17 +179,17 @@ public class TracepointActionDialog extends Dialog { for (int i = 0; i < tracepointActions.size(); i++) { tracepointActions.get(i).setName(tracepointActions.get(i).getDefaultName()); - String actionTypeName = tracepointActions.get(i).getTypeName(); + String actionTypeName = tracepointActions.get(i).getTypeName(); combo.add(actionTypeName); if (actionTypeName.equals(lastTypeName)) { lastSelectedActionTypeIndex = i; if (tracepointAction != null) { tracepointActions.add(i, tracepointAction); - tracepointActions.remove(i+1); + tracepointActions.remove(i + 1); } } } - + combo.select(lastSelectedActionTypeIndex); if (originalAction != null) combo.setEnabled(false); @@ -224,7 +226,8 @@ public class TracepointActionDialog extends Dialog { @Override protected void okPressed() { if (originalAction == null) - GdbUIPlugin.getDefault().getPreferenceStore().setValue(TRACEPOINT_ACTION_DIALOG_LAST_SELECTED, tracepointAction.getTypeName()); + GdbUIPlugin.getDefault().getPreferenceStore().setValue(TRACEPOINT_ACTION_DIALOG_LAST_SELECTED, + tracepointAction.getTypeName()); String newName = actionNameTextWidget.getText(); if (originalAction == null || !originalAction.getName().equals(newName)) { actionName = TracepointActionManager.getInstance().makeUniqueActionName(newName); @@ -245,11 +248,12 @@ public class TracepointActionDialog extends Dialog { actionPages[selectedTypeIndex] = getActionPage(tracepointActions.get(selectedTypeIndex)); actionPage = actionPages[selectedTypeIndex]; if (actionPage instanceof WhileSteppingActionPage) { - ((WhileSteppingActionPage)actionPage).setParentGlobalList(parentGlobalList); + ((WhileSteppingActionPage) actionPage).setParentGlobalList(parentGlobalList); } } if (actionComposites[selectedTypeIndex] == null) { - Composite actionComposite = actionPages[selectedTypeIndex].createComposite(tracepointAction, actionArea, SWT.NONE); + Composite actionComposite = actionPages[selectedTypeIndex].createComposite(tracepointAction, actionArea, + SWT.NONE); actionComposites[selectedTypeIndex] = actionComposite; } actionName = tracepointAction.getName(); @@ -262,7 +266,8 @@ public class TracepointActionDialog extends Dialog { public IExtension[] getBreakpointActionPageExtensions() { if (breakpointActionPageExtensions == null) { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CDebugUIPlugin.PLUGIN_ID, BREAKPOINT_ACTION_PAGE_EXTENSION_POINT_ID); + IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CDebugUIPlugin.PLUGIN_ID, + BREAKPOINT_ACTION_PAGE_EXTENSION_POINT_ID); if (point == null) breakpointActionPageExtensions = new IExtension[0]; else { @@ -296,22 +301,20 @@ public class TracepointActionDialog extends Dialog { return actionPageResult; } - private void addDecorator(Composite parent, final Text control) { - GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); - gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); + GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); + gd.horizontalIndent = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); control.setLayoutData(gd); - final ControlDecoration decoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT, parent ); + final ControlDecoration decoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT, parent); decoration.hide(); control.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { String name = control.getText(); if (name.trim().isEmpty()) { - decoration.setImage( - FieldDecorationRegistry.getDefault().getFieldDecoration( - FieldDecorationRegistry.DEC_ERROR).getImage()); + decoration.setImage(FieldDecorationRegistry.getDefault() + .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoration.setDescriptionText(Messages.getString("ActionDialog.ErrEmptyName")); //$NON-NLS-1$ decoration.show(); } else { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsList.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsList.java index ad29c8a3adc..87b09b6fa2e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsList.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsList.java @@ -204,9 +204,9 @@ public class TracepointActionsList extends Composite { int[] selectedItems = table.getSelectionIndices(); removeButton.setEnabled(selectedItems.length > 0); downButton.setEnabled(selectedItems.length == 1 && selectedItems[0] < (table.getItemCount() - 1)); - upButton.setEnabled(selectedItems.length == 1 && selectedItems[0] > 0); + upButton.setEnabled(selectedItems.length == 1 && selectedItems[0] > 0); } - + /** * Update the appearance of given action. * @param action diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPreferencePage.java index 5c271ba3669..85a36699346 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPreferencePage.java @@ -47,8 +47,10 @@ public class TracepointActionsPreferencePage extends PreferencePage implements I container.setLayout(gridLayout); final Label breakpointActionsAvailableLabel = new Label(container, SWT.NONE); - breakpointActionsAvailableLabel.setText(MessagesForTracepointActions.TracepointActions_Preferences_Actions_Available); - final TracepointGlobalActionsList actionsList = new TracepointGlobalActionsList(container, SWT.NONE, false, null, false); + breakpointActionsAvailableLabel + .setText(MessagesForTracepointActions.TracepointActions_Preferences_Actions_Available); + final TracepointGlobalActionsList actionsList = new TracepointGlobalActionsList(container, SWT.NONE, false, + null, false); actionsList.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); actionsList.getDeleteButton().addSelectionListener(new SelectionAdapter() { @@ -57,14 +59,13 @@ public class TracepointActionsPreferencePage extends PreferencePage implements I actionsList.HandleDeleteButton(); } }); - String helpContextID = GdbUIPlugin.PLUGIN_ID + "." + contextHelpID; //$NON-NLS-1$ + String helpContextID = GdbUIPlugin.PLUGIN_ID + "." + contextHelpID; //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), helpContextID); return container; } - - @Override + @Override public void init(IWorkbench workbench) { } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPropertyPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPropertyPage.java index 0f9a898b9f8..6db87e98122 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPropertyPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPropertyPage.java @@ -31,7 +31,7 @@ import org.eclipse.ui.dialogs.PropertyPage; /** * Property page for Tracepoint actions - * + * * @since 2.1 */ public class TracepointActionsPropertyPage extends PropertyPage { @@ -89,7 +89,7 @@ public class TracepointActionsPropertyPage extends PropertyPage { // connect attached actions list to global list globalActionsList.setClientList(actionsList); - + globalActionsList.getAttachButton().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -117,7 +117,7 @@ public class TracepointActionsPropertyPage extends PropertyPage { /** * Clean up attached actions that were just deleted from the GlobalActionList - * + * * @since 7.0 */ protected void HandleDeleteButton() { @@ -150,7 +150,8 @@ public class TracepointActionsPropertyPage extends PropertyPage { public boolean performOk() { try { TracepointActionManager.getInstance().saveActionData(); - tracepointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, actionsList.getActionNames()); + tracepointMarker.setAttribute(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE, + actionsList.getActionNames()); } catch (CoreException e) { } return super.performOk(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointGlobalActionsList.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointGlobalActionsList.java index 4edd3f2b060..e0fbf34091f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointGlobalActionsList.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointGlobalActionsList.java @@ -43,17 +43,18 @@ public class TracepointGlobalActionsList extends Composite { private Table table; private TracepointActionsList clientList; private boolean isSubAction; - + // When dealing with a "while-stepping" action, we deal with a "child" global // list, and must keep track of the parent global list, to properly update it. // This field will be null when the this class represents the parent class itself. private TracepointGlobalActionsList parentGlobalList; - public TracepointGlobalActionsList(Composite parent, int style, boolean useAttachButton, TracepointGlobalActionsList parentList, boolean isSub) { + public TracepointGlobalActionsList(Composite parent, int style, boolean useAttachButton, + TracepointGlobalActionsList parentList, boolean isSub) { super(parent, style); isSubAction = isSub; parentGlobalList = parentList; - + final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 5; setLayout(gridLayout); @@ -64,6 +65,7 @@ public class TracepointGlobalActionsList extends Composite { public void widgetSelected(SelectionEvent e) { updateButtons(); } + @Override public void widgetDefaultSelected(SelectionEvent e) { HandleEditButton(); @@ -91,7 +93,8 @@ public class TracepointGlobalActionsList extends Composite { ArrayList<ITracepointAction> actions = TracepointActionManager.getInstance().getActions(); for (ITracepointAction element : actions) { - if (isSubAction && element instanceof WhileSteppingAction) continue; + if (isSubAction && element instanceof WhileSteppingAction) + continue; final TableItem tableItem = new TableItem(table, SWT.NONE); tableItem.setText(0, element.getName()); tableItem.setText(1, element.getTypeName()); @@ -133,7 +136,7 @@ public class TracepointGlobalActionsList extends Composite { deleteButton = new Button(this, SWT.NONE); deleteButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); deleteButton.setText(MessagesForTracepointActions.TracepointActions_Delete); - + updateButtons(); } @@ -176,7 +179,7 @@ public class TracepointGlobalActionsList extends Composite { } updateButtons(); } - + void removeAction(ITracepointAction action) { TableItem[] currentItems = table.getItems(); for (int i = 0; i < currentItems.length; i++) { @@ -188,7 +191,7 @@ public class TracepointGlobalActionsList extends Composite { break; } } - updateButtons(); + updateButtons(); } protected void HandleEditButton() { @@ -219,11 +222,11 @@ public class TracepointGlobalActionsList extends Composite { TracepointActionDialog dialog = new TracepointActionDialog(this.getShell(), null, this, isSubAction); int result = dialog.open(); if (result == Window.OK) { - ITracepointAction action = (ITracepointAction)dialog.getTracepointAction(); + ITracepointAction action = (ITracepointAction) dialog.getTracepointAction(); action.setName(dialog.getActionName()); TracepointActionManager.getInstance().addAction(action); addAction(action); - + if (parentGlobalList != null) { assert isSubAction; // Update the parent list also @@ -239,7 +242,7 @@ public class TracepointGlobalActionsList extends Composite { tableItem.setText(2, action.getSummary()); tableItem.setData(action); } - + public void updateButtons() { TableItem[] selectedItems = table.getSelection(); if (attachButton != null) @@ -247,7 +250,7 @@ public class TracepointGlobalActionsList extends Composite { deleteButton.setEnabled(selectedItems.length > 0); editButton.setEnabled(selectedItems.length == 1); } - + /** * Register client list to be notified of changes to actions. * @param actionsList @@ -255,7 +258,7 @@ public class TracepointGlobalActionsList extends Composite { void setClientList(TracepointActionsList actionsList) { clientList = actionsList; } - + /** * Update the appearance of given action. * @param action diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/WhileSteppingActionPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/WhileSteppingActionPage.java index 4837e3d18f0..887bc452787 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/WhileSteppingActionPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/WhileSteppingActionPage.java @@ -44,7 +44,7 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi * Create the composite */ private Composite createWhileSteppingActionComposite(Composite parent, int style) { - + Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout(2, false)); @@ -58,7 +58,7 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi final Label actionsTriggeredWhenLabel = new Label(composite, SWT.NONE); actionsTriggeredWhenLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); - actionsTriggeredWhenLabel.setText(MessagesForTracepointActions.TracepointActions_WhileStepping_Sub_Actions); + actionsTriggeredWhenLabel.setText(MessagesForTracepointActions.TracepointActions_WhileStepping_Sub_Actions); actionsList = new TracepointActionsList(composite, SWT.NONE); GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL); @@ -117,24 +117,24 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi /** * Clean up attached actions that were just deleted from the GlobalActionList - * + * * @since 7.0 */ protected void HandleDeleteButton() { // attached actions are now handled by the GlobalActionsList - + globalActionsList.HandleDeleteButton(); } - + public WhileSteppingAction getWhileSteppingAction() { return fWhileSteppingAction; } - @Override + @Override public void actionDialogCanceled() { } - @Override + @Override public void actionDialogOK() { // Make sure we are dealing with an int int count = 1; @@ -148,13 +148,13 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi fWhileSteppingAction.setSubActionsContent(actionsList.getActionNames()); } - @Override + @Override public Composite createComposite(IBreakpointAction action, Composite composite, int style) { - fWhileSteppingAction = (WhileSteppingAction)action; + fWhileSteppingAction = (WhileSteppingAction) action; return createWhileSteppingActionComposite(composite, style); } - - void setParentGlobalList(TracepointGlobalActionsList list) { - parentGlobalActionsList = list; - } + + void setParentGlobalList(TracepointGlobalActionsList list) { + parentGlobalActionsList = list; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/AbstractImageRegistry.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/AbstractImageRegistry.java index c107482a4c9..2b506899f72 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/AbstractImageRegistry.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/AbstractImageRegistry.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -31,7 +31,7 @@ import org.osgi.framework.Bundle; /** * Abstract image registry that allows for defining fallback paths for images. * This is copy of <code>org.eclipse.cdt.dsf.debug.internal.ui.disassembly.AbstractImageRegistry</code> - * + * * @since 2.1 */ public abstract class AbstractImageRegistry extends ImageRegistry { @@ -42,7 +42,7 @@ public abstract class AbstractImageRegistry extends ImageRegistry { protected AbstractImageRegistry(Plugin plugin) { fBaseUrl = plugin.getBundle().getEntry("/"); //$NON-NLS-1$ } - + /** * Defines the key for a local image, that must be found below the icons directory * in the plugin. @@ -52,10 +52,10 @@ public abstract class AbstractImageRegistry extends ImageRegistry { * key. */ protected void localImage(String key, String dir, String name) { - if (dir== null || dir.isEmpty()) - fLocations.put(key, new String[] {"icons/" + name}); //$NON-NLS-1$ + if (dir == null || dir.isEmpty()) + fLocations.put(key, new String[] { "icons/" + name }); //$NON-NLS-1$ else - fLocations.put(key, new String[] {"icons/" + dir + "/" + name}); //$NON-NLS-1$ //$NON-NLS-2$ + fLocations.put(key, new String[] { "icons/" + dir + "/" + name }); //$NON-NLS-1$ //$NON-NLS-2$ } /** @@ -69,62 +69,62 @@ public abstract class AbstractImageRegistry extends ImageRegistry { * key. */ protected void externalImage(String key, String plugin, String[] dirs, String name) { - if (plugin != null) { - fPlugins.put(key, plugin); - } - String[] locations = new String[dirs.length]; - for (int i = 0; i < dirs.length; i++) { + if (plugin != null) { + fPlugins.put(key, plugin); + } + String[] locations = new String[dirs.length]; + for (int i = 0; i < dirs.length; i++) { String dir = dirs[i]; - if (dir== null || dir.isEmpty()) + if (dir == null || dir.isEmpty()) locations[i] = "icons/" + name; //$NON-NLS-1$ else locations[i] = "icons/" + dir + "/" + name; //$NON-NLS-1$ //$NON-NLS-2$ - } - fLocations.put(key, locations); + } + fLocations.put(key, locations); } - + // overrider @Override final public Image get(String key) { - Image i = super.get(key); - if (i != null) { - return i; - } - - ImageDescriptor d = createFileImageDescriptor(key); - if (d != null) { - put(key, d); - return super.get(key); - } - return null; + Image i = super.get(key); + if (i != null) { + return i; + } + + ImageDescriptor d = createFileImageDescriptor(key); + if (d != null) { + put(key, d); + return super.get(key); + } + return null; } // overrider @Override final public ImageDescriptor getDescriptor(String key) { - ImageDescriptor d = super.getDescriptor(key); - if (d != null) { - return d; - } - - d = createFileImageDescriptor(key); - if (d != null) { - put(key, d); - return d; - } - return null; + ImageDescriptor d = super.getDescriptor(key); + if (d != null) { + return d; + } + + d = createFileImageDescriptor(key); + if (d != null) { + put(key, d); + return d; + } + return null; } private ImageDescriptor createFileImageDescriptor(String key) { URL url = fBaseUrl; String pluginId = fPlugins.get(key); if (pluginId != null) { - Bundle bundle= Platform.getBundle(pluginId); + Bundle bundle = Platform.getBundle(pluginId); if (bundle != null) { url = bundle.getEntry("/"); //$NON-NLS-1$ } } - String[] locations= fLocations.get(key); + String[] locations = fLocations.get(key); if (locations != null) { for (int i = 0; i < locations.length; i++) { String loc = locations[i]; @@ -136,13 +136,14 @@ public abstract class AbstractImageRegistry extends ImageRegistry { return candidate; } } catch (MalformedURLException e) { - GdbUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Malformed Icon URL", e)); //$NON-NLS-1$ + GdbUIPlugin.getDefault().getLog() + .log(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Malformed Icon URL", e)); //$NON-NLS-1$ } catch (SWTException e) { // try the next one. } } } - return null; + return null; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/CircularProgress.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/CircularProgress.java index e060151c367..e8bcba1a041 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/CircularProgress.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/CircularProgress.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Dmitry Kozlov (Mentor Graphics) - initial API and implementation *******************************************************************************/ @@ -23,16 +23,15 @@ import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; public class CircularProgress extends Canvas { - - private static final String PERCENT_SIGN = "%"; //$NON-NLS-1$ - private static final String PERCENT_TEXT = "100%"; //$NON-NLS-1$ + + private static final String PERCENT_SIGN = "%"; //$NON-NLS-1$ + private static final String PERCENT_TEXT = "100%"; //$NON-NLS-1$ private static final int PROGRESS_WIDTH = 8; private static final int PROGRESS_MARGIN = 2; private static final int PROGRESS_ARC = 15; - final protected int[] fBufferProgressMeasure = {0}; + final protected int[] fBufferProgressMeasure = { 0 }; - public CircularProgress(Composite parent, int flags) - { + public CircularProgress(Composite parent, int flags) { super(parent, flags); addPaintListener(new PaintListener() { @@ -44,27 +43,27 @@ public class CircularProgress extends Canvas { GC gc = new GC(this); Point e = gc.textExtent(PERCENT_TEXT); - int size = e.x + 8 * PROGRESS_MARGIN + 2 * PROGRESS_WIDTH; + int size = e.x + 8 * PROGRESS_MARGIN + 2 * PROGRESS_WIDTH; setBounds(0, 0, size, size); } - + /** * Set progress as number of percent (0-100) */ public void setProgress(int progress) { fBufferProgressMeasure[0] = progress; } - + @Override public Point computeSize(int wHint, int hHint, boolean changed) { return computeSize(wHint, hHint); } - + @Override public Point computeSize(int wHint, int hHint) { return new Point(getBounds().width, getBounds().height); } - + private void onPaint(PaintEvent e) { Rectangle clientArea = getClientArea(); int margin = PROGRESS_MARGIN; @@ -72,10 +71,11 @@ public class CircularProgress extends Canvas { e.gc.setBackground(getParent().getBackground()); e.gc.fillRectangle(0, 0, clientArea.width, clientArea.height); e.gc.setBackground(getParent().getDisplay().getSystemColor(SWT.COLOR_GRAY)); - e.gc.fillOval(margin, margin, clientArea.width-2*margin, clientArea.height-2*margin); + e.gc.fillOval(margin, margin, clientArea.width - 2 * margin, clientArea.height - 2 * margin); e.gc.setBackground(getParent().getBackground()); - e.gc.fillOval(margin+width, margin+width, clientArea.width-2*(margin+width), clientArea.height-2*(margin+width)); - + e.gc.fillOval(margin + width, margin + width, clientArea.width - 2 * (margin + width), + clientArea.height - 2 * (margin + width)); + String progress; e.gc.setBackground(getParent().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); @@ -83,24 +83,26 @@ public class CircularProgress extends Canvas { // Draw usual progress bar and text value in % progress = fBufferProgressMeasure[0] + PERCENT_SIGN; int n = (int) (fBufferProgressMeasure[0] * 3.6); - e.gc.fillArc(margin, margin, clientArea.width-2*margin, clientArea.height-2*margin, 90 , -n ); + e.gc.fillArc(margin, margin, clientArea.width - 2 * margin, clientArea.height - 2 * margin, 90, -n); } else { // Draw constantly moving progress without exact value and text value 100% progress = PERCENT_TEXT; int n = (int) ((fBufferProgressMeasure[0] % 100) * 3.6); // Fill in the full buffer first - e.gc.fillOval(margin, margin, clientArea.width-2*margin, clientArea.height-2*margin); + e.gc.fillOval(margin, margin, clientArea.width - 2 * margin, clientArea.height - 2 * margin); // Move progress bar within the buffer e.gc.setBackground(getParent().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); - e.gc.fillArc(margin, margin, clientArea.width-2*margin, clientArea.height-2*margin, 90 - n - PROGRESS_ARC, - PROGRESS_ARC ); + e.gc.fillArc(margin, margin, clientArea.width - 2 * margin, clientArea.height - 2 * margin, + 90 - n - PROGRESS_ARC, -PROGRESS_ARC); } e.gc.setBackground(getParent().getBackground()); - e.gc.fillOval(margin+width, margin+width, clientArea.width-2*(margin+width), clientArea.width-2*(margin+width)); + e.gc.fillOval(margin + width, margin + width, clientArea.width - 2 * (margin + width), + clientArea.width - 2 * (margin + width)); // Progress % in the text form e.gc.setForeground(getParent().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND)); e.gc.setFont(getParent().getDisplay().getSystemFont()); Point p = e.gc.textExtent(progress); - e.gc.drawText(progress,(clientArea.width - p.x)/2 + 1,(clientArea.height-p.y)/2); + e.gc.drawText(progress, (clientArea.width - p.x) / 2 + 1, (clientArea.height - p.y) / 2); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/FlatButton.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/FlatButton.java index a41a58f9e69..d1d0f2a1673 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/FlatButton.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/FlatButton.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Vladimir Prus (Mentor Graphics) - initial API and implementation * Dmitry Kozlov (Mentor Graphics) - extend to be inheritance-friendly @@ -31,14 +31,14 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TypedListener; public class FlatButton extends Canvas { - + protected String fText; protected int fMargin = 4; protected Cursor fHandCursor; - + public FlatButton(Composite parent, int flags) { super(parent, flags); - + fHandCursor = getDisplay().getSystemCursor(SWT.CURSOR_HAND); setCursor(fHandCursor); @@ -54,48 +54,48 @@ public class FlatButton extends Canvas { public void mouseDown(MouseEvent e) { onSelection(e); } - }); + }); } - - public void addSelectionListener (SelectionListener listener) { - checkWidget (); - if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - TypedListener typedListener = new TypedListener (listener); - addListener (SWT.Selection,typedListener); - addListener (SWT.DefaultSelection,typedListener); + + public void addSelectionListener(SelectionListener listener) { + checkWidget(); + if (listener == null) + SWT.error(SWT.ERROR_NULL_ARGUMENT); + TypedListener typedListener = new TypedListener(listener); + addListener(SWT.Selection, typedListener); + addListener(SWT.DefaultSelection, typedListener); } - + public void setText(String text) { fText = text; } - - public String getText() { + + public String getText() { return fText; } - + public void setMargin(int margin) { fMargin = margin; } - + @Override public Point computeSize(int wHint, int hHint, boolean changed) { return computeSize(wHint, hHint); } - + @Override public Point computeSize(int wHint, int hHint) { - + GC gc = new GC(this); if (fText == null || fText.isEmpty()) { Point e = gc.textExtent("A"); //$NON-NLS-1$ - return new Point(0, e.y + fMargin*2); + return new Point(0, e.y + fMargin * 2); } - - + Point e = gc.textExtent(fText); - return new Point(e.x + fMargin*2, e.y + fMargin*2); + return new Point(e.x + fMargin * 2, e.y + fMargin * 2); } - + protected void onPaint(PaintEvent event) { GC gc = event.gc; Rectangle ca = getClientArea(); @@ -106,29 +106,28 @@ public class FlatButton extends Canvas { float h = mainHSB[0]; float s = mainHSB[1]; float b = mainHSB[2]; - - - Color borderColor = new Color(gc.getDevice(), new RGB(h, s, (float)(b*0.7))); - Color shadowColor = new Color(gc.getDevice(), new RGB(h, s, (float)(b*0.5))); - + + Color borderColor = new Color(gc.getDevice(), new RGB(h, s, (float) (b * 0.7))); + Color shadowColor = new Color(gc.getDevice(), new RGB(h, s, (float) (b * 0.5))); + gc.setForeground(borderColor); - gc.drawRectangle(0, 0, ca.width-1, ca.height-1); - + gc.drawRectangle(0, 0, ca.width - 1, ca.height - 1); + gc.setForeground(shadowColor); - gc.drawLine(0, ca.height-1, ca.width-1, ca.height-1); - - gc.fillRectangle(1, 1, ca.width-2, ca.height-2); - + gc.drawLine(0, ca.height - 1, ca.width - 1, ca.height - 1); + + gc.fillRectangle(1, 1, ca.width - 2, ca.height - 2); + gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT)); gc.drawText(fText, fMargin, fMargin, true); - + borderColor.dispose(); shadowColor.dispose(); } - + protected void onSelection(MouseEvent e) { if (isEnabled()) { notifyListeners(SWT.Selection, null); - } + } } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/FlatRadioButton.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/FlatRadioButton.java index 28109f9c49d..2dab6b20179 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/FlatRadioButton.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/FlatRadioButton.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Dmitry Kozlov (Mentor Graphics) - initial API and implementation *******************************************************************************/ @@ -24,7 +24,7 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; public class FlatRadioButton extends FlatButton { - + protected static final String STATE_OFF_LABEL = "OFF"; //$NON-NLS-1$ protected static final String STATE_ON_LABEL = "ON"; //$NON-NLS-1$ @@ -33,21 +33,21 @@ public class FlatRadioButton extends FlatButton { public FlatRadioButton(Composite parent, int flags) { super(parent, flags); } - + @Override public Point computeSize(int wHint, int hHint) { GC gc = new GC(this); if (fText == null || fText.isEmpty()) { Point e = gc.textExtent("A"); //$NON-NLS-1$ - return new Point(0, e.y + fMargin*2); + return new Point(0, e.y + fMargin * 2); } Point e = gc.textExtent(fText); Point pOn = gc.textExtent(STATE_ON_LABEL); Point pOff = gc.textExtent(STATE_OFF_LABEL); int h = Math.max(pOn.y, pOff.y); - return new Point(e.x + fMargin*4 + Math.max(pOn.x, pOff.x), Math.max(e.y, h) + fMargin*2 ); + return new Point(e.x + fMargin * 4 + Math.max(pOn.x, pOff.x), Math.max(e.y, h) + fMargin * 2); } @Override @@ -63,16 +63,16 @@ public class FlatRadioButton extends FlatButton { float b = mainHSB[2]; Point e = gc.textExtent(fText); - Color borderColor = new Color(gc.getDevice(), new RGB(h, s, (float)(b*0.7))); - Color shadowColor = new Color(gc.getDevice(), new RGB(h, s, (float)(b*0.5))); + Color borderColor = new Color(gc.getDevice(), new RGB(h, s, (float) (b * 0.7))); + Color shadowColor = new Color(gc.getDevice(), new RGB(h, s, (float) (b * 0.5))); gc.setForeground(borderColor); - gc.drawRectangle(0, 0, ca.width-1, ca.height-1); + gc.drawRectangle(0, 0, ca.width - 1, ca.height - 1); gc.setForeground(shadowColor); - gc.drawLine(0, ca.height-1, ca.width-1, ca.height-1); + gc.drawLine(0, ca.height - 1, ca.width - 1, ca.height - 1); - gc.fillRectangle(e.x + fMargin*2 , 1, ca.width - 1 - e.x - fMargin*2 , ca.height-2); + gc.fillRectangle(e.x + fMargin * 2, 1, ca.width - 1 - e.x - fMargin * 2, ca.height - 2); gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_FOREGROUND)); gc.drawText(fText, fMargin, fMargin, true); @@ -81,11 +81,11 @@ public class FlatRadioButton extends FlatButton { Point pOn = gc.textExtent(STATE_ON_LABEL); Point pOff = gc.textExtent(STATE_OFF_LABEL); if (selection) { - int offset = pOn.x < pOff.x ? (pOff.x - pOn.x)/2 : 0; - gc.drawText(STATE_ON_LABEL , e.x + fMargin*3 + offset, fMargin); + int offset = pOn.x < pOff.x ? (pOff.x - pOn.x) / 2 : 0; + gc.drawText(STATE_ON_LABEL, e.x + fMargin * 3 + offset, fMargin); } else { - int offset = pOn.x < pOff.x ? 0 : (pOn.x - pOff.x)/2 ; - gc.drawText(STATE_OFF_LABEL , e.x + fMargin*3 + offset, fMargin); + int offset = pOn.x < pOff.x ? 0 : (pOn.x - pOff.x) / 2; + gc.drawText(STATE_OFF_LABEL, e.x + fMargin * 3 + offset, fMargin); } borderColor.dispose(); @@ -95,10 +95,10 @@ public class FlatRadioButton extends FlatButton { @Override protected void onSelection(MouseEvent e) { if (isEnabled()) { - selection = ! selection; + selection = !selection; notifyListeners(SWT.Selection, null); redraw(); - } + } } public void setSelection(boolean selection) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlModel.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlModel.java index 7690824d623..fc55c146643 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlModel.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlModel.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Dmitry Kozlov (Mentor Graphics) - Trace control view enhancements (Bug 390827) *******************************************************************************/ @@ -65,13 +65,13 @@ import org.eclipse.ui.IWorkbenchWindow; * all DSF debug sessions at the same time. */ public class TraceControlModel { - + private String fDebugSessionId; private DsfServicesTracker fServicesTracker; private volatile IGDBTraceControl fGDBTraceControl; private volatile ITraceTargetDMContext fTargetContext; private TraceControlView fTraceControlView; - + private IDebugContextListener fDebugContextListener = new IDebugContextListener() { @Override public void debugContextChanged(DebugContextEvent event) { @@ -83,7 +83,7 @@ public class TraceControlModel { TraceControlModel(TraceControlView view) { fTraceControlView = view; - + IWorkbenchWindow window = fTraceControlView.getSite().getWorkbenchWindow(); DebugUITools.getDebugContextManager().getContextService(window).addDebugContextListener(fDebugContextListener); updateDebugContext(); @@ -94,35 +94,34 @@ public class TraceControlModel { notifyUI(TracepointsMessages.TraceControlView_trace_status_no_debug_session); return; } - + if (fTargetContext == null || fGDBTraceControl == null) { notifyUI(TracepointsMessages.TraceControlView_trace_status_not_supported); return; } - getSession().getExecutor().execute( - new DsfRunnable() { - @Override - public void run() { - if (fTargetContext != null && fGDBTraceControl != null) { - fGDBTraceControl.getTraceStatus( - fTargetContext, new DataRequestMonitor<ITraceStatusDMData>(getSession().getExecutor(), null) { - @Override - protected void handleCompleted() { - if (isSuccess() && getData() != null) { - notifyUI((ITraceStatusDMData2)getData()); - } else { - notifyUI((ITraceStatusDMData2)null); + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + if (fTargetContext != null && fGDBTraceControl != null) { + fGDBTraceControl.getTraceStatus(fTargetContext, + new DataRequestMonitor<ITraceStatusDMData>(getSession().getExecutor(), null) { + @Override + protected void handleCompleted() { + if (isSuccess() && getData() != null) { + notifyUI((ITraceStatusDMData2) getData()); + } else { + notifyUI((ITraceStatusDMData2) null); + } } - } - }); - } else { - notifyUI((ITraceStatusDMData2)null); - } + }); + } else { + notifyUI((ITraceStatusDMData2) null); } + } }); } - + public void init() { if (fDebugSessionId != null) { debugSessionChanged(); @@ -133,19 +132,20 @@ public class TraceControlModel { public void dispose() { IWorkbenchWindow window = fTraceControlView.getSite().getWorkbenchWindow(); - DebugUITools.getDebugContextManager().getContextService(window).removeDebugContextListener(fDebugContextListener); + DebugUITools.getDebugContextManager().getContextService(window) + .removeDebugContextListener(fDebugContextListener); setDebugContext(null); } - + protected void updateDebugContext() { IAdaptable debugContext = DebugUITools.getDebugContext(); if (debugContext instanceof IDMVMContext) { - setDebugContext((IDMVMContext)debugContext); + setDebugContext((IDMVMContext) debugContext); } else { setDebugContext(null); } } - + protected void setDebugContext(IDMVMContext vmContext) { if (vmContext != null) { IDMContext dmContext = vmContext.getDMContext(); @@ -183,20 +183,20 @@ public class TraceControlModel { session.removeServiceEventListener(TraceControlModel.this); } }); - } catch (RejectedExecutionException e) { - // Session is shut down. - } + } catch (RejectedExecutionException e) { + // Session is shut down. + } } fDebugSessionId = null; fTargetContext = null; if (fServicesTracker != null) { - fServicesTracker.dispose(); + fServicesTracker.dispose(); fServicesTracker = null; } debugSessionChanged(); } } - + private void debugSessionChanged() { if (getSession() != null) { try { @@ -207,10 +207,10 @@ public class TraceControlModel { session.addServiceEventListener(TraceControlModel.this, null); } }); - } catch (RejectedExecutionException e) { - // Session is shut down. - } - } + } catch (RejectedExecutionException e) { + // Session is shut down. + } + } updateContent(); } @@ -219,27 +219,28 @@ public class TraceControlModel { if (getSession() == null) { return; } - - getSession().getExecutor().execute( - new DsfRunnable() { - @Override - public void run() { - if (fTargetContext != null && fGDBTraceControl != null) { - if (fGDBTraceControl instanceof IGDBTraceControl2) { - ((IGDBTraceControl2)fGDBTraceControl).stopTraceVisualization(fTargetContext, new ImmediateRequestMonitor()); - } else { - // Legacy way of stopping visualization of trace data - ITraceRecordDMContext emptyDmc = fGDBTraceControl.createTraceRecordContext(fTargetContext, "-1"); //$NON-NLS-1$ - fGDBTraceControl.selectTraceRecord(emptyDmc, new ImmediateRequestMonitor()); - } + + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + if (fTargetContext != null && fGDBTraceControl != null) { + if (fGDBTraceControl instanceof IGDBTraceControl2) { + ((IGDBTraceControl2) fGDBTraceControl).stopTraceVisualization(fTargetContext, + new ImmediateRequestMonitor()); + } else { + // Legacy way of stopping visualization of trace data + ITraceRecordDMContext emptyDmc = fGDBTraceControl.createTraceRecordContext(fTargetContext, + "-1"); //$NON-NLS-1$ + fGDBTraceControl.selectTraceRecord(emptyDmc, new ImmediateRequestMonitor()); } } - }); + } + }); } /** * Get the list of trace variables from the backend. - * + * * @return null when the list cannot be obtained. */ public ITraceVariableDMData[] getTraceVarList() { @@ -250,21 +251,21 @@ public class TraceControlModel { Query<ITraceVariableDMData[]> query = new Query<ITraceVariableDMData[]>() { @Override protected void execute(final DataRequestMonitor<ITraceVariableDMData[]> rm) { - + if (fTargetContext != null && fGDBTraceControl != null) { fGDBTraceControl.getTraceVariables(fTargetContext, new DataRequestMonitor<ITraceVariableDMData[]>(getSession().getExecutor(), rm) { - @Override - protected void handleCompleted() { - if (isSuccess()) { - rm.setData(getData()); - } else { - rm.setData(null); - } - rm.done(); - }; - - }); + @Override + protected void handleCompleted() { + if (isSuccess()) { + rm.setData(getData()); + } else { + rm.setData(null); + } + rm.done(); + }; + + }); } else { rm.setData(null); rm.done(); @@ -290,33 +291,36 @@ public class TraceControlModel { */ public void createVariable(final String name, final String value) throws FailedTraceVariableCreationException { if (getSession() == null) { - throw new TraceControlView.FailedTraceVariableCreationException(TracepointsMessages.TraceControlView_create_variable_error); + throw new TraceControlView.FailedTraceVariableCreationException( + TracepointsMessages.TraceControlView_create_variable_error); } Query<String> query = new Query<String>() { @Override protected void execute(final DataRequestMonitor<String> rm) { - + if (fTargetContext != null && fGDBTraceControl != null) { - fGDBTraceControl.createTraceVariable(fTargetContext, name, value, + fGDBTraceControl.createTraceVariable(fTargetContext, name, value, new RequestMonitor(getSession().getExecutor(), rm) { - @Override - protected void handleFailure() { - String message = TracepointsMessages.TraceControlView_create_variable_error; - Throwable t = getStatus().getException(); - if (t != null) { - message = t.getMessage(); - } - FailedTraceVariableCreationException e = - new FailedTraceVariableCreationException(message); - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Backend error", e)); //$NON-NLS-1$ - rm.done(); - }; - }); + @Override + protected void handleFailure() { + String message = TracepointsMessages.TraceControlView_create_variable_error; + Throwable t = getStatus().getException(); + if (t != null) { + message = t.getMessage(); + } + FailedTraceVariableCreationException e = new FailedTraceVariableCreationException( + message); + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, + IDsfStatusConstants.INVALID_STATE, "Backend error", e)); //$NON-NLS-1$ + rm.done(); + }; + }); } else { - FailedTraceVariableCreationException e = - new FailedTraceVariableCreationException(TracepointsMessages.TraceControlView_trace_variable_tracing_unavailable); - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Tracing unavailable", e)); //$NON-NLS-1$ + FailedTraceVariableCreationException e = new FailedTraceVariableCreationException( + TracepointsMessages.TraceControlView_trace_variable_tracing_unavailable); + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, + "Tracing unavailable", e)); //$NON-NLS-1$ rm.done(); } } @@ -329,9 +333,9 @@ public class TraceControlModel { } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof CoreException) { - t = ((CoreException)t).getStatus().getException(); + t = ((CoreException) t).getStatus().getException(); if (t instanceof FailedTraceVariableCreationException) { - throw (FailedTraceVariableCreationException)t; + throw (FailedTraceVariableCreationException) t; } } throw new FailedTraceVariableCreationException(TracepointsMessages.TraceControlView_create_variable_error); @@ -343,56 +347,56 @@ public class TraceControlModel { return; } - getSession().getExecutor().execute( - new DsfRunnable() { - @Override - public void run() { - if (fTargetContext != null && fGDBTraceControl != null) { - fGDBTraceControl.getCurrentTraceRecordContext( - fTargetContext, - new ImmediateDataRequestMonitor<ITraceRecordDMContext>() { - @Override - protected void handleSuccess() { - final ITraceRecordDMContext previousDmc = getData(); - ITraceRecordDMContext nextRecord = fGDBTraceControl.createTraceRecordContext(fTargetContext, traceRecordId); - - // Must send the event right away to tell the services we are starting visualization - // If we don't, the services won't behave accordingly soon enough - // Bug 347514 - getSession().dispatchEvent(new TraceRecordSelectedChangedEvent(nextRecord), new Hashtable<String, String>()); - - fGDBTraceControl.selectTraceRecord(nextRecord, new ImmediateRequestMonitor() { - @Override - protected void handleError() { - // If we weren't able to select the next record, we must notify that we are still on the previous one - // since we have already sent a TraceRecordSelectedChangedEvent early, but it didn't happen. - getSession().dispatchEvent(new TraceRecordSelectedChangedEvent(previousDmc), new Hashtable<String, String>()); - } - }); - }; - }); - - + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + if (fTargetContext != null && fGDBTraceControl != null) { + fGDBTraceControl.getCurrentTraceRecordContext(fTargetContext, + new ImmediateDataRequestMonitor<ITraceRecordDMContext>() { + @Override + protected void handleSuccess() { + final ITraceRecordDMContext previousDmc = getData(); + ITraceRecordDMContext nextRecord = fGDBTraceControl + .createTraceRecordContext(fTargetContext, traceRecordId); + + // Must send the event right away to tell the services we are starting visualization + // If we don't, the services won't behave accordingly soon enough + // Bug 347514 + getSession().dispatchEvent(new TraceRecordSelectedChangedEvent(nextRecord), + new Hashtable<String, String>()); + + fGDBTraceControl.selectTraceRecord(nextRecord, new ImmediateRequestMonitor() { + @Override + protected void handleError() { + // If we weren't able to select the next record, we must notify that we are still on the previous one + // since we have already sent a TraceRecordSelectedChangedEvent early, but it didn't happen. + getSession().dispatchEvent(new TraceRecordSelectedChangedEvent(previousDmc), + new Hashtable<String, String>()); + } + }); + }; + }); - } } - }); + } + }); } public void setCircularBuffer(final boolean useCircularBuffer) { if (getSession() == null) { return; } - - getSession().getExecutor().execute( - new DsfRunnable() { - @Override - public void run() { - if (fTargetContext != null && fGDBTraceControl != null && fGDBTraceControl instanceof IGDBTraceControl2) { - ((IGDBTraceControl2)fGDBTraceControl).setCircularTraceBuffer(fTargetContext, useCircularBuffer, new ImmediateRequestMonitor()); - } + + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + if (fTargetContext != null && fGDBTraceControl != null + && fGDBTraceControl instanceof IGDBTraceControl2) { + ((IGDBTraceControl2) fGDBTraceControl).setCircularTraceBuffer(fTargetContext, useCircularBuffer, + new ImmediateRequestMonitor()); } - }); + } + }); } public void setDisconnectedTracing(final boolean disconnected) { @@ -400,15 +404,16 @@ public class TraceControlModel { return; } - getSession().getExecutor().execute( - new DsfRunnable() { - @Override - public void run() { - if (fTargetContext != null && fGDBTraceControl != null && fGDBTraceControl instanceof IGDBTraceControl2) { - ((IGDBTraceControl2)fGDBTraceControl).setDisconnectedTracing(fTargetContext, disconnected, new ImmediateRequestMonitor()); - } + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + if (fTargetContext != null && fGDBTraceControl != null + && fGDBTraceControl instanceof IGDBTraceControl2) { + ((IGDBTraceControl2) fGDBTraceControl).setDisconnectedTracing(fTargetContext, disconnected, + new ImmediateRequestMonitor()); } - }); + } + }); } public void setTraceNotes(final String notes) { @@ -416,36 +421,36 @@ public class TraceControlModel { return; } - getSession().getExecutor().execute( - new DsfRunnable() { - @Override - public void run() { - if (fTargetContext != null && fGDBTraceControl != null && fGDBTraceControl instanceof IGDBTraceControl2) { - ((IGDBTraceControl2)fGDBTraceControl).setTraceNotes(fTargetContext, notes, new ImmediateRequestMonitor()); - } + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + if (fTargetContext != null && fGDBTraceControl != null + && fGDBTraceControl instanceof IGDBTraceControl2) { + ((IGDBTraceControl2) fGDBTraceControl).setTraceNotes(fTargetContext, notes, + new ImmediateRequestMonitor()); } - }); + } + }); } - + private void getGDBTraceControl() { if (getSession() == null) { fGDBTraceControl = null; return; } - getSession().getExecutor().execute( - new DsfRunnable() { - @Override - public void run() { - fGDBTraceControl = getService(IGDBTraceControl.class); - } - }); + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + fGDBTraceControl = getService(IGDBTraceControl.class); + } + }); } private DsfSession getSession() { return DsfSession.getSession(fDebugSessionId); } - + private <V> V getService(Class<V> serviceClass) { if (fServicesTracker != null) { return fServicesTracker.getService(serviceClass); @@ -502,6 +507,7 @@ public class TraceControlModel { public void handleEvent(ITraceRecordSelectedChangedDMEvent event) { updateContent(); } + /* * Since something suspended, might as well refresh our status * to show the latest. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlView.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlView.java index 01551309df6..e3b6d3370ac 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlView.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlView.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - Initial API and implementation * Dmitry Kozlov (Mentor Graphics) - Trace control view enhancements (Bug 390827) @@ -59,9 +59,9 @@ import org.eclipse.ui.progress.UIJob; /** * TraceControlView Part - * + * * This view is used to control Tracing. - * + * * @since 2.1 */ public class TraceControlView extends ViewPart implements IViewPart { @@ -71,10 +71,11 @@ public class TraceControlView extends ViewPart implements IViewPart { protected static final int UI_REFRESH_DELAY = 1000; // milliseconds public static class FailedTraceVariableCreationException extends Exception { - private static final long serialVersionUID = -3042693455630687285L; + private static final long serialVersionUID = -3042693455630687285L; + + FailedTraceVariableCreationException() { + } - FailedTraceVariableCreationException() {} - FailedTraceVariableCreationException(String errorMessage) { super(errorMessage); } @@ -86,9 +87,12 @@ public class TraceControlView extends ViewPart implements IViewPart { private final class RefreshViewAction extends Action { public RefreshViewAction() { setText(TracepointsMessages.TraceControlView_action_Refresh_label); - setImageDescriptor(TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Refresh_enabled)); - setDisabledImageDescriptor(TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Refresh_disabled)); + setImageDescriptor( + TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Refresh_enabled)); + setDisabledImageDescriptor( + TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Refresh_disabled)); } + @Override public void run() { fLastRefreshTime = System.currentTimeMillis(); @@ -104,6 +108,7 @@ public class TraceControlView extends ViewPart implements IViewPart { super(TracepointsMessages.TraceControlView_auto_refresh_action_label, AS_CHECK_BOX); setImageDescriptor(TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Refresh_Auto)); } + @Override public void run() { if (isChecked()) { @@ -125,8 +130,10 @@ public class TraceControlView extends ViewPart implements IViewPart { protected final class DisconnectedTracingAction extends Action { public DisconnectedTracingAction() { super(TracepointsMessages.TraceControlView_action_Disconnected_tracing_label, AS_CHECK_BOX); - setImageDescriptor(TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Disconnected_Tracing)); + setImageDescriptor( + TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Disconnected_Tracing)); } + @Override public void run() { fTraceControlModel.setDisconnectedTracing(isChecked()); @@ -136,8 +143,10 @@ public class TraceControlView extends ViewPart implements IViewPart { protected final class OpenTraceVarDetailsAction extends Action { public OpenTraceVarDetailsAction() { setText(TracepointsMessages.TraceControlView_action_trace_variable_details); - setImageDescriptor(TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Trace_Variables)); + setImageDescriptor( + TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Trace_Variables)); } + @Override public void run() { Shell shell = Display.getDefault().getActiveShell(); @@ -149,8 +158,10 @@ public class TraceControlView extends ViewPart implements IViewPart { protected final class ExitVisualizationModeDetailsAction extends Action { public ExitVisualizationModeDetailsAction() { setText(TracepointsMessages.TraceControlView_action_exit_visualization_mode); - setImageDescriptor(TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Exit_Visualization)); + setImageDescriptor( + TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Exit_Visualization)); } + @Override public void run() { fTraceControlModel.exitVisualizationMode(); @@ -158,7 +169,7 @@ public class TraceControlView extends ViewPart implements IViewPart { // triggered by this asynchronous operation. } } - + protected TraceControlModel fTraceControlModel; protected RefreshViewAction fRefreshViewAction; @@ -175,8 +186,8 @@ public class TraceControlView extends ViewPart implements IViewPart { protected Composite fTopComposite; protected Composite fStatusComposite; - protected Label fStatusLabel; - protected Label fSecondaryStatusLabel; + protected Label fStatusLabel; + protected Label fSecondaryStatusLabel; protected Composite fSecondaryStatusComposite; protected FlatButton fActionButton; @@ -189,13 +200,12 @@ public class TraceControlView extends ViewPart implements IViewPart { protected Label fFrameLabel; protected Label fFrameNumberLabel; protected Slider fFrameSlider; - + protected Composite fNotesComposite; protected Label fNotesContentLabel; protected Text fNotesContentText; protected Button fSetNotesButton; - public TraceControlView() { } @@ -204,7 +214,7 @@ public class TraceControlView extends ViewPart implements IViewPart { super.init(site); fTraceControlModel = new TraceControlModel(this); } - + @Override public void init(IViewSite site, IMemento memento) throws PartInitException { init(site); @@ -214,7 +224,7 @@ public class TraceControlView extends ViewPart implements IViewPart { public void createPartControl(Composite parent) { createActions(); - + fTopComposite = new Composite(parent, SWT.NONE); GridLayout topLayout = new GridLayout(1, false); topLayout.marginWidth = 0; @@ -225,13 +235,13 @@ public class TraceControlView extends ViewPart implements IViewPart { // Tracing status line createStatusLine(fTopComposite); - // Secondary status: start time, stop time and reason + // Secondary status: start time, stop time and reason setSecondaryStatusLineVisible(false, null); // Buffer line createBufferLine(fTopComposite); setBufferLineVisible(false, null, false); - + // Frame line createFrameLine(fTopComposite); setFrameLineVisible(false, null); @@ -239,7 +249,7 @@ public class TraceControlView extends ViewPart implements IViewPart { // Trace notes //createNotesLine(fTopComposite); //setNotesLineVisible(false, null, false); - + fTraceControlModel.init(); } @@ -249,7 +259,7 @@ public class TraceControlView extends ViewPart implements IViewPart { gd.horizontalSpan = 2; gd.minimumHeight = 22; fStatusComposite.setLayoutData(gd); - GridLayout l = new GridLayout(2,false); + GridLayout l = new GridLayout(2, false); l.marginBottom = 0; fStatusComposite.setLayout(l); fStatusComposite.setBackgroundMode(SWT.INHERIT_FORCE); @@ -258,39 +268,40 @@ public class TraceControlView extends ViewPart implements IViewPart { if (cachedBold == null) { FontData fontData = fStatusLabel.getFont().getFontData()[0]; fontData.setStyle(SWT.BOLD); - cachedBold = new Font(fStatusLabel.getDisplay(),fontData); + cachedBold = new Font(fStatusLabel.getDisplay(), fontData); } fStatusLabel.setFont(cachedBold); GridData d = new GridData(SWT.LEFT, SWT.CENTER, false, false); fStatusLabel.setLayoutData(d); fStatusLabel.setText(TracepointsMessages.TraceControlView_trace_status_no_debug_session); fStatusLabel.setBackground(parent.getBackground()); - + fActionButton = new FlatButton(fStatusComposite, SWT.NONE); fActionButton.setText(EMPTY_STRING); GridData acGd = new GridData(SWT.LEFT, SWT.CENTER, false, false); acGd.horizontalIndent = ACTION_BUTTON_INDENTATION; fActionButton.setLayoutData(acGd); fActionButton.addSelectionListener(new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { // Run action IHandlerService handlerService = getSite().getService(IHandlerService.class); if (handlerService == null) { - GdbUIPlugin.log(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Missing command handler service")); //$NON-NLS-1$ - return; + GdbUIPlugin + .log(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Missing command handler service")); //$NON-NLS-1$ + return; } try { - String text = ((FlatButton)e.getSource()).getText(); - if (TracepointsMessages.TraceControlView_action_start.equals(text) || - TracepointsMessages.TraceControlView_action_restart.equals(text)) { + String text = ((FlatButton) e.getSource()).getText(); + if (TracepointsMessages.TraceControlView_action_start.equals(text) + || TracepointsMessages.TraceControlView_action_restart.equals(text)) { handlerService.executeCommand("org.eclipse.cdt.debug.ui.command.startTracing", null); //$NON-NLS-1$ } else if (TracepointsMessages.TraceControlView_action_stop.equals(text)) { handlerService.executeCommand("org.eclipse.cdt.debug.ui.command.stopTracing", null); //$NON-NLS-1$ } else if (TracepointsMessages.TraceControlView_action_finish_visualization.equals(text)) { - fTraceControlModel.exitVisualizationMode(); + fTraceControlModel.exitVisualizationMode(); } // Note that the content of the view will be updated due to the event // triggered by the above operations. There is no point in updating the @@ -302,28 +313,28 @@ public class TraceControlView extends ViewPart implements IViewPart { } }); - + fSecondaryStatusLabel = new Label(fStatusComposite, SWT.NONE | SWT.WRAP); GridData sslGd = new GridData(SWT.FILL, SWT.TOP, true, false); sslGd.horizontalSpan = 2; fSecondaryStatusLabel.setLayoutData(sslGd); fSecondaryStatusLabel.setBackground(parent.getBackground()); - + Label separator = new Label(fStatusComposite, SWT.SEPARATOR | SWT.HORIZONTAL); GridData sGd = new GridData(SWT.FILL, SWT.BOTTOM, true, false); //sGd.heightHint = 3; sGd.horizontalSpan = 2; separator.setLayoutData(sGd); } - + protected void setActionLinkVisible(boolean visible, String text) { fActionButton.setVisible(visible); - fActionButton.setText(visible ? text: EMPTY_STRING); + fActionButton.setText(visible ? text : EMPTY_STRING); } - + private void setSecondaryStatusLineVisible(boolean visible, ITraceStatusDMData2 tData) { fSecondaryStatusLabel.setVisible(visible); - ((GridData)fSecondaryStatusLabel.getLayoutData()).exclude = !visible; + ((GridData) fSecondaryStatusLabel.getLayoutData()).exclude = !visible; if (visible && tData != null) { STOP_REASON_ENUM stopReason = tData.getStopReason(); @@ -339,15 +350,12 @@ public class TraceControlView extends ViewPart implements IViewPart { formatTimeInterval(fLastRefreshTime, System.currentTimeMillis(), true)); } if (tData.getUserName() != null && tData.getUserName().length() > 0) { - user = TracepointsMessages.bind(TracepointsMessages.TraceControlView_trace_status_secondary_user, tData.getUserName()); + user = TracepointsMessages.bind(TracepointsMessages.TraceControlView_trace_status_secondary_user, + tData.getUserName()); } - fSecondaryStatusLabel.setText(TracepointsMessages.bind( - TracepointsMessages.TraceControlView_trace_status_secondary_running, - new Object[] { - formatTime(tData.getStartTime()), - user, - lastRefreshed} - )); + fSecondaryStatusLabel.setText( + TracepointsMessages.bind(TracepointsMessages.TraceControlView_trace_status_secondary_running, + new Object[] { formatTime(tData.getStartTime()), user, lastRefreshed })); } else { // Should not happen if usage is correct fSecondaryStatusLabel.setText(EMPTY_STRING); @@ -356,10 +364,10 @@ public class TraceControlView extends ViewPart implements IViewPart { fSecondaryStatusLabel.setText(EMPTY_STRING); } } - + protected void createNotesLine(final Composite parent) { // Trace notes: notes text and edit notes button - fNotesComposite = new Composite(parent, SWT.NONE); + fNotesComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(3, false); layout.marginWidth = 0; layout.marginHeight = 0; @@ -374,17 +382,17 @@ public class TraceControlView extends ViewPart implements IViewPart { slGd.verticalSpan = 4; separator.setLayoutData(slGd); separator.setBackground(fNotesComposite.getBackground()); - + Label fNotesLabel = new Label(fNotesComposite, SWT.NONE); fNotesLabel.setBackground(parent.getBackground()); fNotesLabel.setText(TracepointsMessages.TraceControlView_trace_notes_label); if (cachedBold != null) { fNotesLabel.setFont(cachedBold); } - + fSetNotesButton = new Button(fNotesComposite, SWT.TOGGLE); - fSetNotesButton.setImage(TracepointImageRegistry.getImageDescriptor( - TracepointImageRegistry.ICON_Edit_enabled).createImage()); + fSetNotesButton.setImage( + TracepointImageRegistry.getImageDescriptor(TracepointImageRegistry.ICON_Edit_enabled).createImage()); fSetNotesButton.setSelection(false); fSetNotesButton.setToolTipText(TracepointsMessages.TraceControlView_trace_notes_edit_tooltip); fSetNotesButton.setLayoutData(new GridData(SWT.END, SWT.TOP, false, false)); @@ -394,14 +402,14 @@ public class TraceControlView extends ViewPart implements IViewPart { handleEditNotesButtonPressed(); } }); - + fNotesContentLabel = new Label(fNotesComposite, SWT.WRAP); fNotesContentLabel.setBackground(parent.getBackground()); fNotesContentLabel.setText(TracepointsMessages.TraceControlView_trace_notes_not_set); GridData nclGd = new GridData(SWT.FILL, SWT.TOP, true, false); nclGd.horizontalSpan = 2; fNotesContentLabel.setLayoutData(nclGd); - + fNotesContentText = new Text(fNotesComposite, SWT.BORDER); fNotesContentText.setVisible(false); GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false); @@ -414,9 +422,9 @@ public class TraceControlView extends ViewPart implements IViewPart { fSetNotesButton.setSelection(false); handleEditNotesButtonPressed(); } - }); + }); fNotesContentText.addKeyListener(new KeyAdapter() { - + @Override public void keyPressed(KeyEvent e) { if (e.keyCode == 0x1b) { @@ -426,21 +434,21 @@ public class TraceControlView extends ViewPart implements IViewPart { } } }); - + } protected void handleEditNotesButtonPressed() { handleEditNotesButtonPressed(false); } - + protected void handleEditNotesButtonPressed(boolean cancelEditing) { boolean isEditMode = fSetNotesButton.getSelection(); fNotesContentLabel.setVisible(!isEditMode); - ((GridData)fNotesContentLabel.getLayoutData()).exclude = isEditMode; - + ((GridData) fNotesContentLabel.getLayoutData()).exclude = isEditMode; + fNotesContentText.setVisible(isEditMode); - ((GridData)fNotesContentText.getLayoutData()).exclude = !isEditMode; - + ((GridData) fNotesContentText.getLayoutData()).exclude = !isEditMode; + fNotesContentText.setFocus(); if (isEditMode) { @@ -461,10 +469,9 @@ public class TraceControlView extends ViewPart implements IViewPart { fTraceControlModel.updateContent(); } - protected void setNotesLineVisible(boolean visible, ITraceStatusDMData2 tData, boolean readonly) { fNotesComposite.setVisible(visible); - ((GridData)fNotesComposite.getLayoutData()).exclude = !visible; + ((GridData) fNotesComposite.getLayoutData()).exclude = !visible; if (visible) { if (tData.getNotes() != null && tData.getNotes().length() > 0) { @@ -473,11 +480,11 @@ public class TraceControlView extends ViewPart implements IViewPart { fNotesContentLabel.setText(TracepointsMessages.TraceControlView_trace_notes_not_set); } if (tData != null && tData.getStartTime() != null) - fSetNotesButton.setEnabled(!readonly); + fSetNotesButton.setEnabled(!readonly); } } - protected void createFrameLine(Composite parent) { + protected void createFrameLine(Composite parent) { fFrameComposite = new Composite(parent, SWT.NONE); GridData fcGd = new GridData(SWT.FILL, SWT.TOP, true, false); fcGd.horizontalSpan = 2; @@ -485,7 +492,7 @@ public class TraceControlView extends ViewPart implements IViewPart { GridLayout layout = new GridLayout(2, false); layout.marginHeight = 0; fFrameComposite.setLayout(layout); - + Label separator = new Label(fFrameComposite, SWT.SEPARATOR | SWT.HORIZONTAL); GridData sepGd = new GridData(SWT.FILL, SWT.CENTER, true, false); sepGd.horizontalSpan = 2; @@ -498,33 +505,33 @@ public class TraceControlView extends ViewPart implements IViewPart { fFrameSlider.setLayoutData(gd2); fFrameSlider.setValues(0, 0, 100, 1, 1, 10); fFrameSlider.addSelectionListener(new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { - IHandlerService handlerService = getSite().getService(IHandlerService.class); - if (e.detail == SWT.ARROW_DOWN) { - try { - handlerService.executeCommand("org.eclipse.cdt.dsf.gdb.ui.command.selectNextTraceRecord", null); //$NON-NLS-1$ - } catch (Exception ex) { - } - } else if (e.detail == SWT.ARROW_UP) { - try { - handlerService.executeCommand("org.eclipse.cdt.dsf.gdb.ui.command.selectPreviousTraceRecord", null); //$NON-NLS-1$ - } catch (Exception ex) { - } - } else if (e.detail == SWT.DRAG) { - // We don't want to query gdb while user drags thumb, just update the label instead - // but postpone actual gdb query to the time thumb is released (e.detail == SWT.NONE) - fFrameNumberLabel.setText(TracepointsMessages.bind( - TracepointsMessages.TraceControlView_frame_dragging, - fFrameSlider.getSelection())); - } else { - fTraceControlModel.setCurrentTraceRecord(Integer.toString(fFrameSlider.getSelection())); - } + IHandlerService handlerService = getSite().getService(IHandlerService.class); + if (e.detail == SWT.ARROW_DOWN) { + try { + handlerService.executeCommand("org.eclipse.cdt.dsf.gdb.ui.command.selectNextTraceRecord", null); //$NON-NLS-1$ + } catch (Exception ex) { + } + } else if (e.detail == SWT.ARROW_UP) { + try { + handlerService.executeCommand("org.eclipse.cdt.dsf.gdb.ui.command.selectPreviousTraceRecord", //$NON-NLS-1$ + null); + } catch (Exception ex) { + } + } else if (e.detail == SWT.DRAG) { + // We don't want to query gdb while user drags thumb, just update the label instead + // but postpone actual gdb query to the time thumb is released (e.detail == SWT.NONE) + fFrameNumberLabel.setText(TracepointsMessages + .bind(TracepointsMessages.TraceControlView_frame_dragging, fFrameSlider.getSelection())); + } else { + fTraceControlModel.setCurrentTraceRecord(Integer.toString(fFrameSlider.getSelection())); + } } - + }); - + fFrameLabel = new Label(fFrameComposite, SWT.NONE); fFrameLabel.setText(TracepointsMessages.TraceControlView_frame_label); fFrameLabel.setLayoutData(new GridData()); @@ -537,8 +544,8 @@ public class TraceControlView extends ViewPart implements IViewPart { protected void setFrameLineVisible(boolean visible, ITraceStatusDMData2 traceData) { fFrameComposite.setVisible(visible); - ((GridData)fFrameComposite.getLayoutData()).exclude = !visible; - + ((GridData) fFrameComposite.getLayoutData()).exclude = !visible; + if (visible) { fFrameSlider.setMinimum(0); if (traceData.getNumberOfCollectedFrame() == 0) { @@ -548,12 +555,12 @@ public class TraceControlView extends ViewPart implements IViewPart { } int inc = traceData.getNumberOfCollectedFrame() / 20; fFrameSlider.setPageIncrement(inc <= 1 ? 2 : inc); - + String fl = EMPTY_STRING; if (traceData.getCurrentTraceFrameId() != null) { fl += TracepointsMessages.bind(TracepointsMessages.TraceControlView_frame_looking, - new Object[] { traceData.getCurrentTraceFrameId(), - Integer.valueOf(traceData.getTracepointNumberForCurrentTraceFrame())} ); + new Object[] { traceData.getCurrentTraceFrameId(), + Integer.valueOf(traceData.getTracepointNumberForCurrentTraceFrame()) }); int recId = 0; try { recId = Integer.parseInt(traceData.getCurrentTraceFrameId()); @@ -561,7 +568,8 @@ public class TraceControlView extends ViewPart implements IViewPart { } fFrameSlider.setSelection(recId); } else { - fl += TracepointsMessages.bind(TracepointsMessages.TraceControlView_frame_not_looking, traceData.getNumberOfCollectedFrame()); + fl += TracepointsMessages.bind(TracepointsMessages.TraceControlView_frame_not_looking, + traceData.getNumberOfCollectedFrame()); fFrameSlider.setSelection(0); } fFrameNumberLabel.setText(fl); @@ -570,9 +578,9 @@ public class TraceControlView extends ViewPart implements IViewPart { fFrameSlider.setEnabled(traceData.getNumberOfCollectedFrame() != 0); } } - + protected void createBufferLine(final Composite parent) { - + fBufferComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(3, false); layout.marginHeight = 0; @@ -580,7 +588,7 @@ public class TraceControlView extends ViewPart implements IViewPart { GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false); fBufferComposite.setLayoutData(gd); fBufferComposite.setBackgroundMode(SWT.INHERIT_FORCE); - + Label fBufferLabel = new Label(fBufferComposite, SWT.NONE); fBufferLabel.setText(TracepointsMessages.TraceControlView_buffer_label); if (cachedBold != null) { @@ -610,7 +618,7 @@ public class TraceControlView extends ViewPart implements IViewPart { fTraceControlModel.updateContent(); } }); - + fBufferCollectedFramesLabel = new Label(fBufferComposite, SWT.WRAP); fBufferCollectedFramesLabel.setText(TracepointsMessages.TraceControlView_buffer_label); GridData gd3 = new GridData(SWT.FILL, SWT.BOTTOM, true, false); @@ -619,49 +627,51 @@ public class TraceControlView extends ViewPart implements IViewPart { protected void setBufferLineVisible(boolean visible, ITraceStatusDMData2 tData, boolean readonly) { fBufferComposite.setVisible(visible); - ((GridData)fBufferComposite.getLayoutData()).exclude = !visible; + ((GridData) fBufferComposite.getLayoutData()).exclude = !visible; - if (visible && tData != null){ - if (tData.getStopReason() != null && tData.getStopReason() == STOP_REASON_ENUM.OVERFLOW){ + if (visible && tData != null) { + if (tData.getStopReason() != null && tData.getStopReason() == STOP_REASON_ENUM.OVERFLOW) { // Buffer overflowed, it should be 100% full instead of 99% fBufferProgress.setProgress(100); - } else if (tData.getStopReason() != null && tData.isCircularBuffer() && tData.getNumberOfCreatedFrames() > tData.getNumberOfCollectedFrame()) { + } else if (tData.getStopReason() != null && tData.isCircularBuffer() + && tData.getNumberOfCreatedFrames() > tData.getNumberOfCollectedFrame()) { // Buffer is circular and overflowed once, it should be 100% full instead of 99% fBufferProgress.setProgress(100); - } else if (tData.isCircularBuffer() && tData.isTracingActive() && - tData.getNumberOfCreatedFrames() > tData.getNumberOfCollectedFrame()) { + } else if (tData.isCircularBuffer() && tData.isTracingActive() + && tData.getNumberOfCreatedFrames() > tData.getNumberOfCollectedFrame()) { // If we run with Circular buffer and all buffer was filled in once, we continue displaying progress 100% // and showing moving bar that makes a circle every tData.getNumberOfCollectedFrame() because it is buffer size in frames - // and actual number of collected frames from the start is tData.getNumberOfCreatedFrames(), but only last + // and actual number of collected frames from the start is tData.getNumberOfCreatedFrames(), but only last // tData.getNumberOfCollectedFrame() are stored in the buffer - int p = (tData.getNumberOfCreatedFrames() % tData.getNumberOfCollectedFrame()) * 100 / tData.getNumberOfCollectedFrame(); + int p = (tData.getNumberOfCreatedFrames() % tData.getNumberOfCollectedFrame()) * 100 + / tData.getNumberOfCollectedFrame(); // 100 is an indicator that buffer is already full and should be showed in different manner fBufferProgress.setProgress(100 + p); } else { - fBufferProgress.setProgress((tData.getTotalBufferSize() - tData.getFreeBufferSize()) * 100 / tData.getTotalBufferSize()); + fBufferProgress.setProgress( + (tData.getTotalBufferSize() - tData.getFreeBufferSize()) * 100 / tData.getTotalBufferSize()); } - + fSetCircularBufferButton.setSelection(tData.isCircularBuffer()); fSetCircularBufferButton.setEnabled(!readonly); - fSetCircularBufferButton.setToolTipText(fSetCircularBufferButton.getSelection() ? - TracepointsMessages.TraceControlView_buffer_circular_on_tooltip : - TracepointsMessages.TraceControlView_buffer_circular_off_tooltip); + fSetCircularBufferButton.setToolTipText(fSetCircularBufferButton.getSelection() + ? TracepointsMessages.TraceControlView_buffer_circular_on_tooltip + : TracepointsMessages.TraceControlView_buffer_circular_off_tooltip); fSetCircularBufferButton.redraw(); fSetCircularBufferButton.update(); - + fBufferCollectedFramesLabel.setText(TracepointsMessages.bind( - TracepointsMessages.TraceControlView_buffer_frames_collected, - tData.getNumberOfCollectedFrame(), - (tData.getTotalBufferSize() - tData.getFreeBufferSize())/1000)); + TracepointsMessages.TraceControlView_buffer_frames_collected, tData.getNumberOfCollectedFrame(), + (tData.getTotalBufferSize() - tData.getFreeBufferSize()) / 1000)); fBufferProgress.redraw(); fBufferProgress.update(); } } - + protected void createActions() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); window.getActivePage().showActionSet("org.eclipse.cdt.debug.ui.tracepointActionSet"); //$NON-NLS-1$ - + IActionBars bars = getViewSite().getActionBars(); IToolBarManager manager = bars.getToolBarManager(); @@ -681,11 +691,11 @@ public class TraceControlView extends ViewPart implements IViewPart { fDisconnectedTracingAction = new DisconnectedTracingAction(); manager.add(fDisconnectedTracingAction); fDisconnectedTracingAction.setEnabled(false); - + // Create the action to open the trace variable details fOpenTraceVarDetails = new OpenTraceVarDetailsAction(); manager.add(fOpenTraceVarDetails); - + // Create the action to exit visualization mode fExitVisualizationAction = new ExitVisualizationModeDetailsAction(); manager.add(fExitVisualizationAction); @@ -693,24 +703,24 @@ public class TraceControlView extends ViewPart implements IViewPart { bars.updateActionBars(); updateActionEnablement(null); } - + @Override public void dispose() { fTraceControlModel.dispose(); - fStatusLabel = null; // Indicate that we have been disposed + fStatusLabel = null; // Indicate that we have been disposed if (refreshUIJob != null) { refreshUIJob.cancel(); } - - if (cachedBold != null) { + + if (cachedBold != null) { cachedBold.dispose(); cachedBold = null; } - + super.dispose(); } - + protected void updateUI(final String statusMessage) { try { fLastTraceData = null; @@ -729,7 +739,7 @@ public class TraceControlView extends ViewPart implements IViewPart { protected void updateUI(final ITraceStatusDMData2 traceData) { fLastTraceData = traceData; - if (traceData == null ) { + if (traceData == null) { // should not happen, but still process it correctly updateUI(TracepointsMessages.TraceControlView_trace_status_inactive); } else if (!traceData.isTracingSupported()) { @@ -741,33 +751,34 @@ public class TraceControlView extends ViewPart implements IViewPart { fStatusLabel.setText(s); setActionLinkVisible(false, EMPTY_STRING); - // If start and stop time are not available in trace data file, do not show secondary status line - if (getTimeMilliseconds(traceData.getStartTime()) != 0 && getTimeMilliseconds(traceData.getStopTime()) != 0) { + // If start and stop time are not available in trace data file, do not show secondary status line + if (getTimeMilliseconds(traceData.getStartTime()) != 0 + && getTimeMilliseconds(traceData.getStopTime()) != 0) { setSecondaryStatusLineVisible(true, traceData); } else { setSecondaryStatusLineVisible(false, traceData); } - //setNotesLineVisible(true, traceData, true); + //setNotesLineVisible(true, traceData, true); setBufferLineVisible(true, traceData, true); - setFrameLineVisible(true, traceData); - + setFrameLineVisible(true, traceData); + updateActionEnablement(traceData); updateLayout(); - - } else if (!traceData.isTracingActive() && traceData.getStopReason() == null){ + + } else if (!traceData.isTracingActive() && traceData.getStopReason() == null) { // Tracing is not started yet fDisconnectedTracingAction.setEnabled(true); fStatusLabel.setText(TracepointsMessages.TraceControlView_trace_status_not_started); - setActionLinkVisible(true,TracepointsMessages.TraceControlView_action_start); + setActionLinkVisible(true, TracepointsMessages.TraceControlView_action_start); setSecondaryStatusLineVisible(false, null); - //setNotesLineVisible(true, traceData, false); + //setNotesLineVisible(true, traceData, false); setBufferLineVisible(true, traceData, false); setFrameLineVisible(false, null); updateActionEnablement(traceData); - updateLayout(); - + updateLayout(); + } else { // Live execution tracing started and running or started and stopped fDisconnectedTracingAction.setEnabled(true); @@ -788,7 +799,7 @@ public class TraceControlView extends ViewPart implements IViewPart { if (traceData.getNumberOfCollectedFrame() == 0) { fStatusLabel.setText(TracepointsMessages.TraceControlView_trace_status_not_started); } else { - fStatusLabel.setText(TracepointsMessages.TraceControlView_trace_status_stopped); + fStatusLabel.setText(TracepointsMessages.TraceControlView_trace_status_stopped); } setActionLinkVisible(true, TracepointsMessages.TraceControlView_action_restart); } @@ -808,7 +819,7 @@ public class TraceControlView extends ViewPart implements IViewPart { updateLayout(); } } - + protected void startRefreshUIJob() { if (refreshUIJob == null) { refreshUIJob = new UIJob("Refresh Trace Control view UI") { //$NON-NLS-1$ @@ -821,14 +832,14 @@ public class TraceControlView extends ViewPart implements IViewPart { // Update the UI to simply say how long ago was the last refresh updateUI(fLastTraceData); } - + return Status.OK_STATUS; } }; } refreshUIJob.schedule(UI_REFRESH_DELAY); } - + protected String getStopMessage(ITraceStatusDMData2 tData) { String stopMessage; STOP_REASON_ENUM fStopReason = tData.getStopReason(); @@ -836,7 +847,9 @@ public class TraceControlView extends ViewPart implements IViewPart { stopMessage = TracepointsMessages.TraceControlView_tracing_stopped_user_request; } else if (fStopReason == STOP_REASON_ENUM.PASSCOUNT) { if (tData.getStoppingTracepoint() != null) { - stopMessage = TracepointsMessages.bind(TracepointsMessages.TraceControlView_tracing_stopped_tracepoint_number, tData.getStoppingTracepoint()); + stopMessage = TracepointsMessages.bind( + TracepointsMessages.TraceControlView_tracing_stopped_tracepoint_number, + tData.getStoppingTracepoint()); } else { stopMessage = TracepointsMessages.TraceControlView_tracing_stopped_passcount; } @@ -852,53 +865,46 @@ public class TraceControlView extends ViewPart implements IViewPart { String user = EMPTY_STRING; if (tData.getUserName() != null && tData.getUserName().length() > 0) { - user = TracepointsMessages.bind(TracepointsMessages.TraceControlView_trace_status_secondary_user, tData.getUserName()); + user = TracepointsMessages.bind(TracepointsMessages.TraceControlView_trace_status_secondary_user, + tData.getUserName()); } if (tData.isTracingFromFile()) { - stopMessage = TracepointsMessages.bind( - TracepointsMessages.TraceControlView_trace_status_secondary_offline, - new Object[] {formatTime(tData.getStartTime()), - user, - formatTime(tData.getStopTime()), - stopMessage - }); + stopMessage = TracepointsMessages.bind(TracepointsMessages.TraceControlView_trace_status_secondary_offline, + new Object[] { formatTime(tData.getStartTime()), user, formatTime(tData.getStopTime()), + stopMessage }); } else { - stopMessage = TracepointsMessages.bind( - TracepointsMessages.TraceControlView_trace_status_secondary_stopped, - new Object[] {formatTimeInterval(tData.getStartTime(),tData.getStopTime()), - user, - formatTime(tData.getStopTime()), - stopMessage - }); - } - + stopMessage = TracepointsMessages.bind(TracepointsMessages.TraceControlView_trace_status_secondary_stopped, + new Object[] { formatTimeInterval(tData.getStartTime(), tData.getStopTime()), user, + formatTime(tData.getStopTime()), stopMessage }); + } + return stopMessage; } protected void updateActionEnablement(ITraceStatusDMData2 traceData) { fOpenTraceVarDetails.setEnabled(traceData != null && traceData.isTracingSupported()); - fExitVisualizationAction.setEnabled(traceData != null && traceData.getCurrentTraceFrameId() != null && - !traceData.isTracingFromFile()); + fExitVisualizationAction.setEnabled( + traceData != null && traceData.getCurrentTraceFrameId() != null && !traceData.isTracingFromFile()); fDisconnectedTracingAction.setChecked(traceData != null && traceData.isDisconnectedTracingEnabled()); } - + @Override public void setFocus() { if (fStatusLabel != null) { fStatusLabel.setFocus(); } } - + public void updateLayout() { fStatusComposite.layout(true); fTopComposite.layout(true); } - + protected long getTimeMilliseconds(String time) { long microseconds = 0; - try { + try { if (time.length() != 0) { - String[] times = time.split("\\."); //$NON-NLS-1$ + String[] times = time.split("\\."); //$NON-NLS-1$ microseconds += Long.parseLong(times[0]) * 1000000; microseconds += Long.parseLong(times[1]); } @@ -908,17 +914,17 @@ public class TraceControlView extends ViewPart implements IViewPart { return microseconds / 1000; } - /** + /** * Format time from gdb presentation into user-understandable form * @param time in gd presentation - * @return + * @return */ protected String formatTime(String time) { long milliseconds = getTimeMilliseconds(time); return formatTime(milliseconds); } - /** + /** * Format time from standard milliseconds since Epoch into user-understandable form */ protected String formatTime(long milliseconds) { @@ -927,77 +933,89 @@ public class TraceControlView extends ViewPart implements IViewPart { long days = TimeUnit.MILLISECONDS.toDays(currentTime - milliseconds); if (days == 0) { // today - return TracepointsMessages.bind(TracepointsMessages.TraceControlView_today, DateFormat.getTimeInstance(DateFormat.SHORT).format(date)); + return TracepointsMessages.bind(TracepointsMessages.TraceControlView_today, + DateFormat.getTimeInstance(DateFormat.SHORT).format(date)); } else if (days == 1) { // yesterday - return TracepointsMessages.bind(TracepointsMessages.TraceControlView_yesterday, DateFormat.getTimeInstance(DateFormat.SHORT).format(date)); + return TracepointsMessages.bind(TracepointsMessages.TraceControlView_yesterday, + DateFormat.getTimeInstance(DateFormat.SHORT).format(date)); } - + return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(date); } /** - * Format time interval returned by trace status command into human-readable + * Format time interval returned by trace status command into human-readable */ protected String formatTimeInterval(String startTime, String stopTime) { long startMicroseconds = 0; long stopMicroseconds = 0; - try { + try { if (startTime.length() != 0) { - String[] times = startTime.split("\\."); //$NON-NLS-1$ + String[] times = startTime.split("\\."); //$NON-NLS-1$ startMicroseconds += Long.parseLong(times[0]) * 1000000; startMicroseconds += Long.parseLong(times[1]); } if (stopTime.length() != 0) { - String[] times = stopTime.split("\\."); //$NON-NLS-1$ + String[] times = stopTime.split("\\."); //$NON-NLS-1$ stopMicroseconds += Long.parseLong(times[0]) * 1000000; stopMicroseconds += Long.parseLong(times[1]); } - return formatTimeInterval(startMicroseconds/1000, stopMicroseconds/1000, true); + return formatTimeInterval(startMicroseconds / 1000, stopMicroseconds / 1000, true); } catch (NumberFormatException ex) { GdbPlugin.log(ex); } return EMPTY_STRING; } - + /** - * Format time interval returned by trace status command into human-readable + * Format time interval returned by trace status command into human-readable */ protected String formatTimeInterval(long startMilliseconds, long stopMilliseconds, boolean shortForm) { long millis = stopMilliseconds - startMilliseconds; long days = TimeUnit.MILLISECONDS.toDays(millis); - millis -= TimeUnit.DAYS.toMillis(days); - long hours = TimeUnit.MILLISECONDS.toHours(millis); - millis -= TimeUnit.HOURS.toMillis(hours); - long minutes = TimeUnit.MILLISECONDS.toMinutes(millis); - millis -= TimeUnit.MINUTES.toMillis(minutes); - long seconds = TimeUnit.MILLISECONDS.toSeconds(millis); - - StringBuilder sb = new StringBuilder(64); - if (!shortForm) { - if (days != 0) sb.append(days).append(TracepointsMessages.TraceControlView_date_days); - if (hours != 0) sb.append(hours).append(TracepointsMessages.TraceControlView_date_hours); - if (minutes != 0) sb.append(minutes).append(TracepointsMessages.TraceControlView_date_minutes); - if (seconds != 0) sb.append(seconds).append(TracepointsMessages.TraceControlView_date_seconds); - if (sb.length() == 0) sb.append(TracepointsMessages.TraceControlView_date_zero); - } else { - if (days != 0) sb.append(days).append(TracepointsMessages.TraceControlView_date_short_days); - if (hours != 0) sb.append(hours).append(TracepointsMessages.TraceControlView_date_short_hours); - if (minutes != 0) sb.append(minutes).append(TracepointsMessages.TraceControlView_date_short_minutes); - if (seconds != 0) sb.append(seconds).append(TracepointsMessages.TraceControlView_date_short_seconds); - if (sb.length() == 0) sb.append(TracepointsMessages.TraceControlView_date_short_zero); - - } - return(sb.toString()); - } - - /** + millis -= TimeUnit.DAYS.toMillis(days); + long hours = TimeUnit.MILLISECONDS.toHours(millis); + millis -= TimeUnit.HOURS.toMillis(hours); + long minutes = TimeUnit.MILLISECONDS.toMinutes(millis); + millis -= TimeUnit.MINUTES.toMillis(minutes); + long seconds = TimeUnit.MILLISECONDS.toSeconds(millis); + + StringBuilder sb = new StringBuilder(64); + if (!shortForm) { + if (days != 0) + sb.append(days).append(TracepointsMessages.TraceControlView_date_days); + if (hours != 0) + sb.append(hours).append(TracepointsMessages.TraceControlView_date_hours); + if (minutes != 0) + sb.append(minutes).append(TracepointsMessages.TraceControlView_date_minutes); + if (seconds != 0) + sb.append(seconds).append(TracepointsMessages.TraceControlView_date_seconds); + if (sb.length() == 0) + sb.append(TracepointsMessages.TraceControlView_date_zero); + } else { + if (days != 0) + sb.append(days).append(TracepointsMessages.TraceControlView_date_short_days); + if (hours != 0) + sb.append(hours).append(TracepointsMessages.TraceControlView_date_short_hours); + if (minutes != 0) + sb.append(minutes).append(TracepointsMessages.TraceControlView_date_short_minutes); + if (seconds != 0) + sb.append(seconds).append(TracepointsMessages.TraceControlView_date_short_seconds); + if (sb.length() == 0) + sb.append(TracepointsMessages.TraceControlView_date_short_zero); + + } + return (sb.toString()); + } + + /** * GDB's set trace-user and set trace-notes commands require quotes if argument contains spaces, - * but these quotes are returned by trace status, to workaround this we remove quotes on UI side + * but these quotes are returned by trace status, to workaround this we remove quotes on UI side */ protected String removeQuotes(String s) { - if (s.startsWith("\"") && s.endsWith("\"")) { //$NON-NLS-1$//$NON-NLS-2$ - return s.substring(1, s.length()-1); + if (s.startsWith("\"") && s.endsWith("\"")) { //$NON-NLS-1$//$NON-NLS-2$ + return s.substring(1, s.length() - 1); } else { return s; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceVarDetailsDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceVarDetailsDialog.java index aee11ab019a..0fe82058e94 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceVarDetailsDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceVarDetailsDialog.java @@ -46,7 +46,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.plugin.AbstractUIPlugin; public final class TraceVarDetailsDialog extends Dialog { - + private Button createButton = null; private Button refreshButton = null; private Table table = null; @@ -62,7 +62,7 @@ public final class TraceVarDetailsDialog extends Dialog { setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX); fView = view; } - + @Override protected Control createDialogArea(Composite parent) { getShell().setText(TracepointsMessages.TraceControlView_trace_variable_details_dialog_title); @@ -90,7 +90,7 @@ public final class TraceVarDetailsDialog extends Dialog { nameTableColumn.setWidth(150); nameTableColumn.setText(TracepointsMessages.TraceControlView_trace_variable_details_column_name); nameTableColumn.setAlignment(SWT.LEFT); - + final TableColumn initValTableColumn = new TableColumn(table, SWT.NONE); initValTableColumn.setWidth(120); initValTableColumn.setText(TracepointsMessages.TraceControlView_trace_variable_details_column_init_value); @@ -111,10 +111,10 @@ public final class TraceVarDetailsDialog extends Dialog { }); refreshButton.setText(TracepointsMessages.TraceControlView_trace_variable_details_refresh_button); refreshButton.setEnabled(true); - + Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + // Create the section to create a new variable Composite createComposite = new Composite(composite, SWT.NONE); gridLayout = new GridLayout(1, false); @@ -134,7 +134,7 @@ public final class TraceVarDetailsDialog extends Dialog { nameLabel.setText(TracepointsMessages.TraceControlView_trace_variable_details_name_label); nameInput = new Text(inputComposite, SWT.BORDER); nameInput.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - + Label valueLabel = new Label(inputComposite, SWT.NONE); valueLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); valueLabel.setText(TracepointsMessages.TraceControlView_trace_variable_details_value_label); @@ -163,40 +163,40 @@ public final class TraceVarDetailsDialog extends Dialog { warningIconLabel = new Label(createButtonComposite, SWT.NONE); warningIconLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); - warningImage = AbstractUIPlugin - .imageDescriptorFromPlugin( - GdbUIPlugin.PLUGIN_ID, "icons/full/obj16/warning.gif").createImage(); //$NON-NLS-1$ + warningImage = AbstractUIPlugin.imageDescriptorFromPlugin(GdbUIPlugin.PLUGIN_ID, "icons/full/obj16/warning.gif") //$NON-NLS-1$ + .createImage(); warningIconLabel.setImage(warningImage); warningIconLabel.setVisible(false); - + warningTextLabel = new Label(createButtonComposite, SWT.NONE); warningTextLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); parent.addDisposeListener(new DisposeListener() { - @Override + @Override public void widgetDisposed(DisposeEvent e) { if (warningImage != null) warningImage.dispose(); } }); - + // When the user goes into either input field, then pressing return // should try to create the command FocusListener clearWarningFocusListener = new FocusListener() { - @Override + @Override public void focusGained(FocusEvent e) { getShell().setDefaultButton(createButton); } - @Override + + @Override public void focusLost(FocusEvent e) { } }; - + nameInput.addFocusListener(clearWarningFocusListener); valueInput.addFocusListener(clearWarningFocusListener); // When the user modifies any entry in the input, we should clear any warning ModifyListener clearWarningListener = new ModifyListener() { - @Override + @Override public void modifyText(ModifyEvent e) { setWarningVisible(false); } @@ -210,11 +210,11 @@ public final class TraceVarDetailsDialog extends Dialog { return composite; } - + /** * Set the visibility of the warning. Should be set to true when there * is a problem creating the specific variable; false otherwise - * + * * @param visible * True for visible, false for hidden. */ @@ -222,14 +222,14 @@ public final class TraceVarDetailsDialog extends Dialog { if (warningIconLabel == null) return; warningIconLabel.setVisible(visible); - + if (visible == false) { if (warningTextLabel != null) { warningTextLabel.setText(""); //$NON-NLS-1$ } } } - + /** * Set the visibility of the warning icon to true and set its * text to the parameter message. @@ -245,10 +245,9 @@ public final class TraceVarDetailsDialog extends Dialog { @Override protected void createButtonsForButtonBar(Composite parent) { // create Close button only - createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, - true); + createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); } - + @Override protected void buttonPressed(int buttonId) { if (IDialogConstants.CLOSE_ID == buttonId) { @@ -263,7 +262,7 @@ public final class TraceVarDetailsDialog extends Dialog { createButton.setEnabled(false); return; } - + // Remove the warning and re-enable the create button, since we now // have a list of trace variables. setWarningVisible(false); @@ -291,7 +290,7 @@ public final class TraceVarDetailsDialog extends Dialog { break; } } - + if (index == -1) { index = items.length; } @@ -306,7 +305,7 @@ public final class TraceVarDetailsDialog extends Dialog { nameInput.setText(""); //$NON-NLS-1$ valueInput.setText("0"); //$NON-NLS-1$ } - + protected void handleCreate() { String name = nameInput.getText(); if (name != null && !name.isEmpty()) { @@ -314,7 +313,7 @@ public final class TraceVarDetailsDialog extends Dialog { if (value != null && value.length() == 0) { value = null; // No value specified } - + try { fView.fTraceControlModel.createVariable(name, value); resetInputFields(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TracepointImageRegistry.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TracepointImageRegistry.java index e42a23ddfcc..e90abca9111 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TracepointImageRegistry.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TracepointImageRegistry.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Dmitry Kozlov (Mentor Graphics) - Trace control view enhancements (Bug 390827) @@ -29,47 +29,55 @@ public class TracepointImageRegistry extends AbstractImageRegistry { private static List<Object[]> fStore = new ArrayList<Object[]>(); private static String add(String plugin, String[] dirs, String name) { - String key = plugin+'/'+dirs[0]+'/'+name; - fStore.add(new Object[] {key, plugin, dirs, name}); - return key; + String key = plugin + '/' + dirs[0] + '/' + name; + fStore.add(new Object[] { key, plugin, dirs, name }); + return key; } - - private static final String ORG_ECLIPSE_UI_PLUGIN_ID = "org.eclipse.ui"; //$NON-NLS-1$ - private static final String ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID = "org.eclipse.cdt.dsf.gdb.ui"; //$NON-NLS-1$ - - public static final String ICON_Refresh_enabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/elcl16"}, "refresh_nav.png"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String ICON_Refresh_disabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] {"full/dlcl16"}, "refresh_nav.png"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String ICON_Refresh_Auto = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, new String[] {"full/obj16"}, "refresh_auto.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String ICON_Disconnected_Tracing = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, new String[] {"full/obj16"}, "disconnected_tracing.png"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String ICON_Circular_Buffer = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, new String[] {"full/obj16"}, "circular_buffer.png"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String ICON_Trace_Variables = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, new String[] {"full/obj16"}, "tracevariables.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String ICON_Exit_Visualization = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, new String[] {"full/obj16"}, "stop_visual_trace.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - public static final String ICON_Edit_enabled = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, new String[] {"full/obj16"}, "write_obj.gif"); //$NON-NLS-1$ //$NON-NLS-2$ - - private static TracepointImageRegistry INSTANCE = new TracepointImageRegistry(GdbUIPlugin.getDefault()); - - TracepointImageRegistry(Plugin plugin) { + + private static final String ORG_ECLIPSE_UI_PLUGIN_ID = "org.eclipse.ui"; //$NON-NLS-1$ + private static final String ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID = "org.eclipse.cdt.dsf.gdb.ui"; //$NON-NLS-1$ + + public static final String ICON_Refresh_enabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] { "full/elcl16" }, //$NON-NLS-1$ + "refresh_nav.png"); //$NON-NLS-1$ + public static final String ICON_Refresh_disabled = add(ORG_ECLIPSE_UI_PLUGIN_ID, new String[] { "full/dlcl16" }, //$NON-NLS-1$ + "refresh_nav.png"); //$NON-NLS-1$ + public static final String ICON_Refresh_Auto = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, + new String[] { "full/obj16" }, "refresh_auto.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + public static final String ICON_Disconnected_Tracing = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, + new String[] { "full/obj16" }, "disconnected_tracing.png"); //$NON-NLS-1$ //$NON-NLS-2$ + public static final String ICON_Circular_Buffer = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, + new String[] { "full/obj16" }, "circular_buffer.png"); //$NON-NLS-1$ //$NON-NLS-2$ + public static final String ICON_Trace_Variables = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, + new String[] { "full/obj16" }, "tracevariables.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + public static final String ICON_Exit_Visualization = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, + new String[] { "full/obj16" }, "stop_visual_trace.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + public static final String ICON_Edit_enabled = add(ORG_ECLIPSE_CDT_DSF_GDB_UI_PLUGIN_ID, + new String[] { "full/obj16" }, "write_obj.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + + private static TracepointImageRegistry INSTANCE = new TracepointImageRegistry(GdbUIPlugin.getDefault()); + + TracepointImageRegistry(Plugin plugin) { super(plugin); initialize(); } - void initialize() { - for (Iterator<Object[]> iter = fStore.iterator(); iter.hasNext();) { - Object[] element = iter.next(); - if (element.length == 2) { - String dir= (String) element[0]; - String name= (String) element[1]; - localImage(name, dir, name); - } else { - String key = (String) element[0]; - String plugin= (String) element[1]; - String[] dirs= (String[]) element[2]; - String name= (String) element[3]; - externalImage(key, plugin, dirs, name); - } - } + void initialize() { + for (Iterator<Object[]> iter = fStore.iterator(); iter.hasNext();) { + Object[] element = iter.next(); + if (element.length == 2) { + String dir = (String) element[0]; + String name = (String) element[1]; + localImage(name, dir, name); + } else { + String key = (String) element[0]; + String plugin = (String) element[1]; + String[] dirs = (String[]) element[2]; + String name = (String) element[3]; + externalImage(key, plugin, dirs, name); + } + } } - + public static ImageDescriptor getImageDescriptor(String key) { return INSTANCE.getDescriptor(key); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TracepointsMessages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TracepointsMessages.java index f934e0c00d2..7f7d2ea63c3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TracepointsMessages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TracepointsMessages.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Dmitry Kozlov (Mentor Graphics) - trace control view enhancements (Bug 390827) @@ -24,6 +24,7 @@ public final class TracepointsMessages extends NLS { private TracepointsMessages() { // Do not instantiate } + public static String TraceControlView_buffer_label; public static String TraceControlView_buffer_circular_button_label; public static String TraceControlView_buffer_circular_on_tooltip; @@ -81,18 +82,18 @@ public final class TracepointsMessages extends NLS { public static String TraceControlView_today; public static String TraceControlView_yesterday; public static String TraceControlView_date_days; - public static String TraceControlView_date_hours; - public static String TraceControlView_date_minutes; + public static String TraceControlView_date_hours; + public static String TraceControlView_date_minutes; public static String TraceControlView_date_seconds; public static String TraceControlView_date_zero; public static String TraceControlView_date_short_days; - public static String TraceControlView_date_short_hours; - public static String TraceControlView_date_short_minutes; + public static String TraceControlView_date_short_hours; + public static String TraceControlView_date_short_minutes; public static String TraceControlView_date_short_seconds; public static String TraceControlView_date_short_zero; // Not used public static String TraceControlView_tracing_stopped_at; - + static { NLS.initializeMessages(TracepointsMessages.class.getName(), TracepointsMessages.class); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/FetchMoreChildrenEvent.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/FetchMoreChildrenEvent.java index 3630931782f..200a845de32 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/FetchMoreChildrenEvent.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/FetchMoreChildrenEvent.java @@ -19,19 +19,19 @@ import org.eclipse.jface.viewers.TreePath; /** * Event to fetch additional children for and expression context. - * + * * @since 3.0 */ public class FetchMoreChildrenEvent extends AbstractDMEvent<IExpressionDMContext> { - + private TreePath path; - - public FetchMoreChildrenEvent(IExpressionDMContext exprCtx, TreePath path) { - super(exprCtx); - this.path = path; - } - - public TreePath getPath() { - return path; - } + + public FetchMoreChildrenEvent(IExpressionDMContext exprCtx, TreePath path) { + super(exprCtx); + this.path = path; + } + + public TreePath getPath() { + return path; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java index 8ebbb640ce8..f9c6adc4eeb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java @@ -60,179 +60,181 @@ public class GdbExpressionVMProvider extends ExpressionVMProvider { /** * Constructor (passthru) */ - public GdbExpressionVMProvider(AbstractVMAdapter adapter, - IPresentationContext context, DsfSession session) { + public GdbExpressionVMProvider(AbstractVMAdapter adapter, IPresentationContext context, DsfSession session) { super(adapter, context, session); - final IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); - - Integer childCountLimit = store.getInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); - if (childCountLimit != 0) { - getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, - childCountLimit); - } - - fPreferencesListener = new IPropertyChangeListener() { - @Override + final IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); + + Integer childCountLimit = store + .getInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); + if (childCountLimit != 0) { + getPresentationContext().setProperty( + IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, childCountLimit); + } + + fPreferencesListener = new IPropertyChangeListener() { + @Override public void propertyChange(final PropertyChangeEvent event) { handlePropertyChanged(store, event); - }}; - store.addPropertyChangeListener(fPreferencesListener); + } + }; + store.addPropertyChangeListener(fPreferencesListener); } - @Override + @Override public void dispose() { super.dispose(); - - final IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); + + final IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); store.removePropertyChangeListener(fPreferencesListener); } /** * The only difference between this and our super implementation is that we - * create a GdbVariableVMNode instead of a VariableVMNode. - * + * create a GdbVariableVMNode instead of a VariableVMNode. + * * @see org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider#configureLayout() */ - @Override + @Override protected void configureLayout() { - - /* - * Allocate the synchronous data providers. - */ - SyncRegisterDataAccess syncRegDataAccess = new SyncRegisterDataAccess(getSession()); - SyncVariableDataAccess syncvarDataAccess = new SyncVariableDataAccess(getSession()) ; - - /* - * Create the top level node which provides the anchor starting point. - */ - IRootVMNode rootNode = new RootDMVMNode(this); - - /* - * Now the Over-arching management node. - */ - if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(getPresentationContext().getId())) { - SingleExpressionVMNode expressionManagerNode = new SingleExpressionVMNode(this); - addChildNodes(rootNode, new IVMNode[] { expressionManagerNode }); - } else { - ExpressionManagerVMNode expressionManagerNode = new ExpressionManagerVMNode(this); - addChildNodes(rootNode, new IVMNode[] {expressionManagerNode}); - } - - // Disabled expression node intercepts disabled expressions and prevents them from being - // evaluated by other nodes. - IExpressionVMNode disabledExpressionNode = new DisabledExpressionVMNode(this); - - /* - * The expression view wants to support fully all of the components of the register view. - */ - IExpressionVMNode registerGroupNode = new RegisterGroupVMNode(this, getSession(), syncRegDataAccess); - - IExpressionVMNode registerNode = new RegisterVMNode(this, getSession(), syncRegDataAccess); - addChildNodes(registerGroupNode, new IExpressionVMNode[] {registerNode}); - - /* - * Create the next level which is the bit-field level. - */ - IVMNode bitFieldNode = new RegisterBitFieldVMNode(this, getSession(), syncRegDataAccess); - addChildNodes(registerNode, new IVMNode[] { bitFieldNode }); - - /* - * Create the support for the SubExpressions. Anything which is brought into the expressions - * view comes in as a fully qualified expression so we go directly to the SubExpression layout - * node. - */ - IExpressionVMNode variableNode = new GdbVariableVMNode(this, getSession(), syncvarDataAccess); - addChildNodes(variableNode, new IExpressionVMNode[] {variableNode}); - - /* Wire up the casting support. IExpressions2 service is always available + + /* + * Allocate the synchronous data providers. + */ + SyncRegisterDataAccess syncRegDataAccess = new SyncRegisterDataAccess(getSession()); + SyncVariableDataAccess syncvarDataAccess = new SyncVariableDataAccess(getSession()); + + /* + * Create the top level node which provides the anchor starting point. + */ + IRootVMNode rootNode = new RootDMVMNode(this); + + /* + * Now the Over-arching management node. + */ + if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(getPresentationContext().getId())) { + SingleExpressionVMNode expressionManagerNode = new SingleExpressionVMNode(this); + addChildNodes(rootNode, new IVMNode[] { expressionManagerNode }); + } else { + ExpressionManagerVMNode expressionManagerNode = new ExpressionManagerVMNode(this); + addChildNodes(rootNode, new IVMNode[] { expressionManagerNode }); + } + + // Disabled expression node intercepts disabled expressions and prevents them from being + // evaluated by other nodes. + IExpressionVMNode disabledExpressionNode = new DisabledExpressionVMNode(this); + + /* + * The expression view wants to support fully all of the components of the register view. + */ + IExpressionVMNode registerGroupNode = new RegisterGroupVMNode(this, getSession(), syncRegDataAccess); + + IExpressionVMNode registerNode = new RegisterVMNode(this, getSession(), syncRegDataAccess); + addChildNodes(registerGroupNode, new IExpressionVMNode[] { registerNode }); + + /* + * Create the next level which is the bit-field level. + */ + IVMNode bitFieldNode = new RegisterBitFieldVMNode(this, getSession(), syncRegDataAccess); + addChildNodes(registerNode, new IVMNode[] { bitFieldNode }); + + /* + * Create the support for the SubExpressions. Anything which is brought into the expressions + * view comes in as a fully qualified expression so we go directly to the SubExpression layout + * node. + */ + IExpressionVMNode variableNode = new GdbVariableVMNode(this, getSession(), syncvarDataAccess); + addChildNodes(variableNode, new IExpressionVMNode[] { variableNode }); + + /* Wire up the casting support. IExpressions2 service is always available * for gdb. No need to call hookUpCastingSupport */ ((VariableVMNode) variableNode).setCastToTypeSupport( new DsfCastToTypeSupport(getSession(), GdbExpressionVMProvider.this, syncvarDataAccess)); - - /* - * Tell the expression node which sub-nodes it will directly support. It is very important - * that the variables node be the last in this chain. The model assumes that there is some - * form of metalanguage expression syntax which each of the nodes evaluates and decides if - * they are dealing with it or not. The variables node assumes that the expression is fully - * qualified and there is no analysis or subdivision of the expression it will parse. So it - * it currently the case that the location of the nodes within the array being passed in is - * the order of search/evaluation. Thus variables wants to be last. Otherwise it would just - * assume what it was passed was for it and the real node which wants to handle it would be - * left out in the cold. - */ - setExpressionNodes(new IExpressionVMNode[] {disabledExpressionNode, registerGroupNode, variableNode}); - - /* - * Let the work know which is the top level node. - */ - setRootNode(rootNode); - } - + + /* + * Tell the expression node which sub-nodes it will directly support. It is very important + * that the variables node be the last in this chain. The model assumes that there is some + * form of metalanguage expression syntax which each of the nodes evaluates and decides if + * they are dealing with it or not. The variables node assumes that the expression is fully + * qualified and there is no analysis or subdivision of the expression it will parse. So it + * it currently the case that the location of the nodes within the array being passed in is + * the order of search/evaluation. Thus variables wants to be last. Otherwise it would just + * assume what it was passed was for it and the real node which wants to handle it would be + * left out in the cold. + */ + setExpressionNodes(new IExpressionVMNode[] { disabledExpressionNode, registerGroupNode, variableNode }); + + /* + * Let the work know which is the top level node. + */ + setRootNode(rootNode); + } + @Override public void handleEvent(Object event, final RequestMonitor rm) { - if (event instanceof DoubleClickEvent && !isDisposed()) { - - final ISelection selection= ((DoubleClickEvent) event).getSelection(); - if (selection instanceof IStructuredSelection) { - - Object element= ((IStructuredSelection) selection).getFirstElement(); - if (element instanceof IncompleteChildrenVMC) { - - IncompleteChildrenVMC incompleteChildrenVmc = ((IncompleteChildrenVMC) element); - IVMNode node = incompleteChildrenVmc.getVMNode(); - if (node instanceof GdbVariableVMNode && node.getVMProvider() == this) { - - if (selection instanceof ITreeSelection) { - ITreeSelection treeSelection = (ITreeSelection) selection; - TreePath path = treeSelection.getPaths()[0]; - - IExpressionDMContext exprCtx = incompleteChildrenVmc.getParentDMContext(); - ((GdbVariableVMNode) node).incrementChildCountLimit(exprCtx); - - // replace double click event with the fetch more children event. - final FetchMoreChildrenEvent fetchMoreChildrenEvent = new FetchMoreChildrenEvent( - exprCtx, path); - getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - handleEvent(fetchMoreChildrenEvent, rm); - } - }); - - return; - } - } - } - } - } - + if (event instanceof DoubleClickEvent && !isDisposed()) { + + final ISelection selection = ((DoubleClickEvent) event).getSelection(); + if (selection instanceof IStructuredSelection) { + + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IncompleteChildrenVMC) { + + IncompleteChildrenVMC incompleteChildrenVmc = ((IncompleteChildrenVMC) element); + IVMNode node = incompleteChildrenVmc.getVMNode(); + if (node instanceof GdbVariableVMNode && node.getVMProvider() == this) { + + if (selection instanceof ITreeSelection) { + ITreeSelection treeSelection = (ITreeSelection) selection; + TreePath path = treeSelection.getPaths()[0]; + + IExpressionDMContext exprCtx = incompleteChildrenVmc.getParentDMContext(); + ((GdbVariableVMNode) node).incrementChildCountLimit(exprCtx); + + // replace double click event with the fetch more children event. + final FetchMoreChildrenEvent fetchMoreChildrenEvent = new FetchMoreChildrenEvent(exprCtx, + path); + getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + handleEvent(fetchMoreChildrenEvent, rm); + } + }); + + return; + } + } + } + } + } + super.handleEvent(event, rm); } - /** - * @param store - * @param event - * - * @since 3.0 - */ + /** + * @param store + * @param event + * + * @since 3.0 + */ protected void handlePropertyChanged(final IPreferenceStore store, final PropertyChangeEvent event) { String property = event.getProperty(); if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) { - Integer childCountLimit = store.getInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); - - if (childCountLimit != 0) { - getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, - childCountLimit); - } else { - getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, - null); - } - + Integer childCountLimit = store + .getInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); + + if (childCountLimit != 0) { + getPresentationContext().setProperty( + IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, childCountLimit); + } else { + getPresentationContext() + .setProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, null); + } + getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - handleEvent(event); - } + @Override + public void run() { + handleEvent(event); + } }); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java index a59c757b46c..1fe6d290a0f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java @@ -97,53 +97,53 @@ public class GdbVariableVMNode extends VariableVMNode { // fillUpdateWithVMCs. fillUpdateWithVMCs checks whether there are // limit + 1 children, and if so, will create an IncompleteChildrenVMC // for the last child, discarding the original expression context. - + /** * Specialization of VariableVMNode.VariableExpressionVMC that participates * in the "Add Watchpoint" object contribution action. */ public class GdbVariableExpressionVMC extends VariableVMNode.VariableExpressionVMC implements ICWatchpointTarget { - + /** * Constructor (passthru) */ public GdbVariableExpressionVMC(IDMContext dmc) { - super(dmc); - } - + super(dmc); + } + /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getSize() */ - @Override + @Override public void getSize(final ICWatchpointTarget.GetSizeRequest request) { - final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class); + final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), + IExpressionDMContext.class); if (exprDmc != null) { - getSession().getExecutor().execute(new Runnable() { - @Override - public void run() { - final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); - if (expressionService != null) { - final DataRequestMonitor<IExpressionDMAddress> drm = new DataRequestMonitor<IExpressionDMAddress>(getSession().getExecutor(), null) { - @Override + getSession().getExecutor().execute(new Runnable() { + @Override + public void run() { + final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); + if (expressionService != null) { + final DataRequestMonitor<IExpressionDMAddress> drm = new DataRequestMonitor<IExpressionDMAddress>( + getSession().getExecutor(), null) { + @Override public void handleCompleted() { - if (isSuccess()) { - request.setSize(getData().getSize()); - } - request.setStatus(getStatus()); - request.done(); - } - }; - - expressionService.getExpressionAddressData(exprDmc, drm); - } - else { - request.setStatus(internalError()); - request.done(); - } - } - }); - } - else { + if (isSuccess()) { + request.setSize(getData().getSize()); + } + request.setStatus(getStatus()); + request.done(); + } + }; + + expressionService.getExpressionAddressData(exprDmc, drm); + } else { + request.setStatus(internalError()); + request.done(); + } + } + }); + } else { request.setStatus(internalError()); request.done(); } @@ -152,40 +152,40 @@ public class GdbVariableVMNode extends VariableVMNode { /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#canCreateWatchpoint(org.eclipse.cdt.debug.internal.core.IWatchpointTarget.CanCreateWatchpointRequest) */ - @Override + @Override public void canSetWatchpoint(final ICWatchpointTarget.CanCreateWatchpointRequest request) { // If the expression is an l-value, then we say it supports a // watchpoint. The logic here is basically the same as what's in // getSize(), as the same DSF service method tells us (a) if it's an // lvalue, and (b) its size. - final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class); + final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), + IExpressionDMContext.class); if (exprDmc != null) { - getSession().getExecutor().execute(new Runnable() { - @Override - public void run() { - final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); - if (expressionService != null) { - final DataRequestMonitor<IExpressionDMAddress> drm = new DataRequestMonitor<IExpressionDMAddress>(getSession().getExecutor(), null) { - @Override + getSession().getExecutor().execute(new Runnable() { + @Override + public void run() { + final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); + if (expressionService != null) { + final DataRequestMonitor<IExpressionDMAddress> drm = new DataRequestMonitor<IExpressionDMAddress>( + getSession().getExecutor(), null) { + @Override public void handleCompleted() { - if (isSuccess()) { - request.setCanCreate(getData().getSize() > 0); - } - request.setStatus(getStatus()); - request.done(); - } - }; - - expressionService.getExpressionAddressData(exprDmc, drm); - } - else { - request.setStatus(internalError()); - request.done(); - } - } - }); - } - else { + if (isSuccess()) { + request.setCanCreate(getData().getSize() > 0); + } + request.setStatus(getStatus()); + request.done(); + } + }; + + expressionService.getExpressionAddressData(exprDmc, drm); + } else { + request.setStatus(internalError()); + request.done(); + } + } + }); + } else { request.setStatus(internalError()); request.done(); } @@ -199,19 +199,19 @@ public class GdbVariableVMNode extends VariableVMNode { } return super.canViewInMemory(); } - - @SuppressWarnings({ "unchecked", "rawtypes" }) + + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Object getAdapter(Class adapter) { - if (adapter.isAssignableFrom(IWatchExpressionFactoryAdapter2.class)) { - return fGdbVariableExpressionFactory; - } - return super.getAdapter(adapter); - } + public Object getAdapter(Class adapter) { + if (adapter.isAssignableFrom(IWatchExpressionFactoryAdapter2.class)) { + return fGdbVariableExpressionFactory; + } + return super.getAdapter(adapter); + } }; - + private static boolean isConvenienceVariable(String expr) { - // GDB convenience variables are variables that start with a $ followed + // GDB convenience variables are variables that start with a $ followed // by at least one digit. // Note that registers also start with a $, so we need to make sure // there is a digit immediately following the $. @@ -222,12 +222,12 @@ public class GdbVariableVMNode extends VariableVMNode { // Convenience variables are used for return values of methods calls. // see bug 341731 if (expr.matches(".*" + "\\$\\d" + ".*")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return true; + return true; } return false; } - + private static boolean isRegisterExpression(String expr) { // Registers expressions start with a $ followed by a non-digit. // We must check for the non-digit because we need to make sure @@ -237,7 +237,7 @@ public class GdbVariableVMNode extends VariableVMNode { // such as (int)($eax) // So, we look for a $ followed by a non-digit, anywhere in the expression. if (expr.matches(".*" + "\\$\\D" + ".*")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return true; + return true; } return false; @@ -246,31 +246,31 @@ public class GdbVariableVMNode extends VariableVMNode { /** * A factory to control the "Watch" action for GDB variables. */ - protected class GdbVariableExpressionFactory extends VariableExpressionFactory { - @Override - public boolean canCreateWatchExpression(Object element) { - if (element instanceof VariableExpressionVMC) { - String expression = ((VariableExpressionVMC)element).getExpression(); - if (isConvenienceVariable(expression)) { - return false; - } - } - - return super.canCreateWatchExpression(element); - } - } - - final protected VariableExpressionFactory fGdbVariableExpressionFactory = new GdbVariableExpressionFactory(); + protected class GdbVariableExpressionFactory extends VariableExpressionFactory { + @Override + public boolean canCreateWatchExpression(Object element) { + if (element instanceof VariableExpressionVMC) { + String expression = ((VariableExpressionVMC) element).getExpression(); + if (isConvenienceVariable(expression)) { + return false; + } + } + + return super.canCreateWatchExpression(element); + } + } + + final protected VariableExpressionFactory fGdbVariableExpressionFactory = new GdbVariableExpressionFactory(); /** * The special context representing more children to be available. - * + * * @since 3.0 */ public class IncompleteChildrenVMC extends AbstractVMContext { private IExpressionDMContext parentDmc; - + public IncompleteChildrenVMC(IExpressionDMContext exprDmc, int childCountLimit) { super(GdbVariableVMNode.this); this.parentDmc = exprDmc; @@ -278,8 +278,7 @@ public class GdbVariableVMNode extends VariableVMNode { @Override public boolean equals(Object obj) { - return obj instanceof IncompleteChildrenVMC && - ((IncompleteChildrenVMC)obj).parentDmc.equals(parentDmc); + return obj instanceof IncompleteChildrenVMC && ((IncompleteChildrenVMC) obj).parentDmc.equals(parentDmc); } @Override @@ -289,20 +288,21 @@ public class GdbVariableVMNode extends VariableVMNode { public IExpressionDMContext getParentDMContext() { return parentDmc; - } + } } - + /** * Maps expressions to their current limit on the maximum number of children. */ private Map<IExpressionDMContext, Integer> childCountLimits = new HashMap<IExpressionDMContext, Integer>(); /** - * Utility method to create an IStatus object for an internal error + * Utility method to create an IStatus object for an internal error */ private static Status internalError() { return new Status(Status.ERROR, GdbUIPlugin.getUniqueIdentifier(), Messages.Internal_Error); } + /** * Constructor (passthru) */ @@ -317,14 +317,14 @@ public class GdbVariableVMNode extends VariableVMNode { * "Add Watchpoint" context menu appears for variables and expressions in * GDB-DSF sessions but not necessarily other DSF-based sessions [bugzilla * 248606] - * + * * @see org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMNode#createVMContext(org.eclipse.cdt.dsf.datamodel.IDMContext) */ - @Override - protected IDMVMContext createVMContext(IDMContext dmc) { - return new GdbVariableExpressionVMC(dmc); - } - + @Override + protected IDMVMContext createVMContext(IDMContext dmc) { + return new GdbVariableExpressionVMC(dmc); + } + @Override protected void updateHasElementsInSessionThread(final IHasChildrenUpdate update) { if (update.getElement() instanceof IncompleteChildrenVMC) { @@ -332,88 +332,88 @@ public class GdbVariableVMNode extends VariableVMNode { update.done(); return; } - + super.updateHasElementsInSessionThread(update); } - + @Override protected void updateElementCountInSessionThread(final IChildrenCountUpdate update) { - // Get the data model context object for the current node in the hierarchy. - - final IExpressionDMContext expressionDMC = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressionDMContext.class); - - if ( expressionDMC != null ) { - final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); - - if (expressionService == null) { - handleFailedUpdate(update); - return; - } - - if (expressionService instanceof IMIExpressions) { - final IMIExpressions miExpressions = (IMIExpressions) expressionService; + // Get the data model context object for the current node in the hierarchy. + + final IExpressionDMContext expressionDMC = findDmcInPath(update.getViewerInput(), update.getElementPath(), + IExpressionDMContext.class); + + if (expressionDMC != null) { + final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); + + if (expressionService == null) { + handleFailedUpdate(update); + return; + } + + if (expressionService instanceof IMIExpressions) { + final IMIExpressions miExpressions = (IMIExpressions) expressionService; miExpressions.safeToAskForAllSubExpressions(expressionDMC, new ViewerDataRequestMonitor<Boolean>(getSession().getExecutor(), update) { - @Override - protected void handleCompleted() { - if (! isSuccess()) { - handleFailedUpdate(update); - return; - } + @Override + protected void handleCompleted() { + if (!isSuccess()) { + handleFailedUpdate(update); + return; + } + + boolean limitRequired = !getData().booleanValue(); + if (limitRequired) { + + final int childCountLimit = getOrInitChildCountLimit(expressionDMC); + + miExpressions.getSubExpressionCount(expressionDMC, childCountLimit + 1, + new ViewerDataRequestMonitor<Integer>(getExecutor(), update) { + @Override + public void handleCompleted() { + if (!isSuccess()) { + handleFailedUpdate(update); + return; + } + + int childCount = getData(); + if (childCountLimit < childCount) { + childCount = childCountLimit + 1; + } + + update.setChildCount(childCount); + update.done(); + } + }); + } else { + GdbVariableVMNode.super.updateElementCountInSessionThread(update); + } + } + }); + + return; + } + } - boolean limitRequired = ! getData().booleanValue(); - if (limitRequired) { - - final int childCountLimit = getOrInitChildCountLimit(expressionDMC); - - miExpressions.getSubExpressionCount( - expressionDMC, childCountLimit + 1, - new ViewerDataRequestMonitor<Integer>(getExecutor(), update) { - @Override - public void handleCompleted() { - if (!isSuccess()) { - handleFailedUpdate(update); - return; - } - - int childCount = getData(); - if (childCountLimit < childCount) { - childCount = childCountLimit + 1; - } - - update.setChildCount(childCount); - update.done(); - } - }); - } else { - GdbVariableVMNode.super.updateElementCountInSessionThread(update); - } - } - }); - - return; - } - } - - super.updateElementCountInSessionThread(update); + super.updateElementCountInSessionThread(update); } @Override - protected void fillUpdateWithVMCs(IChildrenUpdate update, - IDMContext[] dmcs, int firstIndex) { + protected void fillUpdateWithVMCs(IChildrenUpdate update, IDMContext[] dmcs, int firstIndex) { super.fillUpdateWithVMCs(update, dmcs, firstIndex); - - IExpressionDMContext expressionDMC = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressionDMContext.class); - - if (expressionDMC != null) { - int childCountLimit = getChildCountLimit(expressionDMC); - int childCount = firstIndex + update.getLength(); - if (childCountLimit < childCount) { - update.setChild(new IncompleteChildrenVMC(expressionDMC, childCountLimit), childCountLimit); - } - } + + IExpressionDMContext expressionDMC = findDmcInPath(update.getViewerInput(), update.getElementPath(), + IExpressionDMContext.class); + + if (expressionDMC != null) { + int childCountLimit = getChildCountLimit(expressionDMC); + int childCount = firstIndex + update.getLength(); + if (childCountLimit < childCount) { + update.setChild(new IncompleteChildrenVMC(expressionDMC, childCountLimit), childCountLimit); + } + } } @Override @@ -422,14 +422,11 @@ public class GdbVariableVMNode extends VariableVMNode { for (IPropertiesUpdate update : updates) { if (update.getElement() instanceof IncompleteChildrenVMC) { - if (update.getProperties().contains( - AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION)) { - update.setProperty( - AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION, - Messages.More_Children); + if (update.getProperties().contains(AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION)) { + update.setProperty(AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION, Messages.More_Children); } - + if (update.getProperties().contains(PROP_NAME)) { update.setProperty(PROP_NAME, Messages.More_Children); } @@ -438,26 +435,25 @@ public class GdbVariableVMNode extends VariableVMNode { realExpressions.add(update); } } - + super.update(realExpressions.toArray(new IPropertiesUpdate[realExpressions.size()])); } private int getInitialChildCountLimit() { - Object initialLimitProperty = getVMProvider().getPresentationContext().getProperty( - IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); - - return (initialLimitProperty instanceof Integer) ? (Integer) initialLimitProperty - : 100; + Object initialLimitProperty = getVMProvider().getPresentationContext() + .getProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); + + return (initialLimitProperty instanceof Integer) ? (Integer) initialLimitProperty : 100; } - + /** * The given expression context requires a child count limit. If a limit * is already available from preceding calls, obtain this limit. Otherwise * calculate the initial value, store it, and return it. - * + * * @param expressionDMC * @return The child count limit to apply for the given expression. - * + * * @since 3.0 */ protected int getOrInitChildCountLimit(IExpressionDMContext expressionDMC) { @@ -467,77 +463,75 @@ public class GdbVariableVMNode extends VariableVMNode { int initialLimit = getInitialChildCountLimit(); childCountLimits.put(expressionDMC, initialLimit); - + return initialLimit; } - + /** * @param expressionDMC * @return The currently stored child count limit for the given expression, * or {@link Integer#MAX_VALUE} if no child count limit is currently * stored. - * + * * @since 3.0 */ protected int getChildCountLimit(IExpressionDMContext expressionDMC) { if (childCountLimits.containsKey(expressionDMC)) { return childCountLimits.get(expressionDMC); } - return Integer.MAX_VALUE; + return Integer.MAX_VALUE; } - - private void resetChildCountLimits(IExecutionDMContext execCtx) { - int initialLimit = getInitialChildCountLimit(); - for (IExpressionDMContext limitCtx : childCountLimits.keySet()) { - if (DMContexts.isAncestorOf(limitCtx, execCtx)) { - childCountLimits.put(limitCtx, initialLimit); - } + + private void resetChildCountLimits(IExecutionDMContext execCtx) { + int initialLimit = getInitialChildCountLimit(); + for (IExpressionDMContext limitCtx : childCountLimits.keySet()) { + if (DMContexts.isAncestorOf(limitCtx, execCtx)) { + childCountLimits.put(limitCtx, initialLimit); + } } - } - - private void resetAllChildCountLimits() { - int initialLimit = getInitialChildCountLimit(); - for (IExpressionDMContext limitCtx : childCountLimits.keySet()) { - childCountLimits.put(limitCtx, initialLimit); + } + + private void resetAllChildCountLimits() { + int initialLimit = getInitialChildCountLimit(); + for (IExpressionDMContext limitCtx : childCountLimits.keySet()) { + childCountLimits.put(limitCtx, initialLimit); } - } - + } + /** * Increment the child count limit by the default increment. * This implementation doubles the current limit. - * + * * @since 3.0 */ public void incrementChildCountLimit(IExpressionDMContext expressionDMC) { - assert(childCountLimits.containsKey(expressionDMC)); - + assert (childCountLimits.containsKey(expressionDMC)); + int childCountLimit = getChildCountLimit(expressionDMC); if (childCountLimit < Integer.MAX_VALUE / 2) { childCountLimits.put(expressionDMC, childCountLimit * 2); } } - + @Override public int getDeltaFlags(Object e) { int flags = super.getDeltaFlags(e); - + if (e instanceof FetchMoreChildrenEvent) { flags |= IModelDelta.CONTENT; } else if (e instanceof ISuspendedDMEvent) { // The child count limit must be reset. flags |= IModelDelta.CONTENT; - } else if (e instanceof PropertyChangeEvent) { - String property = ((PropertyChangeEvent)e).getProperty(); - if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) - { - flags |= IModelDelta.CONTENT; - } + } else if (e instanceof PropertyChangeEvent) { + String property = ((PropertyChangeEvent) e).getProperty(); + if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) { + flags |= IModelDelta.CONTENT; + } } - + return flags; } - - + @Override public int getDeltaFlagsForExpression(IExpression expression, Object event) { int flags = super.getDeltaFlagsForExpression(expression, event); @@ -546,109 +540,99 @@ public class GdbVariableVMNode extends VariableVMNode { flags |= IModelDelta.CONTENT; } else if (event instanceof PropertyChangeEvent) { String property = ((PropertyChangeEvent) event).getProperty(); - if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS - .equals(property)) { + if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) { flags |= IModelDelta.CONTENT; } } return flags; } - + @Override - public void buildDelta(Object e, VMDelta parentDelta, int nodeOffset, - RequestMonitor rm) { - - if (e instanceof FetchMoreChildrenEvent) { - buildDeltaForFetchMoreChildrenEvent((FetchMoreChildrenEvent) e, parentDelta, rm); - return; + public void buildDelta(Object e, VMDelta parentDelta, int nodeOffset, RequestMonitor rm) { + + if (e instanceof FetchMoreChildrenEvent) { + buildDeltaForFetchMoreChildrenEvent((FetchMoreChildrenEvent) e, parentDelta, rm); + return; } else if (e instanceof ISuspendedDMEvent) { resetChildCountLimits(((ISuspendedDMEvent) e).getDMContext()); - } else if (e instanceof PropertyChangeEvent) { - String property = ((PropertyChangeEvent)e).getProperty(); - if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) - { - resetAllChildCountLimits(); - buildDeltaForChildCountLimitPreferenceChangedEvent(parentDelta, rm); - return; - } - } - - super.buildDelta(e, parentDelta, nodeOffset, rm); + } else if (e instanceof PropertyChangeEvent) { + String property = ((PropertyChangeEvent) e).getProperty(); + if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) { + resetAllChildCountLimits(); + buildDeltaForChildCountLimitPreferenceChangedEvent(parentDelta, rm); + return; + } + } + + super.buildDelta(e, parentDelta, nodeOffset, rm); } - + @Override - public void buildDeltaForExpressionElement(Object element, int elementIdx, - Object event, VMDelta parentDelta, RequestMonitor rm) { - - if (event instanceof FetchMoreChildrenEvent) { - FetchMoreChildrenEvent fetchMoreEvent = (FetchMoreChildrenEvent) event; - GdbVariableExpressionVMC topLevelExpressionVMC = (GdbVariableExpressionVMC) element; - if (topLevelExpressionVMC.equals(fetchMoreEvent.getPath().getFirstSegment())) { - buildDeltaForFetchMoreChildrenEvent(fetchMoreEvent, parentDelta, rm); - return; - } + public void buildDeltaForExpressionElement(Object element, int elementIdx, Object event, VMDelta parentDelta, + RequestMonitor rm) { + + if (event instanceof FetchMoreChildrenEvent) { + FetchMoreChildrenEvent fetchMoreEvent = (FetchMoreChildrenEvent) event; + GdbVariableExpressionVMC topLevelExpressionVMC = (GdbVariableExpressionVMC) element; + if (topLevelExpressionVMC.equals(fetchMoreEvent.getPath().getFirstSegment())) { + buildDeltaForFetchMoreChildrenEvent(fetchMoreEvent, parentDelta, rm); + return; + } } else if (event instanceof ISuspendedDMEvent) { resetChildCountLimits(((ISuspendedDMEvent) event).getDMContext()); } else if (event instanceof IContainerSuspendedDMEvent) { resetChildCountLimits(((IContainerSuspendedDMEvent) event).getDMContext()); - } else if (event instanceof PropertyChangeEvent) { - String property = ((PropertyChangeEvent)event).getProperty(); - if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) - { - resetAllChildCountLimits(); - buildDeltaForChildCountLimitPreferenceChangedEvent(parentDelta, rm); - return; - } - } - - super.buildDeltaForExpressionElement(element, elementIdx, event, parentDelta, - rm); + } else if (event instanceof PropertyChangeEvent) { + String property = ((PropertyChangeEvent) event).getProperty(); + if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) { + resetAllChildCountLimits(); + buildDeltaForChildCountLimitPreferenceChangedEvent(parentDelta, rm); + return; + } + } + + super.buildDeltaForExpressionElement(element, elementIdx, event, parentDelta, rm); } - - private void buildDeltaForFetchMoreChildrenEvent( - FetchMoreChildrenEvent fetchMoreChidrenEvent, - VMDelta parentDelta, final RequestMonitor rm) { + + private void buildDeltaForFetchMoreChildrenEvent(FetchMoreChildrenEvent fetchMoreChidrenEvent, VMDelta parentDelta, + final RequestMonitor rm) { TreePath path = fetchMoreChidrenEvent.getPath(); - + // Add all the parents of the expression. Those didn't change, however. for (int i = 0; i < path.getSegmentCount() - 2; ++i) { parentDelta = parentDelta.addNode(path.getSegment(i), IModelDelta.NO_CHANGE); } - - // Add the node for the expression. This one changed, of course. - final VMDelta expressionDelta = - parentDelta.addNode(path.getSegment(path.getSegmentCount() - 2), IModelDelta.CONTENT); + + // Add the node for the expression. This one changed, of course. + final VMDelta expressionDelta = parentDelta.addNode(path.getSegment(path.getSegmentCount() - 2), + IModelDelta.CONTENT); // Make sure the element formerly know as <...more_children...> is selected // afterwards. - - final int offset = getChildCountLimit(fetchMoreChidrenEvent.getDMContext()) / 2; - // The one trailing element is to see whether there are more children. - final int maxLength = offset + 1; - getVMProvider().updateNode( - this, - new VMChildrenUpdate( - expressionDelta, getVMProvider().getPresentationContext(), offset, maxLength, - new DataRequestMonitor<List<Object>>(getExecutor(), rm) { - @Override - public void handleCompleted() { - - // FIXME if the new child has children they do not appear because of this code. -// final List<Object> data= getData(); -// if (data != null && data.size() != 0) { -// expressionDelta.addNode(data.get(0), offset, IModelDelta.SELECT); -// } - rm.done(); - } - }) - ); - } - - private void buildDeltaForChildCountLimitPreferenceChangedEvent( - final VMDelta parentDelta, final RequestMonitor rm) { - parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT); - rm.done(); - } + + final int offset = getChildCountLimit(fetchMoreChidrenEvent.getDMContext()) / 2; + // The one trailing element is to see whether there are more children. + final int maxLength = offset + 1; + getVMProvider().updateNode(this, new VMChildrenUpdate(expressionDelta, getVMProvider().getPresentationContext(), + offset, maxLength, new DataRequestMonitor<List<Object>>(getExecutor(), rm) { + @Override + public void handleCompleted() { + + // FIXME if the new child has children they do not appear because of this code. + // final List<Object> data= getData(); + // if (data != null && data.size() != 0) { + // expressionDelta.addNode(data.get(0), offset, IModelDelta.SELECT); + // } + rm.done(); + } + })); + } + + private void buildDeltaForChildCountLimitPreferenceChangedEvent(final VMDelta parentDelta, + final RequestMonitor rm) { + parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT); + rm.done(); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java index b40f7e3fad2..81bf75e1793 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java @@ -10,7 +10,7 @@ * * Contributors: * Freescale Semiconductor - initial API and implementation - * Axel Mueller - Bug 306555 - Add support for cast to type / view as array (IExpressions2) + * Axel Mueller - Bug 306555 - Add support for cast to type / view as array (IExpressions2) * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel; @@ -51,125 +51,127 @@ public class GdbVariableVMProvider extends VariableVMProvider { /** * Constructor (passthru) */ - public GdbVariableVMProvider(AbstractVMAdapter adapter, - IPresentationContext context, DsfSession session) { + public GdbVariableVMProvider(AbstractVMAdapter adapter, IPresentationContext context, DsfSession session) { super(adapter, context, session); - - final IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); - - Integer childCountLimit = store.getInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); - if (childCountLimit != 0) { - getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, - childCountLimit); - } - - fPreferencesListener = new IPropertyChangeListener() { - @Override + + final IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); + + Integer childCountLimit = store + .getInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); + if (childCountLimit != 0) { + getPresentationContext().setProperty( + IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, childCountLimit); + } + + fPreferencesListener = new IPropertyChangeListener() { + @Override public void propertyChange(final PropertyChangeEvent event) { handlePropertyChanged(store, event); - }}; - store.addPropertyChangeListener(fPreferencesListener); + } + }; + store.addPropertyChangeListener(fPreferencesListener); } - @Override + @Override public void dispose() { super.dispose(); - - final IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); + + final IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); store.removePropertyChangeListener(fPreferencesListener); } /* (non-Javadoc) - * @see org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMProvider#configureLayout(org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess) - */ - @Override + * @see org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMProvider#configureLayout(org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess) + */ + @Override protected void configureLayout() { - // Create the variable data access routines. - SyncVariableDataAccess varAccess = new SyncVariableDataAccess(getSession()) ; - - // Create the top level node to deal with the root selection. - IRootVMNode rootNode = new RootDMVMNode(this); - setRootNode(rootNode); - - // Create the next level which represents members of structs/unions/enums and elements of arrays. - IVMNode subExpressioNode = new GdbVariableVMNode(this, getSession(), varAccess); - addChildNodes(rootNode, new IVMNode[] { subExpressioNode }); + // Create the variable data access routines. + SyncVariableDataAccess varAccess = new SyncVariableDataAccess(getSession()); + + // Create the top level node to deal with the root selection. + IRootVMNode rootNode = new RootDMVMNode(this); + setRootNode(rootNode); + + // Create the next level which represents members of structs/unions/enums and elements of arrays. + IVMNode subExpressioNode = new GdbVariableVMNode(this, getSession(), varAccess); + addChildNodes(rootNode, new IVMNode[] { subExpressioNode }); /* Wire up the casting support. IExpressions2 service is always available * for gdb. No need to call hookUpCastingSupport */ - ((VariableVMNode) subExpressioNode).setCastToTypeSupport( - new DsfCastToTypeSupport(getSession(), GdbVariableVMProvider.this, varAccess)); - - // Configure the sub-expression node to be a child of itself. This way the content - // provider will recursively drill-down the variable hierarchy. - addChildNodes(subExpressioNode, new IVMNode[] { subExpressioNode }); - } + ((VariableVMNode) subExpressioNode) + .setCastToTypeSupport(new DsfCastToTypeSupport(getSession(), GdbVariableVMProvider.this, varAccess)); + + // Configure the sub-expression node to be a child of itself. This way the content + // provider will recursively drill-down the variable hierarchy. + addChildNodes(subExpressioNode, new IVMNode[] { subExpressioNode }); + } @Override public void handleEvent(Object event, final RequestMonitor rm) { - if (event instanceof DoubleClickEvent && !isDisposed()) { - - final ISelection selection= ((DoubleClickEvent) event).getSelection(); - if (selection instanceof IStructuredSelection) { - - Object element= ((IStructuredSelection) selection).getFirstElement(); - if (element instanceof IncompleteChildrenVMC) { - - IncompleteChildrenVMC incompleteChildrenVmc = ((IncompleteChildrenVMC) element); - IVMNode node = incompleteChildrenVmc.getVMNode(); - if (node instanceof GdbVariableVMNode && node.getVMProvider() == this) { - - if (selection instanceof ITreeSelection) { - - ITreeSelection treeSelection = (ITreeSelection) selection; - TreePath path = treeSelection.getPaths()[0]; - IExpressionDMContext exprCtx = incompleteChildrenVmc.getParentDMContext(); - ((GdbVariableVMNode) node).incrementChildCountLimit(exprCtx); - - // replace double click event with the fetch more children event. - final FetchMoreChildrenEvent fetchMoreChildrenEvent = new FetchMoreChildrenEvent( - exprCtx, path); - getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - handleEvent(fetchMoreChildrenEvent, rm); - } - }); - - return; - } - } - } - } - } - + if (event instanceof DoubleClickEvent && !isDisposed()) { + + final ISelection selection = ((DoubleClickEvent) event).getSelection(); + if (selection instanceof IStructuredSelection) { + + Object element = ((IStructuredSelection) selection).getFirstElement(); + if (element instanceof IncompleteChildrenVMC) { + + IncompleteChildrenVMC incompleteChildrenVmc = ((IncompleteChildrenVMC) element); + IVMNode node = incompleteChildrenVmc.getVMNode(); + if (node instanceof GdbVariableVMNode && node.getVMProvider() == this) { + + if (selection instanceof ITreeSelection) { + + ITreeSelection treeSelection = (ITreeSelection) selection; + TreePath path = treeSelection.getPaths()[0]; + IExpressionDMContext exprCtx = incompleteChildrenVmc.getParentDMContext(); + ((GdbVariableVMNode) node).incrementChildCountLimit(exprCtx); + + // replace double click event with the fetch more children event. + final FetchMoreChildrenEvent fetchMoreChildrenEvent = new FetchMoreChildrenEvent(exprCtx, + path); + getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + handleEvent(fetchMoreChildrenEvent, rm); + } + }); + + return; + } + } + } + } + } + super.handleEvent(event, rm); } - + /** * @param store * @param event - * + * * @since 3.0 */ protected void handlePropertyChanged(final IPreferenceStore store, final PropertyChangeEvent event) { String property = event.getProperty(); if (IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS.equals(property)) { - Integer childCountLimit = store.getInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); - - if (childCountLimit != 0) { - getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, - childCountLimit); - } else { - getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, - null); - } - + Integer childCountLimit = store + .getInt(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS); + + if (childCountLimit != 0) { + getPresentationContext().setProperty( + IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, childCountLimit); + } else { + getPresentationContext() + .setProperty(IGdbDebugPreferenceConstants.PREF_INITIAL_CHILD_COUNT_LIMIT_FOR_COLLECTIONS, null); + } + getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - handleEvent(event); - } + @Override + public void run() { + handleEvent(event); + } }); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbViewModelAdapter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbViewModelAdapter.java index 65d68007792..4230c22a680 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbViewModelAdapter.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbViewModelAdapter.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -27,40 +27,39 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentati import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; import org.eclipse.debug.ui.IDebugUIConstants; -/* - * +/* + * */ @ThreadSafe -public class GdbViewModelAdapter extends AbstractDebugVMAdapter -{ - public GdbViewModelAdapter(DsfSession session, SteppingController controller) { - super(session, controller); - getSession().registerModelAdapter(IColumnPresentationFactory.class, this); - } +public class GdbViewModelAdapter extends AbstractDebugVMAdapter { + public GdbViewModelAdapter(DsfSession session, SteppingController controller) { + super(session, controller); + getSession().registerModelAdapter(IColumnPresentationFactory.class, this); + } + + @Override + public void dispose() { + getSession().unregisterModelAdapter(IColumnPresentationFactory.class); + super.dispose(); + } - @Override - public void dispose() { - getSession().unregisterModelAdapter(IColumnPresentationFactory.class); - super.dispose(); - } - - @Override - protected IVMProvider createViewModelProvider(IPresentationContext context) { - if ( IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId()) ) { - return new LaunchVMProvider(this, context, getSession()); - } else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId()) ) { - return new GdbVariableVMProvider(this, context, getSession()); - } else if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId()) ) { - return new RegisterVMProvider(this, context, getSession()); - } else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) { - return new GdbExpressionVMProvider(this, context, getSession()); - } else if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(context.getId()) ) { - return new GdbExpressionVMProvider(this, context, getSession()); - } else if (IDebugUIConstants.ID_MODULE_VIEW.equals(context.getId()) ) { - return new ModulesVMProvider(this, context, getSession()); - } else if (IDebugUIConstants.ID_BREAKPOINT_VIEW.equals(context.getId()) ) { - return new GdbBreakpointVMProvider(this, context, getSession()); - } - return null; - } + @Override + protected IVMProvider createViewModelProvider(IPresentationContext context) { + if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) { + return new LaunchVMProvider(this, context, getSession()); + } else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId())) { + return new GdbVariableVMProvider(this, context, getSession()); + } else if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId())) { + return new RegisterVMProvider(this, context, getSession()); + } else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId())) { + return new GdbExpressionVMProvider(this, context, getSession()); + } else if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(context.getId())) { + return new GdbExpressionVMProvider(this, context, getSession()); + } else if (IDebugUIConstants.ID_MODULE_VIEW.equals(context.getId())) { + return new ModulesVMProvider(this, context, getSession()); + } else if (IDebugUIConstants.ID_BREAKPOINT_VIEW.equals(context.getId())) { + return new GdbBreakpointVMProvider(this, context, getSession()); + } + return null; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/Messages.java index aa0b5d9d21b..bcfd5f38ec2 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/Messages.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/Messages.java @@ -16,16 +16,17 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel; import org.eclipse.osgi.util.NLS; - public class Messages extends NLS { - - static { - // initialize resource bundle - NLS.initializeMessages(/*Messages.class.getName()*/"org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.Message", Messages.class); //$NON-NLS-1$ - } - private Messages() {} + static { + // initialize resource bundle + NLS.initializeMessages(/*Messages.class.getName()*/"org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.Message", //$NON-NLS-1$ + Messages.class); + } + + private Messages() { + } - public static String Internal_Error; - public static String More_Children; + public static String Internal_Error; + public static String More_Children; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMNode.java index 93c3d95758c..999ce014809 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMNode.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Marc Khouzam (Ericsson) - initial API and implementation *******************************************************************************/ @@ -27,33 +27,33 @@ import org.eclipse.jface.util.PropertyChangeEvent; */ public class GdbBreakpointVMNode extends RawBreakpointVMNode { - public GdbBreakpointVMNode(BreakpointVMProvider provider) { - super(provider); - } - - @Override - public int getDeltaFlags(Object event) { - if (event instanceof PropertyChangeEvent) { - String property = ((PropertyChangeEvent)event).getProperty(); - if (IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER.equals(property)) { - return IModelDelta.CONTENT; - } - } - - return super.getDeltaFlags(event); - } - - @Override - public void buildDelta(Object event, VMDelta parent, int nodeOffset, RequestMonitor rm) { - if (event instanceof PropertyChangeEvent) { - String property = ((PropertyChangeEvent)event).getProperty(); - if (IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER.equals(property)) { - parent.setFlags(parent.getFlags() | IModelDelta.CONTENT); - rm.done(); - return; - } - } - - super.buildDelta(event, parent, nodeOffset, rm); - } + public GdbBreakpointVMNode(BreakpointVMProvider provider) { + super(provider); + } + + @Override + public int getDeltaFlags(Object event) { + if (event instanceof PropertyChangeEvent) { + String property = ((PropertyChangeEvent) event).getProperty(); + if (IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER.equals(property)) { + return IModelDelta.CONTENT; + } + } + + return super.getDeltaFlags(event); + } + + @Override + public void buildDelta(Object event, VMDelta parent, int nodeOffset, RequestMonitor rm) { + if (event instanceof PropertyChangeEvent) { + String property = ((PropertyChangeEvent) event).getProperty(); + if (IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER.equals(property)) { + parent.setFlags(parent.getFlags() | IModelDelta.CONTENT); + rm.done(); + return; + } + } + + super.buildDelta(event, parent, nodeOffset, rm); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java index 9dd12a1a9ba..0994819ade3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Mikhail Khodjaiants (Mentor), Marc Khouzam (Ericsson) @@ -74,10 +74,10 @@ import org.eclipse.ui.PlatformUI; */ public class GdbBreakpointVMProvider extends BreakpointVMProvider { - final private DsfSession fSession; - - final private DsfServicesTracker fServicesTracker; - + final private DsfSession fSession; + + final private DsfServicesTracker fServicesTracker; + /** Indicator that we should use aggressive breakpoint filtering */ private boolean fUseAggressiveBpFilter = false; @@ -86,309 +86,316 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { @Override public void propertyChange(final PropertyChangeEvent event) { if (IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER.equals(event.getProperty())) { - fUseAggressiveBpFilter = (Boolean)event.getNewValue(); + fUseAggressiveBpFilter = (Boolean) event.getNewValue(); // Set the property in the presentation context so it can be seen by the vmnode which // will refresh the view - getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, fUseAggressiveBpFilter); + getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, + fUseAggressiveBpFilter); } } }; - public GdbBreakpointVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) { - super(adapter, presentationContext); - fSession = session; - fServicesTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); - - IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); - store.addPropertyChangeListener(fPropertyChangeListener); - fUseAggressiveBpFilter = store.getBoolean(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER); + public GdbBreakpointVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, + DsfSession session) { + super(adapter, presentationContext); + fSession = session; + fServicesTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); + + IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); + store.addPropertyChangeListener(fPropertyChangeListener); + fUseAggressiveBpFilter = store.getBoolean(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER); + } + + @Override + public void dispose() { + GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); + fServicesTracker.dispose(); + super.dispose(); + } + + @Override + protected void calcFileteredBreakpoints(final DataRequestMonitor<IBreakpoint[]> rm) { + if (Boolean.TRUE.equals( + getPresentationContext().getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION))) { + if (fUseAggressiveBpFilter) { + // Aggressive filtering of breakpoints. Only return bps that are installed on the target. + ISelection debugContext = getDebugContext(); + if (debugContext instanceof IStructuredSelection) { + // Use a set to avoid duplicates + final Set<IBreakpoint> bps = new HashSet<IBreakpoint>(); + + int count = 0; + final ImmediateCountingRequestMonitor crm = new ImmediateCountingRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(bps.toArray(new IBreakpoint[bps.size()])); + } + }; + + for (Object element : ((IStructuredSelection) debugContext).toList()) { + + IBreakpointsTargetDMContext bpContext = null; + IExecutionDMContext execContext = null; + if (element instanceof IDMVMContext) { + bpContext = DMContexts.getAncestorOfType(((IDMVMContext) element).getDMContext(), + IBreakpointsTargetDMContext.class); + execContext = DMContexts.getAncestorOfType(((IDMVMContext) element).getDMContext(), + IExecutionDMContext.class); + + if (bpContext != null && fSession.getId().equals(bpContext.getSessionId())) { + count++; + getInstalledBreakpoints(bpContext, execContext, + new DataRequestMonitor<Collection<IBreakpoint>>(getExecutor(), crm) { + @Override + protected void handleCompleted() { + if (isSuccess()) { + bps.addAll(getData()); + } + crm.done(); + } + }); + } + } + } + + crm.setDoneCount(count); + } else { + rm.done(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, + "Invalid debug selection", //$NON-NLS-1$ + null)); + } + } else { + // Original behavior of bp filtering. Return all bp of type ICBreakpoint + IBreakpoint[] allBreakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(); + List<IBreakpoint> filteredBPs = new ArrayList<IBreakpoint>(allBreakpoints.length); + for (IBreakpoint bp : allBreakpoints) { + if (bp instanceof ICBreakpoint && bp.getModelIdentifier().equals(CDebugCorePlugin.PLUGIN_ID)) { + filteredBPs.add(bp); + } + } + rm.done(filteredBPs.toArray(new IBreakpoint[filteredBPs.size()])); + } + } else { + super.calcFileteredBreakpoints(rm); + } } - - @Override - public void dispose() { - GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); - fServicesTracker.dispose(); - super.dispose(); - } - - @Override - protected void calcFileteredBreakpoints( final DataRequestMonitor<IBreakpoint[]> rm ) { - if ( Boolean.TRUE.equals( getPresentationContext().getProperty( IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION ) ) ) { - if ( fUseAggressiveBpFilter ) { - // Aggressive filtering of breakpoints. Only return bps that are installed on the target. - ISelection debugContext = getDebugContext(); - if ( debugContext instanceof IStructuredSelection ) { - // Use a set to avoid duplicates - final Set<IBreakpoint> bps = new HashSet<IBreakpoint>(); - - int count = 0; - final ImmediateCountingRequestMonitor crm = new ImmediateCountingRequestMonitor( rm ) { - @Override - protected void handleSuccess() { - rm.done( bps.toArray( new IBreakpoint[bps.size()] ) ); - } - }; - - for ( Object element : ( (IStructuredSelection)debugContext ).toList() ) { - - IBreakpointsTargetDMContext bpContext = null; - IExecutionDMContext execContext = null; - if ( element instanceof IDMVMContext ) { - bpContext = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IBreakpointsTargetDMContext.class ); - execContext = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IExecutionDMContext.class ); - - if ( bpContext != null && fSession.getId().equals( bpContext.getSessionId() ) ) { - count++; - getInstalledBreakpoints( bpContext, execContext, new DataRequestMonitor<Collection<IBreakpoint>>( getExecutor(), crm ) { - @Override - protected void handleCompleted() { - if ( isSuccess() ) { - bps.addAll( getData() ); - } - crm.done(); - } - } ); - } - } - } - - crm.setDoneCount(count); - } else { - rm.done( new Status( - IStatus.ERROR, - GdbUIPlugin.PLUGIN_ID, - IDsfStatusConstants.INVALID_HANDLE, - "Invalid debug selection", //$NON-NLS-1$ - null ) ); - } - } else { - // Original behavior of bp filtering. Return all bp of type ICBreakpoint - IBreakpoint[] allBreakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(); - List<IBreakpoint> filteredBPs = new ArrayList<IBreakpoint>( allBreakpoints.length ); - for (IBreakpoint bp : allBreakpoints) { - if ( bp instanceof ICBreakpoint && bp.getModelIdentifier().equals( CDebugCorePlugin.PLUGIN_ID ) ) { - filteredBPs.add( bp ); - } - } - rm.done( filteredBPs.toArray( new IBreakpoint[filteredBPs.size()]) ); - } + + @Override + protected IVMNode createBreakpointVMNode() { + return new GdbBreakpointVMNode(this); + } + + @Override + public void getBreakpointsForDebugContext(ISelection debugContext, final DataRequestMonitor<IBreakpoint[]> rm) { + IExecutionDMContext _execCtx = null; + if (debugContext instanceof IStructuredSelection) { + Object element = ((IStructuredSelection) debugContext).getFirstElement(); + if (element instanceof IDMVMContext) { + _execCtx = DMContexts.getAncestorOfType(((IDMVMContext) element).getDMContext(), + IExecutionDMContext.class); + } + } + + if (_execCtx == null || !fSession.getId().equals(_execCtx.getSessionId())) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, + "Debug context doesn't contain a thread", null)); //$NON-NLS-1$ + rm.done(); + return; + } + + final IExecutionDMContext execCtx = _execCtx; + + try { + fSession.getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + IBreakpointsExtension bpService = fServicesTracker.getService(IBreakpointsExtension.class); + if (bpService == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, + "Breakpoints service not available", null)); //$NON-NLS-1$ + rm.done(); + return; + } + bpService.getExecutionContextBreakpoints(execCtx, + new DataRequestMonitor<IBreakpoints.IBreakpointDMContext[]>(fSession.getExecutor(), rm) { + @Override + protected void handleSuccess() { + MIBreakpointsManager bpManager = fServicesTracker + .getService(MIBreakpointsManager.class); + if (bpManager == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, + IDsfStatusConstants.INVALID_STATE, "Breakpoints service not available", //$NON-NLS-1$ + null)); + rm.done(); + return; + } + + IBreakpoint bp = null; + + if (getData().length > 0) { + bp = bpManager.findPlatformBreakpoint(getData()[0]); + } + + if (bp != null) { + rm.setData(new IBreakpoint[] { bp }); + } else { + rm.setData(new IBreakpoint[0]); + } + rm.done(); + } + }); + } + }); + } catch (RejectedExecutionException e) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, + "Request for monitor: '" + toString() + "' resulted in a rejected execution exception.", e)); //$NON-NLS-1$ //$NON-NLS-2$); + rm.done(); } - else { - super.calcFileteredBreakpoints( rm ); + } + + private ISelection getDebugContext() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + return DebugUITools.getDebugContextManager().getContextService(window).getActiveContext(); } - } - - @Override - protected IVMNode createBreakpointVMNode() { - return new GdbBreakpointVMNode(this); - } - - @Override - public void getBreakpointsForDebugContext(ISelection debugContext, final DataRequestMonitor<IBreakpoint[]> rm) { - IExecutionDMContext _execCtx = null; - if (debugContext instanceof IStructuredSelection) { - Object element = ((IStructuredSelection)debugContext).getFirstElement(); - if (element instanceof IDMVMContext) { - _execCtx = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IExecutionDMContext.class); - } - } - - if (_execCtx == null || !fSession.getId().equals(_execCtx.getSessionId())) { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, "Debug context doesn't contain a thread", null)); //$NON-NLS-1$ - rm.done(); - return; - } - - final IExecutionDMContext execCtx = _execCtx; - - try { - fSession.getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - IBreakpointsExtension bpService = fServicesTracker.getService(IBreakpointsExtension.class); - if (bpService == null) { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Breakpoints service not available", null)); //$NON-NLS-1$ - rm.done(); - return; - } - bpService.getExecutionContextBreakpoints( - execCtx, - new DataRequestMonitor<IBreakpoints.IBreakpointDMContext[]>(fSession.getExecutor(), rm) { - @Override - protected void handleSuccess() { - MIBreakpointsManager bpManager = fServicesTracker.getService(MIBreakpointsManager.class); - if (bpManager == null) { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Breakpoints service not available", null)); //$NON-NLS-1$ - rm.done(); - return; - } - - IBreakpoint bp = null; - - - if (getData().length > 0) { - bp = bpManager.findPlatformBreakpoint(getData()[0]); - } - - if (bp != null) { - rm.setData(new IBreakpoint[] { bp }); - } else { - rm.setData(new IBreakpoint[0]); - } - rm.done(); - } - }); - } - }); - } catch (RejectedExecutionException e) { - rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Request for monitor: '" + toString() + "' resulted in a rejected execution exception.", e)); //$NON-NLS-1$ //$NON-NLS-2$); - rm.done(); - } - } - - private ISelection getDebugContext() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if ( window != null ) { - return DebugUITools.getDebugContextManager().getContextService( window ).getActiveContext(); - } - return StructuredSelection.EMPTY; - } - - private void getInstalledBreakpoints( final IBreakpointsTargetDMContext targetContext, - final IExecutionDMContext execContext, - final DataRequestMonitor<Collection<IBreakpoint>> rm ) { - + return StructuredSelection.EMPTY; + } + + private void getInstalledBreakpoints(final IBreakpointsTargetDMContext targetContext, + final IExecutionDMContext execContext, final DataRequestMonitor<Collection<IBreakpoint>> rm) { + try { - fSession.getExecutor().execute( new DsfRunnable() { + fSession.getExecutor().execute(new DsfRunnable() { @Override public void run() { - final IBreakpointsExtension bpService = fServicesTracker.getService( IBreakpointsExtension.class ); - if ( bpService == null ) { - rm.setStatus( new Status( - IStatus.ERROR, - GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, + final IBreakpointsExtension bpService = fServicesTracker.getService(IBreakpointsExtension.class); + if (bpService == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Breakpoints service not available", //$NON-NLS-1$ - null ) ); + null)); rm.done(); return; } - bpService.getBreakpoints( targetContext, new DataRequestMonitor<IBreakpointDMContext[]>( fSession.getExecutor(), rm ) { - - @Override - protected void handleSuccess() { - final MIBreakpointsManager bpManager = fServicesTracker.getService( MIBreakpointsManager.class ); - if ( bpManager == null ) { - rm.setStatus( new Status( - IStatus.ERROR, - GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, - "Breakpoint manager service not available", //$NON-NLS-1$ - null ) ); - rm.done(); - return; - } - - if ( getData().length > 0 ) { - final Set<IBreakpoint> bps = new HashSet<IBreakpoint>( getData().length ); - final CountingRequestMonitor crm = new CountingRequestMonitor( ImmediateExecutor.getInstance(), rm ) { - - @Override - protected void handleSuccess() { - rm.setData( bps ); + bpService.getBreakpoints(targetContext, + new DataRequestMonitor<IBreakpointDMContext[]>(fSession.getExecutor(), rm) { + + @Override + protected void handleSuccess() { + final MIBreakpointsManager bpManager = fServicesTracker + .getService(MIBreakpointsManager.class); + if (bpManager == null) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, + IDsfStatusConstants.INVALID_STATE, + "Breakpoint manager service not available", //$NON-NLS-1$ + null)); rm.done(); + return; } - }; - crm.setDoneCount( getData().length ); - - for ( final IBreakpointDMContext bpCtx : getData() ) { - bpService.getBreakpointDMData( - bpCtx, - new DataRequestMonitor<IBreakpointDMData>( ImmediateExecutor.getInstance(), crm ) { - - /* (non-Javadoc) - * @see org.eclipse.cdt.dsf.concurrent.RequestMonitor#handleSuccess() - */ + + if (getData().length > 0) { + final Set<IBreakpoint> bps = new HashSet<IBreakpoint>(getData().length); + final CountingRequestMonitor crm = new CountingRequestMonitor( + ImmediateExecutor.getInstance(), rm) { + @Override protected void handleSuccess() { - if ( getData() instanceof MIBreakpointDMData ) { - MIBreakpointDMData data = (MIBreakpointDMData)getData(); - if ( !data.isPending() ) { - bpBelongsToContext( execContext, data, new ImmediateDataRequestMonitor<Boolean>(crm) { - @Override - protected void handleSuccess() { - if (getData()) { - IBreakpoint bp = bpManager.findPlatformBreakpoint( bpCtx ); - if ( bp != null ) - bps.add( bp ); + rm.setData(bps); + rm.done(); + } + }; + crm.setDoneCount(getData().length); + + for (final IBreakpointDMContext bpCtx : getData()) { + bpService.getBreakpointDMData(bpCtx, + new DataRequestMonitor<IBreakpointDMData>( + ImmediateExecutor.getInstance(), crm) { + + /* (non-Javadoc) + * @see org.eclipse.cdt.dsf.concurrent.RequestMonitor#handleSuccess() + */ + @Override + protected void handleSuccess() { + if (getData() instanceof MIBreakpointDMData) { + MIBreakpointDMData data = (MIBreakpointDMData) getData(); + if (!data.isPending()) { + bpBelongsToContext(execContext, data, + new ImmediateDataRequestMonitor<Boolean>( + crm) { + @Override + protected void handleSuccess() { + if (getData()) { + IBreakpoint bp = bpManager + .findPlatformBreakpoint( + bpCtx); + if (bp != null) + bps.add(bp); + } + crm.done(); + } + }); + return; } - crm.done(); } - }); - return; - } - } - crm.done(); - } - } ); + crm.done(); + } + }); + } + } else { + rm.setData(new HashSet<IBreakpoint>()); + rm.done(); + } } - } - else { - rm.setData( new HashSet<IBreakpoint>() ); - rm.done(); - } - } - } ); + }); } - } ); - } - catch( RejectedExecutionException e ) { - rm.setStatus( new Status( - IStatus.ERROR, - GdbUIPlugin.PLUGIN_ID, - IDsfStatusConstants.INVALID_STATE, - "Request for monitor: '" + toString() + "' resulted in a rejected execution exception.", e ) ); //$NON-NLS-1$ //$NON-NLS-2$); + }); + } catch (RejectedExecutionException e) { + rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, + "Request for monitor: '" + toString() + "' resulted in a rejected execution exception.", e)); //$NON-NLS-1$ //$NON-NLS-2$); rm.done(); } - } - - private void bpBelongsToContext( IExecutionDMContext execContext, final MIBreakpointDMData data, final DataRequestMonitor<Boolean> rm ) { - if ( execContext == null ) { - // No execution context so accept all breakpoints - rm.done( true ); - return; - } - - // First check if a thread is selected as the context. In that case, we only want to show breakpoints that - // are applicable to that thread. - IMIExecutionDMContext threadContext = DMContexts.getAncestorOfType( execContext, IMIExecutionDMContext.class ); - if ( threadContext != null ) { + } + + private void bpBelongsToContext(IExecutionDMContext execContext, final MIBreakpointDMData data, + final DataRequestMonitor<Boolean> rm) { + if (execContext == null) { + // No execution context so accept all breakpoints + rm.done(true); + return; + } + + // First check if a thread is selected as the context. In that case, we only want to show breakpoints that + // are applicable to that thread. + IMIExecutionDMContext threadContext = DMContexts.getAncestorOfType(execContext, IMIExecutionDMContext.class); + if (threadContext != null) { // A thread is selected. Now make sure this breakpoint is assigned to this thread. - if (data.getThreadId() != null && data.getThreadId().length() > 0) { - String bpThreadId = data.getThreadId().trim(); - // A threadId of 0 means all threads of this process. We therefore will have to check - // if this breakpoint applies to the process that is selected. But if the threadId is not 0 - // we simply make sure we have the right thread selected. - if (!bpThreadId.equals("0")) { //$NON-NLS-1$ - String ctxThreadId = threadContext.getThreadId(); - rm.done(ctxThreadId.equals(bpThreadId)); - return; - } - } - } + if (data.getThreadId() != null && data.getThreadId().length() > 0) { + String bpThreadId = data.getThreadId().trim(); + // A threadId of 0 means all threads of this process. We therefore will have to check + // if this breakpoint applies to the process that is selected. But if the threadId is not 0 + // we simply make sure we have the right thread selected. + if (!bpThreadId.equals("0")) { //$NON-NLS-1$ + String ctxThreadId = threadContext.getThreadId(); + rm.done(ctxThreadId.equals(bpThreadId)); + return; + } + } + } // If we get here it is that the breakpoint is not assigned to a single thread. // We therefore make sure the breakpoint is applicable to the selected process. - final IMIContainerDMContext containerContext = DMContexts.getAncestorOfType( execContext, IMIContainerDMContext.class ); - if ( containerContext != null ) { - if ( data.getGroupIds() != null ) { - List<String> groupIds = Arrays.asList( data.getGroupIds() ); - rm.done( groupIds.contains( containerContext.getGroupId() ) ); + final IMIContainerDMContext containerContext = DMContexts.getAncestorOfType(execContext, + IMIContainerDMContext.class); + if (containerContext != null) { + if (data.getGroupIds() != null) { + List<String> groupIds = Arrays.asList(data.getGroupIds()); + rm.done(groupIds.contains(containerContext.getGroupId())); } else { // This happens if we are debugging a single process, so all breakpoints apply. - rm.done( true ); + rm.done(true); } } else { // Accept breakpoint - rm.done( true ); + rm.done(true); } - } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/commands/RetargetDebugContextCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/commands/RetargetDebugContextCommand.java index dce24b70dc7..3e2d2249633 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/commands/RetargetDebugContextCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/commands/RetargetDebugContextCommand.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial implementation *******************************************************************************/ @@ -38,123 +38,129 @@ import org.eclipse.ui.handlers.HandlerUtil; /** * Base class for actions which delegate functionality to an adapter retrieved * from the current debug context. - * + * * @since 2.0 */ -abstract public class RetargetDebugContextCommand extends AbstractHandler implements IDebugContextListener { - - private ISelection fDebugContext; - private Object fTargetAdapter = null; - private IDebugContextService fContextService = null; - private String fCommandId = null; - - protected Object getTargetAdapter() { return fTargetAdapter; } - protected ISelection getDebugContext() { return fDebugContext; } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) - */ - public RetargetDebugContextCommand() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - fContextService = DebugUITools.getDebugContextManager().getContextService(window); - fContextService.addPostDebugContextListener(this); - fDebugContext = fContextService.getActiveContext(); - update(); - } - - @Override +abstract public class RetargetDebugContextCommand extends AbstractHandler implements IDebugContextListener { + + private ISelection fDebugContext; + private Object fTargetAdapter = null; + private IDebugContextService fContextService = null; + private String fCommandId = null; + + protected Object getTargetAdapter() { + return fTargetAdapter; + } + + protected ISelection getDebugContext() { + return fDebugContext; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) + */ + public RetargetDebugContextCommand() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + fContextService = DebugUITools.getDebugContextManager().getContextService(window); + fContextService.addPostDebugContextListener(this); + fDebugContext = fContextService.getActiveContext(); + update(); + } + + @Override public Object execute(ExecutionEvent event) throws ExecutionException { fCommandId = event.getCommand().getId(); - - if (fTargetAdapter != null) { - try { - performCommand(fTargetAdapter, fDebugContext); - } catch (ExecutionException e) { - Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); - ErrorDialog.openError(shell, MessagesForVMActions.RetargetDebugContextAction_ErrorDialog_title, MessagesForVMActions.RetargetDebugContextAction_ErrorDialog_message, null); - } - } - - update(); - + + if (fTargetAdapter != null) { + try { + performCommand(fTargetAdapter, fDebugContext); + } catch (ExecutionException e) { + Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); + ErrorDialog.openError(shell, MessagesForVMActions.RetargetDebugContextAction_ErrorDialog_title, + MessagesForVMActions.RetargetDebugContextAction_ErrorDialog_message, null); + } + } + + update(); + return null; } - - /** - * Returns whether the specific operation is supported. - * - * @param target the target adapter - * @param debugContext the selection to verify the operation on - * @return whether the operation can be performed - */ - protected abstract boolean canPerformCommand(Object target, ISelection debugContext); - - /** - * Performs the specific operation. - * - * @param target the target adapter - * @param debugContext the selection to verify the operation on - * @throws CoreException if an exception occurs - */ - protected abstract void performCommand(Object target, ISelection debugContext) throws ExecutionException; - - /** - * Returns the type of adapter (target) this command works on. - * - * @return the type of adapter this command works on - */ - protected abstract Class<?> getAdapterClass(); - - public void update() { - boolean enabled = false; - - fTargetAdapter = null; - if (fDebugContext instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) fDebugContext; - if (!ss.isEmpty()) { - Object object = ss.getFirstElement(); - if (object instanceof IAdaptable) { - fTargetAdapter = getAdapter((IAdaptable) object); - if (fTargetAdapter != null) { - enabled = canPerformCommand(fTargetAdapter, fDebugContext); - } - } - } - } - - setBaseEnabled(enabled); - - if (fCommandId != null) { - ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); - if (commandService != null) { - commandService.refreshElements(fCommandId, null); - } - } - } - - @Override + + /** + * Returns whether the specific operation is supported. + * + * @param target the target adapter + * @param debugContext the selection to verify the operation on + * @return whether the operation can be performed + */ + protected abstract boolean canPerformCommand(Object target, ISelection debugContext); + + /** + * Performs the specific operation. + * + * @param target the target adapter + * @param debugContext the selection to verify the operation on + * @throws CoreException if an exception occurs + */ + protected abstract void performCommand(Object target, ISelection debugContext) throws ExecutionException; + + /** + * Returns the type of adapter (target) this command works on. + * + * @return the type of adapter this command works on + */ + protected abstract Class<?> getAdapterClass(); + + public void update() { + boolean enabled = false; + + fTargetAdapter = null; + if (fDebugContext instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) fDebugContext; + if (!ss.isEmpty()) { + Object object = ss.getFirstElement(); + if (object instanceof IAdaptable) { + fTargetAdapter = getAdapter((IAdaptable) object); + if (fTargetAdapter != null) { + enabled = canPerformCommand(fTargetAdapter, fDebugContext); + } + } + } + } + + setBaseEnabled(enabled); + + if (fCommandId != null) { + ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); + if (commandService != null) { + commandService.refreshElements(fCommandId, null); + } + } + } + + @Override public void dispose() { - // Must use the stored service. If we try to fetch the service - // again with the workbenchWindow, it may fail if the window is - // already closed. - fContextService.removePostDebugContextListener(this); - fTargetAdapter = null; - } - - @Override - public void debugContextChanged(DebugContextEvent event) { - fDebugContext = event.getContext(); - update(); - } - - protected Object getAdapter(IAdaptable adaptable) { - Object adapter = adaptable.getAdapter(getAdapterClass()); - if (adapter == null) { - IAdapterManager adapterManager = Platform.getAdapterManager(); - if (adapterManager.hasAdapter(adaptable, getAdapterClass().getName())) { - adapter = adapterManager.loadAdapter(adaptable, getAdapterClass().getName()); - } - } - return adapter; - } + // Must use the stored service. If we try to fetch the service + // again with the workbenchWindow, it may fail if the window is + // already closed. + fContextService.removePostDebugContextListener(this); + fTargetAdapter = null; + } + + @Override + public void debugContextChanged(DebugContextEvent event) { + fDebugContext = event.getContext(); + update(); + } + + protected Object getAdapter(IAdaptable adaptable) { + Object adapter = adaptable.getAdapter(getAdapterClass()); + if (adapter == null) { + IAdapterManager adapterManager = Platform.getAdapterManager(); + if (adapterManager.hasAdapter(adaptable, getAdapterClass().getName())) { + adapter = adapterManager.loadAdapter(adaptable, getAdapterClass().getName()); + } + } + return adapter; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java index ed238d8974c..f1f0849d98d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java @@ -7,18 +7,17 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - Initial API and implementation * Wind River Systems - Factored out AbstractContainerVMNode - * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) + * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) * Marc Khouzam (Ericsson) - Respect the "Show Full Path" option for the process name (Bug 378418) * Marc Khouzam (Ericsson) - Support for exited processes in the debug view (bug 407340) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch; - import java.util.Map; import java.util.concurrent.RejectedExecutionException; @@ -78,194 +77,204 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.ui.IMemento; - -public class ContainerVMNode extends AbstractContainerVMNode - implements IElementLabelProvider, IElementMementoProvider -{ +public class ContainerVMNode extends AbstractContainerVMNode implements IElementLabelProvider, IElementMementoProvider { /** Indicator that we should not display running threads */ private boolean fHideRunningThreadsProperty = false; - + /** PropertyChangeListener to keep track of the PREF_HIDE_RUNNING_THREADS preference */ private IPropertyChangeListener fPropertyChangeListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS)) { - fHideRunningThreadsProperty = (Boolean)event.getNewValue(); + fHideRunningThreadsProperty = (Boolean) event.getNewValue(); } } }; - + public ContainerVMNode(AbstractDMVMProvider provider, DsfSession session) { - super(provider, session); + super(provider, session); - IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); - store.addPropertyChangeListener(fPropertyChangeListener); - fHideRunningThreadsProperty = store.getBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS); + IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); + store.addPropertyChangeListener(fPropertyChangeListener); + fHideRunningThreadsProperty = store.getBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS); } - - @Override - public void dispose() { + + @Override + public void dispose() { GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); - super.dispose(); - } - + super.dispose(); + } + @Override public String toString() { - return "ContainerVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + return "ContainerVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } @Override - protected IElementLabelProvider createLabelProvider() { - PropertiesBasedLabelProvider provider = new PropertiesBasedLabelProvider(); - - provider.setColumnInfo( - PropertiesBasedLabelProvider.ID_COLUMN_NO_COLUMNS, - new LabelColumnInfo(new LabelAttribute[] { - - /* EXITED CONTAINER LABEL */ - new GdbExecutionContextLabelText( - MessagesForGdbLaunchVM.ContainerVMNode_No_columns__exited_format, - new String[] { - ExecutionContextLabelText.PROP_NAME_KNOWN, - PROP_NAME, - ExecutionContextLabelText.PROP_ID_KNOWN, - ILaunchVMConstants.PROP_ID, - IGdbLaunchVMConstants.PROP_EXIT_CODE_KNOWN, - IGdbLaunchVMConstants.PROP_EXIT_CODE }) { - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean exited = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_THREAD_EXITED); - return Boolean.TRUE.equals(exited); - } - }, - /* EXITED CONTAINER IMAGE */ - new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_OS_PROCESS_TERMINATED)) { - { setPropertyNames(new String[] { - IGdbLaunchVMConstants.PROP_THREAD_EXITED }); } - }, - - /* ACTIVE CONTAINER LABEL */ - new GdbExecutionContextLabelText( - MessagesForGdbLaunchVM.ContainerVMNode_No_columns__text_format, - new String[] { - ExecutionContextLabelText.PROP_NAME_KNOWN, - PROP_NAME, - ExecutionContextLabelText.PROP_ID_KNOWN, - ILaunchVMConstants.PROP_ID, - IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN, - IGdbLaunchVMConstants.PROP_CORES_ID, - IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN, - IGdbLaunchVMConstants.PROP_THREAD_SUMMARY }), - - new LabelText(MessagesForGdbLaunchVM.ContainerVMNode_No_columns__Error__label, new String[0]), - - /* RUNNING CONTAINER - RED PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_R_PINNED)) { - { setPropertyNames(new String[] { - ILaunchVMConstants.PROP_IS_SUSPENDED, - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + protected IElementLabelProvider createLabelProvider() { + PropertiesBasedLabelProvider provider = new PropertiesBasedLabelProvider(); + + provider.setColumnInfo(PropertiesBasedLabelProvider.ID_COLUMN_NO_COLUMNS, + new LabelColumnInfo(new LabelAttribute[] { + + /* EXITED CONTAINER LABEL */ + new GdbExecutionContextLabelText( + MessagesForGdbLaunchVM.ContainerVMNode_No_columns__exited_format, + new String[] { ExecutionContextLabelText.PROP_NAME_KNOWN, PROP_NAME, + ExecutionContextLabelText.PROP_ID_KNOWN, ILaunchVMConstants.PROP_ID, + IGdbLaunchVMConstants.PROP_EXIT_CODE_KNOWN, + IGdbLaunchVMConstants.PROP_EXIT_CODE }) { + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean exited = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_THREAD_EXITED); + return Boolean.TRUE.equals(exited); + } + }, + /* EXITED CONTAINER IMAGE */ + new LabelImage( + DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_OS_PROCESS_TERMINATED)) { + { + setPropertyNames(new String[] { IGdbLaunchVMConstants.PROP_THREAD_EXITED }); + } + }, + + /* ACTIVE CONTAINER LABEL */ + new GdbExecutionContextLabelText(MessagesForGdbLaunchVM.ContainerVMNode_No_columns__text_format, + new String[] { ExecutionContextLabelText.PROP_NAME_KNOWN, PROP_NAME, + ExecutionContextLabelText.PROP_ID_KNOWN, ILaunchVMConstants.PROP_ID, + IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN, IGdbLaunchVMConstants.PROP_CORES_ID, + IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN, + IGdbLaunchVMConstants.PROP_THREAD_SUMMARY }), + + new LabelText(MessagesForGdbLaunchVM.ContainerVMNode_No_columns__Error__label, new String[0]), + + /* RUNNING CONTAINER - RED PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_R_PINNED)) { + { + setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); - Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (prop != null && pin_prop != null && pin_color_prop != null) ? - !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; - }; - }, - /* RUNNING CONTAINER - GREEN PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_G_PINNED)) { - { setPropertyNames(new String[] { - ILaunchVMConstants.PROP_IS_SUSPENDED, - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) + ? !prop.booleanValue() && pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.RED) + : false; + }; + }, + /* RUNNING CONTAINER - GREEN PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_G_PINNED)) { + { + setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); - Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (prop != null && pin_prop != null && pin_color_prop != null) ? - !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; - }; - }, - /* RUNNING CONTAINER - BLUE PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_B_PINNED)) { - { setPropertyNames(new String[] { - ILaunchVMConstants.PROP_IS_SUSPENDED, - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) + ? !prop.booleanValue() && pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) + : false; + }; + }, + /* RUNNING CONTAINER - BLUE PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_RUNNING_B_PINNED)) { + { + setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) + ? !prop.booleanValue() && pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) + : false; + }; + }, + /* RUNNING CONTAINER - NO PIN */ + new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET)) { + { + setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); + } + + @Override + public boolean isEnabled(IStatus status, java.util.Map<String, Object> properties) { + return Boolean.FALSE.equals(properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED)); + }; + }, + + /* SUSPENDED CONTAINER - RED PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_R_PINNED)) { + { + setPropertyNames(new String[] { IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; + }; + }, + /* SUSPENDED CONTAINER - GREEN PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_G_PINNED)) { + { + setPropertyNames(new String[] { IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; + }; + }, + /* SUSPENDED CONTAINER - BLUE PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_B_PINNED)) { + { + setPropertyNames(new String[] { IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; + }; + }, + /* SUSPENDED CONTAINER - NO PIN */ + new LabelImage(DebugUITools + .getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_SUSPENDED)), })); + + return provider; + } - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); - Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (prop != null && pin_prop != null && pin_color_prop != null) ? - !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; - }; - }, - /* RUNNING CONTAINER - NO PIN */ - new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET)) { - { setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); } - - @Override - public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) { - return Boolean.FALSE.equals(properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED)); - }; - }, - - /* SUSPENDED CONTAINER - RED PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_R_PINNED)) { - { setPropertyNames(new String[] { - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } - - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (pin_prop != null && pin_color_prop != null) ? - pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; - }; - }, - /* SUSPENDED CONTAINER - GREEN PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_G_PINNED)) { - { setPropertyNames(new String[] { - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } - - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (pin_prop != null && pin_color_prop != null) ? - pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; - }; - }, - /* SUSPENDED CONTAINER - BLUE PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_CONTAINER_SUSPENDED_B_PINNED)) { - { setPropertyNames(new String[] { - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } - - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (pin_prop != null && pin_color_prop != null) ? - pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; - }; - }, - /* SUSPENDED CONTAINER - NO PIN */ - new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_SUSPENDED)), - })); - - return provider; - } - @Override protected void updateElementsInSessionThread(final IChildrenUpdate update) { IProcesses processService = getServicesTracker().getService(IProcesses.class); @@ -275,8 +284,7 @@ public class ContainerVMNode extends AbstractContainerVMNode return; } - processService.getProcessesBeingDebugged( - controlService.getContext(), + processService.getProcessesBeingDebugged(controlService.getContext(), new ViewerDataRequestMonitor<IDMContext[]>(getExecutor(), update) { @Override public void handleCompleted() { @@ -284,301 +292,307 @@ public class ContainerVMNode extends AbstractContainerVMNode handleFailedUpdate(update); return; } - if (getData() != null) fillUpdateWithVMCs(update, getData()); + if (getData() != null) + fillUpdateWithVMCs(update, getData()); update.done(); } }); } - @Override - protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) { - IPropertiesUpdate[] parentUpdates = new IPropertiesUpdate[updates.length]; - - for (int i = 0; i < updates.length; i++) { - final IPropertiesUpdate update = updates[i]; - - final ViewerCountingRequestMonitor countringRm = - new ViewerCountingRequestMonitor(ImmediateExecutor.getInstance(), updates[i]); - int count = 0; - - // Create a delegating update which will let the super-class fill in the - // standard container properties. - parentUpdates[i] = new VMDelegatingPropertiesUpdate(updates[i], countringRm); - count++; - - // set pin properties - IDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IDMContext.class); - IPinElementColorDescriptor colorDesc = PinCloneUtils.getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), dmc); - updates[i].setProperty(IGdbLaunchVMConstants.PROP_PIN_COLOR, - colorDesc != null ? colorDesc.getOverlayColor() : null); - updates[i].setProperty(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), dmc)); - - if (update.getProperties().contains(PROP_NAME) || - update.getProperties().contains(ILaunchVMConstants.PROP_ID) || - update.getProperties().contains(IGdbLaunchVMConstants.PROP_CORES_ID) || - update.getProperties().contains(IGdbLaunchVMConstants.PROP_THREAD_EXITED) || - update.getProperties().contains((IGdbLaunchVMConstants.PROP_EXIT_CODE))) - { - IProcesses processService = getServicesTracker().getService(IProcesses.class); - final IProcessDMContext procDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IProcessDMContext.class); - - if (processService == null || procDmc == null) { - update.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, "Service or handle invalid", null)); //$NON-NLS-1$ - } else { - processService.getExecutionData( - procDmc, - new ViewerDataRequestMonitor<IThreadDMData>(getExecutor(), update) { - @Override - public void handleCompleted() { - if (isSuccess()) { - fillThreadDataProperties(update, getData()); - } else { - update.setStatus(getStatus()); - } - countringRm.done(); - } - }); - count++; - } - } - - if (update.getProperties().contains(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY)) { - fillThreadSummary(update, countringRm); - count++; - } - - countringRm.setDoneCount(count); - } - - super.updatePropertiesInSessionThread(parentUpdates); - } - - protected void fillThreadDataProperties(IPropertiesUpdate update, IThreadDMData data) { - String fileName = data.getName(); - if (fileName != null) { - Object showFullPathPreference = getVMProvider().getPresentationContext().getProperty(IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY); - if (showFullPathPreference instanceof Boolean && (Boolean)showFullPathPreference == false) { - fileName = new Path(fileName).lastSegment(); - } - } - update.setProperty(PROP_NAME, fileName); - update.setProperty(ILaunchVMConstants.PROP_ID, data.getId()); - + @Override + protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) { + IPropertiesUpdate[] parentUpdates = new IPropertiesUpdate[updates.length]; + + for (int i = 0; i < updates.length; i++) { + final IPropertiesUpdate update = updates[i]; + + final ViewerCountingRequestMonitor countringRm = new ViewerCountingRequestMonitor( + ImmediateExecutor.getInstance(), updates[i]); + int count = 0; + + // Create a delegating update which will let the super-class fill in the + // standard container properties. + parentUpdates[i] = new VMDelegatingPropertiesUpdate(updates[i], countringRm); + count++; + + // set pin properties + IDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IDMContext.class); + IPinElementColorDescriptor colorDesc = PinCloneUtils + .getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), dmc); + updates[i].setProperty(IGdbLaunchVMConstants.PROP_PIN_COLOR, + colorDesc != null ? colorDesc.getOverlayColor() : null); + updates[i].setProperty(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), dmc)); + + if (update.getProperties().contains(PROP_NAME) + || update.getProperties().contains(ILaunchVMConstants.PROP_ID) + || update.getProperties().contains(IGdbLaunchVMConstants.PROP_CORES_ID) + || update.getProperties().contains(IGdbLaunchVMConstants.PROP_THREAD_EXITED) + || update.getProperties().contains((IGdbLaunchVMConstants.PROP_EXIT_CODE))) { + IProcesses processService = getServicesTracker().getService(IProcesses.class); + final IProcessDMContext procDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), + IProcessDMContext.class); + + if (processService == null || procDmc == null) { + update.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, + IDsfStatusConstants.INVALID_HANDLE, "Service or handle invalid", null)); //$NON-NLS-1$ + } else { + processService.getExecutionData(procDmc, + new ViewerDataRequestMonitor<IThreadDMData>(getExecutor(), update) { + @Override + public void handleCompleted() { + if (isSuccess()) { + fillThreadDataProperties(update, getData()); + } else { + update.setStatus(getStatus()); + } + countringRm.done(); + } + }); + count++; + } + } + + if (update.getProperties().contains(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY)) { + fillThreadSummary(update, countringRm); + count++; + } + + countringRm.setDoneCount(count); + } + + super.updatePropertiesInSessionThread(parentUpdates); + } + + protected void fillThreadDataProperties(IPropertiesUpdate update, IThreadDMData data) { + String fileName = data.getName(); + if (fileName != null) { + Object showFullPathPreference = getVMProvider().getPresentationContext() + .getProperty(IDsfDebugUIConstants.DEBUG_VIEW_SHOW_FULL_PATH_PROPERTY); + if (showFullPathPreference instanceof Boolean && (Boolean) showFullPathPreference == false) { + fileName = new Path(fileName).lastSegment(); + } + } + update.setProperty(PROP_NAME, fileName); + update.setProperty(ILaunchVMConstants.PROP_ID, data.getId()); + String coresStr = null; - if (data instanceof IGdbThreadDMData) { - String[] cores = ((IGdbThreadDMData)data).getCores(); - if (cores != null) { - StringBuilder str = new StringBuilder(); - for (String core : cores) { - str.append(core).append(','); - } - if (str.length() > 0) { - coresStr = str.substring(0, str.length() - 1); - } - } - } - update.setProperty(IGdbLaunchVMConstants.PROP_CORES_ID, coresStr); - - if (data instanceof IGdbThreadExitedDMData) { - update.setProperty(IGdbLaunchVMConstants.PROP_THREAD_EXITED, true); - - Integer exitCode = ((IGdbThreadExitedDMData)data).getExitCode(); - if (exitCode != null) { - update.setProperty(IGdbLaunchVMConstants.PROP_EXIT_CODE, exitCode); - } - } - } - - protected void fillThreadSummary(final IPropertiesUpdate update, final RequestMonitor rm) { - if (!fHideRunningThreadsProperty) { - // Disable the thread summary when we are not hiding threads - update.setProperty(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY, null); - rm.done(); - return; - } - - IProcesses processService = getServicesTracker().getService(IProcesses.class); - final IContainerDMContext procDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IContainerDMContext.class); - - if (processService == null || procDmc == null) { - update.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, "Service or handle invalid", null)); //$NON-NLS-1$ - } else { - // Fetch all the threads - processService.getProcessesBeingDebugged( - procDmc, - new ViewerDataRequestMonitor<IDMContext[]>(getSession().getExecutor(), update) { - @Override - public void handleCompleted() { - IRunControl runControl = getServicesTracker().getService(IRunControl.class); - if (!isSuccess() || - !(getData() instanceof IExecutionDMContext[]) || - runControl == null) { - update.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, "Unable to get threads summary", null)); //$NON-NLS-1$ - rm.done(); - return; - } - - // For each thread, count how many are running and therefore hidden - // Remove running threads from the list - int runningCount = 0; - for (IExecutionDMContext execDmc : (IExecutionDMContext[])getData()) { - // Keep suspended or stepping threads - if (!runControl.isSuspended(execDmc) && !runControl.isStepping(execDmc)) { - runningCount++; + if (data instanceof IGdbThreadDMData) { + String[] cores = ((IGdbThreadDMData) data).getCores(); + if (cores != null) { + StringBuilder str = new StringBuilder(); + for (String core : cores) { + str.append(core).append(','); + } + if (str.length() > 0) { + coresStr = str.substring(0, str.length() - 1); + } + } + } + update.setProperty(IGdbLaunchVMConstants.PROP_CORES_ID, coresStr); + + if (data instanceof IGdbThreadExitedDMData) { + update.setProperty(IGdbLaunchVMConstants.PROP_THREAD_EXITED, true); + + Integer exitCode = ((IGdbThreadExitedDMData) data).getExitCode(); + if (exitCode != null) { + update.setProperty(IGdbLaunchVMConstants.PROP_EXIT_CODE, exitCode); + } + } + } + + protected void fillThreadSummary(final IPropertiesUpdate update, final RequestMonitor rm) { + if (!fHideRunningThreadsProperty) { + // Disable the thread summary when we are not hiding threads + update.setProperty(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY, null); + rm.done(); + return; + } + + IProcesses processService = getServicesTracker().getService(IProcesses.class); + final IContainerDMContext procDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), + IContainerDMContext.class); + + if (processService == null || procDmc == null) { + update.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, + "Service or handle invalid", null)); //$NON-NLS-1$ + } else { + // Fetch all the threads + processService.getProcessesBeingDebugged(procDmc, + new ViewerDataRequestMonitor<IDMContext[]>(getSession().getExecutor(), update) { + @Override + public void handleCompleted() { + IRunControl runControl = getServicesTracker().getService(IRunControl.class); + if (!isSuccess() || !(getData() instanceof IExecutionDMContext[]) || runControl == null) { + update.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, + IDsfStatusConstants.INVALID_HANDLE, "Unable to get threads summary", null)); //$NON-NLS-1$ + rm.done(); + return; + } + + // For each thread, count how many are running and therefore hidden + // Remove running threads from the list + int runningCount = 0; + for (IExecutionDMContext execDmc : (IExecutionDMContext[]) getData()) { + // Keep suspended or stepping threads + if (!runControl.isSuspended(execDmc) && !runControl.isStepping(execDmc)) { + runningCount++; + } } + update.setProperty(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY, String.format("(%d %s)", //$NON-NLS-1$ + runningCount, MessagesForGdbLaunchVM.ContainerVMNode_filtered_running_threads)); + rm.done(); } - update.setProperty(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY, - String.format("(%d %s)", runningCount, MessagesForGdbLaunchVM.ContainerVMNode_filtered_running_threads)); //$NON-NLS-1$ - rm.done(); - } - }); - } - } - + }); + } + } + @Override public int getDeltaFlags(Object e) { if (e instanceof ICommandControlShutdownDMEvent) { return IModelDelta.CONTENT; } if (e instanceof IThreadRemovedDMEvent) { - IDMContext dmc = e instanceof IDMEvent<?> ? ((IDMEvent<?>)e).getDMContext() : null; - if (dmc instanceof IProcessDMContext) { - return IModelDelta.CONTENT; - } - return IModelDelta.NO_CHANGE; - } - return super.getDeltaFlags(e); + IDMContext dmc = e instanceof IDMEvent<?> ? ((IDMEvent<?>) e).getDMContext() : null; + if (dmc instanceof IProcessDMContext) { + return IModelDelta.CONTENT; + } + return IModelDelta.NO_CHANGE; + } + return super.getDeltaFlags(e); } @Override - public void buildDelta(Object e, final VMDelta parentDelta, final int nodeOffset, final RequestMonitor requestMonitor) { + public void buildDelta(Object e, final VMDelta parentDelta, final int nodeOffset, + final RequestMonitor requestMonitor) { if (e instanceof ICommandControlShutdownDMEvent) { - parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT); - } else if (e instanceof IThreadRemovedDMEvent) { - IDMContext dmc = e instanceof IDMEvent<?> ? ((IDMEvent<?>)e).getDMContext() : null; - if (dmc instanceof IProcessDMContext) { - // A process was removed, refresh the parent - parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT); - } - } else { - super.buildDelta(e, parentDelta, nodeOffset, requestMonitor); - return; - } + parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT); + } else if (e instanceof IThreadRemovedDMEvent) { + IDMContext dmc = e instanceof IDMEvent<?> ? ((IDMEvent<?>) e).getDMContext() : null; + if (dmc instanceof IProcessDMContext) { + // A process was removed, refresh the parent + parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT); + } + } else { + super.buildDelta(e, parentDelta, nodeOffset, requestMonitor); + return; + } requestMonitor.done(); - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#compareElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest[]) - */ - private final String MEMENTO_NAME = "CONTAINER_MEMENTO_NAME"; //$NON-NLS-1$ - - @Override - public void compareElements(IElementCompareRequest[] requests) { - for (final IElementCompareRequest request : requests) { - - Object element = request.getElement(); - final IMemento memento = request.getMemento(); - final String mementoName = memento.getString(MEMENTO_NAME); - - if (mementoName != null) { - if (element instanceof IDMVMContext) { - - IDMContext dmc = ((IDMVMContext)element).getDMContext(); - - if (dmc instanceof IContainerDMContext) - { - final IProcessDMContext procDmc = findDmcInPath(request.getViewerInput(), request.getElementPath(), IProcessDMContext.class); - - if (procDmc != null) { - try { - getSession().getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - final IProcesses processService = getServicesTracker().getService(IProcesses.class); - if (processService != null) { - processService.getExecutionData( - procDmc, - new ViewerDataRequestMonitor<IThreadDMData>(processService.getExecutor(), request) { - @Override - protected void handleCompleted() { - if ( getStatus().isOK() ) { - memento.putString(MEMENTO_NAME, "Container." + getData().getName() + getData().getId()); //$NON-NLS-1$ - } - request.done(); - } - }); - } - else { - request.done(); - } - } - }); - } catch (RejectedExecutionException e) { - request.done(); - } - - continue; - } - } - } - } - request.done(); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[]) - */ - @Override - public void encodeElements(IElementMementoRequest[] requests) { - for (final IElementMementoRequest request : requests) { - - Object element = request.getElement(); - final IMemento memento = request.getMemento(); - - if (element instanceof IDMVMContext) { - - IDMContext dmc = ((IDMVMContext)element).getDMContext(); - - if (dmc instanceof IContainerDMContext) - { - final IProcessDMContext procDmc = findDmcInPath(request.getViewerInput(), request.getElementPath(), IProcessDMContext.class); - - if (procDmc != null) { - try { - getSession().getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - final IProcesses processService = getServicesTracker().getService(IProcesses.class); - if (processService != null) { - processService.getExecutionData( - procDmc, - new ViewerDataRequestMonitor<IThreadDMData>(processService.getExecutor(), request) { - @Override - protected void handleCompleted() { - if ( getStatus().isOK() ) { - memento.putString(MEMENTO_NAME, "Container." + getData().getName() + getData().getId()); //$NON-NLS-1$ - } - request.done(); - } - }); - } else { - request.done(); - } - } - }); - } catch (RejectedExecutionException e) { - request.done(); - } - - continue; - } - } - } - request.done(); - } - } + } + + /* + * (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#compareElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest[]) + */ + private final String MEMENTO_NAME = "CONTAINER_MEMENTO_NAME"; //$NON-NLS-1$ + + @Override + public void compareElements(IElementCompareRequest[] requests) { + for (final IElementCompareRequest request : requests) { + + Object element = request.getElement(); + final IMemento memento = request.getMemento(); + final String mementoName = memento.getString(MEMENTO_NAME); + + if (mementoName != null) { + if (element instanceof IDMVMContext) { + + IDMContext dmc = ((IDMVMContext) element).getDMContext(); + + if (dmc instanceof IContainerDMContext) { + final IProcessDMContext procDmc = findDmcInPath(request.getViewerInput(), + request.getElementPath(), IProcessDMContext.class); + + if (procDmc != null) { + try { + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + final IProcesses processService = getServicesTracker() + .getService(IProcesses.class); + if (processService != null) { + processService.getExecutionData(procDmc, + new ViewerDataRequestMonitor<IThreadDMData>( + processService.getExecutor(), request) { + @Override + protected void handleCompleted() { + if (getStatus().isOK()) { + memento.putString(MEMENTO_NAME, "Container." //$NON-NLS-1$ + + getData().getName() + getData().getId()); + } + request.done(); + } + }); + } else { + request.done(); + } + } + }); + } catch (RejectedExecutionException e) { + request.done(); + } + + continue; + } + } + } + } + request.done(); + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[]) + */ + @Override + public void encodeElements(IElementMementoRequest[] requests) { + for (final IElementMementoRequest request : requests) { + + Object element = request.getElement(); + final IMemento memento = request.getMemento(); + + if (element instanceof IDMVMContext) { + + IDMContext dmc = ((IDMVMContext) element).getDMContext(); + + if (dmc instanceof IContainerDMContext) { + final IProcessDMContext procDmc = findDmcInPath(request.getViewerInput(), request.getElementPath(), + IProcessDMContext.class); + + if (procDmc != null) { + try { + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + final IProcesses processService = getServicesTracker().getService(IProcesses.class); + if (processService != null) { + processService.getExecutionData(procDmc, + new ViewerDataRequestMonitor<IThreadDMData>( + processService.getExecutor(), request) { + @Override + protected void handleCompleted() { + if (getStatus().isOK()) { + memento.putString(MEMENTO_NAME, "Container." //$NON-NLS-1$ + + getData().getName() + getData().getId()); + } + request.done(); + } + }); + } else { + request.done(); + } + } + }); + } catch (RejectedExecutionException e) { + request.done(); + } + + continue; + } + } + } + request.done(); + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbExecutionContextLabelText.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbExecutionContextLabelText.java index f6ffc43ac00..b98ff11ce97 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbExecutionContextLabelText.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbExecutionContextLabelText.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Marc Khouzam (Ericsson) - Support for exited processes in the debug view (bug 407340) @@ -24,40 +24,39 @@ import org.eclipse.core.runtime.IStatus; */ public class GdbExecutionContextLabelText extends ExecutionContextLabelText { - public GdbExecutionContextLabelText(String formatPattern, String[] propertyNames) { - super(formatPattern, propertyNames); - } + public GdbExecutionContextLabelText(String formatPattern, String[] propertyNames) { + super(formatPattern, propertyNames); + } - @Override - protected Object getPropertyValue(String propertyName, IStatus status, Map<String, Object> properties) { - if (IGdbLaunchVMConstants.PROP_OS_ID_KNOWN.equals(propertyName)) { - return properties.get(IGdbLaunchVMConstants.PROP_OS_ID) != null ? 1 : 0; - } - if (IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN.equals(propertyName)) { - return properties.get(IGdbLaunchVMConstants.PROP_CORES_ID) != null ? 1 : 0; - } - if (IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN.equals(propertyName)) { - return properties.get(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY) != null ? 1 : 0; - } - if (IGdbLaunchVMConstants.PROP_EXIT_CODE_KNOWN.equals(propertyName)) { - return properties.get(IGdbLaunchVMConstants.PROP_EXIT_CODE) != null ? 1 : 0; - } - return super.getPropertyValue(propertyName, status, properties); - } + @Override + protected Object getPropertyValue(String propertyName, IStatus status, Map<String, Object> properties) { + if (IGdbLaunchVMConstants.PROP_OS_ID_KNOWN.equals(propertyName)) { + return properties.get(IGdbLaunchVMConstants.PROP_OS_ID) != null ? 1 : 0; + } + if (IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN.equals(propertyName)) { + return properties.get(IGdbLaunchVMConstants.PROP_CORES_ID) != null ? 1 : 0; + } + if (IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN.equals(propertyName)) { + return properties.get(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY) != null ? 1 : 0; + } + if (IGdbLaunchVMConstants.PROP_EXIT_CODE_KNOWN.equals(propertyName)) { + return properties.get(IGdbLaunchVMConstants.PROP_EXIT_CODE) != null ? 1 : 0; + } + return super.getPropertyValue(propertyName, status, properties); + } - @Override - protected boolean checkProperty(String propertyName, IStatus status, Map<String, Object> properties) { - if (IGdbLaunchVMConstants.PROP_OS_ID_KNOWN.equals(propertyName) || - IGdbLaunchVMConstants.PROP_OS_ID.equals(propertyName) || - IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN.equals(propertyName) || - IGdbLaunchVMConstants.PROP_CORES_ID.equals(propertyName) || - IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN.equals(propertyName) || - IGdbLaunchVMConstants.PROP_THREAD_SUMMARY.equals(propertyName) || - IGdbLaunchVMConstants.PROP_EXIT_CODE_KNOWN.equals(propertyName) || - IGdbLaunchVMConstants.PROP_EXIT_CODE.equals(propertyName)) - { - return true; - } - return super.checkProperty(propertyName, status, properties); - } + @Override + protected boolean checkProperty(String propertyName, IStatus status, Map<String, Object> properties) { + if (IGdbLaunchVMConstants.PROP_OS_ID_KNOWN.equals(propertyName) + || IGdbLaunchVMConstants.PROP_OS_ID.equals(propertyName) + || IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN.equals(propertyName) + || IGdbLaunchVMConstants.PROP_CORES_ID.equals(propertyName) + || IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN.equals(propertyName) + || IGdbLaunchVMConstants.PROP_THREAD_SUMMARY.equals(propertyName) + || IGdbLaunchVMConstants.PROP_EXIT_CODE_KNOWN.equals(propertyName) + || IGdbLaunchVMConstants.PROP_EXIT_CODE.equals(propertyName)) { + return true; + } + return super.checkProperty(propertyName, status, properties); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbStackFramesVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbStackFramesVMNode.java index 4a693700c29..fa3b549f96a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbStackFramesVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbStackFramesVMNode.java @@ -37,50 +37,47 @@ public class GdbStackFramesVMNode extends StackFramesVMNode { @Override public int getDeltaFlags(Object e) { if (e instanceof IGDBFocusChangedEvent) { - return IModelDelta.SELECT; + return IModelDelta.SELECT; } - + return super.getDeltaFlags(e); } - + @Override public void buildDelta(final Object e, final VMDelta parentDelta, final int nodeOffset, final RequestMonitor rm) { if (e instanceof IGDBFocusChangedEvent) { - buildDeltaForFocusChangedEvent((IGDBFocusChangedEvent)e, parentDelta, rm); - } - else { + buildDeltaForFocusChangedEvent((IGDBFocusChangedEvent) e, parentDelta, rm); + } else { super.buildDelta(e, parentDelta, nodeOffset, rm); } } - + private void buildDeltaForFocusChangedEvent(IGDBFocusChangedEvent event, VMDelta parentDelta, RequestMonitor rm) { getSession().getExecutor().execute(new Runnable() { @Override public void run() { IDMContext ctx = event.getDMContext(); - - // Is IGDBFocusChangedEvent pertinent for this VMNode? + + // Is IGDBFocusChangedEvent pertinent for this VMNode? if (ctx instanceof IFrameDMContext) { - IFrameDMContext newFrameFocus = (IFrameDMContext)ctx; - IMIExecutionDMContext execDmc = DMContexts.getAncestorOfType(newFrameFocus, IMIExecutionDMContext.class); + IFrameDMContext newFrameFocus = (IFrameDMContext) ctx; + IMIExecutionDMContext execDmc = DMContexts.getAncestorOfType(newFrameFocus, + IMIExecutionDMContext.class); if (execDmc == null) { rm.done(); return; } - IRunControl runControl = getServicesTracker().getService(IRunControl.class); - if (runControl == null) { - // Required services have not initialized yet. Ignore the event. - rm.done(); - return; - } + IRunControl runControl = getServicesTracker().getService(IRunControl.class); + if (runControl == null) { + // Required services have not initialized yet. Ignore the event. + rm.done(); + return; + } if (runControl.isSuspended(execDmc) || runControl.isStepping(execDmc)) { // find the VMC index for the frame that switched, so we can select it correctly. - getVMCIndexForDmc( - GdbStackFramesVMNode.this, - newFrameFocus, - parentDelta, + getVMCIndexForDmc(GdbStackFramesVMNode.this, newFrameFocus, parentDelta, new DataRequestMonitor<Integer>(getExecutor(), rm) { @Override protected void handleSuccess() { @@ -90,24 +87,21 @@ public class GdbStackFramesVMNode extends StackFramesVMNode { // Retrieve the list of stack frames getVMProvider().updateNode(GdbStackFramesVMNode.this, new VMChildrenUpdate(parentDelta, - getVMProvider().getPresentationContext(), -1, - -1, new DataRequestMonitor<List<Object>>( - getExecutor(), rm) { - @Override - public void handleSuccess() { - final List<Object> data = getData(); - if (data != null && data.size() != 0) { - // create the delta to select the - // current stack frame - parentDelta.addNode( - data.get(frameOffset), - frameOffset, - IModelDelta.SELECT | IModelDelta.FORCE - ); - } - rm.done(); - } - })); + getVMProvider().getPresentationContext(), -1, -1, + new DataRequestMonitor<List<Object>>(getExecutor(), rm) { + @Override + public void handleSuccess() { + final List<Object> data = getData(); + if (data != null && data.size() != 0) { + // create the delta to select the + // current stack frame + parentDelta.addNode(data.get(frameOffset), + frameOffset, + IModelDelta.SELECT | IModelDelta.FORCE); + } + rm.done(); + } + })); } }); } else { @@ -119,6 +113,6 @@ public class GdbStackFramesVMNode extends StackFramesVMNode { rm.done(); } } - }); + }); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbStandardProcessVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbStandardProcessVMNode.java index eff58106fb8..1bed684e787 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbStandardProcessVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/GdbStandardProcessVMNode.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Ericsson - initial API and implementation *******************************************************************************/ @@ -28,143 +28,141 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; import org.eclipse.jface.viewers.TreePath; /** - * Layout node for the standard platform debug model IProcess object. This - * node requires that an ILaunch object be found as an ancestor of this node. - * It does not implement the label provider functionality, so the default + * Layout node for the standard platform debug model IProcess object. This + * node requires that an ILaunch object be found as an ancestor of this node. + * It does not implement the label provider functionality, so the default * adapters should be used to retrieve the label. - * + * * This version is specific to DSF-GDB to no longer show the inferiors. */ public class GdbStandardProcessVMNode extends StandardProcessVMNode { - - public GdbStandardProcessVMNode(AbstractVMProvider provider) { - super(provider); - } - @Override - public String toString() { - return "GdbStandardProcessVMNode"; //$NON-NLS-1$ - } + public GdbStandardProcessVMNode(AbstractVMProvider provider) { + super(provider); + } + + @Override + public String toString() { + return "GdbStandardProcessVMNode"; //$NON-NLS-1$ + } + + @Override + public void update(IChildrenUpdate[] updates) { + for (IChildrenUpdate update : updates) { + ILaunch launch = findLaunch(update.getElementPath()); + if (launch == null) { + // There is no launch in the parent of this node. This means that the + // layout is misconfigured. + assert false; + update.done(); + continue; + } + + /* + * Assume that the process objects are stored within the launch, and + * retrieve them on dispatch thread. + */ + int count = 0; + for (IProcess process : launch.getProcesses()) { + if (!(process instanceof InferiorRuntimeProcess)) { + update.setChild(process, count++); + } + } + update.done(); + } + } + + @Override + public void update(final IChildrenCountUpdate[] updates) { + for (IChildrenCountUpdate update : updates) { + if (!checkUpdate(update)) + continue; + ILaunch launch = findLaunch(update.getElementPath()); + if (launch == null) { + assert false; + update.setChildCount(0); + update.done(); + return; + } + + int count = 0; + for (IProcess process : launch.getProcesses()) { + if (!(process instanceof InferiorRuntimeProcess)) { + count++; + } + } + update.setChildCount(count); + update.done(); + } + } + + // @see org.eclipse.cdt.dsf.ui.viewmodel.IViewModelLayoutNode#hasElements(org.eclipse.cdt.dsf.ui.viewmodel.IVMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) + @Override + public void update(IHasChildrenUpdate[] updates) { + for (IHasChildrenUpdate update : updates) { + ILaunch launch = findLaunch(update.getElementPath()); + if (launch == null) { + assert false; + update.setHasChilren(false); + update.done(); + return; + } + + boolean hasChildren = false; + for (IProcess process : launch.getProcesses()) { + if (!(process instanceof InferiorRuntimeProcess)) { + hasChildren = true; + break; + } + } + + update.setHasChilren(hasChildren); + update.done(); + } + } - @Override - public void update(IChildrenUpdate[] updates) { - for (IChildrenUpdate update : updates) { - ILaunch launch = findLaunch(update.getElementPath()); - if (launch == null) { - // There is no launch in the parent of this node. This means that the - // layout is misconfigured. - assert false; - update.done(); - continue; - } - - /* - * Assume that the process objects are stored within the launch, and - * retrieve them on dispatch thread. - */ - int count = 0; - for (IProcess process : launch.getProcesses()) { - if (!(process instanceof InferiorRuntimeProcess)) { - update.setChild(process, count++); - } - } - update.done(); - } - } - - @Override - public void update(final IChildrenCountUpdate[] updates) { - for (IChildrenCountUpdate update : updates) { - if (!checkUpdate(update)) continue; - ILaunch launch = findLaunch(update.getElementPath()); - if (launch == null) { - assert false; - update.setChildCount(0); - update.done(); - return; - } - - int count = 0; - for (IProcess process : launch.getProcesses()) { - if (!(process instanceof InferiorRuntimeProcess)) { - count++; - } - } - update.setChildCount(count); - update.done(); - } - } + /** + * Recursively searches the VMC for Launch VMC, and returns its ILaunch. + * Returns null if an ILaunch is not found. + */ + private ILaunch findLaunch(TreePath path) { + for (int i = path.getSegmentCount() - 1; i >= 0; i--) { + if (path.getSegment(i) instanceof ILaunch) { + return (ILaunch) path.getSegment(i); + } + } + return null; + } - // @see org.eclipse.cdt.dsf.ui.viewmodel.IViewModelLayoutNode#hasElements(org.eclipse.cdt.dsf.ui.viewmodel.IVMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) - @Override - public void update(IHasChildrenUpdate[] updates) { - for (IHasChildrenUpdate update : updates) { - ILaunch launch = findLaunch(update.getElementPath()); - if (launch == null) { - assert false; - update.setHasChilren(false); - update.done(); - return; - } - - boolean hasChildren = false; - for (IProcess process : launch.getProcesses()) { - if (!(process instanceof InferiorRuntimeProcess)) { - hasChildren = true; - break; - } - } - - update.setHasChilren(hasChildren); - update.done(); - } - } + @Override + public int getDeltaFlags(Object e) { + int myFlags = 0; + if (e instanceof DebugEvent) { + DebugEvent de = (DebugEvent) e; + if (!(de.getSource() instanceof InferiorRuntimeProcess) && (de.getKind() == DebugEvent.CHANGE + || de.getKind() == DebugEvent.CREATE || de.getKind() == DebugEvent.TERMINATE)) { + myFlags = IModelDelta.STATE; + } + } + return myFlags; + } - /** - * Recursively searches the VMC for Launch VMC, and returns its ILaunch. - * Returns null if an ILaunch is not found. - */ - private ILaunch findLaunch(TreePath path) { - for (int i = path.getSegmentCount() - 1; i >= 0; i--) { - if (path.getSegment(i) instanceof ILaunch) { - return (ILaunch)path.getSegment(i); - } - } - return null; - } - - @Override - public int getDeltaFlags(Object e) { - int myFlags = 0; - if (e instanceof DebugEvent) { - DebugEvent de = (DebugEvent)e; - if (!(de.getSource() instanceof InferiorRuntimeProcess) && - (de.getKind() == DebugEvent.CHANGE || - de.getKind() == DebugEvent.CREATE || - de.getKind() == DebugEvent.TERMINATE) ) - { - myFlags = IModelDelta.STATE; - } - } - return myFlags; - } - - @Override - public void buildDelta(Object e, VMDelta parent, int nodeOffset, RequestMonitor requestMonitor) { - if (e instanceof DebugEvent && !(((DebugEvent)e).getSource() instanceof InferiorRuntimeProcess)) { - DebugEvent de = (DebugEvent)e; - if (de.getKind() == DebugEvent.CHANGE) { - handleChange(de, parent); - } else if (de.getKind() == DebugEvent.CREATE) { - handleCreate(de, parent); - } else if (de.getKind() == DebugEvent.TERMINATE) { - handleTerminate(de, parent); - } - /* - * No other node should need to process events related to process. - * Therefore, just invoke the request monitor without calling super.buildDelta(). - */ - } - requestMonitor.done(); - } + @Override + public void buildDelta(Object e, VMDelta parent, int nodeOffset, RequestMonitor requestMonitor) { + if (e instanceof DebugEvent && !(((DebugEvent) e).getSource() instanceof InferiorRuntimeProcess)) { + DebugEvent de = (DebugEvent) e; + if (de.getKind() == DebugEvent.CHANGE) { + handleChange(de, parent); + } else if (de.getKind() == DebugEvent.CREATE) { + handleCreate(de, parent); + } else if (de.getKind() == DebugEvent.TERMINATE) { + handleTerminate(de, parent); + } + /* + * No other node should need to process events related to process. + * Therefore, just invoke the request monitor without calling super.buildDelta(). + */ + } + requestMonitor.done(); + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/IGdbLaunchVMConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/IGdbLaunchVMConstants.java index 20c24899464..aed4253d780 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/IGdbLaunchVMConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/IGdbLaunchVMConstants.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) @@ -20,44 +20,44 @@ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch; */ public interface IGdbLaunchVMConstants { - public static final String PROP_OS_ID = "os_id"; //$NON-NLS-1$ - - /** - * Value <code>0</code> means it's not known. Value <code>1</code>, means it's known. - */ - public static final String PROP_OS_ID_KNOWN = "os_id_known"; //$NON-NLS-1$ - - public static final String PROP_CORES_ID = "cores_id"; //$NON-NLS-1$ - - /** - * Value <code>0</code> means it's not known. Value <code>1</code>, means it's known. - */ - public static final String PROP_CORES_ID_KNOWN = "cores_id_known"; //$NON-NLS-1$ - - /** - * The context is pinned. Value <code>true</code> or <code>false</code>. - */ - public static final String PROP_PINNED_CONTEXT = "pinned_context"; //$NON-NLS-1$ - - /** - * The pin color. One of the <code>IPinElementColorDescriptor</code> color value. - */ - public static final String PROP_PIN_COLOR = "pin_color"; //$NON-NLS-1$ - - public static final String PROP_THREAD_SUMMARY_KNOWN = "thread_summary_known"; //$NON-NLS-1$ - public static final String PROP_THREAD_SUMMARY = "thread_summary"; //$NON-NLS-1$ - - /** - * If this property is set, it indicates the process or thread should be shown as exited. - */ - public static final String PROP_THREAD_EXITED = "thread_exited"; //$NON-NLS-1$ - - /** - * Value <code>0</code> means it's not known. Value <code>1</code>, means it's known. - */ - public static final String PROP_EXIT_CODE_KNOWN = "exit_code_known"; //$NON-NLS-1$ - /** - * If set, the value of the property indicates the exit code returned. - */ - public static final String PROP_EXIT_CODE = "exit_code"; //$NON-NLS-1$ + public static final String PROP_OS_ID = "os_id"; //$NON-NLS-1$ + + /** + * Value <code>0</code> means it's not known. Value <code>1</code>, means it's known. + */ + public static final String PROP_OS_ID_KNOWN = "os_id_known"; //$NON-NLS-1$ + + public static final String PROP_CORES_ID = "cores_id"; //$NON-NLS-1$ + + /** + * Value <code>0</code> means it's not known. Value <code>1</code>, means it's known. + */ + public static final String PROP_CORES_ID_KNOWN = "cores_id_known"; //$NON-NLS-1$ + + /** + * The context is pinned. Value <code>true</code> or <code>false</code>. + */ + public static final String PROP_PINNED_CONTEXT = "pinned_context"; //$NON-NLS-1$ + + /** + * The pin color. One of the <code>IPinElementColorDescriptor</code> color value. + */ + public static final String PROP_PIN_COLOR = "pin_color"; //$NON-NLS-1$ + + public static final String PROP_THREAD_SUMMARY_KNOWN = "thread_summary_known"; //$NON-NLS-1$ + public static final String PROP_THREAD_SUMMARY = "thread_summary"; //$NON-NLS-1$ + + /** + * If this property is set, it indicates the process or thread should be shown as exited. + */ + public static final String PROP_THREAD_EXITED = "thread_exited"; //$NON-NLS-1$ + + /** + * Value <code>0</code> means it's not known. Value <code>1</code>, means it's known. + */ + public static final String PROP_EXIT_CODE_KNOWN = "exit_code_known"; //$NON-NLS-1$ + /** + * If set, the value of the property indicates the exit code returned. + */ + public static final String PROP_EXIT_CODE = "exit_code"; //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMModelProxyStrategy.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMModelProxyStrategy.java index 04e27364868..45a1bbb4bf5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMModelProxyStrategy.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMModelProxyStrategy.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -19,24 +19,24 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.jface.viewers.TreePath; /** - * + * */ public class LaunchVMModelProxyStrategy extends DefaultVMModelProxyStrategy { - final private TreePath fRootPath; - - public LaunchVMModelProxyStrategy(AbstractVMProvider provider, Object rootElement) { - super(provider, rootElement); - fRootPath = new TreePath( new Object[] { rootElement }); - } - - @Override - public Object getViewerInput() { - return DebugPlugin.getDefault().getLaunchManager(); - } - - @Override - public TreePath getRootPath() { - return fRootPath; - } + final private TreePath fRootPath; + + public LaunchVMModelProxyStrategy(AbstractVMProvider provider, Object rootElement) { + super(provider, rootElement); + fRootPath = new TreePath(new Object[] { rootElement }); + } + + @Override + public Object getViewerInput() { + return DebugPlugin.getDefault().getLaunchManager(); + } + + @Override + public TreePath getRootPath() { + return fRootPath; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java index b49887e1078..18440f8f97d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Ericsson - Modified for new functionality @@ -42,135 +42,123 @@ import org.eclipse.debug.core.IDebugEventSetListener; import org.eclipse.debug.core.ILaunchesListener2; import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; - /** - * + * */ -public class LaunchVMProvider extends AbstractLaunchVMProvider - implements IDebugEventSetListener, ILaunchesListener2 -{ - +public class LaunchVMProvider extends AbstractLaunchVMProvider implements IDebugEventSetListener, ILaunchesListener2 { + /** * Indicates that we are currently visualizing trace data. */ private boolean fTracepointVisualizationModeEnabled; - + @ThreadSafe - public LaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) - { - super(adapter, presentationContext, session); - - createNodes(); - } + public LaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) { + super(adapter, presentationContext, session); + + createNodes(); + } protected void createNodes() { - IRootVMNode launchNode = new LaunchRootVMNode(this); - setRootNode(launchNode); - - // Container node to contain all processes and threads - IVMNode containerNode = new ContainerVMNode(this, getSession()); - IVMNode processesNode = new GdbStandardProcessVMNode(this); - addChildNodes(launchNode, new IVMNode[] { containerNode, processesNode}); - - IVMNode threadsNode = new ThreadVMNode(this, getSession()); - addChildNodes(containerNode, new IVMNode[] { threadsNode }); - - IVMNode stackFramesNode = new GdbStackFramesVMNode(this, getSession()); - addChildNodes(threadsNode, new IVMNode[] { stackFramesNode }); - } - - @Override - protected boolean canSkipHandlingEvent(Object newEvent, Object eventToSkip) { - // Never skip the process lifecycle events. - if (eventToSkip instanceof ICommandControlInitializedDMEvent || - eventToSkip instanceof ICommandControlShutdownDMEvent) - { - return false; - } - - if (eventToSkip instanceof ITracingStartedDMEvent || - eventToSkip instanceof ITracingStoppedDMEvent) - { - if (newEvent instanceof ITracingStartedDMEvent || - newEvent instanceof ITracingStoppedDMEvent) - { - return true; - } - } - - if (eventToSkip instanceof ITracingSupportedChangeDMEvent) - { - if (newEvent instanceof ITracingSupportedChangeDMEvent) - { - return true; - } - } - - if (eventToSkip instanceof ITraceRecordSelectedChangedDMEvent) { - ITraceRecordSelectedChangedDMEvent recordChanged = (ITraceRecordSelectedChangedDMEvent)eventToSkip; - if (recordChanged.isVisualizationModeEnabled() == fTracepointVisualizationModeEnabled) { - // We only care about this event if it indicates a change of visualization state - return true; - } - } - - return super.canSkipHandlingEvent(newEvent, eventToSkip); - } - - @Override - public void handleEvent(Object event, RequestMonitor rm) { - if (event instanceof ITracingStartedDMEvent || - event instanceof ITracingStoppedDMEvent || - event instanceof ITracingSupportedChangeDMEvent) - { - // Refresh the view to trigger a context change, which - // will cause command enablement to be refreshed - refresh(); - rm.done(); - return; - } - - if (event instanceof ITraceRecordSelectedChangedDMEvent) { - ITraceRecordSelectedChangedDMEvent recordChanged = (ITraceRecordSelectedChangedDMEvent)event; - // If trace visualization has changed we have to refresh the debug view - if (recordChanged.isVisualizationModeEnabled() != fTracepointVisualizationModeEnabled) { - fTracepointVisualizationModeEnabled = recordChanged.isVisualizationModeEnabled(); - - // Refresh the view because the set of threads has totally changed. - refresh(); - rm.done(); - return; - } - } - - super.handleEvent(event, rm); - } - - @Override - public void refresh() { - super.refresh(); - try { - getSession().getExecutor().execute(new DsfRunnable() { - @Override - public void run() { - DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), getSession().getId()); - IProcesses processesService = tracker.getService(IProcesses.class); - if (processesService instanceof ICachingService) { - ((ICachingService)processesService).flushCache(null); - } - IStack stackService = tracker.getService(IStack.class); - if (stackService instanceof ICachingService) { - ((ICachingService)stackService).flushCache(null); - } - IRunControl runControlService = tracker.getService(IRunControl.class); - if (runControlService instanceof ICachingService) { - ((ICachingService)runControlService).flushCache(null); - } - tracker.dispose(); - } - }); - } catch (RejectedExecutionException e) { - // Session disposed, ignore. - } - } + IRootVMNode launchNode = new LaunchRootVMNode(this); + setRootNode(launchNode); + + // Container node to contain all processes and threads + IVMNode containerNode = new ContainerVMNode(this, getSession()); + IVMNode processesNode = new GdbStandardProcessVMNode(this); + addChildNodes(launchNode, new IVMNode[] { containerNode, processesNode }); + + IVMNode threadsNode = new ThreadVMNode(this, getSession()); + addChildNodes(containerNode, new IVMNode[] { threadsNode }); + + IVMNode stackFramesNode = new GdbStackFramesVMNode(this, getSession()); + addChildNodes(threadsNode, new IVMNode[] { stackFramesNode }); + } + + @Override + protected boolean canSkipHandlingEvent(Object newEvent, Object eventToSkip) { + // Never skip the process lifecycle events. + if (eventToSkip instanceof ICommandControlInitializedDMEvent + || eventToSkip instanceof ICommandControlShutdownDMEvent) { + return false; + } + + if (eventToSkip instanceof ITracingStartedDMEvent || eventToSkip instanceof ITracingStoppedDMEvent) { + if (newEvent instanceof ITracingStartedDMEvent || newEvent instanceof ITracingStoppedDMEvent) { + return true; + } + } + + if (eventToSkip instanceof ITracingSupportedChangeDMEvent) { + if (newEvent instanceof ITracingSupportedChangeDMEvent) { + return true; + } + } + + if (eventToSkip instanceof ITraceRecordSelectedChangedDMEvent) { + ITraceRecordSelectedChangedDMEvent recordChanged = (ITraceRecordSelectedChangedDMEvent) eventToSkip; + if (recordChanged.isVisualizationModeEnabled() == fTracepointVisualizationModeEnabled) { + // We only care about this event if it indicates a change of visualization state + return true; + } + } + + return super.canSkipHandlingEvent(newEvent, eventToSkip); + } + + @Override + public void handleEvent(Object event, RequestMonitor rm) { + if (event instanceof ITracingStartedDMEvent || event instanceof ITracingStoppedDMEvent + || event instanceof ITracingSupportedChangeDMEvent) { + // Refresh the view to trigger a context change, which + // will cause command enablement to be refreshed + refresh(); + rm.done(); + return; + } + + if (event instanceof ITraceRecordSelectedChangedDMEvent) { + ITraceRecordSelectedChangedDMEvent recordChanged = (ITraceRecordSelectedChangedDMEvent) event; + // If trace visualization has changed we have to refresh the debug view + if (recordChanged.isVisualizationModeEnabled() != fTracepointVisualizationModeEnabled) { + fTracepointVisualizationModeEnabled = recordChanged.isVisualizationModeEnabled(); + + // Refresh the view because the set of threads has totally changed. + refresh(); + rm.done(); + return; + } + } + + super.handleEvent(event, rm); + } + + @Override + public void refresh() { + super.refresh(); + try { + getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), + getSession().getId()); + IProcesses processesService = tracker.getService(IProcesses.class); + if (processesService instanceof ICachingService) { + ((ICachingService) processesService).flushCache(null); + } + IStack stackService = tracker.getService(IStack.class); + if (stackService instanceof ICachingService) { + ((ICachingService) stackService).flushCache(null); + } + IRunControl runControlService = tracker.getService(IRunControl.class); + if (runControlService instanceof ICachingService) { + ((ICachingService) runControlService).flushCache(null); + } + tracker.dispose(); + } + }); + } catch (RejectedExecutionException e) { + // Session disposed, ignore. + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/MessagesForGdbLaunchVM.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/MessagesForGdbLaunchVM.java index 2354e322d0d..7177ad6b367 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/MessagesForGdbLaunchVM.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/MessagesForGdbLaunchVM.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation * Marc Khouzam (Ericsson) - Support for exited processes in the debug view (bug 407340) @@ -21,19 +21,19 @@ import org.eclipse.osgi.util.NLS; * @noinstantiate This class is not intended to be instantiated by clients. */ public class MessagesForGdbLaunchVM extends NLS { - public static String ThreadVMNode_No_columns__text_format; - public static String ThreadVMNode_No_columns__Error__label; - public static String ContainerVMNode_No_columns__text_format; - public static String ContainerVMNode_No_columns__exited_format; - public static String ContainerVMNode_No_columns__Error__label; - /** since 2.3 */ - public static String ContainerVMNode_filtered_running_threads; - - static { - // initialize resource bundle - NLS.initializeMessages(MessagesForGdbLaunchVM.class.getName(), MessagesForGdbLaunchVM.class); - } + public static String ThreadVMNode_No_columns__text_format; + public static String ThreadVMNode_No_columns__Error__label; + public static String ContainerVMNode_No_columns__text_format; + public static String ContainerVMNode_No_columns__exited_format; + public static String ContainerVMNode_No_columns__Error__label; + /** since 2.3 */ + public static String ContainerVMNode_filtered_running_threads; + + static { + // initialize resource bundle + NLS.initializeMessages(MessagesForGdbLaunchVM.class.getName(), MessagesForGdbLaunchVM.class); + } - private MessagesForGdbLaunchVM() { - } + private MessagesForGdbLaunchVM() { + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java index 1acf6ac7333..5d904de1fb3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java @@ -7,10 +7,10 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * Wind River Systems - initial API and implementation - * Ericsson - Modified for multi threaded functionality + * Ericsson - Modified for multi threaded functionality * Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch; @@ -72,202 +72,213 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.ui.IMemento; - -public class ThreadVMNode extends AbstractThreadVMNode - implements IElementLabelProvider, IElementMementoProvider -{ +public class ThreadVMNode extends AbstractThreadVMNode implements IElementLabelProvider, IElementMementoProvider { /** Indicator that we should not display running threads */ private boolean fHideRunningThreadsProperty = false; - + /** PropertyChangeListener to keep track of the PREF_HIDE_RUNNING_THREADS preference */ private IPropertyChangeListener fPropertyChangeListener = new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS)) { - fHideRunningThreadsProperty = (Boolean)event.getNewValue(); + fHideRunningThreadsProperty = (Boolean) event.getNewValue(); // Refresh the debug view to take in consideration this change getDMVMProvider().refresh(); } } }; - - public ThreadVMNode(AbstractDMVMProvider provider, DsfSession session) { - super(provider, session); - + + public ThreadVMNode(AbstractDMVMProvider provider, DsfSession session) { + super(provider, session); + IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); store.addPropertyChangeListener(fPropertyChangeListener); fHideRunningThreadsProperty = store.getBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS); - } + } - @Override - public void dispose() { + @Override + public void dispose() { GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); - super.dispose(); - } - @Override - public String toString() { - return "ThreadVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Override - protected IElementLabelProvider createLabelProvider() { - PropertiesBasedLabelProvider provider = new PropertiesBasedLabelProvider(); - - provider.setColumnInfo( - PropertiesBasedLabelProvider.ID_COLUMN_NO_COLUMNS, - new LabelColumnInfo(new LabelAttribute[] { - // Text is made of the thread name followed by its state and state change reason. - new GdbExecutionContextLabelText( - MessagesForGdbLaunchVM.ThreadVMNode_No_columns__text_format, - new String[] { - ExecutionContextLabelText.PROP_NAME_KNOWN, - PROP_NAME, - ExecutionContextLabelText.PROP_ID_KNOWN, - ILaunchVMConstants.PROP_ID, - IGdbLaunchVMConstants.PROP_OS_ID_KNOWN, - IGdbLaunchVMConstants.PROP_OS_ID, - IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN, - IGdbLaunchVMConstants.PROP_CORES_ID, - ILaunchVMConstants.PROP_IS_SUSPENDED, - ExecutionContextLabelText.PROP_STATE_CHANGE_REASON_KNOWN, - ILaunchVMConstants.PROP_STATE_CHANGE_REASON, - ExecutionContextLabelText.PROP_STATE_CHANGE_DETAILS_KNOWN, - ILaunchVMConstants.PROP_STATE_CHANGE_DETAILS}), - new LabelText(MessagesForGdbLaunchVM.ThreadVMNode_No_columns__Error__label, new String[0]), - /* RUNNING THREAD - RED PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_R_PINNED)) { - { setPropertyNames(new String[] { - ILaunchVMConstants.PROP_IS_SUSPENDED, - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + super.dispose(); + } - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); - Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (prop != null && pin_prop != null && pin_color_prop != null) ? - !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; - }; - }, - /* RUNNING THREAD - GREEN PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_G_PINNED)) { - { setPropertyNames(new String[] { - ILaunchVMConstants.PROP_IS_SUSPENDED, - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + @Override + public String toString() { + return "ThreadVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + } - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); - Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (prop != null && pin_prop != null && pin_color_prop != null) ? - !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; - }; - }, - /* RUNNING THREAD - BLUE PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_B_PINNED)) { - { setPropertyNames(new String[] { - ILaunchVMConstants.PROP_IS_SUSPENDED, - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } + @Override + protected IElementLabelProvider createLabelProvider() { + PropertiesBasedLabelProvider provider = new PropertiesBasedLabelProvider(); - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); - Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (prop != null && pin_prop != null && pin_color_prop != null) ? - !prop.booleanValue() && pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; - }; - }, - /* RUNNING THREAD - NO PIN */ - new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING)) { - { setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); } - - @Override - public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) { - // prop has been seen to be null during session shutdown [313823] - Boolean prop = (Boolean)properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); - return (prop != null) ? !prop.booleanValue() : false; - }; - }, - /* SUSPENDED THREAD - RED PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_R_PINNED)) { - { setPropertyNames(new String[] { - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } - - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (pin_prop != null && pin_color_prop != null) ? - pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; - }; - }, - /* SUSPENDED THREAD - GREEN PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_G_PINNED)) { - { setPropertyNames(new String[] { - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } - - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (pin_prop != null && pin_color_prop != null) ? - pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; - }; - }, - /* SUSPENDED THREAD - BLUE PIN */ - new LabelImage(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_B_PINNED)) { - { setPropertyNames(new String[] { - IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - IGdbLaunchVMConstants.PROP_PIN_COLOR }); } - - @Override - public boolean isEnabled(IStatus status, Map<String, Object> properties) { - Boolean pin_prop = (Boolean)properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); - Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); - return (pin_prop != null && pin_color_prop != null) ? - pin_prop.booleanValue() && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; - }; - }, - /* SUSPENDED THREAD - NO PIN */ - new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED)), - })); - return provider; - } + provider.setColumnInfo(PropertiesBasedLabelProvider.ID_COLUMN_NO_COLUMNS, + new LabelColumnInfo(new LabelAttribute[] { + // Text is made of the thread name followed by its state and state change reason. + new GdbExecutionContextLabelText(MessagesForGdbLaunchVM.ThreadVMNode_No_columns__text_format, + new String[] { ExecutionContextLabelText.PROP_NAME_KNOWN, PROP_NAME, + ExecutionContextLabelText.PROP_ID_KNOWN, ILaunchVMConstants.PROP_ID, + IGdbLaunchVMConstants.PROP_OS_ID_KNOWN, IGdbLaunchVMConstants.PROP_OS_ID, + IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN, IGdbLaunchVMConstants.PROP_CORES_ID, + ILaunchVMConstants.PROP_IS_SUSPENDED, + ExecutionContextLabelText.PROP_STATE_CHANGE_REASON_KNOWN, + ILaunchVMConstants.PROP_STATE_CHANGE_REASON, + ExecutionContextLabelText.PROP_STATE_CHANGE_DETAILS_KNOWN, + ILaunchVMConstants.PROP_STATE_CHANGE_DETAILS }), + new LabelText(MessagesForGdbLaunchVM.ThreadVMNode_No_columns__Error__label, new String[0]), + /* RUNNING THREAD - RED PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_R_PINNED)) { + { + setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) + ? !prop.booleanValue() && pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.RED) + : false; + }; + }, + /* RUNNING THREAD - GREEN PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_G_PINNED)) { + { + setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) + ? !prop.booleanValue() && pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) + : false; + }; + }, + /* RUNNING THREAD - BLUE PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_RUNNING_B_PINNED)) { + { + setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED, + IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (prop != null && pin_prop != null && pin_color_prop != null) + ? !prop.booleanValue() && pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) + : false; + }; + }, + /* RUNNING THREAD - NO PIN */ + new LabelImage(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_RUNNING)) { + { + setPropertyNames(new String[] { ILaunchVMConstants.PROP_IS_SUSPENDED }); + } + + @Override + public boolean isEnabled(IStatus status, java.util.Map<String, Object> properties) { + // prop has been seen to be null during session shutdown [313823] + Boolean prop = (Boolean) properties.get(ILaunchVMConstants.PROP_IS_SUSPENDED); + return (prop != null) ? !prop.booleanValue() : false; + }; + }, + /* SUSPENDED THREAD - RED PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_R_PINNED)) { + { + setPropertyNames(new String[] { IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.RED) : false; + }; + }, + /* SUSPENDED THREAD - GREEN PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_G_PINNED)) { + { + setPropertyNames(new String[] { IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.GREEN) : false; + }; + }, + /* SUSPENDED THREAD - BLUE PIN */ + new LabelImage( + CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_THREAD_SUSPENDED_B_PINNED)) { + { + setPropertyNames(new String[] { IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + IGdbLaunchVMConstants.PROP_PIN_COLOR }); + } + + @Override + public boolean isEnabled(IStatus status, Map<String, Object> properties) { + Boolean pin_prop = (Boolean) properties.get(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT); + Object pin_color_prop = properties.get(IGdbLaunchVMConstants.PROP_PIN_COLOR); + return (pin_prop != null && pin_color_prop != null) ? pin_prop.booleanValue() + && pin_color_prop.equals(IPinElementColorDescriptor.BLUE) : false; + }; + }, + /* SUSPENDED THREAD - NO PIN */ + new LabelImage( + DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED)), })); + return provider; + } @Override - protected void updateElementsInSessionThread(final IChildrenUpdate update) { - IProcesses procService = getServicesTracker().getService(IProcesses.class); - final IContainerDMContext contDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IContainerDMContext.class); - if (procService == null || contDmc == null) { - handleFailedUpdate(update); - return; - } - - procService.getProcessesBeingDebugged( - contDmc, - new ViewerDataRequestMonitor<IDMContext[]>(getSession().getExecutor(), update){ + protected void updateElementsInSessionThread(final IChildrenUpdate update) { + IProcesses procService = getServicesTracker().getService(IProcesses.class); + final IContainerDMContext contDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), + IContainerDMContext.class); + if (procService == null || contDmc == null) { + handleFailedUpdate(update); + return; + } + + procService.getProcessesBeingDebugged(contDmc, + new ViewerDataRequestMonitor<IDMContext[]>(getSession().getExecutor(), update) { @Override public void handleCompleted() { if (!isSuccess() || !(getData() instanceof IExecutionDMContext[])) { handleFailedUpdate(update); return; } - - IExecutionDMContext[] execDmcs = (IExecutionDMContext[])getData(); + + IExecutionDMContext[] execDmcs = (IExecutionDMContext[]) getData(); if (fHideRunningThreadsProperty) { // Remove running threads from the list - IRunControl runControl = getServicesTracker().getService(IRunControl.class); - if (runControl == null) { - handleFailedUpdate(update); - return; - } + IRunControl runControl = getServicesTracker().getService(IRunControl.class); + if (runControl == null) { + handleFailedUpdate(update); + return; + } List<IExecutionDMContext> execDmcsNotRunning = new ArrayList<IExecutionDMContext>(); for (IExecutionDMContext execDmc : execDmcs) { @@ -278,156 +289,154 @@ public class ThreadVMNode extends AbstractThreadVMNode } execDmcs = execDmcsNotRunning.toArray(new IExecutionDMContext[execDmcsNotRunning.size()]); } - + fillUpdateWithVMCs(update, execDmcs); update.done(); } }); - } - - @Override - protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) { - IPropertiesUpdate[] parentUpdates = new IPropertiesUpdate[updates.length]; - - for (int i = 0; i < updates.length; i++) { - final IPropertiesUpdate update = updates[i]; - - final ViewerCountingRequestMonitor countringRm = - new ViewerCountingRequestMonitor(ImmediateExecutor.getInstance(), updates[i]); - int count = 0; - - // Create a delegating update which will let the super-class fill in the - // standard container properties. - parentUpdates[i] = new VMDelegatingPropertiesUpdate(updates[i], countringRm); - count++; - - IMIExecutionDMContext execDmc = findDmcInPath( - update.getViewerInput(), update.getElementPath(), IMIExecutionDMContext.class); - if (execDmc != null) { - update.setProperty(ILaunchVMConstants.PROP_ID, execDmc.getThreadId()); - - // set pin properties - IPinElementColorDescriptor colorDesc = PinCloneUtils.getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), execDmc); - updates[i].setProperty(IGdbLaunchVMConstants.PROP_PIN_COLOR, - colorDesc != null ? colorDesc.getOverlayColor() : null); - updates[i].setProperty(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, - PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), execDmc)); - } - - if (update.getProperties().contains(PROP_NAME) || - update.getProperties().contains(IGdbLaunchVMConstants.PROP_OS_ID) || - update.getProperties().contains(IGdbLaunchVMConstants.PROP_CORES_ID)) - { - IProcesses processService = getServicesTracker().getService(IProcesses.class); - final IThreadDMContext threadDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IThreadDMContext.class); - - if (processService == null || threadDmc == null) { - update.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service or handle invalid", null)); //$NON-NLS-1$ - } else { - processService.getExecutionData( - threadDmc, - new ViewerDataRequestMonitor<IThreadDMData>(getExecutor(), update) { - @Override - public void handleCompleted() { - if (isSuccess()) { - fillThreadDataProperties(update, getData()); - } - update.setStatus(getStatus()); - countringRm.done(); - } - }); - count++; - } - } - - countringRm.setDoneCount(count); - } - super.updatePropertiesInSessionThread(parentUpdates); - } - - protected void fillThreadDataProperties(IPropertiesUpdate update, IThreadDMData data) { - if (data.getName() != null && data.getName().length() > 0) { - update.setProperty(PROP_NAME, data.getName()); - } - update.setProperty(IGdbLaunchVMConstants.PROP_OS_ID, data.getId()); - - if (data instanceof IGdbThreadDMData) { - String[] cores = ((IGdbThreadDMData)data).getCores(); - if (cores != null) { - StringBuilder str = new StringBuilder(); - for (String core : cores) { - str.append(core).append(','); - } - if (str.length() > 0) { - String coresStr = str.substring(0, str.length() - 1); - update.setProperty(IGdbLaunchVMConstants.PROP_CORES_ID, coresStr); - } - } - } - } + } + + @Override + protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) { + IPropertiesUpdate[] parentUpdates = new IPropertiesUpdate[updates.length]; + + for (int i = 0; i < updates.length; i++) { + final IPropertiesUpdate update = updates[i]; + + final ViewerCountingRequestMonitor countringRm = new ViewerCountingRequestMonitor( + ImmediateExecutor.getInstance(), updates[i]); + int count = 0; + + // Create a delegating update which will let the super-class fill in the + // standard container properties. + parentUpdates[i] = new VMDelegatingPropertiesUpdate(updates[i], countringRm); + count++; + + IMIExecutionDMContext execDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), + IMIExecutionDMContext.class); + if (execDmc != null) { + update.setProperty(ILaunchVMConstants.PROP_ID, execDmc.getThreadId()); + + // set pin properties + IPinElementColorDescriptor colorDesc = PinCloneUtils + .getPinElementColorDescriptor(GdbPinProvider.getPinnedHandles(), execDmc); + updates[i].setProperty(IGdbLaunchVMConstants.PROP_PIN_COLOR, + colorDesc != null ? colorDesc.getOverlayColor() : null); + updates[i].setProperty(IGdbLaunchVMConstants.PROP_PINNED_CONTEXT, + PinCloneUtils.isPinnedTo(GdbPinProvider.getPinnedHandles(), execDmc)); + } + + if (update.getProperties().contains(PROP_NAME) + || update.getProperties().contains(IGdbLaunchVMConstants.PROP_OS_ID) + || update.getProperties().contains(IGdbLaunchVMConstants.PROP_CORES_ID)) { + IProcesses processService = getServicesTracker().getService(IProcesses.class); + final IThreadDMContext threadDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), + IThreadDMContext.class); + + if (processService == null || threadDmc == null) { + update.setStatus( + new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, "Service or handle invalid", null)); //$NON-NLS-1$ + } else { + processService.getExecutionData(threadDmc, + new ViewerDataRequestMonitor<IThreadDMData>(getExecutor(), update) { + @Override + public void handleCompleted() { + if (isSuccess()) { + fillThreadDataProperties(update, getData()); + } + update.setStatus(getStatus()); + countringRm.done(); + } + }); + count++; + } + } + + countringRm.setDoneCount(count); + } + super.updatePropertiesInSessionThread(parentUpdates); + } + + protected void fillThreadDataProperties(IPropertiesUpdate update, IThreadDMData data) { + if (data.getName() != null && data.getName().length() > 0) { + update.setProperty(PROP_NAME, data.getName()); + } + update.setProperty(IGdbLaunchVMConstants.PROP_OS_ID, data.getId()); + + if (data instanceof IGdbThreadDMData) { + String[] cores = ((IGdbThreadDMData) data).getCores(); + if (cores != null) { + StringBuilder str = new StringBuilder(); + for (String core : cores) { + str.append(core).append(','); + } + if (str.length() > 0) { + String coresStr = str.substring(0, str.length() - 1); + update.setProperty(IGdbLaunchVMConstants.PROP_CORES_ID, coresStr); + } + } + } + } private String produceThreadElementName(String viewName, IMIExecutionDMContext execCtx) { return "Thread." + execCtx.getThreadId(); //$NON-NLS-1$ - } + } - @Override + @Override public int getDeltaFlags(Object e) { - if (fHideRunningThreadsProperty && e instanceof IResumedDMEvent) { - // Special handling in the case of hiding the running threads to - // cause a proper refresh when a thread is resumed. - // We don't need to worry about the ISuspendedDMEvent in this case - // because a proper refresh will be triggered anyway by the stack frame - // being displayed. - return IModelDelta.CONTENT; - } - else if (e instanceof IGDBFocusChangedEvent) { - return IModelDelta.SELECT; - } - return super.getDeltaFlags(e); - } - - @Override + if (fHideRunningThreadsProperty && e instanceof IResumedDMEvent) { + // Special handling in the case of hiding the running threads to + // cause a proper refresh when a thread is resumed. + // We don't need to worry about the ISuspendedDMEvent in this case + // because a proper refresh will be triggered anyway by the stack frame + // being displayed. + return IModelDelta.CONTENT; + } else if (e instanceof IGDBFocusChangedEvent) { + return IModelDelta.SELECT; + } + return super.getDeltaFlags(e); + } + + @Override public void buildDelta(Object e, final VMDelta parentDelta, final int nodeOffset, final RequestMonitor rm) { - if (fHideRunningThreadsProperty && e instanceof IResumedDMEvent) { - // Special handling in the case of hiding the running threads to - // cause a proper refresh when a thread is resumed. - // We don't need to worry about the ISuspendedDMEvent in this case - // because a proper refresh will be triggered anyway by the stack frame - // being displayed. - // - // - If not stepping, update the content of the parent, to allow for - // this thread to become hidden. - // - If stepping, do nothing to avoid too many updates. If a - // time-out is reached before the step completes, the - // ISteppingTimedOutEvent will trigger a refresh. - if (((IResumedDMEvent)e).getReason() != IRunControl.StateChangeReason.STEP) { - VMDelta ancestorDelta = parentDelta.getParentDelta(); - ancestorDelta.setFlags(ancestorDelta.getFlags() | IModelDelta.CONTENT); - } - rm.done(); - } else if (e instanceof IGDBFocusChangedEvent) { - buildDeltaForFocusChangedEvent((IGDBFocusChangedEvent)e, parentDelta, nodeOffset, rm); - } else { - super.buildDelta(e, parentDelta, nodeOffset, rm); - } - } - - private void buildDeltaForFocusChangedEvent(IGDBFocusChangedEvent event, VMDelta parentDelta, int nodeOffset, RequestMonitor rm) { - getSession().getExecutor().execute(new DsfRunnable() { + if (fHideRunningThreadsProperty && e instanceof IResumedDMEvent) { + // Special handling in the case of hiding the running threads to + // cause a proper refresh when a thread is resumed. + // We don't need to worry about the ISuspendedDMEvent in this case + // because a proper refresh will be triggered anyway by the stack frame + // being displayed. + // + // - If not stepping, update the content of the parent, to allow for + // this thread to become hidden. + // - If stepping, do nothing to avoid too many updates. If a + // time-out is reached before the step completes, the + // ISteppingTimedOutEvent will trigger a refresh. + if (((IResumedDMEvent) e).getReason() != IRunControl.StateChangeReason.STEP) { + VMDelta ancestorDelta = parentDelta.getParentDelta(); + ancestorDelta.setFlags(ancestorDelta.getFlags() | IModelDelta.CONTENT); + } + rm.done(); + } else if (e instanceof IGDBFocusChangedEvent) { + buildDeltaForFocusChangedEvent((IGDBFocusChangedEvent) e, parentDelta, nodeOffset, rm); + } else { + super.buildDelta(e, parentDelta, nodeOffset, rm); + } + } + + private void buildDeltaForFocusChangedEvent(IGDBFocusChangedEvent event, VMDelta parentDelta, int nodeOffset, + RequestMonitor rm) { + getSession().getExecutor().execute(new DsfRunnable() { @Override public void run() { - // can we find a thread context in the hierarchy of the IGDBFocusChangedEvent's context? + // can we find a thread context in the hierarchy of the IGDBFocusChangedEvent's context? IDMContext thread = DMContexts.getAncestorOfType(event.getDMContext(), IMIExecutionDMContext.class); final IDMContext newThreadFocus = thread; if (newThreadFocus != null) { // we need to find the VMC index for the thread that switched, so we can - // select it correctly. - getVMCIndexForDmc( - ThreadVMNode.this, - newThreadFocus, - parentDelta, - new DataRequestMonitor<Integer>(getExecutor(), rm) { - @Override + // select it correctly. + getVMCIndexForDmc(ThreadVMNode.this, newThreadFocus, parentDelta, + new DataRequestMonitor<Integer>(getExecutor(), rm) { + @Override protected void handleSuccess() { final int threadOffset = getData(); // Create a delta for the thread node - Select it whether it's running or not @@ -438,69 +447,70 @@ public class ThreadVMNode extends AbstractThreadVMNode IModelDelta.SELECT | IModelDelta.FORCE); rm.done(); } - }); + }); } else { // context not a thread - nothing to do here rm.done(); } } - }); - } - - - private static final String MEMENTO_NAME = "THREAD_MEMENTO_NAME"; //$NON-NLS-1$ - - /* - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#compareElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest[]) - */ - @Override - public void compareElements(IElementCompareRequest[] requests) { - - for ( IElementCompareRequest request : requests ) { - - Object element = request.getElement(); - IMemento memento = request.getMemento(); - String mementoName = memento.getString(MEMENTO_NAME); - - if (mementoName != null) { - if (element instanceof IDMVMContext) { - - IDMContext dmc = ((IDMVMContext)element).getDMContext(); - - if ( dmc instanceof IMIExecutionDMContext) { - - String elementName = produceThreadElementName( request.getPresentationContext().getId(), (IMIExecutionDMContext) dmc ); - request.setEqual( elementName.equals( mementoName ) ); - } - } - } - request.done(); - } - } - - /* - * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[]) - */ - @Override - public void encodeElements(IElementMementoRequest[] requests) { - - for ( IElementMementoRequest request : requests ) { - - Object element = request.getElement(); - IMemento memento = request.getMemento(); - - if (element instanceof IDMVMContext) { - - IDMContext dmc = ((IDMVMContext)element).getDMContext(); - - if ( dmc instanceof IMIExecutionDMContext) { - - String elementName = produceThreadElementName( request.getPresentationContext().getId(), (IMIExecutionDMContext) dmc ); - memento.putString(MEMENTO_NAME, elementName); - } - } - request.done(); - } - } + }); + } + + private static final String MEMENTO_NAME = "THREAD_MEMENTO_NAME"; //$NON-NLS-1$ + + /* + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#compareElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest[]) + */ + @Override + public void compareElements(IElementCompareRequest[] requests) { + + for (IElementCompareRequest request : requests) { + + Object element = request.getElement(); + IMemento memento = request.getMemento(); + String mementoName = memento.getString(MEMENTO_NAME); + + if (mementoName != null) { + if (element instanceof IDMVMContext) { + + IDMContext dmc = ((IDMVMContext) element).getDMContext(); + + if (dmc instanceof IMIExecutionDMContext) { + + String elementName = produceThreadElementName(request.getPresentationContext().getId(), + (IMIExecutionDMContext) dmc); + request.setEqual(elementName.equals(mementoName)); + } + } + } + request.done(); + } + } + + /* + * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[]) + */ + @Override + public void encodeElements(IElementMementoRequest[] requests) { + + for (IElementMementoRequest request : requests) { + + Object element = request.getElement(); + IMemento memento = request.getMemento(); + + if (element instanceof IDMVMContext) { + + IDMContext dmc = ((IDMVMContext) element).getDMContext(); + + if (dmc instanceof IMIExecutionDMContext) { + + String elementName = produceThreadElementName(request.getPresentationContext().getId(), + (IMIExecutionDMContext) dmc); + memento.putString(MEMENTO_NAME, elementName); + } + } + request.done(); + } + } } |