mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Bug 520245: Avoid writing launch files with no changes
On shutdown of a debug session the launch files are written, often (normally) with no changes. This commit prevents unneeded deltas on the launch files and prevents a lot of the callbacks of launch configurations changing. This also ameliorates the case in Bug 500988. Change-Id: Iddbd9c5c5695dcd2d255cbc761a48316fa5acbb1
This commit is contained in:
parent
7f3b2120fe
commit
07a9aa0543
2 changed files with 34 additions and 11 deletions
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.debug.internal.core;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
|
@ -32,7 +33,7 @@ import org.w3c.dom.Element;
|
|||
import org.w3c.dom.Node;
|
||||
|
||||
public class RegisterGroupsPersistance {
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
private static final String DEFAULT_ATTR_DEBUGGER_REGISTER_GROUPS_VALUE = ""; //$NON-NLS-1$
|
||||
private static final String DEFAULT_LAUNCH_CONFIGURATION_TARGET_ATTRIBUTE = ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_REGISTER_GROUPS;
|
||||
private static final String ELEMENT_REGISTER_GROUP_LIST = "registerGroups"; //$NON-NLS-1$
|
||||
private static final String ATTR_REGISTER_GROUP_MEMENTO = "memento"; //$NON-NLS-1$
|
||||
|
@ -166,7 +167,8 @@ public class RegisterGroupsPersistance {
|
|||
List<IRegisterGroupDescriptor> groups = new ArrayList<IRegisterGroupDescriptor>();
|
||||
String memento;
|
||||
|
||||
memento = fLaunchConfig.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_REGISTER_GROUPS, BLANK_STRING);
|
||||
memento = fLaunchConfig.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_REGISTER_GROUPS,
|
||||
DEFAULT_ATTR_DEBUGGER_REGISTER_GROUPS_VALUE);
|
||||
|
||||
if (memento != null && memento.length() > 0) {
|
||||
Node node = DebugPlugin.parseDocument(memento);
|
||||
|
@ -207,9 +209,19 @@ public class RegisterGroupsPersistance {
|
|||
try {
|
||||
ILaunchConfigurationWorkingCopy wc = fLaunchConfig.getWorkingCopy();
|
||||
|
||||
//if no groups present, save to a blank string, i.e. expected by CDI and handled by DSF
|
||||
wc.setAttribute(fLaunchConfigTargetAttribute, (groups.length > 0) ? getMemento(groups) : BLANK_STRING);
|
||||
wc.doSave();
|
||||
// if no groups present, save to a blank string, i.e. expected by CDI and
|
||||
// handled by DSF
|
||||
String newValue = (groups.length > 0) ? getMemento(groups) : DEFAULT_ATTR_DEBUGGER_REGISTER_GROUPS_VALUE;
|
||||
String oldValue = DEFAULT_ATTR_DEBUGGER_REGISTER_GROUPS_VALUE;
|
||||
try {
|
||||
oldValue = wc.getAttribute(fLaunchConfigTargetAttribute, DEFAULT_ATTR_DEBUGGER_REGISTER_GROUPS_VALUE);
|
||||
} catch (CoreException e) {
|
||||
// ignored, treat as default
|
||||
}
|
||||
if (!Objects.equals(oldValue, newValue)) {
|
||||
wc.setAttribute(fLaunchConfigTargetAttribute, newValue);
|
||||
wc.doSave();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
abort(e.getMessage() + ", cause: " + e.getCause(), e); //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.eclipse.cdt.dsf.debug.model;
|
|||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
|
@ -77,6 +78,7 @@ import org.w3c.dom.NodeList;
|
|||
*/
|
||||
public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBlockRetrievalExtension
|
||||
{
|
||||
private static final String DEFAULT_ATTR_DEBUGGER_MEMORY_BLOCKS_VALUE = ""; //$NON-NLS-1$
|
||||
private final String fModelId;
|
||||
private final DsfSession fSession;
|
||||
private final DsfExecutor fExecutor;
|
||||
|
@ -213,7 +215,8 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
|||
*/
|
||||
public void initialize(final IMemoryDMContext memoryCtx) {
|
||||
try {
|
||||
final String memento = fLaunchConfig.getAttribute(ATTR_DEBUGGER_MEMORY_BLOCKS, ""); //$NON-NLS-1$
|
||||
final String memento = fLaunchConfig.getAttribute(ATTR_DEBUGGER_MEMORY_BLOCKS,
|
||||
DEFAULT_ATTR_DEBUGGER_MEMORY_BLOCKS_VALUE);
|
||||
if (memento != null && memento.trim().length() != 0) {
|
||||
// Submit the runnable to install the monitors on dispatch thread.
|
||||
getExecutor().submit(new Runnable() {
|
||||
|
@ -281,11 +284,19 @@ public class DsfMemoryBlockRetrieval extends PlatformObject implements IMemoryBl
|
|||
public void saveMemoryBlocks() {
|
||||
try {
|
||||
ILaunchConfigurationWorkingCopy wc = fLaunchConfig.getWorkingCopy();
|
||||
wc.setAttribute(ATTR_DEBUGGER_MEMORY_BLOCKS, getMemento());
|
||||
wc.doSave();
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
DsfPlugin.getDefault().getLog().log(e.getStatus());
|
||||
String newValue = getMemento();
|
||||
String oldValue = DEFAULT_ATTR_DEBUGGER_MEMORY_BLOCKS_VALUE;
|
||||
try {
|
||||
oldValue = wc.getAttribute(ATTR_DEBUGGER_MEMORY_BLOCKS, DEFAULT_ATTR_DEBUGGER_MEMORY_BLOCKS_VALUE);
|
||||
} catch (CoreException e) {
|
||||
// ignored, treat as default
|
||||
}
|
||||
if (!Objects.equals(oldValue, newValue)) {
|
||||
wc.setAttribute(ATTR_DEBUGGER_MEMORY_BLOCKS, newValue);
|
||||
wc.doSave();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
DsfPlugin.getDefault().getLog().log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue