Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2015-01-15 21:57:45 +0000
committerGerrit Code Review @ Eclipse.org2015-01-19 19:58:18 +0000
commit8db788ee920ff431b19f35076a2f6a810ce2d017 (patch)
treeaa315d5224b6cd8494ac96b3cc2ada77375d3738
parent92641573ba09ab09097824ae26dfb057dd297524 (diff)
downloadorg.eclipse.cdt-8db788ee920ff431b19f35076a2f6a810ce2d017.tar.gz
org.eclipse.cdt-8db788ee920ff431b19f35076a2f6a810ce2d017.tar.xz
org.eclipse.cdt-8db788ee920ff431b19f35076a2f6a810ce2d017.zip
Bug 214398: Implement Load Symbols and Load Symbols for All
- switched default ui from actions to commands - for DSF implemented this in DSF GDB - for CDI implemented command wrappers - created new API to support loading symbols in IModules service (IModules2) Change-Id: Id44f42fa9f0f3d7f22ff7dda07c0830262667d9c
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.properties2
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml125
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/LoadAllSymbolsCommandHandler.java37
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/LoadSymbolsCommandHandler.java38
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml28
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfLoadSymbolsCommandHandler.java168
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java107
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java13
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLISharedLibrary.java36
-rw-r--r--dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IModules2.java48
10 files changed, 547 insertions, 55 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index 3daa217a7df..7b06a3471ab 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -83,7 +83,7 @@ BinaryVariableFormatAction.label=Binary
CDebugActionGroup.name=C/C++ Debug
LoadSymbolsAction.label=Load Symbols
-LoadSymbolsAction.tooltip=Load Modules's Symbols
+LoadSymbolsAction.tooltip=Load Modules' Symbols
LoadSymbolsForAllAction.label=Load Symbols For All
LoadSymbolsForAllAction.tooltip=Load Symbols For All Modules
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 0b58b5245ec..bf71eb556ee 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -803,15 +803,6 @@
objectClass="org.eclipse.cdt.debug.core.model.ICModule"
id="org.eclipse.cdt.debug.ui.ModuleActions">
<action
- helpContextId="load_symbols_action_context"
- enablesFor="1"
- label="%LoadSymbolsAction.label"
- tooltip="%LoadSymbolsAction.tooltip"
- icon="icons/elcl16/load_symbols_co.gif"
- class="org.eclipse.cdt.debug.internal.ui.actions.LoadModuleSymbolsActionDelegate"
- menubarPath="modulesGroup"
- id="org.eclipse.cdt.debug.ui.LoadSymbolsAction"/>
- <action
helpContextId="module_properties_action_context"
enablesFor="1"
label="%ModulePropertiesAction.label"
@@ -822,25 +813,6 @@
</action>
</objectContribution>
<viewerContribution
- targetID="org.eclipse.debug.ui.ModuleView"
- id="org.eclipse.cdt.debug.ui.modulesView.popupMenu">
- <action
- helpContextId="load_symbols_for_all_context"
- label="%LoadSymbolsForAllAction.label"
- tooltip="%LoadSymbolsForAllAction.tooltip"
- icon="icons/elcl16/load_all_symbols_co.gif"
- class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate"
- style="push"
- menubarPath="modulesGroup"
- id="org.eclipse.cdt.debug.ui.LoadSymbolsForAllAction">
- <enablement>
- <pluginState
- value="activated"
- id="org.eclipse.cdt.debug.ui"/>
- </enablement>
- </action>
- </viewerContribution>
- <viewerContribution
id="org.eclipse.debug.ui.MemoryView.RenderingViewPane.popupMenu.1"
targetID="org.eclipse.debug.ui.MemoryView.RenderingViewPane.1">
<action
@@ -1024,26 +996,6 @@
</menu>
</viewContribution>
<viewContribution
- targetID="org.eclipse.debug.ui.ModuleView"
- id="org.eclipse.debug.ui.modulesView.toolbar">
- <action
- helpContextId="load_symbols_for_all_context"
- disabledIcon="icons/dlcl16/load_all_symbols_co.gif"
- toolbarPath="modulesGroup"
- label="%LoadSymbolsForAllAction.label"
- tooltip="%LoadSymbolsForAllAction.tooltip"
- icon="icons/elcl16/load_all_symbols_co.gif"
- class="org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate"
- style="push"
- id="org.eclipse.cdt.debug.ui.LoadSymbolsForAllAction">
- <enablement>
- <pluginState
- value="activated"
- id="org.eclipse.cdt.debug.ui"/>
- </enablement>
- </action>
- </viewContribution>
- <viewContribution
id="org.eclipse.cdt.debug.ui.expression.toolbar"
targetID="org.eclipse.debug.ui.ExpressionView">
<action
@@ -2045,6 +1997,14 @@
id="org.eclipse.cdt.debug.ui.command.debugNewExecutable"
name="%DebugNewExecutable.name">
</command>
+ <command
+ id="org.eclipse.cdt.debug.ui.command.loadSymbols"
+ name="%LoadSymbolsAction.label">
+ </command>
+ <command
+ id="org.eclipse.cdt.debug.ui.command.loadAllSymbols"
+ name="%LoadSymbolsForAllAction.label">
+ </command>
</extension>
<extension
point="org.eclipse.ui.handlers">
@@ -2118,6 +2078,34 @@
</with>
</activeWhen>
</handler>
+ <handler
+ class="org.eclipse.cdt.debug.internal.ui.commands.LoadSymbolsCommandHandler"
+ commandId="org.eclipse.cdt.debug.ui.command.loadSymbols">
+ <activeWhen>
+ <with variable="selection">
+ <iterate operator="and">
+ <instanceof value="org.eclipse.cdt.debug.core.model.ICModule">
+ </instanceof>
+ </iterate>
+ <count value="+">
+ </count>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.cdt.debug.internal.ui.commands.LoadAllSymbolsCommandHandler"
+ commandId="org.eclipse.cdt.debug.ui.command.loadAllSymbols">
+ <activeWhen>
+ <with variable="selection">
+ <iterate operator="and">
+ <instanceof value="org.eclipse.cdt.debug.core.model.ICModule">
+ </instanceof>
+ </iterate>
+ <count value="+">
+ </count>
+ </with>
+ </activeWhen>
+ </handler>
<handler
class="org.eclipse.cdt.debug.internal.ui.commands.ReverseToggleCommandHandler"
commandId="org.eclipse.cdt.debug.ui.command.reverseToggle">
@@ -2889,7 +2877,46 @@
<visibleWhen checkEnabled="true">
</visibleWhen>
</command>
- </menuContribution>
+ </menuContribution>
+ <!-- items for Module view... -->
+ <menuContribution
+ locationURI="popup:org.eclipse.debug.ui.ModuleView?after=modulesGroup">
+ <command commandId="org.eclipse.cdt.debug.ui.command.loadSymbols"
+ id="org.eclipse.cdt.debug.menu.command.loadSymbols"
+ helpContextId="load_symbols_action_context"
+ label="%LoadSymbolsAction.label"
+ tooltip="%LoadSymbolsAction.tooltip"
+ icon="icons/elcl16/load_symbols_co.gif">
+ <visibleWhen checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="popup:org.eclipse.debug.ui.ModuleView?after=modulesGroup">
+ <command commandId="org.eclipse.cdt.debug.ui.command.loadAllSymbols"
+ id="org.eclipse.cdt.debug.menu.command.loadAllSymbols"
+ helpContextId="load_symbols_for_all_context"
+ label="%LoadSymbolsForAllAction.label"
+ tooltip="%LoadSymbolsForAllAction.tooltip"
+ icon="icons/elcl16/load_all_symbols_co.gif"
+ disabledIcon="icons/dlcl16/load_all_symbols_co.gif">
+ <visibleWhen checkEnabled="true">
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ locationURI="toolbar:org.eclipse.debug.ui.ModuleView?after=modulesGroup">
+ <command commandId="org.eclipse.cdt.debug.ui.command.loadAllSymbols"
+ id="org.eclipse.cdt.debug.toolbar.command.loadAllSymbols"
+ helpContextId="load_symbols_for_all_context"
+ label="%LoadSymbolsForAllAction.label"
+ tooltip="%LoadSymbolsForAllAction.tooltip"
+ icon="icons/elcl16/load_all_symbols_co.gif"
+ disabledIcon="icons/dlcl16/load_all_symbols_co.gif">
+ <visibleWhen checkEnabled="false">
+ </visibleWhen>
+ </command>
+ </menuContribution>
</extension>
<extension
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/LoadAllSymbolsCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/LoadAllSymbolsCommandHandler.java
new file mode 100644
index 00000000000..82e27d01f2e
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/LoadAllSymbolsCommandHandler.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software System 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:
+ * Elena Laskavaia (QNX) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.commands;
+
+import org.eclipse.cdt.debug.internal.ui.actions.LoadSymbolsForAllActionDelegate;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class LoadAllSymbolsCommandHandler extends AbstractHandler implements IHandler {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IWorkbenchPart part = HandlerUtil.getActivePart(event);
+
+ if (part instanceof IViewPart) {
+ LoadSymbolsForAllActionDelegate delegate = new LoadSymbolsForAllActionDelegate();
+ delegate.init((IViewPart) part);
+ delegate.run(new Action() {
+ });
+ delegate.dispose();
+ }
+ return null;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/LoadSymbolsCommandHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/LoadSymbolsCommandHandler.java
new file mode 100644
index 00000000000..44bb6aae0c4
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/commands/LoadSymbolsCommandHandler.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software System 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:
+ * Elena Laskavaia (QNX) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.commands;
+
+import org.eclipse.cdt.debug.internal.ui.actions.LoadModuleSymbolsActionDelegate;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class LoadSymbolsCommandHandler extends AbstractHandler implements IHandler {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ final IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ LoadModuleSymbolsActionDelegate delegate = new LoadModuleSymbolsActionDelegate();
+ IAction action = new Action() { };// fake action
+ delegate.selectionChanged(action, selection);
+ delegate.setActivePart(action, part);
+ if (action.isEnabled())
+ delegate.run(action);
+ delegate.dispose();
+ return null;
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
index 5c1b5fc4b5d..f71579cc5a3 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
@@ -328,6 +328,34 @@
class="org.eclipse.cdt.dsf.gdb.internal.ui.commands.SelectPrevTraceRecordCommandHandler"
commandId="org.eclipse.cdt.dsf.gdb.ui.command.selectPreviousTraceRecord">
</handler>
+ <handler
+ class="org.eclipse.cdt.dsf.gdb.internal.ui.actions.DsfLoadSymbolsCommandHandler"
+ commandId="org.eclipse.cdt.debug.ui.command.loadSymbols">
+ <activeWhen>
+ <with variable="selection">
+ <iterate operator="and">
+ <instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.modules.ModulesVMNode$ModuleVMContext">
+ </instanceof>
+ </iterate>
+ <count value="+">
+ </count>
+ </with>
+ </activeWhen>
+ </handler>
+ <handler
+ class="org.eclipse.cdt.dsf.gdb.internal.ui.actions.DsfLoadSymbolsCommandHandler"
+ commandId="org.eclipse.cdt.debug.ui.command.loadAllSymbols">
+ <activeWhen>
+ <with variable="selection">
+ <iterate operator="or">
+ <instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.modules.ModulesVMNode$ModuleVMContext">
+ </instanceof>
+ </iterate>
+ <count value="+">
+ </count>
+ </with>
+ </activeWhen>
+ </handler>
</extension>
<extension
point="org.eclipse.ui.menus">
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
new file mode 100644
index 00000000000..fb71b41b39b
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfLoadSymbolsCommandHandler.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software System 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:
+ * Elena Laskavaia (QNX Software System) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
+
+import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
+import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
+import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
+import org.eclipse.cdt.dsf.datamodel.DMContexts;
+import org.eclipse.cdt.dsf.datamodel.IDMContext;
+import org.eclipse.cdt.dsf.debug.service.IModules.IModuleDMContext;
+import org.eclipse.cdt.dsf.debug.service.IModules.ISymbolDMContext;
+import org.eclipse.cdt.dsf.debug.service.IModules2;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.actions.IRefreshAllTarget;
+import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
+import org.eclipse.cdt.dsf.gdb.launching.GDBProcess;
+import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
+import org.eclipse.cdt.dsf.service.DsfServicesTracker;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Handler used for both Load Symbols and Load All Symbols commands
+ */
+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;
+ boolean all = event.getCommand().getId().equals("org.eclipse.cdt.debug.ui.command.loadAllSymbols");//$NON-NLS-1$
+ String sessionId = getSessionIdFromContext(selection);
+ loadSymbols(selection, sessionId, all);
+ return null;
+ }
+
+ void loadSymbols(final IStructuredSelection selection, String sessionId, final boolean all) {
+ if (sessionId == null)
+ return; // we failed to determine dsf session id
+ final DsfSession dsfSession = DsfSession.getSession(sessionId);
+ if (dsfSession == null || !(dsfSession.isActive())) {
+ return;
+ }
+ dsfSession.getExecutor().execute(new DsfRunnable() {
+ @Override
+ public void run() {
+ if (all) {
+ queueLoadAllSymbols(dsfSession, selection);
+ } else {
+ // load symbols of specific element
+ for (Object o : selection.toList()) {
+ queueLoadSymbols(dsfSession, o);
+ }
+ }
+ }
+ });
+ }
+
+ @ConfinedToDsfExecutor("fSession.getExecutor()")
+ private void queueLoadSymbols(final DsfSession session, final Object module) {
+ if (!(module instanceof IDMVMContext))
+ return;
+
+ IDMContext context = ((IDMVMContext) module).getDMContext();
+ if (context instanceof IModuleDMContext) {
+ DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
+ try {
+ IModules2 modules = tracker.getService(IModules2.class);
+ if (modules != null) {
+ modules.loadSymbols((IModuleDMContext)context, new RequestMonitor(session.getExecutor(), null) {
+ @Override
+ protected void handleSuccess() {
+ doRefresh(session, module);
+ }
+ });
+ }
+ } finally {
+ tracker.dispose();
+ }
+ }
+ }
+
+ @ConfinedToDsfExecutor("fSession.getExecutor()")
+ private void queueLoadAllSymbols(final DsfSession session, IStructuredSelection selection) {
+ IAdaptable debugContext = DebugUITools.getDebugContext();
+ IDMContext dmcontext = (IDMContext) debugContext.getAdapter(IDMContext.class);
+ ISymbolDMContext symDmc = DMContexts.getAncestorOfType(dmcontext, ISymbolDMContext.class);
+ if (symDmc != null) {
+ DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
+ try {
+ IModules2 modules = tracker.getService(IModules2.class);
+ if (modules != null) {
+ modules.loadSymbolsForAllModules(symDmc, new RequestMonitor(session.getExecutor(), null) {
+ @Override
+ protected void handleSuccess() {
+ doRefresh(session, DebugUITools.getDebugContext());
+ }
+ });
+ }
+ } finally {
+ tracker.dispose();
+ }
+ }
+ }
+
+ /**
+ * 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
+ */
+ private void doRefresh(DsfSession session, Object element) {
+ if (element != null) {
+ try {
+ IRefreshAllTarget refreshTarget = (IRefreshAllTarget)session.getModelAdapter(IRefreshAllTarget.class);
+ if (refreshTarget != null) {
+ refreshTarget.refresh(new StructuredSelection(element));
+ }
+ } catch (CoreException e) {
+ // refresh failed, sad
+ }
+ }
+ }
+
+ private String getSessionIdFromContext(IStructuredSelection selection) {
+
+ Object element = selection.getFirstElement();
+ if (element instanceof IDMVMContext) {
+ IDMContext context = ((IDMVMContext) element).getDMContext();
+
+ String sessionId = context.getSessionId();
+ if (sessionId != null)
+ return sessionId;
+ }
+
+ IAdaptable debugContext = DebugUITools.getDebugContext();
+ String sessionId = null;
+ if (debugContext instanceof IDMVMContext) {
+ sessionId = ((IDMVMContext) debugContext).getDMContext().getSessionId();
+ } else if (debugContext instanceof GdbLaunch) {
+ GdbLaunch gdbLaunch = (GdbLaunch) debugContext;
+ if (gdbLaunch.isTerminated() == false) {
+ sessionId = gdbLaunch.getSession().getId();
+ }
+ } else if (debugContext instanceof GDBProcess) {
+ ILaunch launch = ((GDBProcess) debugContext).getLaunch();
+ if (launch.isTerminated() == false && launch instanceof GdbLaunch) {
+ sessionId = ((GdbLaunch) launch).getSession().getId();
+ }
+ }
+ return sessionId;
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java
index cddc67a8fa8..5fc1b113cda 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems and others.
+ * Copyright (c) 2007, 2015 Wind River Systems 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
@@ -16,20 +16,25 @@ import java.util.Hashtable;
import org.eclipse.cdt.core.IAddress;
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.datamodel.AbstractDMContext;
+import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.ICachingService;
import org.eclipse.cdt.dsf.debug.service.IModules;
+import org.eclipse.cdt.dsf.debug.service.IModules2;
import org.eclipse.cdt.dsf.debug.service.command.CommandCache;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoSharedLibraryInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.CLIInfoSharedLibraryInfo.DsfMISharedInfo;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.service.AbstractDsfService;
+import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -38,8 +43,26 @@ import org.osgi.framework.BundleContext;
/**
*
*/
-public class MIModules extends AbstractDsfService implements IModules, ICachingService {
+public class MIModules extends AbstractDsfService implements IModules2, ICachingService {
+
+ private static class SymbolsLoadedEvent extends AbstractDMEvent<ISymbolDMContext>
+ implements ISymbolsLoadedDMEvent {
+
+ private IModuleDMContext[] fModules;
+
+ public SymbolsLoadedEvent(ISymbolDMContext context, IModuleDMContext[] modules) {
+ super(context);
+ fModules = modules;
+ }
+
+ @Override
+ public IModuleDMContext[] getModules() {
+ return fModules;
+ }
+ }
+
private CommandCache fModulesCache;
+ private CommandCache fModulesLoadCache;
private CommandFactory fCommandFactory;
public MIModules(DsfSession session) {
@@ -66,13 +89,18 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS
ICommandControlService commandControl = getServicesTracker().getService(ICommandControlService.class);
fModulesCache = new CommandCache(getSession(), commandControl);
fModulesCache.setContextAvailable(commandControl.getContext(), true);
+ fModulesLoadCache = new CommandCache(getSession(), commandControl);
+ fModulesLoadCache.setContextAvailable(commandControl.getContext(), true);
fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
/*
* Make ourselves known so clients can use us.
*/
- register(new String[]{IModules.class.getName(), MIModules.class.getName()}, new Hashtable<String,String>());
+ register(new String[]{ IModules.class.getName(),
+ IModules2.class.getName(),
+ MIModules.class.getName() },
+ new Hashtable<String,String>());
requestMonitor.done();
}
@@ -90,6 +118,10 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS
fFile = file;
}
+ public String getFile() {
+ return fFile;
+ }
+
@Override
public boolean equals(Object obj) {
return baseEquals(obj) && fFile.equals(((ModuleDMContext)obj).fFile);
@@ -99,6 +131,11 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS
public int hashCode() {
return baseHashCode() + fFile.hashCode();
}
+
+ @Override
+ public String toString() {
+ return baseToString() + ".file[" + fFile + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
static class ModuleDMData implements IModuleDMData {
@@ -213,6 +250,61 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS
}
}
+ /**
+ * @since 4.6
+ */
+ @Override
+ public void loadSymbolsForAllModules(final ISymbolDMContext symDmc, final RequestMonitor rm) {
+ assert symDmc != null;
+ if (symDmc != null) {
+ fModulesLoadCache.execute(fCommandFactory.createCLISharedLibrary(symDmc),
+ new ImmediateDataRequestMonitor<MIInfo>(rm) {
+ @Override
+ protected void handleSuccess() {
+ getModules(symDmc, new ImmediateDataRequestMonitor<IModuleDMContext[]>() {
+ @Override
+ protected void handleCompleted() {
+ if (isSuccess()) {
+ getSession().dispatchEvent(new SymbolsLoadedEvent(symDmc, getData()),
+ getProperties());
+ } else {
+ // Some error in getting the list of modules. Send an event anyway without the list
+ getSession().dispatchEvent(new SymbolsLoadedEvent(symDmc, new IModuleDMContext[0]),
+ getProperties());
+ }
+ rm.done();
+ };
+ });
+ }
+ });
+ } else {
+ rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid DM Context", null)); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @since 4.6
+ */
+ @Override
+ public void loadSymbols(final IModuleDMContext modDmc, final RequestMonitor rm) {
+ assert modDmc != null;
+ final ISymbolDMContext symDmc = DMContexts.getAncestorOfType(modDmc, ISymbolDMContext.class);
+ if (symDmc != null && modDmc instanceof ModuleDMContext) {
+ fModulesLoadCache.execute(fCommandFactory.createCLISharedLibrary(symDmc, ((ModuleDMContext)modDmc).getFile()),
+ new ImmediateDataRequestMonitor<MIInfo>(rm) {
+ @Override
+ protected void handleSuccess() {
+ getSession().dispatchEvent(new SymbolsLoadedEvent(symDmc, new IModuleDMContext[] { modDmc }),
+ getProperties());
+ rm.done();
+ }
+ });
+ } else {
+ rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid DM Context", null)); //$NON-NLS-1$
+ }
+ }
+
+
private IModuleDMData createSharedLibInfo(ModuleDMContext dmc, CLIInfoSharedLibraryInfo info){
for (CLIInfoSharedLibraryInfo.DsfMISharedInfo shared : info.getMIShared()) {
if(shared.getName().equals(dmc.fFile)){
@@ -235,12 +327,19 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS
rm.done();
}
+ @DsfServiceEventHandler
+ public void eventDispatched(ISymbolsLoadedDMEvent e) {
+ fModulesCache.reset();
+ // Do not clear fModulesLoadCache since those commands do not need to be resent.
+ }
+
/**
* {@inheritDoc}
* @since 1.1
*/
@Override
public void flushCache(IDMContext context) {
- fModulesCache.reset();
+ fModulesCache.reset();
+ fModulesLoadCache.reset();
}
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java
index 474b2c92fc4..5d2d59901fe 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 QNX Software Systems and others.
+ * Copyright (c) 2000, 2015 QNX Software Systems 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
@@ -60,6 +60,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.CLIMaintenance;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIPasscount;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIRecord;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIRemoteGet;
+import org.eclipse.cdt.dsf.mi.service.command.commands.CLISharedLibrary;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIShowEndian;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLISource;
import org.eclipse.cdt.dsf.mi.service.command.commands.CLIThread;
@@ -320,6 +321,16 @@ public class CommandFactory {
return new CLIRemoteGet(ctx, remoteFile, localFile);
}
+ /** @since 4.6 */
+ public ICommand<MIInfo> createCLISharedLibrary(ISymbolDMContext ctx) {
+ return new CLISharedLibrary(ctx);
+ }
+
+ /** @since 4.6 */
+ public ICommand<MIInfo> createCLISharedLibrary(ISymbolDMContext ctx, String name) {
+ return new CLISharedLibrary(ctx, name);
+ }
+
/**
* @since 4.2
*/
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLISharedLibrary.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLISharedLibrary.java
new file mode 100644
index 00000000000..721898aad7d
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLISharedLibrary.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software System 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:
+ * Elena Laskavaia (QNX Software System) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.mi.service.command.commands;
+
+import org.eclipse.cdt.dsf.debug.service.IModules.ISymbolDMContext;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
+
+/**
+ * CLI command implement gdb sharedlibary command<br>
+ * sharedlibrary regex<br>
+ * Load shared object library symbols for files matching a Unix regular
+ * expression. As with files loaded automatically, it only loads shared
+ * libraries required by your program for a core file or after typing run. If
+ * regex is omitted all shared libraries required by your program are loaded.
+ *
+ * @since 4.6
+ */
+public class CLISharedLibrary extends MIInterpreterExecConsole<MIInfo> {
+ private static final String SHARED_LIBRARY = "sharedlibrary"; //$NON-NLS-1$
+
+ public CLISharedLibrary(ISymbolDMContext ctx) {
+ super(ctx, SHARED_LIBRARY);
+ }
+
+ public CLISharedLibrary(ISymbolDMContext ctx, String name) {
+ super(ctx, SHARED_LIBRARY + " " + name); //$NON-NLS-1$
+ }
+}
diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IModules2.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IModules2.java
new file mode 100644
index 00000000000..8b5c3049f06
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IModules2.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software System 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:
+ * Elena Laskavaia (QNX Software System) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.debug.service;
+
+import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
+import org.eclipse.cdt.dsf.datamodel.IDMEvent;
+
+/**
+ * Extends to IModules interface to supporting loading symbols.
+ * @since 2.6
+ */
+public interface IModules2 extends IModules {
+
+ /**
+ * Event indicating a change in the symbols of certain modules of the symbol context.
+ */
+ public interface ISymbolsChangedDMEvent extends IDMEvent<ISymbolDMContext> {
+ public IModuleDMContext[] getModules();
+ }
+
+ /**
+ * Indicates symbols were loaded for some modules.
+ */
+ public interface ISymbolsLoadedDMEvent extends ISymbolsChangedDMEvent {}
+
+ /**
+ * Indicates symbols were unloaded for some modules.
+ */
+ public interface ISymbolsUnloadedDMEvent extends ISymbolsChangedDMEvent {}
+
+ /**
+ * Load symbols for all modules of the specified symbol context
+ */
+ void loadSymbolsForAllModules(ISymbolDMContext symCtx, RequestMonitor rm);
+
+ /**
+ * Load symbols for the specified module
+ */
+ void loadSymbols(IModuleDMContext dmc, RequestMonitor rm);
+}

Back to the top