diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.classpath b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.classpath new file mode 100644 index 00000000000..098194ca4b7 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.project b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.project new file mode 100644 index 00000000000..9bcd88e7af4 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.project @@ -0,0 +1,28 @@ + + + org.eclipse.cdt.examples.dsf.gdb + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.settings/org.eclipse.jdt.core.prefs b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..625b641ae3b --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,70 @@ +#Tue Jun 24 11:04:03 PDT 2008 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning +org.eclipse.jdt.core.compiler.problem.nullReference=error +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=error +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..3cad61e9758 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/META-INF/MANIFEST.MF @@ -0,0 +1,27 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: GDB DSF Debugger Extension Example +Bundle-SymbolicName: org.eclipse.cdt.examples.dsf.gdb;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.cdt.examples.dsf.gdb.GDBExamplePlugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.cdt.dsf.gdb, + org.eclipse.cdt.dsf, + org.eclipse.debug.core, + org.eclipse.cdt.launch, + org.eclipse.debug.ui, + org.eclipse.cdt.dsf.gdb.ui, + org.eclipse.cdt.dsf.ui, + org.eclipse.cdt.ui, + org.eclipse.cdt.debug.core, + org.eclipse.cdt.debug.ui +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ActivationPolicy: lazy +Bundle-Vendor: Eclipse CDT +Export-Package: org.eclipse.cdt.examples.dsf.gdb;x-internal:=true, + org.eclipse.cdt.examples.dsf.gdb.launch;x-internal:=true, + org.eclipse.cdt.examples.dsf.gdb.service;x-internal:=true, + org.eclipse.cdt.examples.dsf.gdb.service.command;x-internal:=true, + org.eclipse.cdt.examples.dsf.gdb.service.command.commands;x-internal:=true, + org.eclipse.cdt.examples.dsf.gdb.viewmodel;x-internal:=true diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/about.html b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/about.html new file mode 100644 index 00000000000..c1cb2e12f40 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/about.html @@ -0,0 +1,28 @@ + + + + +About + + +

About This Content

+ +

