From 9fde5658f32adc0b6c835ea3675d4e66b41fc693 Mon Sep 17 00:00:00 2001 From: Ali Azam Rana <85216275+alirana01@users.noreply.github.com> Date: Wed, 20 Nov 2024 17:30:45 +0100 Subject: [PATCH] fix(process): Debug Launch to return true for disconnect and terminate --- .../idf/debug/gdbjtag/openocd/dsf/Launch.java | 30 +++++++++---------- .../openocd/dsf/LaunchProcessDictionary.java | 21 +++++++++++++ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/Launch.java b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/Launch.java index a774af32d..4b2583375 100644 --- a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/Launch.java +++ b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/Launch.java @@ -264,23 +264,23 @@ public Process call() throws CoreException public void terminate() throws DebugException { super.terminate(); - for(IProcess process : getProcesses()) - { - if (process != null) - { - try - { - process.terminate(); - } - catch (Exception e) - { - e.printStackTrace(); - } - - } - } + + LaunchProcessDictionary.getInstance().killAllProcessesInLaunch(getLaunchConfiguration().getName()); } + @Override + public boolean canDisconnect() + { + return true; + } + + @Override + public boolean canTerminate() + { + return true; + } + + @Override public IProcess[] getProcesses() { diff --git a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchProcessDictionary.java b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchProcessDictionary.java index 52c7eb3cb..3199d8989 100644 --- a/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchProcessDictionary.java +++ b/bundles/com.espressif.idf.debug.gdbjtag.openocd/src/com/espressif/idf/debug/gdbjtag/openocd/dsf/LaunchProcessDictionary.java @@ -3,6 +3,7 @@ import java.util.HashMap; import java.util.Map; +import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IProcess; public class LaunchProcessDictionary @@ -48,5 +49,25 @@ public IProcess getProcessFromDictionary(String launchName, String procName) return processDictionary.get(launchName).get(procName); } + + public void killAllProcessesInLaunch(String launchName) + { + if(!processDictionary.containsKey(launchName)) + { + return; + } + + for (IProcess process : processDictionary.get(launchName).values()) + { + try + { + process.terminate(); + } + catch (DebugException e) + { + e.printStackTrace(); + } + } + } }