mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
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
This commit is contained in:
parent
92641573ba
commit
8db788ee92
10 changed files with 547 additions and 55 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -802,15 +802,6 @@
|
|||
<objectContribution
|
||||
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"
|
||||
|
@ -821,25 +812,6 @@
|
|||
id="org.eclipse.cdt.debug.ui.ModulePropertiesAction">
|
||||
</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">
|
||||
|
@ -1023,26 +995,6 @@
|
|||
<separator name="emptyRefreshGroup"/>
|
||||
</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">
|
||||
|
@ -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">
|
||||
|
@ -2117,6 +2077,34 @@
|
|||
</count>
|
||||
</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"
|
||||
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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">
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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$
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
Loading…
Add table
Reference in a new issue