May 14, 2008

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + + \ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/build.properties b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/build.properties new file mode 100644 index 00000000000..e9863e281ea --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/plugin.xml b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/plugin.xml new file mode 100644 index 00000000000..d82f295af96 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/plugin.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/pom.xml b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/pom.xml new file mode 100644 index 00000000000..39a25d8ca68 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + org.eclipse.cdt + cdt-parent + 8.5.0-SNAPSHOT + ../../pom.xml + + + 1.0.0-SNAPSHOT + org.eclipse.cdt.examples.dsf.gdb + eclipse-plugin + diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/GDBExamplePlugin.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/GDBExamplePlugin.java new file mode 100644 index 00000000000..86609f1dcf7 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/GDBExamplePlugin.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class GDBExamplePlugin extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.cdt.examples.dsf.gdb"; //$NON-NLS-1$ + + // The shared instance + private static GDBExamplePlugin plugin; + + private static BundleContext fgBundleContext; + + /** + * The constructor + */ + public GDBExamplePlugin() { + } + + @Override + public void start(BundleContext context) throws Exception { + fgBundleContext = context; + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + fgBundleContext = null; + } + + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static GDBExamplePlugin getDefault() { + return plugin; + } + + public static BundleContext getBundleContext() { + return fgBundleContext; + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/GdbExtendedAdapterFactory.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/GdbExtendedAdapterFactory.java new file mode 100644 index 00000000000..d509ad0704b --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/GdbExtendedAdapterFactory.java @@ -0,0 +1,434 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.WeakHashMap; + +import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.core.model.IConnectHandler; +import org.eclipse.cdt.debug.core.model.IDebugNewExecutableHandler; +import org.eclipse.cdt.debug.core.model.IResumeWithoutSignalHandler; +import org.eclipse.cdt.debug.core.model.IReverseResumeHandler; +import org.eclipse.cdt.debug.core.model.IReverseStepIntoHandler; +import org.eclipse.cdt.debug.core.model.IReverseStepOverHandler; +import org.eclipse.cdt.debug.core.model.IReverseToggleHandler; +import org.eclipse.cdt.debug.core.model.ISaveTraceDataHandler; +import org.eclipse.cdt.debug.core.model.IStartTracingHandler; +import org.eclipse.cdt.debug.core.model.IStepIntoSelectionHandler; +import org.eclipse.cdt.debug.core.model.ISteppingModeTarget; +import org.eclipse.cdt.debug.core.model.IStopTracingHandler; +import org.eclipse.cdt.debug.core.model.IUncallHandler; +import org.eclipse.cdt.debug.ui.IPinProvider; +import org.eclipse.cdt.dsf.concurrent.Immutable; +import org.eclipse.cdt.dsf.concurrent.ThreadSafe; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfResumeCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepIntoCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepIntoSelectionCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepOverCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepReturnCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.DsfSuspendCommand; +import org.eclipse.cdt.dsf.debug.ui.actions.IDsfStepIntoSelection; +import org.eclipse.cdt.dsf.debug.ui.sourcelookup.DsfSourceDisplayAdapter; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.DefaultRefreshAllTarget; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.IRefreshAllTarget; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.DefaultDsfModelSelectionPolicyFactory; +import org.eclipse.cdt.dsf.gdb.internal.commands.ISelectNextTraceRecordHandler; +import org.eclipse.cdt.dsf.gdb.internal.commands.ISelectPrevTraceRecordHandler; +import org.eclipse.cdt.dsf.gdb.internal.ui.GdbDebugTextHover; +import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider; +import org.eclipse.cdt.dsf.gdb.internal.ui.GdbSuspendTrigger; +import org.eclipse.cdt.dsf.gdb.internal.ui.actions.DsfTerminateCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbDisconnectCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRestartCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbSteppingModeTarget; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbConnectCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbDebugNewExecutableCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbResumeWithoutSignalCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseResumeCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseStepIntoCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseStepOverCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbReverseToggleCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbSaveTraceDataCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbSelectNextTraceRecordCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbSelectPrevTraceRecordCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbStartTracingCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbStopTracingCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.commands.GdbUncallCommand; +import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.GdbViewModelAdapter; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.examples.dsf.gdb.viewmodel.GdbExtendedViewModelAdapter; +import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchesListener2; +import org.eclipse.debug.core.commands.IDisconnectHandler; +import org.eclipse.debug.core.commands.IRestartHandler; +import org.eclipse.debug.core.commands.IResumeHandler; +import org.eclipse.debug.core.commands.IStepIntoHandler; +import org.eclipse.debug.core.commands.IStepOverHandler; +import org.eclipse.debug.core.commands.IStepReturnHandler; +import org.eclipse.debug.core.commands.ISuspendHandler; +import org.eclipse.debug.core.commands.ITerminateHandler; +import org.eclipse.debug.core.model.IDebugModelProvider; +import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider; +import org.eclipse.debug.ui.contexts.ISuspendTrigger; +import org.eclipse.debug.ui.sourcelookup.ISourceDisplay; + +/** + * This implementation of platform adapter factory only retrieves the adapters + * 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. + */ +@SuppressWarnings("restriction") +@ThreadSafe +public class GdbExtendedAdapterFactory + implements IAdapterFactory, ILaunchesListener2 +{ + @Immutable + class SessionAdapterSet { + final GdbLaunch fLaunch; + final GdbViewModelAdapter fViewModelAdapter; + final DsfSourceDisplayAdapter fSourceDisplayAdapter; + final DsfStepIntoCommand fStepIntoCommand; + final DsfStepIntoSelectionCommand fStepIntoSelectionCommand; + final GdbReverseStepIntoCommand fReverseStepIntoCommand; + final DsfStepOverCommand fStepOverCommand; + final GdbReverseStepOverCommand fReverseStepOverCommand; + final DsfStepReturnCommand fStepReturnCommand; + final GdbUncallCommand fUncallCommand; + final DsfSuspendCommand fSuspendCommand; + final DsfResumeCommand fResumeCommand; + final GdbReverseResumeCommand fReverseResumeCommand; + final GdbResumeWithoutSignalCommand fResumeWithoutSignalCommand; + final GdbRestartCommand fRestartCommand; + final DsfTerminateCommand fTerminateCommand; + final GdbDebugNewExecutableCommand fDebugNewExecutableCommand; + final GdbConnectCommand fConnectCommand; + final GdbDisconnectCommand fDisconnectCommand; + final IDebugModelProvider fDebugModelProvider; + final GdbSuspendTrigger fSuspendTrigger; + final GdbSteppingModeTarget fSteppingModeTarget; + final IModelSelectionPolicyFactory fModelSelectionPolicyFactory; + final SteppingController fSteppingController; + final DefaultRefreshAllTarget fRefreshAllTarget; + final GdbReverseToggleCommand fReverseToggleTarget; + final GdbStartTracingCommand fStartTracingTarget; + final GdbStopTracingCommand fStopTracingTarget; + final GdbSaveTraceDataCommand fSaveTraceDataTarget; + final GdbSelectNextTraceRecordCommand fSelectNextRecordTarget; + final GdbSelectPrevTraceRecordCommand fSelectPrevRecordTarget; + final GdbDebugTextHover fDebugTextHover; + final GdbPinProvider fPinProvider; + + SessionAdapterSet(GdbLaunch launch) { + fLaunch = launch; + DsfSession session = launch.getSession(); + + // register stepping controller + fSteppingController = new SteppingController(session); + session.registerModelAdapter(SteppingController.class, fSteppingController); + + fViewModelAdapter = new GdbExtendedViewModelAdapter(session, fSteppingController); + session.registerModelAdapter(IViewerInputProvider.class, fViewModelAdapter); + + if (launch.getSourceLocator() instanceof ISourceLookupDirector) { + fSourceDisplayAdapter = new DsfSourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator(), fSteppingController); + } else { + fSourceDisplayAdapter = null; + } + session.registerModelAdapter(ISourceDisplay.class, fSourceDisplayAdapter); + + fSteppingModeTarget = new GdbSteppingModeTarget(session); + fStepIntoCommand = new DsfStepIntoCommand(session, fSteppingModeTarget); + fStepIntoSelectionCommand = new DsfStepIntoSelectionCommand(session); + fReverseStepIntoCommand = new GdbReverseStepIntoCommand(session, fSteppingModeTarget); + fStepOverCommand = new DsfStepOverCommand(session, fSteppingModeTarget); + fReverseStepOverCommand = new GdbReverseStepOverCommand(session, fSteppingModeTarget); + fStepReturnCommand = new DsfStepReturnCommand(session); + fUncallCommand = new GdbUncallCommand(session, fSteppingModeTarget); + fSuspendCommand = new DsfSuspendCommand(session); + fResumeCommand = new DsfResumeCommand(session); + fReverseResumeCommand = new GdbReverseResumeCommand(session); + fResumeWithoutSignalCommand = new GdbResumeWithoutSignalCommand(session); + fRestartCommand = new GdbRestartCommand(session, fLaunch); + fTerminateCommand = new DsfTerminateCommand(session); + fDebugNewExecutableCommand = new GdbDebugNewExecutableCommand(session, fLaunch); + fConnectCommand = new GdbConnectCommand(session, fLaunch); + fDisconnectCommand = new GdbDisconnectCommand(session); + fSuspendTrigger = new GdbSuspendTrigger(session, fLaunch); + fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory(); + fRefreshAllTarget = new DefaultRefreshAllTarget(); + fReverseToggleTarget = new GdbReverseToggleCommand(session); + fStartTracingTarget = new GdbStartTracingCommand(session); + fStopTracingTarget = new GdbStopTracingCommand(session); + fSaveTraceDataTarget = new GdbSaveTraceDataCommand(session); + fSelectNextRecordTarget = new GdbSelectNextTraceRecordCommand(session); + fSelectPrevRecordTarget = new GdbSelectPrevTraceRecordCommand(session); + fPinProvider = new GdbPinProvider(session); + + session.registerModelAdapter(ISteppingModeTarget.class, fSteppingModeTarget); + session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand); + session.registerModelAdapter(IStepIntoSelectionHandler.class, fStepIntoSelectionCommand); + session.registerModelAdapter(IReverseStepIntoHandler.class, fReverseStepIntoCommand); + session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand); + session.registerModelAdapter(IReverseStepOverHandler.class, fReverseStepOverCommand); + session.registerModelAdapter(IStepReturnHandler.class, fStepReturnCommand); + session.registerModelAdapter(IUncallHandler.class, fUncallCommand); + session.registerModelAdapter(ISuspendHandler.class, fSuspendCommand); + session.registerModelAdapter(IResumeHandler.class, fResumeCommand); + session.registerModelAdapter(IReverseResumeHandler.class, fReverseResumeCommand); + session.registerModelAdapter(IResumeWithoutSignalHandler.class, fResumeWithoutSignalCommand); + session.registerModelAdapter(IRestartHandler.class, fRestartCommand); + session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand); + session.registerModelAdapter(IConnectHandler.class, fConnectCommand); + session.registerModelAdapter(IDebugNewExecutableHandler.class, fDebugNewExecutableCommand); + session.registerModelAdapter(IDisconnectHandler.class, fDisconnectCommand); + session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory); + session.registerModelAdapter(IRefreshAllTarget.class, fRefreshAllTarget); + session.registerModelAdapter(IReverseToggleHandler.class, fReverseToggleTarget); + session.registerModelAdapter(IStartTracingHandler.class, fStartTracingTarget); + session.registerModelAdapter(IStopTracingHandler.class, fStopTracingTarget); + session.registerModelAdapter(ISaveTraceDataHandler.class, fSaveTraceDataTarget); + session.registerModelAdapter(ISelectNextTraceRecordHandler.class, fSelectNextRecordTarget); + session.registerModelAdapter(ISelectPrevTraceRecordHandler.class, fSelectPrevRecordTarget); + session.registerModelAdapter(IPinProvider.class, fPinProvider); + session.registerModelAdapter(IDsfStepIntoSelection.class, fStepIntoSelectionCommand); + + fDebugModelProvider = 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$ + } + }; + session.registerModelAdapter(IDebugModelProvider.class, fDebugModelProvider); + + /* + * Registering the launch as an adapter, ensures that this launch, + * and debug model ID will be associated with all DMContexts from this + * session. + */ + session.registerModelAdapter(ILaunch.class, fLaunch); + + /* + * Register debug hover adapter (bug 309001). + */ + fDebugTextHover = new GdbDebugTextHover(); + session.registerModelAdapter(ICEditorTextHover.class, fDebugTextHover); + } + + void dispose() { + DsfSession session = fLaunch.getSession(); + + fViewModelAdapter.dispose(); + session.unregisterModelAdapter(IViewerInputProvider.class); + + session.unregisterModelAdapter(ISourceDisplay.class); + if (fSourceDisplayAdapter != null) fSourceDisplayAdapter.dispose(); + + session.unregisterModelAdapter(SteppingController.class); + fSteppingController.dispose(); + + session.unregisterModelAdapter(ISteppingModeTarget.class); + session.unregisterModelAdapter(IStepIntoHandler.class); + session.unregisterModelAdapter(IStepIntoSelectionHandler.class); + session.unregisterModelAdapter(IReverseStepIntoHandler.class); + session.unregisterModelAdapter(IStepOverHandler.class); + session.unregisterModelAdapter(IReverseStepOverHandler.class); + session.unregisterModelAdapter(IStepReturnHandler.class); + session.unregisterModelAdapter(IUncallHandler.class); + session.unregisterModelAdapter(ISuspendHandler.class); + session.unregisterModelAdapter(IResumeHandler.class); + session.unregisterModelAdapter(IReverseResumeHandler.class); + session.unregisterModelAdapter(IResumeWithoutSignalHandler.class); + session.unregisterModelAdapter(IRestartHandler.class); + session.unregisterModelAdapter(ITerminateHandler.class); + session.unregisterModelAdapter(IConnectHandler.class); + session.unregisterModelAdapter(IDebugNewExecutableHandler.class); + session.unregisterModelAdapter(IDisconnectHandler.class); + session.unregisterModelAdapter(IModelSelectionPolicyFactory.class); + session.unregisterModelAdapter(IRefreshAllTarget.class); + session.unregisterModelAdapter(IReverseToggleHandler.class); + session.unregisterModelAdapter(IStartTracingHandler.class); + session.unregisterModelAdapter(IStopTracingHandler.class); + session.unregisterModelAdapter(ISaveTraceDataHandler.class); + session.unregisterModelAdapter(ISelectNextTraceRecordHandler.class); + session.unregisterModelAdapter(ISelectPrevTraceRecordHandler.class); + session.unregisterModelAdapter(IPinProvider.class); + + session.unregisterModelAdapter(IDebugModelProvider.class); + session.unregisterModelAdapter(ILaunch.class); + + session.unregisterModelAdapter(ICEditorTextHover.class); + + fSteppingModeTarget.dispose(); + fStepIntoCommand.dispose(); + fStepIntoSelectionCommand.dispose(); + fReverseStepIntoCommand.dispose(); + fStepOverCommand.dispose(); + fReverseStepOverCommand.dispose(); + fStepReturnCommand.dispose(); + fUncallCommand.dispose(); + fSuspendCommand.dispose(); + fResumeCommand.dispose(); + fReverseResumeCommand.dispose(); + fResumeWithoutSignalCommand.dispose(); + fRestartCommand.dispose(); + fTerminateCommand.dispose(); + fConnectCommand.dispose(); + fDebugNewExecutableCommand.dispose(); + fDisconnectCommand.dispose(); + fSuspendTrigger.dispose(); + fReverseToggleTarget.dispose(); + fStartTracingTarget.dispose(); + fStopTracingTarget.dispose(); + fSaveTraceDataTarget.dispose(); + fSelectNextRecordTarget.dispose(); + fSelectPrevRecordTarget.dispose(); + fPinProvider.dispose(); + } + } + + /** + * Active adapter sets. They are accessed using the launch instance + * which owns the debug services session. + */ + private static Map 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. + *

