Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2011-06-20 14:08:35 -0400
committereutarass2011-06-20 14:08:35 -0400
commitc2101475b4ae4e435d4ada7c25839f1a8c9df229 (patch)
treed03317dbb6f294fd74354a6058a1550ef55a84ad /plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse
parent16ab867ae015b7dfbf0ac6a9c9db87e46fc1ef9b (diff)
downloadorg.eclipse.tcf-c2101475b4ae4e435d4ada7c25839f1a8c9df229.tar.gz
org.eclipse.tcf-c2101475b4ae4e435d4ada7c25839f1a8c9df229.tar.xz
org.eclipse.tcf-c2101475b4ae4e435d4ada7c25839f1a8c9df229.zip
TCF Debugger: implemented "View Memory" command in Variables and Expressions views.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/AbstractActionDelegate.java31
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SignalsCommand.java2
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/ViewMemoryCommand.java87
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFMemoryBlockRetrieval.java18
4 files changed, 132 insertions, 6 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/AbstractActionDelegate.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/AbstractActionDelegate.java
index 0227b7775..d46939ca3 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/AbstractActionDelegate.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/AbstractActionDelegate.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.tm.internal.tcf.debug.ui.commands;
+import java.util.ArrayList;
+
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -127,6 +129,35 @@ implements IViewActionDelegate, IActionDelegate2, IWorkbenchWindowActionDelegate
return null;
}
+ public TCFNode[] getSelectedNodes() {
+ ArrayList<TCFNode> list = new ArrayList<TCFNode>();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection s = (IStructuredSelection)selection;
+ if (s.size() > 0) {
+ for (final Object o : s.toArray()) {
+ if (o instanceof TCFNode) {
+ list.add((TCFNode)o);
+ }
+ else if (o instanceof TCFLaunch) {
+ list.add(new TCFTask<TCFNode>() {
+ public void run() {
+ TCFLaunch launch = (TCFLaunch)o;
+ TCFModel model = Activator.getModelManager().getModel(launch);
+ if (model != null) {
+ done(model.getRootNode());
+ }
+ else {
+ done(null);
+ }
+ }
+ }.getE());
+ }
+ }
+ }
+ }
+ return list.toArray(new TCFNode[list.size()]);
+ }
+
protected abstract void selectionChanged();
protected abstract void run();
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SignalsCommand.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SignalsCommand.java
index 77106610b..05dc7a6c3 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SignalsCommand.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/SignalsCommand.java
@@ -16,6 +16,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFModel;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExpression;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeLaunch;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeModule;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeStackFrame;
@@ -26,6 +27,7 @@ public class SignalsCommand extends AbstractActionDelegate {
if (n instanceof TCFNodeLaunch) return true;
if (n instanceof TCFNodeExecContext) return true;
if (n instanceof TCFNodeStackFrame) return true;
+ if (n instanceof TCFNodeExpression) return true;
if (n instanceof TCFNodeModule) return true;
return false;
}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/ViewMemoryCommand.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/ViewMemoryCommand.java
new file mode 100644
index 000000000..f8fba229f
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/ViewMemoryCommand.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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.tm.internal.tcf.debug.ui.commands;
+
+import java.util.ArrayList;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IMemoryBlock;
+import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.tm.internal.tcf.debug.ui.Activator;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExpression;
+import org.eclipse.tm.tcf.services.IExpressions;
+import org.eclipse.tm.tcf.util.TCFDataCache;
+import org.eclipse.tm.tcf.util.TCFTask;
+import org.eclipse.ui.IWorkbenchPage;
+
+public class ViewMemoryCommand extends AbstractActionDelegate {
+
+ private static class Block {
+ long addr;
+ long size;
+ }
+
+ @Override
+ protected void run() {
+ try {
+ IWorkbenchPage page = getWindow().getActivePage();
+ page.showView(IDebugUIConstants.ID_MEMORY_VIEW, null, IWorkbenchPage.VIEW_ACTIVATE);
+ final ArrayList<IMemoryBlock> list = new ArrayList<IMemoryBlock>();
+ for (final TCFNode node : getSelectedNodes()) {
+ final IMemoryBlockRetrievalExtension mem_retrieval = (IMemoryBlockRetrievalExtension)
+ node.getAdapter(IMemoryBlockRetrievalExtension.class);
+ if (mem_retrieval == null) continue;
+ Block b = new TCFTask<Block>(node.getChannel()) {
+ public void run() {
+ try {
+ Number addr = null;
+ long size = -1;
+ if (node instanceof TCFNodeExpression) {
+ TCFDataCache<IExpressions.Value> val_cache = ((TCFNodeExpression)node).getValue();
+ if (!val_cache.validate(this)) return;
+ IExpressions.Value val_data = val_cache.getData();
+ if (val_data != null) {
+ addr = val_data.getAddress();
+ if (addr != null) {
+ byte[] bytes = val_data.getValue();
+ if (bytes != null) size = bytes.length;
+ }
+ }
+ }
+ Block b = null;
+ if (addr != null) {
+ b = new Block();
+ b.addr = addr.longValue();
+ b.size = size;
+ }
+ done(b);
+ }
+ catch (Exception x) {
+ error(x);
+ }
+ }
+ }.get();
+ if (b != null) list.add(mem_retrieval.getMemoryBlock(b.addr, b.size));
+ }
+ DebugPlugin.getDefault().getMemoryBlockManager().addMemoryBlocks(list.toArray(new IMemoryBlock[list.size()]));
+ }
+ catch (Exception x) {
+ Activator.log("Cannot open memory view", x);
+ }
+ }
+
+ @Override
+ protected void selectionChanged() {
+ getAction().setEnabled(getSelectedNodes().length > 0);
+ }
+}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFMemoryBlockRetrieval.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFMemoryBlockRetrieval.java
index 6a8a9fabd..ca9e67849 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFMemoryBlockRetrieval.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFMemoryBlockRetrieval.java
@@ -45,6 +45,7 @@ class TCFMemoryBlockRetrieval implements IMemoryBlockRetrievalExtension {
private class MemoryBlock extends PlatformObject implements IMemoryBlockExtension {
private final String expression;
+ private final long length;
private final Set<Object> connections = new HashSet<Object>();
private final TCFDataCache<IExpressions.Expression> remote_expression;
private final TCFDataCache<IExpressions.Value> expression_value;
@@ -52,8 +53,9 @@ class TCFMemoryBlockRetrieval implements IMemoryBlockRetrievalExtension {
private boolean disposed;
- MemoryBlock(final String expression) {
+ MemoryBlock(final String expression, long length) {
this.expression = expression;
+ this.length = length;
final TCFLaunch launch = exec_ctx.model.getLaunch();
final IChannel channel = launch.getChannel();
remote_expression = new TCFDataCache<IExpressions.Expression>(channel) {
@@ -323,7 +325,7 @@ class TCFMemoryBlockRetrieval implements IMemoryBlockRetrievalExtension {
}
public long getLength() {
- return -1; // Unbounded
+ return length;
}
public BigInteger getMemoryBlockStartAddress() throws DebugException {
@@ -335,7 +337,7 @@ class TCFMemoryBlockRetrieval implements IMemoryBlockRetrievalExtension {
}
public BigInteger getBigLength() throws DebugException {
- return BigInteger.valueOf(-1); // Unbounded
+ return BigInteger.valueOf(length);
}
public void setBaseAddress(BigInteger address) throws DebugException {
@@ -391,13 +393,17 @@ class TCFMemoryBlockRetrieval implements IMemoryBlockRetrievalExtension {
public IMemoryBlockExtension getExtendedMemoryBlock(final String expression, Object context) throws DebugException {
return new TCFDebugTask<IMemoryBlockExtension>() {
public void run() {
- done(new MemoryBlock(expression));
+ done(new MemoryBlock(expression, -1));
}
}.getD();
}
- public IMemoryBlock getMemoryBlock(long address, long length) throws DebugException {
- return getExtendedMemoryBlock("0x" + Long.toHexString(address), exec_ctx);
+ public IMemoryBlock getMemoryBlock(final long address, final long length) throws DebugException {
+ return new TCFDebugTask<IMemoryBlockExtension>() {
+ public void run() {
+ done(new MemoryBlock("0x" + Long.toHexString(address), length));
+ }
+ }.getD();
}
public boolean supportsStorageRetrieval() {

Back to the top