diff options
5 files changed, 121 insertions, 78 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java index da6f96e85..726ba26c8 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/disassembly/TCFDisassemblyBackend.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010-2019 Wind River Systems, Inc. and others. + * Copyright (c) 2010-2021 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 2.0 * which accompanies this distribution, and is available at @@ -157,7 +157,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { public void contextSuspended(String context, String pc, String reason, Map<String, Object> params) { if (fExecContext.getID().equals(context)) { - handleContextSuspended(pc != null ? new BigInteger(pc) : null); + handleContextSuspended(); } } @@ -172,12 +172,12 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { String[] suspended_ids) { String id = fExecContext.getID(); if (id.equals(context)) { - handleContextSuspended(pc != null ? new BigInteger(pc) : null); + handleContextSuspended(); return; } for (String contextId : suspended_ids) { if (id.equals(contextId)) { - handleContextSuspended(null); + handleContextSuspended(); return; } } @@ -218,6 +218,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { private volatile TCFNodeExecContext fExecContext; private volatile TCFNodeExecContext fMemoryContext; private volatile TCFNodeStackFrame fActiveFrame; + private volatile TCFContextState fContextState; private volatile int fSuspendCount; private volatile int fContextCount; private volatile boolean disposed; @@ -338,6 +339,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } fSuspended = false; + fContextState = null; fMemoryContext = null; fActiveFrame = null; if (fExecContext != null) { @@ -349,16 +351,11 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { if (!mem_cache.validate(this)) return; TCFDataCache<TCFContextState> state_cache = fExecContext.getState(); if (!state_cache.validate(this)) return; - if (context instanceof TCFNodeExecContext) { - TCFChildrenStackTrace stack = ((TCFNodeExecContext)context).getStackTrace(); - if (!stack.validate(this)) return; - fActiveFrame = stack.getTopFrame(); - } - else if (context instanceof TCFNodeStackFrame) { + if (context instanceof TCFNodeStackFrame) { fActiveFrame = (TCFNodeStackFrame)context; } - TCFContextState state_data = state_cache.getData(); - fSuspended = state_data != null && state_data.is_suspended; + fContextState = state_cache.getData(); + fSuspended = fContextState != null && fContextState.is_suspended; fMemoryContext = mem_cache.getData(); done(null); } @@ -370,7 +367,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } result.sessionId = fExecContext != null ? fExecContext.getID() : null; - if (!result.contextChanged && fActiveFrame != null) { + if (!result.contextChanged && fExecContext != null) { fCallback.asyncExec(new Runnable() { public void run() { fCallback.gotoFrameIfActive(getFrameLevel()); @@ -411,14 +408,16 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { }); } - private void handleContextSuspended(BigInteger pc) { + private void handleContextSuspended() { fSuspendCount++; fSuspended = true; + fContextState = null; fCallback.handleTargetSuspended(); } private void handleContextResumed() { fSuspended = false; + fContextState = null; fCallback.handleTargetResumed(); } @@ -429,6 +428,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { public void clearDebugContext() { fSuspended = false; + fContextState = null; if (fExecContext != null) { removeListeners(fExecContext); } @@ -483,9 +483,18 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } } + public boolean isSuspended() { + return fSuspended; + } + + public boolean hasFrameContext() { + return fActiveFrame != null || fContextState != null; + } + public int getFrameLevel() { - if (fActiveFrame == null) return -1; - return new TCFTask<Integer>() { + if (fExecContext == null) return -1; + if (fActiveFrame == null) return 0; + return new TCFTask<Integer>(fExecContext.getChannel()) { public void run() { if (!fExecContext.getStackTrace().validate(this)) return; done(fActiveFrame.getFrameNo()); @@ -493,24 +502,26 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { }.getE(); } - public boolean isSuspended() { - return fSuspended; - } - - public boolean hasFrameContext() { - return fActiveFrame != null; - } - public String getFrameFile() { - if (fActiveFrame == null) return null; - return new TCFTask<String>(fActiveFrame.getChannel()) { + if (fExecContext == null) return null; + return new TCFTask<String>(fExecContext.getChannel()) { public void run() { - TCFDataCache<TCFSourceRef> sourceRefCache = fActiveFrame.getLineInfo(); - if (!sourceRefCache.validate(this)) return; - TCFSourceRef sourceRef = sourceRefCache.getData(); - if (sourceRef != null && sourceRef.area != null) { - done(TCFSourceLookupParticipant.toFileName(sourceRef.area)); - return; + TCFDataCache<TCFSourceRef> sourceRefCache = null; + if (fActiveFrame != null) { + sourceRefCache = fActiveFrame.getLineInfo(); + } + else if (fContextState != null) { + BigInteger addr = new BigInteger(fContextState.suspend_pc); + sourceRefCache = fExecContext.getLineInfo(addr); + + } + if (sourceRefCache != null) { + if (!sourceRefCache.validate(this)) return; + TCFSourceRef sourceRef = sourceRefCache.getData(); + if (sourceRef != null && sourceRef.area != null) { + done(TCFSourceLookupParticipant.toFileName(sourceRef.area)); + return; + } } done(null); } @@ -518,15 +529,25 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } public int getFrameLine() { - if (fActiveFrame == null) return -1; - return new TCFTask<Integer>(fActiveFrame.getChannel()) { + if (fExecContext == null) return -1; + return new TCFTask<Integer>(fExecContext.getChannel()) { public void run() { - TCFDataCache<TCFSourceRef> sourceRefCache = fActiveFrame.getLineInfo(); - if (!sourceRefCache.validate(this)) return; - TCFSourceRef sourceRef = sourceRefCache.getData(); - if (sourceRef != null && sourceRef.area != null) { - done(sourceRef.area.start_line); - return; + TCFDataCache<TCFSourceRef> sourceRefCache = null; + if (fActiveFrame != null) { + sourceRefCache = fActiveFrame.getLineInfo(); + } + else if (fContextState != null) { + BigInteger addr = new BigInteger(fContextState.suspend_pc); + sourceRefCache = fExecContext.getLineInfo(addr); + + } + if (sourceRefCache != null) { + if (!sourceRefCache.validate(this)) return; + TCFSourceRef sourceRef = sourceRefCache.getData(); + if (sourceRef != null && sourceRef.area != null) { + done(sourceRef.area.start_line); + return; + } } done(-1); } @@ -947,15 +968,13 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } public void gotoSymbol(final String symbol) { - final TCFNodeStackFrame activeFrame = fActiveFrame; - if (activeFrame == null) return; - Protocol.invokeLater(new Runnable() { + if (fExecContext == null) return; + new TCFTask<String>(fExecContext.getChannel()) { public void run() { - if (activeFrame != fActiveFrame) return; - IChannel channel = activeFrame.getChannel(); + IChannel channel = fExecContext.getChannel(); final IExpressions exprSvc = channel.getRemoteService(IExpressions.class); if (exprSvc != null) { - TCFNode evalContext = activeFrame.isEmulated() ? activeFrame.getParent() : activeFrame; + TCFNode evalContext = fActiveFrame == null || fActiveFrame.isEmulated() ? fExecContext : fActiveFrame; exprSvc.create(evalContext.getID(), null, symbol, new DoneCreate() { public void doneCreate(IToken token, Exception error, final Expression context) { if (error == null) { @@ -973,6 +992,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { else { handleError(error); } + done(null); exprSvc.dispose(context.getID(), new DoneDispose() { public void doneDispose(IToken token, Exception error) { // no-op @@ -983,10 +1003,14 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } else { handleError(error); + done(null); } } }); } + else { + done(null); + } } protected void handleError(final Exception error) { fCallback.asyncExec(new Runnable() { @@ -996,7 +1020,7 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } }); } - }); + }.getE(); } public void retrieveDisassembly(String file, int lines, @@ -1008,13 +1032,13 @@ public class TCFDisassemblyBackend extends AbstractDisassemblyBackend { } public String evaluateExpression(final String expression) { - if (fActiveFrame == null) return null; - String value = new TCFTask<String>(fActiveFrame.getChannel()) { + if (fExecContext == null) return null; + String value = new TCFTask<String>(fExecContext.getChannel()) { public void run() { - IChannel channel = fActiveFrame.getChannel(); + IChannel channel = fExecContext.getChannel(); final IExpressions exprSvc = channel.getRemoteService(IExpressions.class); if (exprSvc != null) { - TCFNode evalContext = fActiveFrame.isEmulated() ? fActiveFrame.getParent() : fActiveFrame; + TCFNode evalContext = fActiveFrame == null || fActiveFrame.isEmulated() ? fExecContext : fActiveFrame; exprSvc.create(evalContext.getID(), null, expression, new DoneCreate() { public void doneCreate(IToken token, Exception error, final Expression context) { if (error == null) { diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationManager.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationManager.java index d19c60d4d..bf5b1f977 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationManager.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationManager.java @@ -651,6 +651,7 @@ public class TCFAnnotationManager { TCFNodeExecContext memory = null; TCFNodeStackFrame frame = null; TCFNodeStackFrame last_top_frame = null; + TCFContextState state_data = null; String bp_group = null; boolean suspended = false; if (node instanceof TCFNodeStackFrame) { @@ -662,10 +663,6 @@ public class TCFAnnotationManager { } else if (node instanceof TCFNodeExecContext) { thread = (TCFNodeExecContext)node; - // Make sure frame.getTopFrame() is valid - TCFChildrenStackTrace trace = thread.getStackTrace(); - if (!trace.validate(this)) return; - frame = trace.getTopFrame(); } if (thread != null) { TCFAction action = thread.model.getActiveAction(thread.id); @@ -681,7 +678,8 @@ public class TCFAnnotationManager { last_top_frame = thread.getLastTopFrame(); TCFDataCache<TCFContextState> state_cache = thread.getState(); if (!state_cache.validate(this)) return; - suspended = state_cache.getData() != null && state_cache.getData().is_suspended; + state_data = state_cache.getData(); + suspended = state_data != null && state_data.is_suspended; } } Set<TCFAnnotation> set = new LinkedHashSet<TCFAnnotation>(); @@ -789,18 +787,35 @@ public class TCFAnnotationManager { set.add(a); } } - if (!suspended && last_top_frame != null) { - TCFDataCache<TCFSourceRef> line_cache = last_top_frame.getLineInfo(); + else if (suspended && state_data != null && state_data.suspend_pc != null) { + BigInteger addr_data = new BigInteger(state_data.suspend_pc); + TCFDataCache<TCFSourceRef> line_cache = thread.getLineInfo(addr_data); if (!line_cache.validate(this)) return; TCFSourceRef line_data = line_cache.getData(); if (line_data != null && line_data.area != null) { + String addr_str = ""; + addr_str += ", IP: 0x" + addr_data.toString(16); + addr_str += ", line: " + line_data.area.start_line; TCFAnnotation a = new TCFAnnotation(line_data.context_id, null, null, line_data.area, - ImageCache.IMG_INSTRUCTION_POINTER, - "Last Instruction Pointer position", - TYPE_STACK_FRAME); + ImageCache.IMG_INSTRUCTION_POINTER_TOP, + "Current Instruction Pointer" + addr_str, + TYPE_TOP_FRAME); set.add(a); } } + if (!suspended && last_top_frame != null) { + TCFDataCache<TCFSourceRef> line_cache = last_top_frame.getLineInfo(); + if (line_cache.isValid()) { + TCFSourceRef line_data = line_cache.getData(); + if (line_data != null && line_data.area != null) { + TCFAnnotation a = new TCFAnnotation(line_data.context_id, null, null, line_data.area, + ImageCache.IMG_INSTRUCTION_POINTER, + "Last Instruction Pointer position", + TYPE_STACK_FRAME); + set.add(a); + } + } + } done(set); } private void done(final Set<TCFAnnotation> res) { diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java index ed8b609c5..b1da592e0 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.tcf.internal.debug.ui.model; +import java.math.BigInteger; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; @@ -1949,18 +1950,22 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab Protocol.invokeLater(25, new Runnable() { public void run() { if (!displaySourceCheck(page, generation)) return; - TCFNodeStackFrame stack_frame = null; + String ctx_id = null; + boolean top_frame = false; + TCFDataCache<TCFSourceRef> line_info = null; if (!disposed && channel.getState() == IChannel.STATE_OPEN) { if (element instanceof TCFNodeExecContext) { TCFNodeExecContext exec_ctx = (TCFNodeExecContext)element; if (!exec_ctx.isDisposed() && active_actions.get(exec_ctx.id) == null) { - TCFDataCache<TCFContextState> state_cache = exec_ctx.getMinState(); + TCFDataCache<TCFContextState> state_cache = exec_ctx.getState(); if (!state_cache.validate(this)) return; TCFContextState state_data = state_cache.getData(); - if (state_data != null && state_data.is_suspended && !state_data.isNotActive()) { - TCFChildrenStackTrace stack_trace = exec_ctx.getStackTrace(); - if (!stack_trace.validate(this)) return; - stack_frame = stack_trace.getTopFrame(); + if (state_data != null && state_data.is_suspended && + state_data.suspend_pc != null && !state_data.isNotActive()) { + BigInteger addr = new BigInteger(state_data.suspend_pc); + line_info = exec_ctx.getLineInfo(addr); + top_frame = true; + ctx_id = exec_ctx.id; } } } @@ -1975,17 +1980,16 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab // Validate stack trace to make sure stack_frame.getFrameNo() is valid TCFChildrenStackTrace stack_trace = exec_ctx.getStackTrace(); if (!stack_trace.validate(this)) return; - stack_frame = f; + line_info = f.getLineInfo(); + top_frame = f.getFrameNo() == 0; + ctx_id = f.parent.id; } } } } - String ctx_id = null; String mem_id = null; - boolean top_frame = false; ILineNumbers.CodeArea area = null; - if (stack_frame != null) { - TCFDataCache<TCFSourceRef> line_info = stack_frame.getLineInfo(); + if (line_info != null) { if (!line_info.validate(this)) return; Throwable error = line_info.getError(); TCFSourceRef src_ref = line_info.getData(); @@ -1995,8 +1999,6 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab mem_id = src_ref.context_id; area = src_ref.area; } - top_frame = stack_frame.getFrameNo() == 0; - ctx_id = stack_frame.parent.id; } displaySource(generation, page, element, ctx_id, mem_id, top_frame, area, event); } diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java index 4e5bf3b56..2cc58e584 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExecContext.java @@ -947,7 +947,8 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner, ITCFExe } private boolean okToShowLastStack() { - return resume_pending && last_stack_trace != null; + if (last_stack_trace == null) return false; + return resume_pending || (launch.getContextActionsCount(id) > 0 && model.getDelayStackUpdateUtilLastStep()); } private boolean okToHideStack() { @@ -1388,6 +1389,7 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner, ITCFExe result.setInputElement(this); String view_id = result.getPresentationContext().getId(); if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(view_id)) { + if (launch.getContextActionsCount(id) > 0 && model.getDelayStackUpdateUtilLastStep()) return true; if (!children_stack.validate(done)) return false; TCFNodeStackFrame frame = children_stack.getTopFrame(); if (frame != null) result.setInputElement(frame); diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java index aad6ccc50..233033c39 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008-2020 Wind River Systems, Inc. and others. + * Copyright (c) 2008-2021 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 2.0 * which accompanies this distribution, and is available at @@ -940,7 +940,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT if (p instanceof TCFNodeStackFrame) { TCFNodeExecContext exe = (TCFNodeExecContext)p.parent; TCFAction action = model.getActiveAction(exe.id); - if (action != null && action.showRunning()) return true; + if (action != null && (action.showRunning() || model.getDelayStackUpdateUtilLastStep())) return true; TCFDataCache<TCFContextState> state_cache = exe.getState(); if (!state_cache.validate(done)) return null; TCFContextState state = state_cache.getData(); @@ -952,7 +952,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT else if (p instanceof TCFNodeExecContext) { TCFNodeExecContext exe = (TCFNodeExecContext)p; TCFAction action = model.getActiveAction(exe.id); - if (action != null && action.showRunning()) return true; + if (action != null && (action.showRunning() || model.getDelayStackUpdateUtilLastStep())) return true; TCFDataCache<TCFContextState> state_cache = exe.getState(); if (!state_cache.validate(done)) return null; TCFContextState state = state_cache.getData(); |