+ * Access to this map is synchronized using the fgLaunchAdapterSets + * instance. + *

+ */ + private static Map fgDisposedLaunchAdapterSets = + new WeakHashMap(); + + static void disposeAdapterSet(ILaunch launch) { + synchronized(fgLaunchAdapterSets) { + if ( fgLaunchAdapterSets.containsKey(launch) ) { + fgLaunchAdapterSets.remove(launch).dispose(); + fgDisposedLaunchAdapterSets.put(launch, null); + } + } + } + + public GdbExtendedAdapterFactory() { + DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); + } + + /** + * This method only actually returns adapters for the launch object. + */ + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Object adaptableObject, Class 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. + + SessionAdapterSet 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 = new SessionAdapterSet(launch); + fgLaunchAdapterSets.put(launch, adapterSet); + } + } + + // Returns the adapter type for the launch object. + if (adapterType.equals(IElementContentProvider.class)) return adapterSet.fViewModelAdapter; + else if (adapterType.equals(IModelProxyFactory.class)) return adapterSet.fViewModelAdapter; + else if (adapterType.equals(IColumnPresentationFactory.class)) return adapterSet.fViewModelAdapter; + else if (adapterType.equals(ISuspendTrigger.class)) return adapterSet.fSuspendTrigger; + else return null; + } + + @SuppressWarnings("rawtypes") + @Override + public Class[] getAdapterList() { + return new Class[] { + IElementContentProvider.class, IModelProxyFactory.class, ISuspendTrigger.class, + IColumnPresentationFactory.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) { + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedFinalLaunchSequence_7_7.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedFinalLaunchSequence_7_7.java new file mode 100644 index 00000000000..8785ffb540e --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedFinalLaunchSequence_7_7.java @@ -0,0 +1,124 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.launch; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; +import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; +import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence_7_7; +import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; +import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; +import org.eclipse.cdt.dsf.service.DsfServicesTracker; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.examples.dsf.gdb.GDBExamplePlugin; +import org.eclipse.cdt.examples.dsf.gdb.service.IGDBExtendedFunctions; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +public class GdbExtendedFinalLaunchSequence_7_7 extends FinalLaunchSequence_7_7 { + + private IGDBControl fControl; + private DsfServicesTracker fTracker; + + public GdbExtendedFinalLaunchSequence_7_7(DsfSession session, Map attributes, RequestMonitorWithProgress rm) { + super(session, attributes, rm); + } + + @Override + protected String[] getExecutionOrder(String group) { + if (GROUP_TOP_LEVEL.equals(group)) { + // Initialize the list with the base class' steps + // We need to create a list that we can modify, which is why we create our own ArrayList. + List orderList = new ArrayList(Arrays.asList(super.getExecutionOrder(GROUP_TOP_LEVEL))); + + // Now insert our init step right after the initialization of the base class. + orderList.add(orderList.indexOf("stepInitializeFinalLaunchSequence_7_7") + 1, "stepInitializeExtendedFinalLaunchSequence_7_7"); //$NON-NLS-1$ //$NON-NLS-2$ + + // As the first operation to do, show the user the version of GDB + orderList.add(orderList.indexOf("stepInitializeExtendedFinalLaunchSequence_7_7") + 1, "stepNotifyVersion"); //$NON-NLS-1$ //$NON-NLS-2$ + + // Add the step to set pagination before the .gdbinit file is sourced + // that way the user can override this setting using .gdbinit. + orderList.add(orderList.indexOf("stepSourceGDBInitFile"), "stepSetPagination"); //$NON-NLS-1$ //$NON-NLS-2$ + + return orderList.toArray(new String[orderList.size()]); + } + + return null; + } + + @Execute + public void stepInitializeExtendedFinalLaunchSequence_7_7(RequestMonitor rm) { + fTracker = new DsfServicesTracker(GDBExamplePlugin.getBundleContext(), getSession().getId()); + fControl = fTracker.getService(IGDBControl.class); + + if (fControl == null) { + rm.done(new Status(IStatus.ERROR, GDBExamplePlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Cannot obtain service", null)); //$NON-NLS-1$ + return; + } + + rm.done(); + } + + @RollBack("stepInitializeExtendedFinalLaunchSequence_7_7") + public void rollBackInitializeExtendedFinalLaunchSequence_7_7(RequestMonitor rm) { + if (fTracker != null) fTracker.dispose(); + fTracker = null; + rm.done(); + } + + @Execute + public void stepNotifyVersion(final RequestMonitor rm) { + final IGDBExtendedFunctions funcService = fTracker.getService(IGDBExtendedFunctions.class); + funcService.getVersion( + fControl.getContext(), + new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleCompleted() { + String str; + if (isSuccess()) { + str = "======= GDB version: " + getData() + " ======="; //$NON-NLS-1$ //$NON-NLS-2$ + } else { + str = "Could not obtain GDB version. Error: " + //$NON-NLS-1$ + getStatus(); + } + funcService.notify(fControl.getContext(), str, rm); + } + }); + } + + @Execute + public void stepSetPagination(final RequestMonitor rm) { + // Make sure pagination is always off + fControl.queueCommand( + fControl.getCommandFactory().createMIGDBSetPagination(fControl.getContext(), false), + new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleCompleted() { + // We accept errors + rm.done(); + } + }); + } + + @Execute + public void stepCleanupExtendedFinalLaunchSequence_7_7(final RequestMonitor rm) { + if (fTracker != null) fTracker.dispose(); + fTracker = null; + rm.done(); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunch.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunch.java new file mode 100644 index 00000000000..be0fd631380 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunch.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.launch; + +import org.eclipse.cdt.dsf.concurrent.ThreadSafe; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.model.ISourceLocator; + +@ThreadSafe +public class GdbExtendedLaunch extends GdbLaunch +{ + public GdbExtendedLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) { + super(launchConfiguration, mode, locator); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunchDelegate.java new file mode 100644 index 00000000000..96011424a13 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedLaunchDelegate.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.launch; + +import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.debug.service.IDsfDebugServicesFactory; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate; +import org.eclipse.cdt.dsf.gdb.launching.LaunchUtils; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.examples.dsf.gdb.GDBExamplePlugin; +import org.eclipse.cdt.examples.dsf.gdb.service.GdbExtendedDebugServicesFactory; +import org.eclipse.cdt.examples.dsf.gdb.service.GdbExtendedDebugServicesFactoryNS; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.model.ISourceLocator; + +public class GdbExtendedLaunchDelegate extends GdbLaunchDelegate { + public GdbExtendedLaunchDelegate() { + super(); + } + + @Override + protected GdbLaunch createGdbLaunch(ILaunchConfiguration configuration, String mode, ISourceLocator locator) throws CoreException { + return new GdbExtendedLaunch(configuration, mode, locator); + } + + @Override + protected Sequence getServicesSequence(DsfSession session, ILaunch launch, IProgressMonitor rm) { + return new GdbExtendedServicesLaunchSequence(session, (GdbLaunch)launch, rm); + } + + @Override + protected IDsfDebugServicesFactory newServiceFactory(ILaunchConfiguration config, String version) { + boolean nonStop = LaunchUtils.getIsNonStopMode(config); + if (nonStop && isNonStopSupportedInGdbVersion(version)) { + return new GdbExtendedDebugServicesFactoryNS(version); + } + return new GdbExtendedDebugServicesFactory(version); + } + + @Override + protected String getPluginID() { + return GDBExamplePlugin.PLUGIN_ID; + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedServicesLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedServicesLaunchSequence.java new file mode 100644 index 00000000000..28a11b41756 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/launch/GdbExtendedServicesLaunchSequence.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.launch; + +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; +import org.eclipse.cdt.dsf.gdb.launching.ServicesLaunchSequence; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.examples.dsf.gdb.service.IGDBExtendedFunctions; +import org.eclipse.core.runtime.IProgressMonitor; + +public class GdbExtendedServicesLaunchSequence extends ServicesLaunchSequence { + + private GdbLaunch fLaunch; + + public GdbExtendedServicesLaunchSequence(DsfSession session, GdbLaunch launch, IProgressMonitor pm) { + super(session, launch, pm); + fLaunch = launch; + } + + @Override + public Step[] getSteps() { + // Add an extra step at the end to create the new service + Step[] steps = super.getSteps(); + Step[] moreSteps = new Step[steps.length + 1]; + System.arraycopy(steps, 0, moreSteps, 0, steps.length); + moreSteps[steps.length] = new Step() { + @Override + public void execute(RequestMonitor requestMonitor) { + fLaunch.getServiceFactory().createService(IGDBExtendedFunctions.class, fLaunch.getSession()).initialize(requestMonitor); + } + }; + return moreSteps; + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GDBExtendedControl_7_7.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GDBExtendedControl_7_7.java new file mode 100644 index 00000000000..a59a5fab5fb --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GDBExtendedControl_7_7.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.service; + +import java.util.Map; + +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; +import org.eclipse.cdt.dsf.concurrent.Sequence; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_7; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.examples.dsf.gdb.launch.GdbExtendedFinalLaunchSequence_7_7; +import org.eclipse.debug.core.ILaunchConfiguration; + +public class GDBExtendedControl_7_7 extends GDBControl_7_7 { + public GDBExtendedControl_7_7(DsfSession session, ILaunchConfiguration config, CommandFactory factory) { + super(session, config, factory); + } + + @Override + protected Sequence getCompleteInitializationSequence(Map attributes, RequestMonitorWithProgress rm) { + return new GdbExtendedFinalLaunchSequence_7_7(getSession(), attributes, rm); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GDBExtendedService.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GDBExtendedService.java new file mode 100644 index 00000000000..c8dca46ff11 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GDBExtendedService.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.service; + +import java.util.Hashtable; + +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.debug.service.command.CommandCache; +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; +import org.eclipse.cdt.dsf.gdb.IGdbDebugConstants; +import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; +import org.eclipse.cdt.dsf.mi.service.IMICommandControl; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.mi.service.command.output.MIGDBVersionInfo; +import org.eclipse.cdt.dsf.service.AbstractDsfService; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.examples.dsf.gdb.GDBExamplePlugin; +import org.eclipse.cdt.examples.dsf.gdb.service.command.GdbExtendedCommandFactory_6_8; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.IStatusHandler; +import org.osgi.framework.BundleContext; + +public class GDBExtendedService extends AbstractDsfService implements IGDBExtendedFunctions { + + private IMICommandControl fCommandControl; + private CommandFactory fCommandFactory; + private CommandCache fVersionCache; + + public GDBExtendedService(DsfSession session) { + super(session); + } + + @Override + public void initialize(final RequestMonitor rm) { + super.initialize(new ImmediateRequestMonitor(rm) { + @Override + protected void handleSuccess() { + doInitialize(rm); + } + }); + } + + private void doInitialize(RequestMonitor rm) { + fCommandControl = getServicesTracker().getService(IMICommandControl.class); + fCommandFactory = fCommandControl.getCommandFactory(); + + fVersionCache = new CommandCache(getSession(), fCommandControl); + fVersionCache.setContextAvailable(fCommandControl.getContext(), true); + + register(new String[] { IGDBExtendedFunctions.class.getName() }, + new Hashtable()); + + rm.done(); + } + + + @Override + public void shutdown(RequestMonitor rm) { + unregister(); + super.shutdown(rm); + } + + @Override + protected BundleContext getBundleContext() { + return GDBExamplePlugin.getBundleContext(); + } + + @Override + public void notify(ICommandControlDMContext ctx, String str, RequestMonitor rm) { + IStatus status = new Status( + IStatus.INFO, + GdbPlugin.getUniqueIdentifier(), + IGdbDebugConstants.STATUS_HANDLER_CODE, + str, + null); + IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(status); + if (statusHandler != null) { + try { + statusHandler.handleStatus(status, null); + } + catch(CoreException e) { + GDBExamplePlugin.getDefault().getLog().log(e.getStatus()); + } + } + rm.done(); + } + + @Override + public void getVersion(ICommandControlDMContext ctx, final DataRequestMonitor rm) { + if (fCommandFactory instanceof GdbExtendedCommandFactory_6_8) { + GdbExtendedCommandFactory_6_8 factory = (GdbExtendedCommandFactory_6_8)fCommandFactory; + + // Use the cache to avoid having to go to GDB more than once for a value + // that does not change. No need to even clear the cache since the GDB version will never change. + fVersionCache.execute(factory.createCLIGDBVersion(ctx), + new ImmediateDataRequestMonitor(rm) { + @Override + protected void handleSuccess() { + rm.done(getData().getVersion()); + } + }); + } else { + rm.done(new Status(IStatus.ERROR, GDBExamplePlugin.PLUGIN_ID, + NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ + } + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactory.java new file mode 100644 index 00000000000..2a1065e4a12 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactory.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.service; + +import org.eclipse.cdt.dsf.debug.service.command.ICommandControl; +import org.eclipse.cdt.dsf.gdb.service.GdbDebugServicesFactory; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_0; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_2; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_4; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.examples.dsf.gdb.service.command.GdbExtendedCommandFactory_6_8; +import org.eclipse.debug.core.ILaunchConfiguration; + +public class GdbExtendedDebugServicesFactory extends GdbDebugServicesFactory { + + public GdbExtendedDebugServicesFactory(String version) { + super(version); + } + + @Override + @SuppressWarnings("unchecked") + public V createService(Class clazz, DsfSession session, Object ... optionalArguments) { + if (IGDBExtendedFunctions.class.isAssignableFrom(clazz)) { + return (V)createExtendedService(session); + } + return super.createService(clazz, session, optionalArguments); + } + + @Override + protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) { + if (GDB_7_7_VERSION.compareTo(getVersion()) <= 0) { + return new GDBExtendedControl_7_7(session, config, new GdbExtendedCommandFactory_6_8()); + } + if (GDB_7_4_VERSION.compareTo(getVersion()) <= 0) { + return new GDBControl_7_4(session, config, new GdbExtendedCommandFactory_6_8()); + } + if (GDB_7_2_VERSION.compareTo(getVersion()) <= 0) { + return new GDBControl_7_2(session, config, new GdbExtendedCommandFactory_6_8()); + } + if (GDB_7_0_VERSION.compareTo(getVersion()) <= 0) { + return new GDBControl_7_0(session, config, new GdbExtendedCommandFactory_6_8()); + } + if (GDB_6_8_VERSION.compareTo(getVersion()) <= 0) { + return new GDBControl(session, config, new GdbExtendedCommandFactory_6_8()); + } + return new GDBControl(session, config, new CommandFactory()); + } + + protected IGDBExtendedFunctions createExtendedService(DsfSession session) { + return new GDBExtendedService(session); + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactoryNS.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactoryNS.java new file mode 100644 index 00000000000..6e732d83e42 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/GdbExtendedDebugServicesFactoryNS.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.service; + +import org.eclipse.cdt.dsf.debug.service.IRunControl; +import org.eclipse.cdt.dsf.gdb.service.GDBRunControl_7_0_NS; +import org.eclipse.cdt.dsf.gdb.service.GDBRunControl_7_2_NS; +import org.eclipse.cdt.dsf.service.DsfSession; + +public class GdbExtendedDebugServicesFactoryNS extends GdbExtendedDebugServicesFactory { + + public GdbExtendedDebugServicesFactoryNS(String version) { + super(version); + } + + @Override + protected IRunControl createRunControlService(DsfSession session) { + if (GDB_7_2_VERSION.compareTo(getVersion()) <= 0) { + return new GDBRunControl_7_2_NS(session); + } + return new GDBRunControl_7_0_NS(session); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/IGDBExtendedFunctions.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/IGDBExtendedFunctions.java new file mode 100644 index 00000000000..318f8fa3cea --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/IGDBExtendedFunctions.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.service; + +import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; +import org.eclipse.cdt.dsf.service.IDsfService; + + +public interface IGDBExtendedFunctions extends IDsfService { + /** + * Request a notification to the user + */ + void notify(ICommandControlDMContext ctx, String str, RequestMonitor rm); + + /** + * Get the version of the debugger + */ + void getVersion(ICommandControlDMContext ctx, DataRequestMonitor rm); + +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/command/GdbExtendedCommandFactory_6_8.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/command/GdbExtendedCommandFactory_6_8.java new file mode 100644 index 00000000000..a0003b07703 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/command/GdbExtendedCommandFactory_6_8.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.service.command; + +import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext; +import org.eclipse.cdt.dsf.debug.service.command.ICommand; +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; +import org.eclipse.cdt.dsf.gdb.service.command.CommandFactory_6_8; +import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIGDBVersionInfo; +import org.eclipse.cdt.examples.dsf.gdb.service.command.commands.CLIGDBVersion; + +public class GdbExtendedCommandFactory_6_8 extends CommandFactory_6_8 { + @Override + public ICommand createMIDPrintfInsert( + IBreakpointsTargetDMContext ctx, boolean isTemporary, + String condition, int ignoreCount, int tid, boolean disabled, + String location, String printfStr) { + // Prefix all dynamic printf with the [EX] tag + printfStr = printfStr.replaceFirst("^\"", "\"[EX] "); //$NON-NLS-1$ //$NON-NLS-2$ + return super.createMIDPrintfInsert(ctx, isTemporary, condition, ignoreCount, + tid, disabled, location, printfStr); + } + + public ICommand createCLIGDBVersion(ICommandControlDMContext ctx) { + return new CLIGDBVersion(ctx); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/command/commands/CLIGDBVersion.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/command/commands/CLIGDBVersion.java new file mode 100644 index 00000000000..06ff3658446 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/service/command/commands/CLIGDBVersion.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.service.command.commands; + +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; +import org.eclipse.cdt.dsf.mi.service.command.commands.MIInterpreterExecConsole; +import org.eclipse.cdt.dsf.mi.service.command.output.MIGDBVersionInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput; + +/** + * We use -interpreter-exec console "show version" instead + * of -gdb-version to avoid having the output automatically printed + * to our console. + * + */ +public class CLIGDBVersion extends MIInterpreterExecConsole { + private static final String COMMAND = "show version"; //$NON-NLS-1$ + + public CLIGDBVersion(ICommandControlDMContext ctx) { + super(ctx, COMMAND); + } + + @Override + public MIInfo getResult(MIOutput out) { + return new MIGDBVersionInfo(out); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedLaunchVMProvider.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedLaunchVMProvider.java new file mode 100644 index 00000000000..059a07abf6e --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedLaunchVMProvider.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.viewmodel; + +import org.eclipse.cdt.dsf.concurrent.ThreadSafe; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.LaunchRootVMNode; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.StackFramesVMNode; +import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.ContainerVMNode; +import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.GdbStandardProcessVMNode; +import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.LaunchVMProvider; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter; +import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode; +import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; + +@SuppressWarnings("restriction") +public class GdbExtendedLaunchVMProvider extends LaunchVMProvider +{ + @ThreadSafe + public GdbExtendedLaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) + { + super(adapter, presentationContext, session); + } + + @Override + 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 GdbExtendedThreadVMNode(this, getSession()); + addChildNodes(containerNode, new IVMNode[] { threadsNode }); + + IVMNode stackFramesNode = new StackFramesVMNode(this, getSession()); + addChildNodes(threadsNode, new IVMNode[] { stackFramesNode }); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedThreadVMNode.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedThreadVMNode.java new file mode 100644 index 00000000000..41bb56e2093 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedThreadVMNode.java @@ -0,0 +1,172 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.viewmodel; + +import java.util.Map; + +import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants; +import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.GdbExecutionContextLabelText; +import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.IGdbLaunchVMConstants; +import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch.ThreadVMNode; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider; +import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelAttribute; +import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelColumnInfo; +import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelImage; +import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText; +import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider; +import org.eclipse.cdt.ui.CDTSharedImages; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugUIConstants; + +@SuppressWarnings("restriction") +public class GdbExtendedThreadVMNode extends ThreadVMNode { + public GdbExtendedThreadVMNode(AbstractDMVMProvider provider, DsfSession session) { + super(provider, session); + } + + @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( + GdbExtendedVMMessages.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(GdbExtendedVMMessages.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 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 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 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 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 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 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 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; + } + +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedVMMessages.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedVMMessages.java new file mode 100644 index 00000000000..0e84cef24d9 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedVMMessages.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.viewmodel; + +import org.eclipse.osgi.util.NLS; + +/** + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public class GdbExtendedVMMessages 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__Error__label; + /** since 2.3 */ + public static String ContainerVMNode_filtered_running_threads; + + static { + // initialize resource bundle + NLS.initializeMessages(GdbExtendedVMMessages.class.getName(), GdbExtendedVMMessages.class); + } + + private GdbExtendedVMMessages() { + } +} diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedVMMessages.properties b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedVMMessages.properties new file mode 100644 index 00000000000..423c501b611 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedVMMessages.properties @@ -0,0 +1,41 @@ +############################################################################### +# Copyright (c) 2014 Ericsson and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Marc Khouzam (Ericsson) - Initial API and implementation +############################################################################### + +# {0} - name available, 0=not available/1=available +# {1} - name +# {2} - ID available, 0=not available/1=available +# {3} - ID +# {4} - OS Thread ID available, 0=not available/1=available +# {5} - OS Thread ID +# {6} - Core available, 0=not available/1=available +# {7} - Core +# {8} - 0=running/1=suspended +# {9} - state change reason available, 0=not available/1=available +# {10} - state change reason +# {11} - state change details available, 0=not available/1=available +# {12} - state change details +ThreadVMNode_No_columns__text_format=DSP{2,choice,0#|1# #{3}}{0,choice,0#|1# [{1}]}{4,choice,0#|1# {5}}{6,choice,0#|1# [core: {7}]} ({8,choice,0#Running|1#Suspended}{9,choice,0#|1# : {10}}{11,choice,0#|1# : {12}}) + +ThreadVMNode_No_columns__Error__label= + +# {0} - name available, 0=not available/1=available +# {1} - name +# {2} - ID available, 0=not available/1=available +# {3} - ID +# {4} - Cores available, 0=not available/1=available +# {5} - Cores +# {6} - Thread summary available, 0=not available/1=available +# {7} - Thread summary in text format +ContainerVMNode_No_columns__text_format={0,choice,0#Process|1#{1}}{2,choice,0#|1# [{3}]}{4,choice,0#|1# [cores: {5}]}{6,choice,0#|1# {7}} + +ContainerVMNode_No_columns__Error__label= + +ContainerVMNode_filtered_running_threads=filtered running DSPs \ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedViewModelAdapter.java b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedViewModelAdapter.java new file mode 100644 index 00000000000..25ef040fd28 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.examples.dsf.gdb/src/org/eclipse/cdt/examples/dsf/gdb/viewmodel/GdbExtendedViewModelAdapter.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Khouzam (Ericsson) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.examples.dsf.gdb.viewmodel; + +import org.eclipse.cdt.dsf.concurrent.ThreadSafe; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController; +import org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.GdbViewModelAdapter; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.cdt.dsf.ui.viewmodel.IVMProvider; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; +import org.eclipse.debug.ui.IDebugUIConstants; + +@SuppressWarnings("restriction") +@ThreadSafe +public class GdbExtendedViewModelAdapter extends GdbViewModelAdapter +{ + public GdbExtendedViewModelAdapter(DsfSession session, SteppingController controller) { + super(session, controller); + } + + @Override + public void dispose() { + super.dispose(); + } + + @Override + protected IVMProvider createViewModelProvider(IPresentationContext context) { + if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) { + return new GdbExtendedLaunchVMProvider(this, context, getSession()); + } else { + return super.createViewModelProvider(context); + } + } +} diff --git a/pom.xml b/pom.xml index b578f66a73d..8aad9ab495a 100644 --- a/pom.xml +++ b/pom.xml @@ -177,6 +177,7 @@ build/org.eclipse.cdt.make.ui.tests dsf-gdb/org.eclipse.cdt.dsf.gdb.tests dsf-gdb/org.eclipse.cdt.tests.dsf.gdb + dsf-gdb/org.eclipse.cdt.examples.dsf.gdb build/org.eclipse.cdt.autotools.core build/org.eclipse.cdt.autotools.docs