mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Implementation of disassembly mode.
This commit is contained in:
parent
20520c0827
commit
aa7651d574
4 changed files with 154 additions and 5 deletions
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
|
|||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
|
||||
/**
|
||||
|
@ -36,6 +37,8 @@ public class DisassemblyStorage implements IDisassemblyStorage
|
|||
{
|
||||
setDebugTarget( target );
|
||||
setInstructions( instructions );
|
||||
initializeAddresses();
|
||||
createContent();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -85,7 +88,18 @@ public class DisassemblyStorage implements IDisassemblyStorage
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return null;
|
||||
try
|
||||
{
|
||||
if ( getDebugTarget() != null )
|
||||
{
|
||||
return getDebugTarget().getName();
|
||||
}
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
return "disassembly";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -119,4 +133,18 @@ public class DisassemblyStorage implements IDisassemblyStorage
|
|||
{
|
||||
fInstructions = intructions;
|
||||
}
|
||||
|
||||
private void createContent()
|
||||
{
|
||||
StringBuffer lines = new StringBuffer();
|
||||
for ( int i = 0; i < fInstructions.length; ++i )
|
||||
{
|
||||
lines.append( fInstructions[i].toString() );
|
||||
}
|
||||
fInputStream = new ByteArrayInputStream( lines.toString().getBytes() );
|
||||
}
|
||||
|
||||
private void initializeAddresses()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.ICFunctionBreakpoint;
|
|||
import org.eclipse.cdt.debug.core.ICLineBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.ICValue;
|
||||
import org.eclipse.cdt.debug.core.ICWatchpoint;
|
||||
import org.eclipse.cdt.debug.core.IDisassemblyStorage;
|
||||
import org.eclipse.cdt.debug.core.IStackFrameInfo;
|
||||
import org.eclipse.cdt.debug.core.IState;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
|
||||
|
@ -23,10 +24,12 @@ import org.eclipse.cdt.debug.core.cdi.ICDIExitInfo;
|
|||
import org.eclipse.cdt.debug.core.cdi.ICDISignal;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointScope;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIWatchpointTrigger;
|
||||
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
@ -136,11 +139,11 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
{
|
||||
return new FileStorageEditorInput( (IFileStorage)element );
|
||||
}
|
||||
*/
|
||||
if ( element instanceof IDisassemblyStorage )
|
||||
{
|
||||
return new DisassemblyEditorInput( (IStorage)element );
|
||||
}
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.ui.IStorageEditorInput;
|
|||
*/
|
||||
public class DisassemblyEditorInput implements IStorageEditorInput
|
||||
{
|
||||
private final static String FILE_NAME_EXTENSION = ".s";
|
||||
protected IStorage fStorage;
|
||||
|
||||
/**
|
||||
|
@ -59,7 +60,18 @@ public class DisassemblyEditorInput implements IStorageEditorInput
|
|||
*/
|
||||
public String getName()
|
||||
{
|
||||
return "disassembly.s";
|
||||
try
|
||||
{
|
||||
if ( getStorage() != null )
|
||||
{
|
||||
return getStorage().getName() + FILE_NAME_EXTENSION;
|
||||
}
|
||||
}
|
||||
catch( CoreException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -75,7 +87,7 @@ public class DisassemblyEditorInput implements IStorageEditorInput
|
|||
*/
|
||||
public String getToolTipText()
|
||||
{
|
||||
return null;
|
||||
return "Disassembly";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -85,4 +97,26 @@ public class DisassemblyEditorInput implements IStorageEditorInput
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(Object)
|
||||
*/
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( obj != null && obj instanceof DisassemblyEditorInput )
|
||||
{
|
||||
try
|
||||
{
|
||||
IStorage storage = ((DisassemblyEditorInput)obj).getStorage();
|
||||
if ( storage != null && storage.equals( fStorage ) )
|
||||
return true;
|
||||
else if ( storage == null && fStorage == null )
|
||||
return true;
|
||||
}
|
||||
catch( CoreException e )
|
||||
{
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Map;
|
|||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.cdt.debug.core.IDisassemblyStorage;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
|
||||
import org.eclipse.cdt.debug.core.ISwitchToFrame;
|
||||
|
@ -12,9 +13,11 @@ import org.eclipse.cdt.debug.core.ISwitchToThread;
|
|||
import org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
|
||||
import org.eclipse.cdt.debug.internal.ui.ColorManager;
|
||||
import org.eclipse.cdt.debug.internal.ui.editors.DisassemblyEditorInput;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.MemoryViewPreferencePage;
|
||||
import org.eclipse.cdt.debug.internal.ui.preferences.RegistersViewPreferencePage;
|
||||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -23,7 +26,11 @@ import org.eclipse.core.runtime.IExtensionPoint;
|
|||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.IDebugEventSetListener;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
import org.eclipse.debug.core.model.IStackFrame;
|
||||
import org.eclipse.debug.core.model.IThread;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
|
@ -36,6 +43,9 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
|||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
@ -45,7 +55,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin;
|
|||
/**
|
||||
* The main plugin class to be used in the desktop.
|
||||
*/
|
||||
public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListener
|
||||
public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListener, IDebugEventSetListener
|
||||
{
|
||||
//The shared instance.
|
||||
private static CDebugUIPlugin plugin;
|
||||
|
@ -312,6 +322,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
|
|||
*/
|
||||
public void shutdown() throws CoreException
|
||||
{
|
||||
DebugPlugin.getDefault().removeDebugEventListener( this );
|
||||
IWorkbenchWindow ww = getActiveWorkbenchWindow();
|
||||
if ( ww != null )
|
||||
{
|
||||
|
@ -335,6 +346,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
|
|||
{
|
||||
ww.getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
}
|
||||
DebugPlugin.getDefault().addDebugEventListener( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -378,4 +390,76 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(DebugEvent[])
|
||||
*/
|
||||
public void handleDebugEvents( DebugEvent[] events )
|
||||
{
|
||||
for ( int i = 0; i < events.length; i++ )
|
||||
{
|
||||
DebugEvent event = events[i];
|
||||
if ( event.getKind() == DebugEvent.TERMINATE )
|
||||
{
|
||||
Object element = event.getSource();
|
||||
if ( element != null && element instanceof IDebugTarget )
|
||||
{
|
||||
closeDisassemblyEditors( (IDebugTarget)element );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void closeDisassemblyEditors( final IDebugTarget target )
|
||||
{
|
||||
IWorkbenchWindow[] windows = getWorkbench().getWorkbenchWindows();
|
||||
for ( int i = 0; i < windows.length; ++i )
|
||||
{
|
||||
IWorkbenchPage[] pages = windows[i].getPages();
|
||||
for ( int j = 0; j < pages.length; ++j )
|
||||
{
|
||||
IEditorReference[] refs = pages[j].getEditorReferences();
|
||||
for ( int k = 0; k < refs.length; ++k )
|
||||
{
|
||||
IEditorPart editor = refs[k].getEditor( false );
|
||||
if ( editor != null )
|
||||
{
|
||||
IEditorInput input = editor.getEditorInput();
|
||||
if ( input != null && input instanceof DisassemblyEditorInput )
|
||||
{
|
||||
try
|
||||
{
|
||||
IStorage storage = ((DisassemblyEditorInput)input).getStorage();
|
||||
if ( storage != null && storage instanceof IDisassemblyStorage &&
|
||||
target.equals( ((IDisassemblyStorage)storage).getDebugTarget() ) )
|
||||
{
|
||||
Shell shell = windows[i].getShell();
|
||||
if ( shell != null )
|
||||
{
|
||||
Display display = shell.getDisplay();
|
||||
if ( display != null )
|
||||
{
|
||||
final IWorkbenchPage page = pages[j];
|
||||
final IEditorPart editor0 = editor;
|
||||
display.asyncExec( new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
page.closeEditor( editor0, false );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( CoreException e )
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue