From fcf416ab6d6c95aee09165dd370431b1da8480e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Svensson?= Date: Sat, 29 Jan 2022 16:27:31 +0100 Subject: [PATCH] Bug 578400: Handle refresh event to show right source code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the ICommandControlRefreshAllDMEvent is sent, open the coresponding source file to the new stack frame. It could be the same or a completly different file as before the event. Contributed by STMicroelectronics Also-By: Jonah Graham Signed-off-by: Torbjörn Svensson Change-Id: Ib99f19f444a5bae1d99072ec9ed07e5666732bb6 --- .../sourcelookup/DsfSourceDisplayAdapter.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java index 5351e506ced..d2c9f815c51 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java @@ -43,6 +43,7 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason; import org.eclipse.cdt.dsf.debug.service.IStack; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData; +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.debug.sourcelookup.DsfSourceLookupParticipant; import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController; import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController.ISteppingControlParticipant; @@ -986,6 +987,28 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl startAnnotationClearingJob(e.getDMContext()); } + /** + * @noreference This method is not intended to be referenced by clients. + */ + @DsfServiceEventHandler + public void eventDispatched(final ICommandControlService.ICommandControlRefreshAllDMEvent e) { + if (DEBUG) { + System.out.println("[DsfSourceDisplayAdapter] eventDispatched e=" + e); //$NON-NLS-1$ + } + // trigger source display immediately (should be optional?) + Display.getDefault().asyncExec(() -> { + Object context = DebugUITools.getDebugContext(); + if (context instanceof IDMVMContext) { + final IDMContext dmc = ((IDMVMContext) context).getDMContext(); + if (dmc instanceof IFrameDMContext && DMContexts.isAncestorOf(dmc, e.getDMContext())) { + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + doDisplaySource((IFrameDMContext) dmc, page, false, true); + return; + } + } + }); + } + @DsfServiceEventHandler public void eventDispatched(final IRunControl.ISuspendedDMEvent e) { updateStepTiming();