1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 369998 - IBreakpointLocationProvider methods need a target or

viewsite parameter
This commit is contained in:
Patrick Chuong 2012-02-06 12:58:53 -05:00
parent 4fc4a8bc3b
commit 2e5c77c1ab
3 changed files with 41 additions and 30 deletions

View file

@ -9,9 +9,10 @@
* Wind River Systems - initial API and implementation
* Patrick Chuong (Texas Instruments) - Bug 326670
* Patrick Chuong (Texas Instruments) - Bug 329682
* Patrick Chuong (Texas Instruments) - bug 330259
* Patrick Chuong (Texas Instruments) - Bug 330259
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Bug 364405
* Patrick Chuong (Texas Instruments) - Bug 369998
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
@ -303,6 +304,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
protected boolean fTrackExpression = false;
private String fPCLastLocationTxt = DisassemblyMessages.Disassembly_GotoLocation_initial_text;
private BigInteger fPCLastAddress = PC_UNKNOWN;
private IAdaptable fDebugContext;
private String fPCAnnotationColorKey;
@ -1851,22 +1853,22 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
protected void updateDebugContext() {
IAdaptable context = DebugUITools.getPartDebugContext(getSite());
fDebugContext = DebugUITools.getPartDebugContext(getSite());
IDisassemblyBackend prevBackend = fBackend;
IDisassemblyBackend newBackend = null;
fDebugSessionId = null;
boolean needUpdate = false;
if (context != null) {
IDisassemblyBackend contextBackend = (IDisassemblyBackend)context.getAdapter(IDisassemblyBackend.class);
if (fDebugContext != null) {
IDisassemblyBackend contextBackend = (IDisassemblyBackend)fDebugContext.getAdapter(IDisassemblyBackend.class);
// Need to compare the backend classes to prevent reusing the same backend object.
// sub class can overwrite the standard disassembly backend to provide its own customization.
if ((prevBackend != null) && (contextBackend != null) && prevBackend.getClass().equals(contextBackend.getClass()) && prevBackend.supportsDebugContext(context)) {
if ((prevBackend != null) && (contextBackend != null) && prevBackend.getClass().equals(contextBackend.getClass()) && prevBackend.supportsDebugContext(fDebugContext)) {
newBackend = prevBackend;
} else {
needUpdate = true;
newBackend = (IDisassemblyBackend)context.getAdapter(IDisassemblyBackend.class);
newBackend = (IDisassemblyBackend)fDebugContext.getAdapter(IDisassemblyBackend.class);
if (newBackend != null) {
if (newBackend.supportsDebugContext(context)) {
if (newBackend.supportsDebugContext(fDebugContext)) {
newBackend.init(this);
} else {
newBackend = null;
@ -1876,7 +1878,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
}
fBackend = newBackend;
if (newBackend != null) {
IDisassemblyBackend.SetDebugContextResult result = newBackend.setDebugContext(context);
IDisassemblyBackend.SetDebugContextResult result = newBackend.setDebugContext(fDebugContext);
if (result != null) {
fDebugSessionId = result.sessionId;
if (result.contextChanged) {
@ -1981,7 +1983,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
IAnnotationModel annotationModel = fViewer.getAnnotationModel();
if (annotationModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ame= (IAnnotationModelExtension) annotationModel;
ame.addAnnotationModel(BREAKPOINT_ANNOTATIONS, new BreakpointsAnnotationModel());
ame.addAnnotationModel(BREAKPOINT_ANNOTATIONS, new BreakpointsAnnotationModel(fDebugContext));
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Wind River Systems, Inc. and others.
* Copyright (c) 2008, 2012 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
@ -7,7 +7,8 @@
*
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
* Patrick Chuong (Texas Instruments) - bug 300053
* Patrick Chuong (Texas Instruments) - Bug 300053
* Patrick Chuong (Texas Instruments) - Bug 369998
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model;
@ -25,6 +26,7 @@ import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointListener;
import org.eclipse.debug.core.IBreakpointManager;
@ -47,6 +49,11 @@ import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
public class BreakpointsAnnotationModel extends DisassemblyAnnotationModel implements IBreakpointListener, IDocumentListener {
private Runnable fCatchup;
private IAdaptable fDebugContext;
public BreakpointsAnnotationModel(IAdaptable debugContext) {
fDebugContext = debugContext;
}
@Override
public void connect(IDocument document) {
@ -159,14 +166,14 @@ public class BreakpointsAnnotationModel extends DisassemblyAnnotationModel imple
if (locationProvider != null) {
/* if there is source info, than create a source line position */
String sourceFile = locationProvider.getSourceFile(breakpoint);
String sourceFile = locationProvider.getSourceFile(breakpoint, fDebugContext);
if (sourceFile != null) {
int lineNumber = locationProvider.getLineNumber(breakpoint) - 1;
int lineNumber = locationProvider.getLineNumber(breakpoint, fDebugContext) - 1;
return createPositionFromSourceLine(sourceFile, lineNumber);
} else {
/* if there is label info, than create a label position */
IAddress labelAddress = locationProvider.getLabelAddress(breakpoint);
IAddress labelAddress = locationProvider.getLabelAddress(breakpoint, fDebugContext);
if (labelAddress != null) {
return createPositionFromLabel(labelAddress.getValue());
@ -178,7 +185,7 @@ public class BreakpointsAnnotationModel extends DisassemblyAnnotationModel imple
//
// So for now, we only create an annotation for the first valid address. We can add
// support for multiple annotations per breakpoint when it's needed.
IAddress[] addresses = locationProvider.getAddresses(breakpoint);
IAddress[] addresses = locationProvider.getAddresses(breakpoint, fDebugContext);
for (int i = 0; addresses != null && i < addresses.length; ++i) {
BigInteger address = addresses[i].getValue();
Position position = createPositionFromAddress(address);

View file

@ -1,5 +1,5 @@
/*****************************************************************
* Copyright (c) 2010 Texas Instruments and others
* Copyright (c) 2010, 2012 Texas Instruments 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
@ -7,11 +7,13 @@
*
* Contributors:
* Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 300053)
* Patrick Chuong (Texas Instruments) - Bug 369998
*****************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.ILineBreakpoint;
@ -46,31 +48,31 @@ public interface IBreakpointLocationProvider {
* Returns the line number of the breakpoint or -1 if no line number is
* available.
*
* @param breakpoint
* the breakpoint
* @param breakpoint the breakpoint
* @param debugContext the debug context of the view
* @return the line number or -1
*/
int getLineNumber(IBreakpoint breakpoint);
int getLineNumber(IBreakpoint breakpoint, IAdaptable debugContext);
/**
* Returns the source file path of the breakpoint or <code>null</code> if no
* source file is associated with this breakpoint.
*
* @param breakpoint
* the breakpoint
* @param breakpoint the breakpoint
* @param debugContext the debug context of the view
* @return the file path, can be <code>null</code>
*/
String getSourceFile(IBreakpoint breakpoint);
String getSourceFile(IBreakpoint breakpoint, IAdaptable debugContext);
/**
* Returns the label address of the breakpoint or <code>null</code> if no
* label is associated with this breakpoint.
*
* @param breakpoint
* the breakpoint
* @param breakpoint the breakpoint
* @param debugContext the debug context of the view
* @return the label address, can be <code>null</code>
*/
IAddress getLabelAddress(IBreakpoint breakpoint);
IAddress getLabelAddress(IBreakpoint breakpoint, IAdaptable debugContext);
/**
* Returns the addresses of the breakpoint.
@ -81,9 +83,9 @@ public interface IBreakpointLocationProvider {
* multiple annotations per breakpoint is up for future enhancements. </i>
* </p>
*
* @param breakpoint
* the breakpoint
* @param breakpoint the breakpoint
* @param debugContext the debug context of the view
* @return the addresses, can be <code>null</code>
*/
IAddress[] getAddresses(IBreakpoint breakpoint);
IAddress[] getAddresses(IBreakpoint breakpoint, IAdaptable debugContext);
}