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

Bug 317226: Disassembly view throws NPE when debugging with CDI

This commit is contained in:
John Cortell 2010-06-18 15:31:50 +00:00
parent 19768142fd
commit 9303fa016e

View file

@ -115,13 +115,21 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
fTargetContext = null; fTargetContext = null;
if (context instanceof ICStackFrame) { if (context instanceof ICStackFrame) {
fTargetFrameContext = (ICStackFrame)context; fTargetFrameContext = null;
fTargetContext = (ICThread)fTargetFrameContext.getThread(); fTargetContext = (ICThread)((ICStackFrame)context).getThread();
try { try {
// CDI frame levels are ordered opposite of DSF. Frame 0 is the // Get the topmost stack frame. Note that the state of the
// root frame of the thread where in DSF it's the topmost frame // thread may have changed by now. It may be running, in
// (where the PC is). Do a little math to flip reverse the value // which case we'll get null here. See bugzilla 317226
result.frameLevel = ((CStackFrame)((fTargetContext.getTopStackFrame()))).getLevel() - fTargetFrameContext.getLevel(); IStackFrame topFrame = fTargetContext.getTopStackFrame();
if (topFrame != null) {
fTargetFrameContext = (ICStackFrame)context;
// 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)topFrame).getLevel() - fTargetFrameContext.getLevel();
}
} catch (DebugException e) { } catch (DebugException e) {
} }
} }
@ -133,18 +141,26 @@ public class DisassemblyBackendCdi implements IDisassemblyBackend, IDebugEventSe
} }
} }
else if (context instanceof ICStackFrame) { else if (context instanceof ICStackFrame) {
fTargetFrameContext = (ICStackFrame)context; fTargetFrameContext = null;
ICThread newTargetContext = (ICThread)fTargetFrameContext.getThread(); ICThread newTargetContext = (ICThread)((ICStackFrame)context).getThread();
ICThread oldTargetContext = fTargetContext; ICThread oldTargetContext = fTargetContext;
fTargetContext = newTargetContext; fTargetContext = newTargetContext;
if (oldTargetContext != null && newTargetContext != null) { if (oldTargetContext != null && newTargetContext != null) {
result.contextChanged = !oldTargetContext.getDebugTarget().equals(newTargetContext.getDebugTarget()); result.contextChanged = !oldTargetContext.getDebugTarget().equals(newTargetContext.getDebugTarget());
} }
try { try {
// CDI frame levels are ordered opposite of DSF. Frame 0 is the // Get the topmost stack frame. Note that the state of the
// root frame of the thread where in DSF it's the topmost frame // thread may have changed by now. It may be running, in
// (where the PC is). Do a little math to flip reverse the value // which case we'll get null here. See bugzilla 317226
result.frameLevel = ((CStackFrame)((fTargetContext.getTopStackFrame()))).getLevel() - fTargetFrameContext.getLevel(); IStackFrame topFrame = fTargetContext.getTopStackFrame();
if (topFrame != null) {
fTargetFrameContext = (ICStackFrame)context;
// 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)topFrame).getLevel() - fTargetFrameContext.getLevel();
}
} catch (DebugException e) { } catch (DebugException e) {
} }
fFrameLevel = result.frameLevel; fFrameLevel = result.frameLevel;