mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
[302554] [disassembly][api] Provisional disassembly API should use IAddress instead of BigInteger
This commit is contained in:
parent
ae828d8792
commit
1e9767d045
9 changed files with 225 additions and 232 deletions
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.IMoveToAddress;
|
||||
|
@ -21,7 +19,6 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.Disassembly
|
|||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.utils.Addr64;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -46,12 +43,8 @@ public class DisassemblyMoveToLineAdapter implements IMoveToLineTarget {
|
|||
selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
|
||||
}
|
||||
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
|
||||
BigInteger rawAddress = disassemblySelection.getStartAddress();
|
||||
if (rawAddress == null) {
|
||||
return;
|
||||
}
|
||||
final IAddress address = disassemblySelection.getStartAddress();
|
||||
|
||||
final IAddress address = new Addr64(rawAddress);
|
||||
if (address != null && target instanceof IAdaptable) {
|
||||
final IMoveToAddress moveToAddress = (IMoveToAddress)((IAdaptable)target).getAdapter(IMoveToAddress.class);
|
||||
if (moveToAddress != null && moveToAddress.canMoveToAddress(address)) {
|
||||
|
@ -77,12 +70,11 @@ public class DisassemblyMoveToLineAdapter implements IMoveToLineTarget {
|
|||
selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
|
||||
}
|
||||
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
|
||||
BigInteger rawAddress = disassemblySelection.getStartAddress();
|
||||
if (rawAddress == null) {
|
||||
final IAddress address = disassemblySelection.getStartAddress();
|
||||
if (address == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IAddress address = new Addr64(rawAddress);
|
||||
return moveToAddress.canMoveToAddress(address);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.IResumeAtAddress;
|
||||
|
@ -21,7 +19,6 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.Disassembly
|
|||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.utils.Addr64;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -46,12 +43,8 @@ public class DisassemblyResumeAtLineAdapter implements IResumeAtLineTarget {
|
|||
selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
|
||||
}
|
||||
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
|
||||
BigInteger rawAddress = disassemblySelection.getStartAddress();
|
||||
if (rawAddress == null) {
|
||||
return;
|
||||
}
|
||||
final IAddress address = disassemblySelection.getStartAddress();
|
||||
|
||||
final IAddress address = new Addr64(rawAddress);
|
||||
if (address != null && target instanceof IAdaptable) {
|
||||
final IResumeAtAddress resumeAtAddress = (IResumeAtAddress)((IAdaptable)target).getAdapter(IResumeAtAddress.class);
|
||||
if (resumeAtAddress != null && resumeAtAddress.canResumeAtAddress(address)) {
|
||||
|
@ -77,12 +70,11 @@ public class DisassemblyResumeAtLineAdapter implements IResumeAtLineTarget {
|
|||
selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
|
||||
}
|
||||
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
|
||||
BigInteger rawAddress = disassemblySelection.getStartAddress();
|
||||
if (rawAddress == null) {
|
||||
final IAddress address = disassemblySelection.getStartAddress();
|
||||
if (address == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IAddress address = new Addr64(rawAddress);
|
||||
return resumeAtAddress.canResumeAtAddress(address);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.IRunToAddress;
|
||||
|
@ -20,7 +18,6 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.Disassembly
|
|||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.cdt.utils.Addr64;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
@ -51,12 +48,8 @@ public class DisassemblyRunToLineAdapter implements IRunToLineTarget {
|
|||
selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
|
||||
}
|
||||
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
|
||||
BigInteger rawAddress = disassemblySelection.getStartAddress();
|
||||
if (rawAddress == null) {
|
||||
return;
|
||||
}
|
||||
final IAddress address = disassemblySelection.getStartAddress();
|
||||
|
||||
final IAddress address = new Addr64(rawAddress);
|
||||
if (address != null && target instanceof IAdaptable) {
|
||||
final IRunToAddress runToAddress = (IRunToAddress)((IAdaptable)target).getAdapter(IRunToAddress.class);
|
||||
if (runToAddress != null && runToAddress.canRunToAddress(address)) {
|
||||
|
@ -86,12 +79,11 @@ public class DisassemblyRunToLineAdapter implements IRunToLineTarget {
|
|||
selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
|
||||
}
|
||||
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
|
||||
BigInteger rawAddress = disassemblySelection.getStartAddress();
|
||||
if (rawAddress == null) {
|
||||
final IAddress address = disassemblySelection.getStartAddress();
|
||||
if (address == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IAddress address = new Addr64(rawAddress);
|
||||
return runToAddress.canRunToAddress(address);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2010 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
|
||||
|
@ -10,18 +10,17 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
|
||||
import org.eclipse.cdt.utils.Addr64;
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -125,7 +124,7 @@ public class DisassemblyToggleBreakpointsTarget implements IToggleBreakpointsTar
|
|||
return breakpoints.toArray(breakpointsArray );
|
||||
}
|
||||
private void insertBreakpoint(IDisassemblySelection selection) throws CoreException {
|
||||
BigInteger address = selection.getStartAddress();
|
||||
IAddress address = selection.getStartAddress();
|
||||
if (address == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -147,7 +146,7 @@ public class DisassemblyToggleBreakpointsTarget implements IToggleBreakpointsTar
|
|||
CDIDebugModel.createLineBreakpoint(filePath, resource, ICBreakpointType.REGULAR, srcLine + 1, true, 0, "", true); //$NON-NLS-1$
|
||||
} else {
|
||||
IResource resource = ResourcesPlugin.getWorkspace().getRoot();
|
||||
CDIDebugModel.createAddressBreakpoint(null, null, resource, ICBreakpointType.REGULAR, new Addr64(address), true, 0, "", true); //$NON-NLS-1$
|
||||
CDIDebugModel.createAddressBreakpoint(null, null, resource, ICBreakpointType.REGULAR, address, true, 0, "", true); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,18 +10,17 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
|
||||
import org.eclipse.cdt.utils.Addr64;
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -125,7 +124,7 @@ public class DisassemblyToggleTracepointsTarget implements IToggleBreakpointsTar
|
|||
return breakpoints.toArray(breakpointsArray );
|
||||
}
|
||||
private void insertBreakpoint(IDisassemblySelection selection) throws CoreException {
|
||||
BigInteger address = selection.getStartAddress();
|
||||
IAddress address = selection.getStartAddress();
|
||||
if (address == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -147,7 +146,7 @@ public class DisassemblyToggleTracepointsTarget implements IToggleBreakpointsTar
|
|||
CDIDebugModel.createLineTracepoint(filePath, resource, ICBreakpointType.REGULAR, srcLine + 1, true, 0, "", true); //$NON-NLS-1$
|
||||
} else {
|
||||
IResource resource = ResourcesPlugin.getWorkspace().getRoot();
|
||||
CDIDebugModel.createAddressTracepoint(null, null, resource, ICBreakpointType.REGULAR, -1, new Addr64(address), true, 0, "", true); //$NON-NLS-1$
|
||||
CDIDebugModel.createAddressTracepoint(null, null, resource, ICBreakpointType.REGULAR, -1, address, true, 0, "", true); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.ErrorPosition;
|
||||
|
@ -190,8 +191,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
private static final String COMMAND_ID_GOTO_ADDRESS = "org.eclipse.cdt.dsf.debug.ui.disassembly.commands.gotoAddress"; //$NON-NLS-1$
|
||||
private static final String COMMAND_ID_GOTO_PC = "org.eclipse.cdt.dsf.debug.ui.disassembly.commands.gotoPC"; //$NON-NLS-1$
|
||||
private static final String COMMAND_ID_TOGGLE_BREAKPOINT = "org.eclipse.cdt.dsf.debug.ui.disassembly.commands.rulerToggleBreakpoint"; //$NON-NLS-1$
|
||||
// private static final String COMMAND_ID_RUN_TO_LINE = "org.eclipse.debug.ui.commands.RunToLine"; //$NON-NLS-1$
|
||||
// private static final String COMMAND_ID_TOGGLE_STEPPING_MODE = "org.eclipse.cdt.dsf.debug.ui.debug.ui.menu.showDisassemblyAction"; //$NON-NLS-1$
|
||||
|
||||
public static final String KEY_BINDING_CONTEXT_DISASSEMBLY = "org.eclipse.cdt.dsf.debug.ui.disassembly.context"; //$NON-NLS-1$
|
||||
|
||||
|
@ -1341,6 +1340,15 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
/*
|
||||
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#gotoAddress(java.math.BigInteger)
|
||||
*/
|
||||
public final void gotoAddress(IAddress address) {
|
||||
if (address != null) {
|
||||
gotoAddress(address.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoAddress(java.math.BigInteger)
|
||||
*/
|
||||
public final void gotoAddress(BigInteger address) {
|
||||
fFocusAddress = address;
|
||||
if (fDebugSessionId == null) {
|
||||
|
|
|
@ -13,9 +13,12 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional;
|
|||
import java.math.BigInteger;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.SourcePosition;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
|
||||
import org.eclipse.cdt.utils.Addr64;
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -35,7 +38,7 @@ public class DisassemblySelection implements IDisassemblySelection {
|
|||
private final ITextSelection fTextSelection;
|
||||
private IStorage fSourceFile;
|
||||
private int fSourceLine;
|
||||
private BigInteger fStartAddress;
|
||||
private IAddress fStartAddress;
|
||||
|
||||
/**
|
||||
* Create a disassembly selection from a normal text selection and a disassembly part.
|
||||
|
@ -56,17 +59,26 @@ public class DisassemblySelection implements IDisassemblySelection {
|
|||
} catch (BadLocationException exc) {
|
||||
sourcePosition = null;
|
||||
}
|
||||
BigInteger docAddress = null;
|
||||
if (sourcePosition != null) {
|
||||
fStartAddress = sourcePosition.fAddressOffset;
|
||||
docAddress = sourcePosition.fAddressOffset;
|
||||
if (sourcePosition.length > 0) {
|
||||
fSourceFile = sourcePosition.fFileInfo.fFile;
|
||||
DisassemblyPosition pos = (DisassemblyPosition) document.getDisassemblyPosition(fStartAddress);
|
||||
if (pos != null) {
|
||||
fSourceLine = pos.getLine();
|
||||
AddressRangePosition pos = document.getDisassemblyPosition(docAddress);
|
||||
if (pos instanceof DisassemblyPosition) {
|
||||
fSourceLine = ((DisassemblyPosition) pos).getLine();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fStartAddress = document.getAddressOfOffset(offset);
|
||||
docAddress = document.getAddressOfOffset(offset);
|
||||
}
|
||||
if (docAddress != null) {
|
||||
try {
|
||||
fStartAddress = new Addr64(docAddress);
|
||||
} catch (RuntimeException rte) {
|
||||
// not a valid address
|
||||
fStartAddress = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +168,7 @@ public class DisassemblySelection implements IDisassemblySelection {
|
|||
/*
|
||||
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection#getStartAddress()
|
||||
*/
|
||||
public BigInteger getStartAddress() {
|
||||
public IAddress getStartAddress() {
|
||||
return fStartAddress;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2008, 2010 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
|
||||
|
@ -10,8 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
import org.eclipse.jface.text.source.ISourceViewer;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
@ -74,7 +73,7 @@ public interface IDisassemblyPart extends IWorkbenchPart {
|
|||
*
|
||||
* @param address
|
||||
*/
|
||||
void gotoAddress(BigInteger address);
|
||||
void gotoAddress(IAddress address);
|
||||
|
||||
/**
|
||||
* Navigate to current program counter.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2010 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
|
||||
|
@ -10,9 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
|
||||
|
@ -28,9 +28,9 @@ import org.eclipse.jface.text.ITextSelection;
|
|||
public interface IDisassemblySelection extends ITextSelection {
|
||||
|
||||
/**
|
||||
* @return the address associated with the start of the selection
|
||||
* @return the address associated with the start of the selection, may be <code>null</code>
|
||||
*/
|
||||
BigInteger getStartAddress();
|
||||
IAddress getStartAddress();
|
||||
|
||||
/**
|
||||
* @return the {@link IFile} associated with the selection, may be <code>null</code>
|
||||
|
|
Loading…
Add table
Reference in a new issue