mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-13 03:55:22 +02:00
Commit fix for bug 248610, add "View Memory" support to DSF (Stephen Chong)
This commit is contained in:
parent
ee3a2444d1
commit
f20d66d319
8 changed files with 357 additions and 119 deletions
|
@ -206,6 +206,10 @@ ResumeWithoutSignal.description=Resume Without Signal
|
||||||
ResumeWithoutSignal.label=Resume Without Signal
|
ResumeWithoutSignal.label=Resume Without Signal
|
||||||
ResumeWithoutSignal.tooltip=Resume Ignoring Signal
|
ResumeWithoutSignal.tooltip=Resume Ignoring Signal
|
||||||
|
|
||||||
|
# View memory command
|
||||||
|
command.viewMemory.description=View variable in memory view
|
||||||
|
command.viewMemory.name=View Memory
|
||||||
|
|
||||||
# Reverse debugging
|
# Reverse debugging
|
||||||
ReverseActionSet.label = Reverse Debugging
|
ReverseActionSet.label = Reverse Debugging
|
||||||
ReverseDebuggingCategory.name = Reverse Debugging Commands
|
ReverseDebuggingCategory.name = Reverse Debugging Commands
|
||||||
|
@ -240,7 +244,6 @@ StopTracing.name=Stop Tracing
|
||||||
SaveTraceData.description=Save Trace Data to File
|
SaveTraceData.description=Save Trace Data to File
|
||||||
SaveTraceData.name=Save Trace Data
|
SaveTraceData.name=Save Trace Data
|
||||||
|
|
||||||
viewMemory.label = View Memory
|
|
||||||
disassemblyViewMenu.label = disassemblyViewMenu
|
disassemblyViewMenu.label = disassemblyViewMenu
|
||||||
sourceNotFoundEditor.name = C/C++ Source Not Found Editor
|
sourceNotFoundEditor.name = C/C++ Source Not Found Editor
|
||||||
displayMode.name = displayMode
|
displayMode.name = displayMode
|
||||||
|
|
|
@ -325,6 +325,13 @@
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
</menuContribution>
|
</menuContribution>
|
||||||
|
<menuContribution
|
||||||
|
locationURI="popup:org.eclipse.debug.ui.VariableView?after=variableGroup">
|
||||||
|
<command
|
||||||
|
commandId="org.eclipse.cdt.debug.ui.commands.viewMemory"
|
||||||
|
label="%command.viewMemory.name">
|
||||||
|
</command>
|
||||||
|
</menuContribution>
|
||||||
<menuContribution
|
<menuContribution
|
||||||
locationURI="popup:org.eclipse.debug.ui.RegisterView?after=variableGroup">
|
locationURI="popup:org.eclipse.debug.ui.RegisterView?after=variableGroup">
|
||||||
<menu
|
<menu
|
||||||
|
@ -550,20 +557,6 @@
|
||||||
</action>
|
</action>
|
||||||
</viewerContribution>
|
</viewerContribution>
|
||||||
|
|
||||||
<objectContribution
|
|
||||||
objectClass="org.eclipse.cdt.debug.core.model.ICVariable"
|
|
||||||
id="org.eclipse.cdt.debug.ui.CVariableActions">
|
|
||||||
<action
|
|
||||||
label="%viewMemory.label"
|
|
||||||
helpContextId="view_memory_context"
|
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.ViewMemoryActionDelegate"
|
|
||||||
menubarPath="variableGroup"
|
|
||||||
enablesFor="+"
|
|
||||||
id="org.eclipse.cdt.debug.ui.actions.ViewMemoryAction">
|
|
||||||
</action>
|
|
||||||
</objectContribution>
|
|
||||||
|
|
||||||
|
|
||||||
<objectContribution
|
<objectContribution
|
||||||
objectClass="org.eclipse.cdt.debug.core.model.ICSignal"
|
objectClass="org.eclipse.cdt.debug.core.model.ICSignal"
|
||||||
id="org.eclipse.cdt.debug.ui.SignalActions">
|
id="org.eclipse.cdt.debug.ui.SignalActions">
|
||||||
|
@ -1886,6 +1879,12 @@
|
||||||
id="org.eclipse.cdt.debug.ui.command.resumeWithoutSignal"
|
id="org.eclipse.cdt.debug.ui.command.resumeWithoutSignal"
|
||||||
name="%ResumeWithoutSignal.name">
|
name="%ResumeWithoutSignal.name">
|
||||||
</command>
|
</command>
|
||||||
|
<command
|
||||||
|
id="org.eclipse.cdt.debug.ui.commands.viewMemory"
|
||||||
|
description="%command.viewMemory.description"
|
||||||
|
helpContextId="view_memory_context"
|
||||||
|
name="%command.viewMemory.name">
|
||||||
|
</command>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.handlers">
|
point="org.eclipse.ui.handlers">
|
||||||
|
@ -1926,6 +1925,20 @@
|
||||||
commandId="org.eclipse.cdt.debug.ui.command.resumeWithoutSignal"
|
commandId="org.eclipse.cdt.debug.ui.command.resumeWithoutSignal"
|
||||||
helpContextId="resume_without_signal_action_context">
|
helpContextId="resume_without_signal_action_context">
|
||||||
</handler>
|
</handler>
|
||||||
|
<handler
|
||||||
|
class="org.eclipse.cdt.debug.internal.ui.commands.ViewMemoryHandler"
|
||||||
|
commandId="org.eclipse.cdt.debug.ui.commands.viewMemory">
|
||||||
|
<activeWhen>
|
||||||
|
<with variable="selection">
|
||||||
|
<iterate operator="and">
|
||||||
|
<instanceof value="org.eclipse.cdt.debug.core.model.ICVariable">
|
||||||
|
</instanceof>
|
||||||
|
</iterate>
|
||||||
|
<count value="+">
|
||||||
|
</count>
|
||||||
|
</with>
|
||||||
|
</activeWhen>
|
||||||
|
</handler>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.core.expressions.definitions">
|
point="org.eclipse.core.expressions.definitions">
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2008 Nokia 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:
|
|
||||||
* Ken Ryall (Nokia) - initial API and implementation (207231)
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICVariable;
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.memory.AddMemoryBlocks;
|
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
|
||||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
|
||||||
import org.eclipse.debug.ui.memory.IMemoryRenderingSite;
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.ui.IObjectActionDelegate;
|
|
||||||
import org.eclipse.ui.IViewPart;
|
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
|
||||||
import org.eclipse.ui.PartInitException;
|
|
||||||
|
|
||||||
public class ViewMemoryActionDelegate implements IObjectActionDelegate {
|
|
||||||
|
|
||||||
private ICVariable[] variables;
|
|
||||||
|
|
||||||
public ViewMemoryActionDelegate() {}
|
|
||||||
|
|
||||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(IAction action) {
|
|
||||||
|
|
||||||
IWorkbenchPage page = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
|
||||||
IViewPart newView;
|
|
||||||
try {
|
|
||||||
newView = page.showView(IDebugUIConstants.ID_MEMORY_VIEW, null, IWorkbenchPage.VIEW_ACTIVATE);
|
|
||||||
IMemoryRenderingSite memSite = (IMemoryRenderingSite) newView;
|
|
||||||
new AddMemoryBlocks().addMemoryBlocksForVariables(variables, memSite);
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
CDebugUIUtils.openError(ActionMessages.getString("ViewMemoryActionDelegate.ErrorTitle"), ActionMessages.getString("ViewMemoryActionDelegate.CantOpenMemoryView"), e); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
} catch (PartInitException e) {
|
|
||||||
CDebugUIUtils.openError(ActionMessages.getString("ViewMemoryActionDelegate.ErrorTitle"), ActionMessages.getString("ViewMemoryActionDelegate.CantOpenMemoryView"), e); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
} catch (DebugException e) {
|
|
||||||
CDebugUIUtils.openError(ActionMessages.getString("ViewMemoryActionDelegate.ErrorTitle"), ActionMessages.getString("ViewMemoryActionDelegate.CantViewMemory"), e); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
|
||||||
if ( selection instanceof IStructuredSelection ) {
|
|
||||||
List<Object> list = new ArrayList<Object>();
|
|
||||||
IStructuredSelection ssel = (IStructuredSelection)selection;
|
|
||||||
Iterator<Object> i = ssel.iterator();
|
|
||||||
while( i.hasNext() ) {
|
|
||||||
Object o = i.next();
|
|
||||||
if ( o instanceof ICVariable ) {
|
|
||||||
action.setEnabled( true );
|
|
||||||
list.add( o );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setVariables( list.toArray( new ICVariable[list.size()] ) );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
action.setChecked( false );
|
|
||||||
action.setEnabled( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ICVariable[] getVariables() {
|
|
||||||
return variables;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setVariables( ICVariable[] variables ) {
|
|
||||||
this.variables = variables;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010 Nokia 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:
|
||||||
|
* Nokia - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.debug.internal.ui.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICVariable;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.views.memory.AddMemoryBlocks;
|
||||||
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
|
import org.eclipse.debug.ui.memory.IMemoryRenderingSite;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.IViewPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.PartInitException;
|
||||||
|
import org.eclipse.ui.handlers.HandlerUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for viewing variable in memory view command, based on
|
||||||
|
* org.eclipse.cdt.debug.internal.ui.actions.ViewMemoryActionDelegate
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ViewMemoryHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
||||||
|
*/
|
||||||
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
|
ISelection selection = HandlerUtil.getCurrentSelection(event);
|
||||||
|
if (selection instanceof IStructuredSelection) {
|
||||||
|
List<Object> list = new ArrayList<Object>();
|
||||||
|
Iterator<?> iter = ((IStructuredSelection)selection).iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Object obj = iter.next();
|
||||||
|
if (obj instanceof ICVariable) {
|
||||||
|
list.add(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ICVariable[] variables = list.toArray(new ICVariable[list.size()]);
|
||||||
|
showInMemoryView(variables);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showInMemoryView(ICVariable[] variables) {
|
||||||
|
try {
|
||||||
|
IWorkbenchPage page = CDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
IViewPart newView = page.showView(IDebugUIConstants.ID_MEMORY_VIEW, null, IWorkbenchPage.VIEW_ACTIVATE);
|
||||||
|
IMemoryRenderingSite memSite = (IMemoryRenderingSite) newView;
|
||||||
|
new AddMemoryBlocks().addMemoryBlocksForVariables(variables, memSite);
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
CDebugUIPlugin.log(e);
|
||||||
|
} catch (PartInitException e) {
|
||||||
|
CDebugUIPlugin.log(e);
|
||||||
|
} catch (DebugException e) {
|
||||||
|
CDebugUIPlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,18 +44,6 @@ public class GdbVariableVMNode extends VariableVMNode {
|
||||||
super(dmc);
|
super(dmc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getExpression()
|
|
||||||
*/
|
|
||||||
public String getExpression() {
|
|
||||||
final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class);
|
|
||||||
if (exprDmc != null) {
|
|
||||||
return exprDmc.getExpression();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ""; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getSize()
|
* @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getSize()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -288,6 +288,20 @@
|
||||||
<reference definitionId="org.eclipse.cdt.dsf.debug.ui.testAreUpdatePoliciesSupported"/>
|
<reference definitionId="org.eclipse.cdt.dsf.debug.ui.testAreUpdatePoliciesSupported"/>
|
||||||
</activeWhen>
|
</activeWhen>
|
||||||
</handler>
|
</handler>
|
||||||
|
<handler
|
||||||
|
class="org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions.DsfViewMemoryHandler"
|
||||||
|
commandId="org.eclipse.cdt.debug.ui.commands.viewMemory">
|
||||||
|
<activeWhen>
|
||||||
|
<with variable="selection">
|
||||||
|
<iterate operator="and">
|
||||||
|
<instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMNode$VariableExpressionVMC">
|
||||||
|
</instanceof>
|
||||||
|
</iterate>
|
||||||
|
<count value="+">
|
||||||
|
</count>
|
||||||
|
</with>
|
||||||
|
</activeWhen>
|
||||||
|
</handler>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<extension point="org.eclipse.core.expressions.definitions">
|
<extension point="org.eclipse.core.expressions.definitions">
|
||||||
|
|
|
@ -0,0 +1,221 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010 Nokia 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:
|
||||||
|
* Nokia - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||||
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.model.DsfMemoryBlockRetrieval;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData.BasicType;
|
||||||
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMNode.VariableExpressionVMC;
|
||||||
|
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||||
|
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
|
import org.eclipse.core.commands.AbstractHandler;
|
||||||
|
import org.eclipse.core.commands.ExecutionEvent;
|
||||||
|
import org.eclipse.core.commands.ExecutionException;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.model.IDebugElement;
|
||||||
|
import org.eclipse.debug.core.model.IMemoryBlock;
|
||||||
|
import org.eclipse.debug.core.model.IMemoryBlockExtension;
|
||||||
|
import org.eclipse.debug.core.model.IMemoryBlockRetrieval;
|
||||||
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
|
import org.eclipse.debug.ui.memory.IMemoryRendering;
|
||||||
|
import org.eclipse.debug.ui.memory.IMemoryRenderingContainer;
|
||||||
|
import org.eclipse.debug.ui.memory.IMemoryRenderingSite;
|
||||||
|
import org.eclipse.debug.ui.memory.IMemoryRenderingType;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.IViewPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.PartInitException;
|
||||||
|
import org.eclipse.ui.handlers.HandlerUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DSF version of handler for viewing variable in memory view command.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DsfViewMemoryHandler extends AbstractHandler {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
||||||
|
*/
|
||||||
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||||
|
ISelection selection = HandlerUtil.getCurrentSelection(event);
|
||||||
|
if (selection instanceof IStructuredSelection) {
|
||||||
|
List<Object> list = new ArrayList<Object>();
|
||||||
|
Iterator<?> iter = ((IStructuredSelection)selection).iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Object obj = iter.next();
|
||||||
|
if (obj instanceof VariableExpressionVMC) {
|
||||||
|
list.add(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showInMemoryView(list.toArray(new VariableExpressionVMC[list.size()]));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDefaultRenderings(IMemoryBlock memoryBlock, IMemoryRenderingSite memRendSite) {
|
||||||
|
|
||||||
|
// This method was mostly lifted from the platform's AddMemoryBlockAction
|
||||||
|
|
||||||
|
IMemoryRenderingType primaryType = DebugUITools.getMemoryRenderingManager().getPrimaryRenderingType(
|
||||||
|
memoryBlock);
|
||||||
|
IMemoryRenderingType renderingTypes[] = DebugUITools.getMemoryRenderingManager().getDefaultRenderingTypes(
|
||||||
|
memoryBlock);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (primaryType != null) {
|
||||||
|
createRenderingInContainer(memoryBlock, memRendSite,
|
||||||
|
primaryType, IDebugUIConstants.ID_RENDERING_VIEW_PANE_1);
|
||||||
|
} else if (renderingTypes.length > 0) {
|
||||||
|
primaryType = renderingTypes[0];
|
||||||
|
createRenderingInContainer(memoryBlock, memRendSite,
|
||||||
|
renderingTypes[0],
|
||||||
|
IDebugUIConstants.ID_RENDERING_VIEW_PANE_1);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
DsfUIPlugin.logErrorMessage(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < renderingTypes.length; i++) {
|
||||||
|
try {
|
||||||
|
boolean create = true;
|
||||||
|
if (primaryType != null) {
|
||||||
|
if (primaryType.getId().equals(renderingTypes[i].getId()))
|
||||||
|
create = false;
|
||||||
|
}
|
||||||
|
if (create)
|
||||||
|
createRenderingInContainer(memoryBlock, memRendSite,
|
||||||
|
renderingTypes[i],
|
||||||
|
IDebugUIConstants.ID_RENDERING_VIEW_PANE_2);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
DsfUIPlugin.logErrorMessage(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createRenderingInContainer(IMemoryBlock memoryBlock,
|
||||||
|
IMemoryRenderingSite memRendSite, IMemoryRenderingType primaryType,
|
||||||
|
String paneId) throws CoreException {
|
||||||
|
|
||||||
|
// This method was mostly lifted from the platform's AddMemoryBlockAction
|
||||||
|
|
||||||
|
IMemoryRendering rendering = primaryType.createRendering();
|
||||||
|
IMemoryRenderingContainer container = memRendSite.getContainer(paneId);
|
||||||
|
rendering.init(container, memoryBlock);
|
||||||
|
container.addMemoryRendering(rendering);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderMemoryBlock(IMemoryBlockExtension memBlock, IMemoryRenderingSite memRendSite) {
|
||||||
|
IMemoryBlock[] memArray = new IMemoryBlock[] { memBlock };
|
||||||
|
DebugPlugin.getDefault().getMemoryBlockManager().addMemoryBlocks(memArray);
|
||||||
|
addDefaultRenderings(memBlock, memRendSite);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showExpressionInMemoryView(VariableExpressionVMC context, IExpressionDMData exprData,
|
||||||
|
IMemoryRenderingSite memRendSite) {
|
||||||
|
try {
|
||||||
|
BasicType type = exprData.getBasicType();
|
||||||
|
String exprString;
|
||||||
|
if (type == BasicType.array || type == BasicType.pointer) {
|
||||||
|
exprString = context.getExpression();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
exprString = "&(" + context.getExpression() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
IDMContext dmc = context.getDMContext();
|
||||||
|
IMemoryBlockRetrieval retrieval = (IMemoryBlockRetrieval) context.getAdapter(IMemoryBlockRetrieval.class);
|
||||||
|
if (retrieval == null && context instanceof IDebugElement)
|
||||||
|
retrieval = ((IDebugElement)context).getDebugTarget();
|
||||||
|
if (retrieval == null || !(retrieval instanceof DsfMemoryBlockRetrieval))
|
||||||
|
return;
|
||||||
|
DsfMemoryBlockRetrieval dsfRetrieval = (DsfMemoryBlockRetrieval) retrieval;
|
||||||
|
IMemoryBlockExtension memBlock = dsfRetrieval.getExtendedMemoryBlock(exprString, dmc);
|
||||||
|
renderMemoryBlock(memBlock, memRendSite);
|
||||||
|
} catch (DebugException e) {
|
||||||
|
DsfUIPlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showInMemoryView(VariableExpressionVMC contexts[]) {
|
||||||
|
try {
|
||||||
|
IWorkbenchPage page = DsfUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||||
|
IViewPart memoryView = page.showView(IDebugUIConstants.ID_MEMORY_VIEW, null, IWorkbenchPage.VIEW_ACTIVATE);
|
||||||
|
final IMemoryRenderingSite memRendSite = (IMemoryRenderingSite) memoryView;
|
||||||
|
for (final VariableExpressionVMC context : contexts) {
|
||||||
|
final IExpressionDMContext dmc = DMContexts.getAncestorOfType(context.getDMContext(), IExpressionDMContext.class);
|
||||||
|
if (dmc == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final DsfSession session = DsfSession.getSession(context.getDMContext().getSessionId());
|
||||||
|
if (session == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final DsfExecutor executor = session.getExecutor();
|
||||||
|
if (executor == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
executor.execute(new DsfRunnable() {
|
||||||
|
public void run() {
|
||||||
|
DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId());
|
||||||
|
IExpressions service = tracker.getService(IExpressions.class);
|
||||||
|
tracker.dispose();
|
||||||
|
if (service != null) {
|
||||||
|
service.getExpressionData(dmc, new DataRequestMonitor<IExpressionDMData>(executor, null) {
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
final IExpressionDMData exprData = getData();
|
||||||
|
if (exprData != null) {
|
||||||
|
Job job = new Job("View Memory") { //$NON-NLS-1$
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
showExpressionInMemoryView(context, exprData, memRendSite);
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
job.setSystem(true);
|
||||||
|
job.schedule();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (PartInitException e) {
|
||||||
|
DsfUIPlugin.log(e);
|
||||||
|
} catch (RejectedExecutionException e) {
|
||||||
|
DsfUIPlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,16 +32,16 @@ import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.DsfCastToTypeSupport;
|
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.DsfCastToTypeSupport;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IStack;
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation;
|
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
|
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IStack;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMData;
|
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMData;
|
||||||
|
@ -149,6 +149,17 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
||||||
super(dmc);
|
super(dmc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getExpression()
|
||||||
|
*/
|
||||||
|
public String getExpression() {
|
||||||
|
final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class);
|
||||||
|
if (exprDmc != null) {
|
||||||
|
return exprDmc.getExpression();
|
||||||
|
}
|
||||||
|
return ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
public void setExpression(IExpression expression) {
|
public void setExpression(IExpression expression) {
|
||||||
fExpression = expression;
|
fExpression = expression;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue