1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Implementing retargettable actions.

This commit is contained in:
Mikhail Khodjaiants 2004-04-08 22:20:56 +00:00
parent e5bb96e955
commit 03d56777ac
9 changed files with 293 additions and 40 deletions

View file

@ -1,3 +1,9 @@
2004-04-08 Mikhail Khodjaiants
Implementing retargettable actions.
* IRunToAddress.java
* IRunToLine.java
* IDisassemblyStorage.java
2004-04-07 Mikhail Khodjaiants
Removed the support of debugger process.
* ICDebugTarget.java

View file

@ -1,31 +1,33 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
*/
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.DebugException;
/**
*
* Provides the ability to run a debug target to the given address.
*
* @since Jan 13, 2003
*/
public interface IRunToAddress
{
public interface IRunToAddress {
/**
* Returns whether this operation is currently available for this element.
*
*
* @return whether this operation is currently available
*/
public boolean canRunToAddress( long address );
/**
* Causes this element to run to specified address.
*
*
* @exception DebugException on failure. Reasons include:
*/
public void runToAddress( long address ) throws DebugException;
}
}

View file

@ -1,46 +1,48 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
*/
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.resources.IFile;
import org.eclipse.debug.core.DebugException;
/**
*
* Provides the ability to run a debug target to the given line.
*
* @since Sep 19, 2002
*/
public interface IRunToLine
{
public interface IRunToLine {
/**
* Returns whether this operation is currently available for this file and line number.
*
*
* @return whether this operation is currently available
*/
public boolean canRunToLine( IFile file, int lineNumber );
/**
* Causes this element to run to specified location.
*
*
* @exception DebugException on failure. Reasons include:
*/
public void runToLine( IFile file, int lineNumber ) throws DebugException;
/**
* Returns whether this operation is currently available for this file and line number.
*
*
* @return whether this operation is currently available
*/
public boolean canRunToLine( String fileName, int lineNumber );
/**
* Causes this element to run to specified location.
*
*
* @exception DebugException on failure. Reasons include:
*/
public void runToLine( String fileName, int lineNumber ) throws DebugException;
}
}

View file

@ -1,9 +1,13 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
*/
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.sourcelookup;
import org.eclipse.core.resources.IStorage;
@ -11,11 +15,9 @@ import org.eclipse.debug.core.model.IDebugTarget;
/**
* Defines methods specific to disassembly.
*
* @since: Oct 8, 2002
*/
public interface IDisassemblyStorage extends IStorage
{
public interface IDisassemblyStorage extends IStorage {
/**
* Returns the debug target of this disassembly.
*
@ -33,15 +35,17 @@ public interface IDisassemblyStorage extends IStorage
/**
* Returns the line number for given address.
* @param address - an address
*
* @param address - an address
* @return the line number for given address
*/
int getLineNumber( long address ) ;
int getLineNumber( long address );
/**
* Returns the address of instruction at given line.
* @param lineNumber - a line number
*
* @param lineNumber - a line number
* @return the address of instruction at given line
*/
long getAddress( int lineNumber ) ;
}
long getAddress( int lineNumber );
}

View file

@ -1,3 +1,10 @@
2004-04-08 Mikhail Khodjaiants
Implementing retargettable actions.
* plugin.xml
* RetargettableActionAdapterFactory.java
* RunToLineAdapter.java
* ToggleBreakpointAdapter.java
2004-04-08 Mikhail Khodjaiants
Added breakpoint images and implemented the extension points for breakpoint
marker annotations.

View file

@ -1228,5 +1228,28 @@
annotationType="org.eclipse.cdt.debug.core.breakpoint">
</specification>
</extension>
<extension
point="org.eclipse.core.runtime.adapters">
<factory
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
adaptableType="org.eclipse.cdt.internal.ui.editor.CEditor">
<adapter
type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
</adapter>
<adapter
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
</adapter>
</factory>
<factory
adaptableType="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory">
<adapter
type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
</adapter>
<adapter
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
</adapter>
</factory>
</extension>
</plugin>

View file

@ -0,0 +1,43 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.debug.ui.actions.IRunToLineTarget;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
/**
* Creates adapters for retargettable actions in debug platform.
* Contributed via <code>org.eclipse.core.runtime.adapters</code>
* extension point.
*/
public class RetargettableActionAdapterFactory implements IAdapterFactory {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
public Object getAdapter( Object adaptableObject, Class adapterType ) {
if ( adapterType == IToggleBreakpointsTarget.class ) {
return new ToggleBreakpointAdapter();
}
if ( adapterType == IRunToLineTarget.class ) {
return new RunToLineAdapter();
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
public Class[] getAdapterList() {
return new Class[]{ IRunToLineTarget.class, IToggleBreakpointsTarget.class };
}
}

View file

@ -0,0 +1,81 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.ISuspendResume;
import org.eclipse.debug.ui.actions.IRunToLineTarget;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.ITextEditor;
/**
* Run to line target adapter for the CDI debugger
*/
public class RunToLineAdapter implements IRunToLineTarget {
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection,
* org.eclipse.debug.core.model.ISuspendResume)
*/
public void runToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) throws CoreException {
IEditorPart editorPart = (IEditorPart)part;
IEditorInput input = editorPart.getEditorInput();
String errorMessage = null;
if ( input == null ) {
errorMessage = "Empty editor";
}
else {
final ITextEditor textEditor = (ITextEditor)editorPart;
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
if ( document == null ) {
errorMessage = "Missing document";
}
else {
IFile file = getFile( input );
ITextSelection textSelection = (ITextSelection)selection;
int lineNumber = textSelection.getStartLine() + 1;
}
}
throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection,
* org.eclipse.debug.core.model.ISuspendResume)
*/
public boolean canRunToLine( IWorkbenchPart part, ISelection selection, ISuspendResume target ) {
return target instanceof IDebugElement && ((IDebugElement)target).getModelIdentifier().equals( CDIDebugModel.getPluginIdentifier() );
}
private IFile getFile( IEditorInput input ) {
if ( input instanceof IFileEditorInput ) {
return ((IFileEditorInput)input).getFile();
}
return null;
}
}

View file

@ -0,0 +1,85 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.IEditorStatusLine;
/**
* Toggles a line breakpoint in a C/C++ editor.
*/
public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public void toggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public boolean canToggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) {
return ( selection instanceof ITextSelection );
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public void toggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public boolean canToggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) {
// TODO for now
return ( selection instanceof ITextSelection );
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public void toggleWatchpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) {
// TODO for now
return ( selection instanceof ITextSelection );
}
protected void report( String message, IWorkbenchPart part ) {
IEditorStatusLine statusLine = (IEditorStatusLine)part.getAdapter( IEditorStatusLine.class );
if ( statusLine != null ) {
if ( message != null ) {
statusLine.setMessage( true, message, null );
}
else {
statusLine.setMessage( true, null, null );
}
}
if ( message != null && CDebugUIPlugin.getActiveWorkbenchShell() != null ) {
CDebugUIPlugin.getActiveWorkbenchShell().getDisplay().beep();
}
}
}