mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[187888] Initial (stubbed) version of the modules service and the connection to the Modules view.
This commit is contained in:
parent
27bc6ae2b6
commit
cfd78eff47
6 changed files with 217 additions and 51 deletions
|
@ -28,6 +28,7 @@ Export-Package:
|
|||
org.eclipse.dd.dsf.debug.ui.viewmodel.expression,
|
||||
org.eclipse.dd.dsf.debug.ui.viewmodel.formatsupport,
|
||||
org.eclipse.dd.dsf.debug.ui.viewmodel.launch,
|
||||
org.eclipse.dd.dsf.debug.ui.viewmodel.modules,
|
||||
org.eclipse.dd.dsf.debug.ui.viewmodel.register,
|
||||
org.eclipse.dd.dsf.debug.ui.viewmodel.variable
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.modules;
|
||||
|
||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.dd.dsf.debug.service.IModules;
|
||||
import org.eclipse.dd.dsf.debug.service.IRegisters;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||
import org.eclipse.dd.dsf.debug.service.IModules.IModuleDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IModules.IModuleDMData;
|
||||
import org.eclipse.dd.dsf.debug.service.IRegisters.IGroupChangedDMEvent;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.dsf.service.IDsfService;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.update.VMCacheManager;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class ModulesLayoutNode extends AbstractDMVMLayoutNode
|
||||
{
|
||||
public ModulesLayoutNode(AbstractVMProvider provider, DsfSession session) {
|
||||
super(provider, session, IModuleDMContext.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateElementsInSessionThread(final IChildrenUpdate update) {
|
||||
if (!checkService(IRegisters.class, null, update)) return;
|
||||
|
||||
final IExecutionDMContext execDmc = findDmcInPath(update.getElementPath(), IExecutionDMContext.class) ;
|
||||
|
||||
if (execDmc != null) {
|
||||
getServicesTracker().getService(IModules.class).getModules(
|
||||
execDmc,
|
||||
new DataRequestMonitor<IModuleDMContext[]>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
public void handleCompleted() {
|
||||
if (!getStatus().isOK()) {
|
||||
update.done();
|
||||
return;
|
||||
}
|
||||
fillUpdateWithVMCs(update, getData());
|
||||
update.done();
|
||||
}});
|
||||
} else {
|
||||
handleFailedUpdate(update);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateLabelInSessionThread(ILabelUpdate[] updates) {
|
||||
for (final ILabelUpdate update : updates) {
|
||||
final IModuleDMContext dmc = findDmcInPath(update.getElementPath(), IModuleDMContext.class);
|
||||
if (!checkDmc(dmc, update) || !checkService(IModules.class, null, update)) continue;
|
||||
|
||||
getServicesTracker().getService(IModules.class, null).getModuleData(
|
||||
dmc,
|
||||
new DataRequestMonitor<IModuleDMData>(getSession().getExecutor(), null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
/*
|
||||
* The request could fail if the state of the service
|
||||
* changed during the request, but the view model
|
||||
* has not been updated yet.
|
||||
*/
|
||||
if (!getStatus().isOK()) {
|
||||
assert getStatus().isOK() ||
|
||||
getStatus().getCode() != IDsfService.INTERNAL_ERROR ||
|
||||
getStatus().getCode() != IDsfService.NOT_SUPPORTED;
|
||||
handleFailedUpdate(update);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If columns are configured, call the protected methods to
|
||||
* fill in column values.
|
||||
*/
|
||||
String[] localColumns = update.getPresentationContext().getColumns();
|
||||
if (localColumns == null) localColumns = new String[] { null };
|
||||
|
||||
for (int i = 0; i < localColumns.length; i++) {
|
||||
fillColumnLabel(dmc, getData(), localColumns[i], i, update);
|
||||
}
|
||||
update.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillColumnLabel(IModuleDMContext dmContext, IModuleDMData dmData,
|
||||
String columnId, int idx, ILabelUpdate update)
|
||||
{
|
||||
if ( columnId == null ) {
|
||||
/*
|
||||
* If the Column ID comes in as "null" then this is the case where the user has decided
|
||||
* to not have any columns. So we need a default action which makes the most sense and
|
||||
* is doable. In this case we elect to simply display the name.
|
||||
*/
|
||||
update.setLabel(dmData.getName(), idx);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNodeDeltaFlagsForDMEvent(IDMEvent<?> e) {
|
||||
if (e instanceof IRunControl.ISuspendedDMEvent) {
|
||||
return IModelDelta.CONTENT;
|
||||
}
|
||||
else if (e instanceof IRegisters.IGroupsChangedDMEvent) {
|
||||
return IModelDelta.CONTENT;
|
||||
}
|
||||
else if (e instanceof IRegisters.IGroupChangedDMEvent) {
|
||||
return IModelDelta.STATE;
|
||||
}
|
||||
return IModelDelta.NO_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildDeltaForDMEvent(IDMEvent<?> e, VMDelta parent, int nodeOffset, RequestMonitor rm) {
|
||||
if (e instanceof IRunControl.ISuspendedDMEvent) {
|
||||
// Create a delta that indicates all groups have changed
|
||||
parent.addFlags(IModelDelta.CONTENT);
|
||||
}
|
||||
else if (e instanceof IRegisters.IGroupsChangedDMEvent) {
|
||||
// flush the cache
|
||||
VMCacheManager.getVMCacheManager().flush(super.getVMProvider().getPresentationContext());
|
||||
|
||||
// Create a delta that indicates all groups have changed
|
||||
parent.addFlags(IModelDelta.CONTENT);
|
||||
}
|
||||
else if (e instanceof IRegisters.IGroupChangedDMEvent) {
|
||||
// flush the cache
|
||||
VMCacheManager.getVMCacheManager().flush(super.getVMProvider().getPresentationContext());
|
||||
|
||||
// Create a delta that indicates that specific group changed
|
||||
parent.addNode( createVMContext(((IGroupChangedDMEvent)e).getDMContext()), IModelDelta.STATE );
|
||||
}
|
||||
|
||||
super.buildDeltaForDMEvent(e, parent, nodeOffset, rm);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.dsf.debug.ui.viewmodel.modules;
|
||||
|
||||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProvider;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.dm.DMVMRootLayoutNode;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class ModulesVMProvider extends AbstractDMVMProvider {
|
||||
/*
|
||||
* Current default for register formatting.
|
||||
*/
|
||||
public ModulesVMProvider(AbstractVMAdapter adapter, IPresentationContext context, DsfSession session) {
|
||||
super(adapter, context, session);
|
||||
|
||||
/*
|
||||
* Create the top level node to deal with the root selection.
|
||||
*/
|
||||
IVMRootLayoutNode debugViewSelection = new DMVMRootLayoutNode(this);
|
||||
|
||||
/*
|
||||
* Create the Group nodes next. They represent the first level shown in the view.
|
||||
*/
|
||||
IVMLayoutNode modulesNode = new ModulesLayoutNode(this, getSession());
|
||||
debugViewSelection.setChildNodes(new IVMLayoutNode[] { modulesNode });
|
||||
|
||||
/*
|
||||
* Now set this schema set as the layout set.
|
||||
*/
|
||||
setRootLayoutNode(debugViewSelection);
|
||||
}
|
||||
}
|
|
@ -15,14 +15,13 @@ import java.math.BigInteger;
|
|||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMData;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMEvent;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMService;
|
||||
import org.eclipse.dd.dsf.service.IDsfService;
|
||||
|
||||
/**
|
||||
* Debugger service representing module handling logic of a debugger.
|
||||
*/
|
||||
public interface IModules extends IDMService {
|
||||
public interface IModules extends IDsfService {
|
||||
|
||||
/**
|
||||
* Symbol context represents the space into which module symbols are loaded.
|
||||
|
@ -56,59 +55,14 @@ public interface IModules extends IDMService {
|
|||
IModuleDMContext getUnloadedModuleContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Object representing a unuqie location in a symbol context, based on
|
||||
* a module, section, and address offset within the seciton.
|
||||
*/
|
||||
public final class ModuleSectionOffset {
|
||||
private final IModuleDMContext fModule;
|
||||
private final Section fSection;
|
||||
private final BigInteger fOffset;
|
||||
|
||||
public IModuleDMContext getModule() { return fModule; }
|
||||
public Section getSection() { return fSection; }
|
||||
public BigInteger getOffset() { return fOffset; }
|
||||
|
||||
public ModuleSectionOffset(IModuleDMContext module, Section section, BigInteger offset) {
|
||||
this.fModule = module;
|
||||
this.fSection = section;
|
||||
this.fOffset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return fModule.hashCode() + fSection.hashCode() + fOffset.intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ModuleSectionOffset)) return false;
|
||||
ModuleSectionOffset mso = (ModuleSectionOffset)o;
|
||||
return fModule.equals(mso.fModule) && fSection.equals(mso.fSection) && fOffset.equals(mso.fOffset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Symbol context data includes a mapping between run-time addresses and
|
||||
* module-section-offset coordinates.
|
||||
*/
|
||||
public interface ISymbolDMData extends IDMData {
|
||||
/** Convert link-time address 'addr' to run-time address */
|
||||
public long convertToRT(ModuleSectionOffset mso);
|
||||
|
||||
/** Convert run-time address 'addr' to link-time address */
|
||||
public ModuleSectionOffset convertFromRT(IAddress addr);
|
||||
}
|
||||
|
||||
/** Module information. */
|
||||
public interface IModuleDMData {
|
||||
String getName();
|
||||
String getFile();
|
||||
long getTimeStamp();
|
||||
Section[] getSections();
|
||||
}
|
||||
|
||||
/** Section information */
|
||||
/** i information */
|
||||
public interface Section {
|
||||
String getName();
|
||||
IAddress getStartAddress();
|
||||
|
@ -131,6 +85,8 @@ public interface IModules extends IDMService {
|
|||
IAddress getEndAddress();
|
||||
}
|
||||
|
||||
void getModuleData(IModuleDMContext dmc, DataRequestMonitor<IModuleDMData> rm);
|
||||
|
||||
/**
|
||||
* Retreives the list of modules loaded in given symbol context.
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.dd.dsf.datamodel;
|
|||
import org.eclipse.core.runtime.PlatformObject;
|
||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||
import org.eclipse.dd.dsf.service.DsfSession;
|
||||
import org.eclipse.dd.dsf.service.IDsfService;
|
||||
|
||||
/**
|
||||
* Base implementation of the IDMContext interface. There are two pieces of
|
||||
|
@ -45,7 +46,7 @@ abstract public class AbstractDMContext extends PlatformObject
|
|||
}
|
||||
|
||||
/** Convenience constructor */
|
||||
public AbstractDMContext(IDMService service, IDMContext[] parents) {
|
||||
public AbstractDMContext(IDsfService service, IDMContext[] parents) {
|
||||
this(service.getSession().getId(), parents);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,11 @@ import org.eclipse.dd.dsf.concurrent.ThreadSafe;
|
|||
*/
|
||||
public class DMContexts {
|
||||
|
||||
/**
|
||||
* Convenience constant.
|
||||
*/
|
||||
public static final IDMContext[] EMPTY_CONTEXTS_ARRAY = new IDMContext[0];
|
||||
|
||||
/**
|
||||
* Finds a data model context of given type among ancestors of the
|
||||
* specified context.
|
||||
|
|
Loading…
Add table
Reference in a new issue