Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorAlena Laskavaia2009-03-12 16:33:01 -0400
committerAlena Laskavaia2009-03-12 16:33:01 -0400
commitf38d981cc8d752e433e221a84709c574d0f94e01 (patch)
tree483ecc6c6a598d6eb688a499d296149982d0e705 /debug
parent666c642f447fe28a02a55cf0b23e7c6fc79af3cd (diff)
downloadorg.eclipse.cdt-f38d981cc8d752e433e221a84709c574d0f94e01.tar.gz
org.eclipse.cdt-f38d981cc8d752e433e221a84709c574d0f94e01.tar.xz
org.eclipse.cdt-f38d981cc8d752e433e221a84709c574d0f94e01.zip
[111711] - added go to address action to cdi dissasembly view
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java11
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.properties3
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml17
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/GoToAddressActionDelegate.java124
4 files changed, 155 insertions, 0 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java
index 95c9b60ae1..46c83be5ce 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassembly.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
+import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.debug.core.DebugException;
@@ -28,6 +29,16 @@ public interface IDisassembly extends ICDebugElement {
IDisassemblyBlock getDisassemblyBlock( ICStackFrame frame ) throws DebugException;
/**
+ * Returns the disassembly block for given stack frame.
+ *
+ * @param address the address from which the disassembly starts
+ * @return the disassembly block for given memory address
+ * @throws DebugException if this method fails.
+ * @since 6.0
+ */
+ IDisassemblyBlock getDisassemblyBlock( IAddress address ) throws DebugException;
+
+ /**
* Returns the address factory associated with this element.
*
* @return the address factory
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index b8c407ca6b..9bf8f79d7d 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -29,6 +29,9 @@ DebugActionSet.label=C/C++ Debug
RestartAction.label=Restart
RestartAction.tooltip=Restart
+DisassemblyViewAction.label=Go to address...
+DisassemblyViewAction.tooltip=Enter memory address for the assembly code
+
ToggleInstructionStepModeAction.label=Instruction Stepping Mode
ToggleInstructionStepModeAction.tooltip=Instruction Stepping Mode
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index f7e3a7eb23..9b1ed8c3bb 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -1089,6 +1089,23 @@
</action>
</viewContribution>
<viewContribution
+ id="org.eclipse.cdt.debug.ui.disassemblyView.menu"
+ targetID="org.eclipse.cdt.debug.ui.DisassemblyView">
+ <menu
+ id="org.eclipse.cdt.debug.ui.disassemblyViewMenu"
+ label="disassemblyViewMenu">
+ </menu>
+ <action
+ class="org.eclipse.cdt.debug.internal.ui.views.disassembly.GoToAddressActionDelegate"
+ icon="icons/elcl16/show_ascii.gif"
+ id="org.eclipse.cdt.debug.internal.ui.actions.disassemblyViewAction"
+ label="%DisassemblyViewAction.label"
+ menubarPath="org.eclipse.cdt.debug.ui.disassemblyViewMenu"
+ style="push"
+ tooltip="%DisassemblyViewAction.tooltip">
+ </action>
+ </viewContribution>
+ <viewContribution
targetID="org.eclipse.debug.ui.VariableView"
id="org.eclipse.debug.ui.variablesView.toolbar">
<action
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/GoToAddressActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/GoToAddressActionDelegate.java
new file mode 100644
index 0000000000..daed395e82
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/GoToAddressActionDelegate.java
@@ -0,0 +1,124 @@
+package org.eclipse.cdt.debug.internal.ui.views.disassembly;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.debug.core.model.ICDebugTarget;
+import org.eclipse.cdt.debug.core.model.ICStackFrame;
+import org.eclipse.cdt.debug.core.model.IDisassembly;
+import org.eclipse.cdt.debug.core.model.IDisassemblyBlock;
+import org.eclipse.cdt.debug.internal.core.model.Disassembly;
+import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyEditorInput;
+import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
+import org.eclipse.cdt.utils.Addr32;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+
+public class GoToAddressActionDelegate implements IActionDelegate, IViewActionDelegate {
+ private IViewPart fView;
+ private IAction fAction;
+ private DisassemblyView fDisassemblyView;
+
+ public void init(IViewPart view) {
+ setView(view);
+ if (view instanceof DisassemblyView) {
+ fDisassemblyView = (DisassemblyView) view;
+ }
+ }
+
+ private void setView(IViewPart view) {
+ fView = view;
+ }
+
+ protected IViewPart getView() {
+ return fView;
+ }
+
+ public void run(IAction action) {
+ String address;
+ InputDialog dialog = new InputDialog(fView.getViewSite().getShell(), "Enter address", "Enter address to go to", "",
+ new IInputValidator() {
+ public String isValid(String in) {
+ try {
+ String input = in.trim();
+ if (input.length() == 0)
+ return "Cannot be empty address";
+ if (input.toLowerCase().startsWith("0x")) {
+ Long.parseLong(input.substring(2), 16);
+ } else {
+ Long.parseLong(input);
+ }
+ return null;
+ } catch (NumberFormatException ex) {
+ return "Must be a hexadecimal or decimal address";
+ }
+ }
+ });
+ if (dialog.open() == Window.OK) {
+ address = dialog.getValue();
+ gotoAddress(address);
+ }
+ }
+
+ protected void setAction(IAction action) {
+ fAction = action;
+ }
+
+ protected IAction getAction() {
+ return fAction;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ setAction(action);
+ }
+
+ private void gotoAddress(String addr) {
+ IAddress address = new Addr32(addr);
+ if (fDisassemblyView != null) {
+ ICDebugTarget target = null;
+ ISelection selection = fDisassemblyView.getSite().getPage().getSelection(IDebugUIConstants.ID_DEBUG_VIEW);
+ if (selection instanceof IStructuredSelection) {
+ Object element = ((IStructuredSelection) selection).getFirstElement();
+ if (element instanceof ICStackFrame) {
+ IDebugTarget tar = ((ICStackFrame) element).getDebugTarget();
+ if (tar instanceof ICDebugTarget) {
+ target = (ICDebugTarget) tar;
+ }
+ }
+ }
+ DisassemblyEditorInput input = null;
+ try {
+ input = create(target, address);
+ fDisassemblyView.setViewerInput(input);
+ } catch (DebugException e) {
+ MessageDialog dialog = new MessageDialog(fView.getViewSite().getShell(), "Wrong address", null,
+ "Cannot access memory at address " + addr, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL },
+ 0);
+ dialog.open();
+ }
+ }
+ }
+
+ public static DisassemblyEditorInput create(ICDebugTarget target, IAddress address) throws DebugException {
+ DisassemblyEditorInput input = null;
+ IDisassembly disassembly = target.getDisassembly();
+ if (disassembly instanceof Disassembly) {
+ IDisassemblyBlock block = ((Disassembly) disassembly).getDisassemblyBlock(address);
+ input = DisassemblyEditorInput.create(block);
+ }
+ return input;
+ }
+
+
+}
+

Back to the top