1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Bug 337851 - [disassembly] Enable target request while it is running

Change-Id: I67683ee5c9c55ec609de7011140e67a22e6e87ea
Reviewed-on: https://git.eclipse.org/r/14669
Reviewed-by: Anton Leherbauer <anton.leherbauer@windriver.com>
IP-Clean: Patrick Chuong <pchuong@ti.com>
Tested-by: Patrick Chuong <pchuong@ti.com>
Reviewed-by: Patrick Chuong <pchuong@ti.com>
This commit is contained in:
Patrick Chuong 2013-07-24 17:08:30 -04:00
parent 156990d03e
commit 3e84751400
4 changed files with 73 additions and 12 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
* Copyright (c) 2011, 2013 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
@ -11,6 +11,7 @@
* Patrick Chuong (Texas Instruments) - Bug 329682
* Patrick Chuong (Texas Instruments) - Bug 353351
* Patrick Chuong (Texas Instruments) - Bug 364405
* Patrick Chuong (Texas Instruments) - Bug 337851
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.disassembly.dsf;
@ -22,6 +23,7 @@ import org.eclipse.jface.text.source.IAnnotationModel;
public abstract class AbstractDisassemblyBackend implements IDisassemblyBackend {
protected final BigInteger UNKNOWN_ADDRESS = BigInteger.valueOf(-1);
protected IDisassemblyPartCallback fCallback;
protected AbstractDisassemblyBackend() {
@ -75,4 +77,14 @@ public abstract class AbstractDisassemblyBackend implements IDisassemblyBackend
@Override
public void updateExtendedPCAnnotation(IAnnotationModel model) {
}
@Override
public boolean canDisassemble() {
return isSuspended();
}
@Override
public BigInteger getLastKnownAddress() {
return BigInteger.valueOf(-1);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2012 Wind River Systems, Inc. and others.
* Copyright (c) 2010, 2013 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
@ -9,6 +9,7 @@
* Wind River Systems - initial API and implementation
* Freescale Semiconductor - refactoring
* Patrick Chuong (Texas Instruments) - Bug 364405
* Patrick Chuong (Texas Instruments) - Bug 337851
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.disassembly.dsf;
@ -198,4 +199,17 @@ public interface IDisassemblyBackend {
* Update the extended PC annotation.
*/
void updateExtendedPCAnnotation(IAnnotationModel model);
/**
* Returns true if this backend can disassemble instructions.
* @return true if backend can perform disassemble
*/
boolean canDisassemble();
/**
* Returns the last know address, this API will be call if the selected
* debug context is not a stackframe.
* @return the last know address, -1 if unknown
*/
BigInteger getLastKnownAddress();
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010 Wind River Systems, Inc. and others.
* Copyright (c) 2010, 2013 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
@ -12,6 +12,7 @@
* Patrick Chuong (Texas Instruments) - Bug 329682
* Patrick Chuong (Texas Instruments) - Bug 328168
* Patrick Chuong (Texas Instruments) - Bug 353351
* Patrick Chuong (Texas Instruments) - Bug 337851
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
@ -175,12 +176,13 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
fTargetFrameContext = null;
result.contextChanged = true;
if (dmContext instanceof IFrameDMContext) {
IFrameDMContext frame= (IFrameDMContext) dmContext;
IExecutionDMContext executionContext= DMContexts.getAncestorOfType(frame, IExecutionDMContext.class);
if (canDisassembleContext(dmContext)) {
if (dmContext instanceof IFrameDMContext) {
fTargetFrameContext = (IFrameDMContext) dmContext;
}
IExecutionDMContext executionContext= DMContexts.getAncestorOfType(dmContext, IExecutionDMContext.class);
if (executionContext != null) {
fTargetContext= executionContext;
fTargetFrameContext= frame;
}
}
if (fTargetContext != null) {
@ -242,6 +244,10 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
fTargetFrameContext = null;
result.contextChanged = true;
}
} else if (dmContext.equals(fTargetContext) && canDisassemble()) {
result.contextChanged = false;
result.sessionId = fDsfSessionId;
} else {
fTargetContext = null;
fTargetFrameContext = null;
@ -305,7 +311,18 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
if (fTargetFrameContext != null) {
retrieveFrameAddressInSessionThread(frame);
} else {
fCallback.setUpdatePending(false);
fCallback.setUpdatePending(false);
if (canDisassemble()) {
final BigInteger address = getLastKnownAddress();
if (address != null && !UNKNOWN_ADDRESS.equals(address)) {
fCallback.asyncExec(new Runnable() {
@Override
public void run() {
fCallback.updatePC(address);
}
});
}
}
}
}
});
@ -1168,4 +1185,21 @@ public class DisassemblyBackendDsf extends AbstractDisassemblyBackend implements
}
});
}
/**
* Sub classes can override this method to allow disassemble for other DMContext.
* @param context
* @return
*/
protected boolean canDisassembleContext(IDMContext context) {
return context instanceof IFrameDMContext;
}
/**
* Returns the target context for the current selected debug context.
* @return
*/
protected IExecutionDMContext getExecutionDMContext() {
return fTargetContext;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2012 Wind River Systems and others.
* Copyright (c) 2007, 2013 Wind River Systems 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
@ -13,6 +13,7 @@
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
* Patrick Chuong (Texas Instruments) - Bug 364405
* Patrick Chuong (Texas Instruments) - Bug 369998
* Patrick Chuong (Texas Instruments) - Bug 337851
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
@ -1507,7 +1508,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (!fActive || fUpdatePending || fViewer == null || fDebugSessionId == null) {
return;
}
if (fBackend == null || !fBackend.hasDebugContext() || !fBackend.isSuspended() || fFrameAddress == PC_UNKNOWN) {
if (fBackend == null || !fBackend.hasDebugContext() || !fBackend.canDisassemble() || fFrameAddress == PC_UNKNOWN) {
return;
}
StyledText styledText = fViewer.getTextWidget();
@ -2244,7 +2245,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fFrameAddress = address;
if (fTargetFrame == -1) {
fTargetFrame = getActiveStackFrame();
if (fTargetFrame < 0 && fBackend != null && fBackend.isSuspended()) {
if (fTargetFrame < 0 && fBackend != null && fBackend.canDisassemble()) {
fTargetFrame= 0;
}
if (fTargetFrame == -1) {
@ -2259,7 +2260,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (fFrameAddress.compareTo(PC_UNKNOWN) == 0) {
if (!fUpdatePending) {
fGotoFramePending = false;
if (fBackend != null && fBackend.hasDebugContext() && fBackend.isSuspended()) {
if (fBackend != null && fBackend.hasDebugContext() && fBackend.canDisassemble()) {
if (DEBUG) System.out.println("retrieveFrameAddress "+frame); //$NON-NLS-1$
fUpdatePending = true;
fBackend.retrieveFrameAddress(fTargetFrame);