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

[302006] Disassembly view doesn't take into account active debug context when jumping to an address

This commit is contained in:
Anton Leherbauer 2010-02-17 09:33:12 +00:00
parent ed9c03f437
commit a603dc072a
3 changed files with 44 additions and 26 deletions

View file

@ -60,6 +60,8 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
private String fCdiSessionId;
private ICStackFrame fTargetFrameContext;
private CDIDisassemblyRetrieval fDisassemblyRetrieval;
/* The frame level as the disassembly callback expects it (0 = topmost frame) */
private int fFrameLevel;
public DisassemblyBackendCdi() {
}
@ -120,6 +122,7 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
} catch (DebugException e) {
}
}
fFrameLevel = result.frameLevel;
if (fTargetContext != null) {
result.sessionId = fCdiSessionId = cdiSessionId;
@ -127,16 +130,22 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
}
}
else if (context instanceof ICStackFrame) {
if (context instanceof ICStackFrame) {
fTargetFrameContext = (ICStackFrame)context;
fTargetContext = (ICThread)fTargetFrameContext.getThread();
try {
// CDI frame levels are ordered opposite of DSF. Frame 0 is the
// root frame of the thread where in DSF it's the topmost frame
// (where the PC is). Do a little math to flip reverse the value
result.frameLevel = ((CStackFrame)((fTargetContext.getTopStackFrame()))).getLevel() - fTargetFrameContext.getLevel();
} catch (DebugException e) {
}
fTargetFrameContext = (ICStackFrame)context;
ICThread newTargetContext = (ICThread)fTargetFrameContext.getThread();
ICThread oldTargetContext = fTargetContext;
fTargetContext = newTargetContext;
if (oldTargetContext != null && newTargetContext != null) {
result.contextChanged = !oldTargetContext.getDebugTarget().equals(newTargetContext.getDebugTarget());
}
try {
// CDI frame levels are ordered opposite of DSF. Frame 0 is the
// root frame of the thread where in DSF it's the topmost frame
// (where the PC is). Do a little math to flip reverse the value
result.frameLevel = ((CStackFrame)((fTargetContext.getTopStackFrame()))).getLevel() - fTargetFrameContext.getLevel();
} catch (DebugException e) {
}
fFrameLevel = result.frameLevel;
if (!result.contextChanged) {
fCallback.gotoFrame(result.frameLevel);
}
}
@ -167,6 +176,7 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
fCdiSessionId = null;
fTargetFrameContext = null;
fDisassemblyRetrieval = null;
fFrameLevel = 0;
}
/* (non-Javadoc)
@ -174,7 +184,12 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
*/
public void retrieveFrameAddress(final int targetFrame) {
try {
IStackFrame stackFrame= fTargetContext.getStackFrames()[targetFrame];
final IStackFrame[] stackFrames= fTargetContext.getStackFrames();
if (stackFrames.length <= targetFrame) {
fCallback.setUpdatePending(false);
return;
}
IStackFrame stackFrame= stackFrames[targetFrame];
fDisassemblyRetrieval.asyncGetFrameAddress(stackFrame, new IDisassemblyRetrieval.AddressRequest() {
@Override
public void done() {
@ -199,7 +214,7 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend#getFrameLevel()
*/
public int getFrameLevel() {
return fTargetFrameContext.getLevel();
return fFrameLevel;
}
/* (non-Javadoc)

View file

@ -181,15 +181,17 @@ public class DisassemblyBackendDsf implements IDisassemblyBackend, SessionEndedL
} else if (dmContext instanceof IFrameDMContext) {
// switch to different frame
IFrameDMContext frame= (IFrameDMContext) dmContext;
final IDMContext[] parents= frame.getParents();
for (IDMContext parent : parents) {
if (parent instanceof IExecutionDMContext) {
fTargetContext= (IExecutionDMContext) parent;
fTargetFrameContext= frame;
IExecutionDMContext newExeDmc = DMContexts.getAncestorOfType(frame, IExecutionDMContext.class);
if (newExeDmc != null) {
IDisassemblyDMContext newDisDmc = DMContexts.getAncestorOfType(newExeDmc, IDisassemblyDMContext.class);
IDisassemblyDMContext oldDisDmc = DMContexts.getAncestorOfType(fTargetContext, IDisassemblyDMContext.class);
result.contextChanged = !newDisDmc.equals(oldDisDmc);
fTargetContext= newExeDmc;
fTargetFrameContext= frame;
if (!result.contextChanged) {
fCallback.gotoFrameIfActive(frame.getLevel());
result.frameLevel = getFrameLevel();
break;
}
result.frameLevel = getFrameLevel();
}
}

View file

@ -1842,7 +1842,12 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fJumpToAddressAction.setEnabled(true);
fAddressBar.enableAddressBox(true);
updatePC(PC_UNKNOWN);
int activeFrame = getActiveStackFrame();
if (activeFrame > 0) {
gotoFrame(activeFrame);
} else {
updatePC(PC_UNKNOWN);
}
if (fGotoAddressPending != PC_UNKNOWN) {
gotoAddress(fGotoAddressPending);
@ -1856,10 +1861,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fAddressBar.enableAddressBox(false);
fViewer.removeViewportListener(this);
fGotoMarkerPending = null;
// invokeLater(new Runnable() {
// public void run() {
// closePart();
// }});
}
updateTitle();
updateStateDependentActions();
@ -1917,7 +1918,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fGotoFramePending = false;
fPCAddress = fFrameAddress = PC_RUNNING;
fTargetFrame = -1;
fGotoAddressPending = fFocusAddress;
fGotoAddressPending = PC_UNKNOWN;
fFocusAddress = PC_UNKNOWN;
setFocusPosition(null);
fPCHistory.clear();