1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 235747: [registers] Allow user to edit the register groups.

Bug 235747: Move register group actions to the command framework.

Change-Id: Ife5aefc1a1609309724db01d92a35750e25def24
Signed-off-by: Alvaro Sanchez-Leon <alvsan09@gmail.com>
Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/13980
Tested-by: Hudson CI
This commit is contained in:
Alvaro Sanchez-Leon 2014-10-24 11:42:04 -04:00
parent a830f285fe
commit 3ab1678bc3
42 changed files with 4758 additions and 937 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true
Bundle-Version: 7.5.0.qualifier Bundle-Version: 7.6.0.qualifier
Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Bundle-Localization: plugin Bundle-Localization: plugin
@ -16,20 +16,28 @@ Export-Package: org.eclipse.cdt.debug.core,
org.eclipse.cdt.debug.core.disassembly, org.eclipse.cdt.debug.core.disassembly,
org.eclipse.cdt.debug.core.executables, org.eclipse.cdt.debug.core.executables,
org.eclipse.cdt.debug.core.model, org.eclipse.cdt.debug.core.model,
org.eclipse.cdt.debug.core.model.provisional;x-friends:="org.eclipse.cdt.dsf,org.eclipse.cdt.debug.ui.memory.memorybrowser,org.eclipse.cdt.dsf.gdb,org.eclipse.cdt.debug.ui.memory.traditional", org.eclipse.cdt.debug.core.model.provisional;
x-friends:="org.eclipse.cdt.dsf,
org.eclipse.cdt.debug.ui.memory.memorybrowser,
org.eclipse.cdt.dsf.gdb,
org.eclipse.cdt.debug.ui.memory.traditional",
org.eclipse.cdt.debug.core.sourcelookup, org.eclipse.cdt.debug.core.sourcelookup,
org.eclipse.cdt.debug.internal.core;x-friends:="org.eclipse.cdt.dsf.gdb,org.eclipse.cdt.dsf.gdb.ui,org.eclipse.cdt.dsf,org.eclipse.cdt.dsf.ui", org.eclipse.cdt.debug.internal.core;
x-friends:="org.eclipse.cdt.dsf.gdb,
org.eclipse.cdt.dsf.gdb.ui,
org.eclipse.cdt.dsf,
org.eclipse.cdt.dsf.ui",
org.eclipse.cdt.debug.internal.core.breakpoints;x-friends:="org.eclipse.cdt.debug.edc,org.eclipse.cdt.dsf.gdb", org.eclipse.cdt.debug.internal.core.breakpoints;x-friends:="org.eclipse.cdt.debug.edc,org.eclipse.cdt.dsf.gdb",
org.eclipse.cdt.debug.internal.core.disassembly;x-internal:=true, org.eclipse.cdt.debug.internal.core.disassembly;x-internal:=true,
org.eclipse.cdt.debug.internal.core.executables;x-internal:=true, org.eclipse.cdt.debug.internal.core.executables;x-internal:=true,
org.eclipse.cdt.debug.internal.core.model;x-internal:=true, org.eclipse.cdt.debug.internal.core.model;x-friends:="org.eclipse.cdt.dsf.ui,org.eclipse.cdt.dsf.gdb",
org.eclipse.cdt.debug.internal.core.srcfinder;x-internal:=true,
org.eclipse.cdt.debug.internal.core.sourcelookup; org.eclipse.cdt.debug.internal.core.sourcelookup;
x-friends:="org.eclipse.cdt.dsf.ui, x-friends:="org.eclipse.cdt.dsf.ui,
org.eclipse.cdt.debug.edc, org.eclipse.cdt.debug.edc,
org.eclipse.cdt.debug.gdbjtag.core, org.eclipse.cdt.debug.gdbjtag.core,
org.eclipse.cdt.dsf.gdb, org.eclipse.cdt.dsf.gdb,
org.eclipse.cdt.dsf" org.eclipse.cdt.dsf",
org.eclipse.cdt.debug.internal.core.srcfinder;x-internal:=true
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)",

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>
<version>7.5.0-SNAPSHOT</version> <version>7.6.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.debug.core</artifactId> <artifactId>org.eclipse.cdt.debug.core</artifactId>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
</project> </project>

View file

@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.commands.IDebugCommandHandler;
/**
* Handler interface to for the addRegisterGroup command
*
* @since 7.6
*/
public interface IAddRegisterGroupHandler extends IDebugCommandHandler {
}

View file

@ -0,0 +1,21 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.commands.IDebugCommandHandler;
/**
* Handler interface to for the editRegisterGroup command
* @since 7.6
*/
public interface IEditRegisterGroupHandler extends IDebugCommandHandler {
}

View file

@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.commands.IDebugCommandHandler;
/**
* Handler interface to for the removeRegisterGroups command
* @since 7.6
*/
public interface IRemoveRegisterGroupsHandler extends IDebugCommandHandler {
}

View file

@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.commands.IDebugCommandHandler;
/**
* Handler interface to for the restoreRegisterGroups command
* @since 7.6
*/
public interface IRestoreRegisterGroupsHandler extends IDebugCommandHandler {
}

View file

@ -0,0 +1,263 @@
/*******************************************************************************
* Copyright (c) 2000, 2014 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation in CRegisterManager.java and CRegisterGroup.java
* Alvaro Sanchez-Leon (Ericsson) - Integrated from files above for Bug 235747
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
import org.eclipse.cdt.debug.internal.core.model.CoreModelMessages;
import org.eclipse.cdt.debug.internal.core.model.IRegisterGroupDescriptor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.w3c.dom.Document;
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_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$
private static final String ELEMENT_GROUP = "group"; //$NON-NLS-1$
private static final String ELEMENT_REGISTER_GROUP = "registerGroup"; //$NON-NLS-1$
private static final String ATTR_REGISTER_GROUP_NAME = "name"; //$NON-NLS-1$
private static final String ATTR_REGISTER_GROUP_ENABLED = "enabled"; //$NON-NLS-1$
private static final String ELEMENT_REGISTER = "register"; //$NON-NLS-1$
private static final String ATTR_REGISTER_NAME = "name"; //$NON-NLS-1$
private static final String ATTR_REGISTER_ORIGINAL_GROUP_NAME = "originalGroupName"; //$NON-NLS-1$
private final ILaunchConfiguration fLaunchConfig;
private String fLaunchConfigTargetAttribute = DEFAULT_LAUNCH_CONFIGURATION_TARGET_ATTRIBUTE;
// Constructor
public RegisterGroupsPersistance(ILaunchConfiguration configuration) {
fLaunchConfig = configuration;
}
private class RegisterGroupDescriptor implements IRegisterGroupDescriptor {
private final String fMemento;
private final String fName;
private final boolean fEnabled;
IRegisterDescriptor[] fRegisterDescriptors = null;
public RegisterGroupDescriptor(String memento, String groupName, boolean enabled) {
fMemento = memento;
fName = groupName;
fEnabled = enabled;
}
@Override
public String getName() {
return fName;
}
@Override
public boolean isEnabled() {
return fEnabled;
}
@Override
public IRegisterDescriptor[] getChildren() throws CoreException {
if (fRegisterDescriptors == null) {
Node node = DebugPlugin.parseDocument(fMemento);
Element element = (Element) node;
List<IRegisterDescriptor> list = new ArrayList<IRegisterDescriptor>();
Node childNode = element.getFirstChild();
while (childNode != null) {
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
Element child = (Element) childNode;
if (ELEMENT_REGISTER.equals(child.getNodeName())) {
String name = child.getAttribute(ATTR_REGISTER_NAME);
String originalGroupName = child.getAttribute(ATTR_REGISTER_ORIGINAL_GROUP_NAME);
if (name == null || name.length() == 0 || originalGroupName == null
|| originalGroupName.length() == 0) {
abort(CoreModelMessages.getString("CRegisterGroup.3"), null); //$NON-NLS-1$
} else {
IRegisterDescriptor d = findDescriptor(originalGroupName, name);
if (d != null)
list.add(d);
else
CDebugCorePlugin.log(CoreModelMessages.getString("CRegisterGroup.4")); //$NON-NLS-1$
}
}
}
childNode = childNode.getNextSibling();
}
fRegisterDescriptors = list.toArray(new IRegisterDescriptor[list.size()]);
}
return fRegisterDescriptors;
}
}
class RegisterDescriptor implements IRegisterDescriptor {
private final String fGroupName;
private final String fName;
private RegisterDescriptor(String oGroupName, String rname) {
fGroupName = oGroupName;
fName = rname;
}
@Override
public String getName() {
return fName;
}
@Override
public String getGroupName() {
return fGroupName;
}
}
public void setLaunchConfigurationTargetAttribute(String launchConfigurationTargetAttribute) {
fLaunchConfigTargetAttribute = launchConfigurationTargetAttribute;
}
public String getLaunchConfigurationTargetAttribute() {
return fLaunchConfigTargetAttribute;
}
public IRegisterGroupDescriptor[] parseGroups() {
List<IRegisterGroupDescriptor> groups = new ArrayList<IRegisterGroupDescriptor>();
String memento;
try {
memento = fLaunchConfig.getAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_REGISTER_GROUPS, BLANK_STRING);
if (memento != null && memento.length() > 0) {
Node node = DebugPlugin.parseDocument(memento);
if (node.getNodeType() != Node.ELEMENT_NODE) {
abort("Unable to restore register groups - invalid memento.", null); //$NON-NLS-1$
}
Element element = (Element) node;
if (!ELEMENT_REGISTER_GROUP_LIST.equals(element.getNodeName())) {
abort("Unable to restore register groups - expecting register group list element.", null); //$NON-NLS-1$
}
Node childNode = element.getFirstChild();
while (childNode != null) {
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
Element child = (Element) childNode;
if (ELEMENT_GROUP.equals(child.getNodeName())) {
String groupMemento = child.getAttribute(ATTR_REGISTER_GROUP_MEMENTO);
//
IRegisterGroupDescriptor groupdesc = createGroupFromMemento(groupMemento);
if (groupdesc != null) {
groups.add(groupdesc);
}
}
}
childNode = childNode.getNextSibling();
}
}
} catch (CoreException e) {
e.printStackTrace();
}
return groups.toArray(new IRegisterGroupDescriptor[groups.size()]);
}
public void saveGroups(IRegisterGroupDescriptor[] groups) throws CoreException {
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();
} catch (CoreException e) {
abort(e.getMessage() + ", cause: " + e.getCause(), e); //$NON-NLS-1$
}
}
protected IRegisterDescriptor findDescriptor(String originalGroupName, String name) {
return new RegisterDescriptor(originalGroupName, name);
}
private IRegisterGroupDescriptor createGroupFromMemento(String memento) throws CoreException {
Node node = DebugPlugin.parseDocument(memento);
if (node.getNodeType() != Node.ELEMENT_NODE) {
abort(CoreModelMessages.getString("CRegisterGroup.0"), null); //$NON-NLS-1$
}
Element element = (Element) node;
if (!ELEMENT_REGISTER_GROUP.equals(element.getNodeName())) {
abort(CoreModelMessages.getString("CRegisterGroup.1"), null); //$NON-NLS-1$
}
String groupName = element.getAttribute(ATTR_REGISTER_GROUP_NAME);
if (groupName == null || groupName.length() == 0) {
abort(CoreModelMessages.getString("CRegisterGroup.2"), null); //$NON-NLS-1$
}
String e = element.getAttribute(ATTR_REGISTER_GROUP_ENABLED);
boolean enabled = Boolean.parseBoolean(e);
IRegisterGroupDescriptor group = new RegisterGroupDescriptor(memento, groupName, enabled);
return group;
}
private String getMemento(IRegisterGroupDescriptor[] groups) throws CoreException {
Document document = DebugPlugin.newDocument();
Element element = document.createElement(ELEMENT_REGISTER_GROUP_LIST);
for (IRegisterGroupDescriptor group : groups) {
Element child = document.createElement(ELEMENT_GROUP);
child.setAttribute(ATTR_REGISTER_GROUP_MEMENTO, getMemento(group));
element.appendChild(child);
}
document.appendChild(element);
return DebugPlugin.serializeDocument(document);
}
private String getMemento(IRegisterGroupDescriptor group) throws CoreException {
Document document = DebugPlugin.newDocument();
Element element = document.createElement(ELEMENT_REGISTER_GROUP);
element.setAttribute(ATTR_REGISTER_GROUP_NAME, group.getName());
element.setAttribute(ATTR_REGISTER_GROUP_ENABLED, Boolean.valueOf(group.isEnabled()).toString());
IRegisterDescriptor[] registerDescriptors = group.getChildren();
for (int i = 0; i < registerDescriptors.length; ++i) {
Element child = document.createElement(ELEMENT_REGISTER);
child.setAttribute(ATTR_REGISTER_NAME, registerDescriptors[i].getName());
child.setAttribute(ATTR_REGISTER_ORIGINAL_GROUP_NAME, registerDescriptors[i].getGroupName());
element.appendChild(child);
}
document.appendChild(element);
return DebugPlugin.serializeDocument(document);
}
private void abort(String message, Throwable exception) throws CoreException {
IStatus status = new Status(IStatus.ERROR, CDebugCorePlugin.PLUGIN_ID, IStatus.ERROR, message, exception);
throw new CoreException(status);
}
}

View file

@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson AB and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alvaro Sanchez-Leon (Ericsson) - First Implementation and API (Bug 235747)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
import org.eclipse.core.runtime.CoreException;
/**
* Describes a register Group
*/
public interface IRegisterGroupDescriptor {
/**
* @return the register group's name
*/
public String getName();
/**
* @return the enabled state
*/
public boolean isEnabled();
/**
* @return the registers associated to this group
* @throws CoreException
*/
public IRegisterDescriptor[] getChildren() throws CoreException;
}

View file

@ -142,12 +142,26 @@ ModulesDetailPaneFontDefinition.description=The text font used in the detail pan
ModulePropertiesAction.label=Properties... ModulePropertiesAction.label=Properties...
ModulePropertiesAction.tooltip=Open Module Properties Dialog ModulePropertiesAction.tooltip=Open Module Properties Dialog
RegisterGroupingCategory.description=Set of commands for Register Grouping
RegisterGroupingCategory.name=Register Grouping commands
AddRegisterGroup.description=Adds a Register Group
AddRegisterGroup.name=Add RegisterGroup
AddRegisterGroup.label=Add Register Group
AddRegisterGroupAction.label=Add Register Group AddRegisterGroupAction.label=Add Register Group
AddRegisterGroupAction.tooltip=Add Register Group AddRegisterGroupAction.tooltip=Add Register Group
RemoveRegisterGroupAction.label=Remove Register Group RemoveRegisterGroups.description=Removes one or more Register Groups
RemoveRegisterGroupAction.tooltip=Remove Register Group RemoveRegisterGroups.name=Remove Register Groups
RemoveRegisterGroups.label=Remove Register Groups
RemoveRegisterGroupsAction.label=Remove Register Groups
RemoveRegisterGroupsAction.tooltip=Remove Register Groups
EditRegisterGroup.description=Edits a Register Group
EditRegisterGroup.name=Edit Register Group
EditRegisterGroup.label=Edit Register Group
EditRegisterGroupAction.label=Edit Register Group EditRegisterGroupAction.label=Edit Register Group
EditRegisterGroupAction.tooltip=Edit Register Group EditRegisterGroupAction.tooltip=Edit Register Group
RestoreRegisterGroups.description=Restores the Default Register Groups
RestoreRegisterGroups.name=Restore Default Register Groups
RestoreRegisterGroups.label=Restore Default Register Groups
RestoredefaultRegisterGroupsAction.label=Restore Default Register Groups RestoredefaultRegisterGroupsAction.label=Restore Default Register Groups
RestoredefaultRegisterGroupsAction.tooltip=Restore Default Register Groups RestoredefaultRegisterGroupsAction.tooltip=Restore Default Register Groups

View file

@ -798,34 +798,6 @@
class="org.eclipse.cdt.debug.core.model.ICVariable"> class="org.eclipse.cdt.debug.core.model.ICVariable">
</selection> </selection>
</action> </action>
<action
class="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultRegisterGroupsActionDelegate"
helpContextId="restore_default_register_groups_action_context"
id="org.eclipse.cdt.debug.ui.restoreDefaultRegisterGroupsAction"
label="%RestoredefaultRegisterGroupsAction.label"
menubarPath="additions"
style="push"
tooltip="%RestoredefaultRegisterGroupsAction.tooltip">
<enablement>
<pluginState
id="org.eclipse.cdt.debug.ui"
value="activated"/>
</enablement>
</action>
<action
class="org.eclipse.cdt.debug.internal.ui.actions.AddRegisterGroupActionDelegate"
helpContextId="add_register_group_action_context"
id="org.eclipse.cdt.debug.ui.addRegisterGroupAction"
label="%AddRegisterGroupAction.label"
menubarPath="additions"
style="push"
tooltip="%AddRegisterGroupAction.tooltip">
<enablement>
<pluginState
id="org.eclipse.cdt.debug.ui"
value="activated"/>
</enablement>
</action>
</viewerContribution> </viewerContribution>
<objectContribution <objectContribution
objectClass="org.eclipse.cdt.debug.core.model.ICModule" objectClass="org.eclipse.cdt.debug.core.model.ICModule"
@ -868,27 +840,6 @@
</enablement> </enablement>
</action> </action>
</viewerContribution> </viewerContribution>
<objectContribution
adaptable="false"
id="org.eclipse.cdt.debug.ui.RegisterGroupActions"
objectClass="org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup">
<action
class="org.eclipse.cdt.debug.internal.ui.actions.RemoveRegisterGroupActionDelegate"
enablesFor="+"
helpContextId="remove_register_group_action_context"
id="org.eclipse.cdt.debug.ui.removeRegisterGroupAction"
label="%RemoveRegisterGroupAction.label"
menubarPath="additions"
tooltip="%RemoveRegisterGroupAction.tooltip"/>
<action
class="org.eclipse.cdt.debug.internal.ui.actions.EditRegisterGroupActionDelegate"
enablesFor="1"
helpContextId="edit_register_group_action_context"
id="org.eclipse.cdt.debug.ui.editRegisterGroupAction"
label="%EditRegisterGroupAction.label"
menubarPath="additions"
tooltip="%EditRegisterGroupAction.tooltip"/>
</objectContribution>
<viewerContribution <viewerContribution
id="org.eclipse.debug.ui.MemoryView.RenderingViewPane.popupMenu.1" id="org.eclipse.debug.ui.MemoryView.RenderingViewPane.popupMenu.1"
targetID="org.eclipse.debug.ui.MemoryView.RenderingViewPane.1"> targetID="org.eclipse.debug.ui.MemoryView.RenderingViewPane.1">
@ -1395,18 +1346,14 @@
<factory <factory
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory" class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
adaptableType="org.eclipse.cdt.internal.ui.editor.CEditor"> adaptableType="org.eclipse.cdt.internal.ui.editor.CEditor">
<adapter <adapter type="org.eclipse.debug.ui.actions.IRunToLineTarget"/>
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
</adapter>
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/> <adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/> <adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/>
</factory> </factory>
<factory <factory
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory" class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
adaptableType="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"> adaptableType="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor">
<adapter <adapter type="org.eclipse.debug.ui.actions.IRunToLineTarget"/>
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
</adapter>
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/> <adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/> <adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/>
</factory> </factory>
@ -1964,6 +1911,35 @@
</extension> </extension>
<extension <extension
point="org.eclipse.ui.commands"> point="org.eclipse.ui.commands">
<category
description="%RegisterGroupingCategory.description"
id="org.eclipse.cdt.debug.ui.category.registerGrouping"
name="%RegisterGroupingCategory.name">
</category>
<command
categoryId="org.eclipse.cdt.debug.ui.category.registerGrouping"
description="%AddRegisterGroup.description"
id="org.eclipse.cdt.debug.ui.command.addRegisterGroup"
name="%AddRegisterGroup.name">
</command>
<command
categoryId="org.eclipse.cdt.debug.ui.category.registerGrouping"
description="%EditRegisterGroup.description"
id="org.eclipse.cdt.debug.ui.command.editRegisterGroup"
name="%EditRegisterGroup.name">
</command>
<command
categoryId="org.eclipse.cdt.debug.ui.category.registerGrouping"
description="%RestoreRegisterGroups.description"
id="org.eclipse.cdt.debug.ui.command.restoreRegisterGroups"
name="%RestoreRegisterGroups.name">
</command>
<command
categoryId="org.eclipse.cdt.debug.ui.category.registerGrouping"
description="%RemoveRegisterGroups.description"
id="org.eclipse.cdt.debug.ui.command.removeRegisterGroups"
name="%RemoveRegisterGroups.name">
</command>
<category <category
description="%ReverseDebuggingCategory.description" description="%ReverseDebuggingCategory.description"
id="org.eclipse.cdt.debug.ui.category.reverseDebugging" id="org.eclipse.cdt.debug.ui.category.reverseDebugging"
@ -2072,6 +2048,76 @@
</extension> </extension>
<extension <extension
point="org.eclipse.ui.handlers"> point="org.eclipse.ui.handlers">
<handler
class="org.eclipse.cdt.debug.internal.ui.commands.AddRegisterGroupCommandHandler"
commandId="org.eclipse.cdt.debug.ui.command.addRegisterGroup">
<activeWhen>
<with variable="selection">
<iterate operator="and">
<or>
<instanceof
value="org.eclipse.cdt.debug.internal.core.model.CRegisterGroup">
</instanceof>
<instanceof
value="org.eclipse.cdt.debug.internal.core.model.CRegister">
</instanceof>
</or>
</iterate>
<count value="+">
</count>
</with>
</activeWhen>
</handler>
<handler
class="org.eclipse.cdt.debug.internal.ui.commands.EditRegisterGroupCommandHandler"
commandId="org.eclipse.cdt.debug.ui.command.editRegisterGroup">
<activeWhen>
<with variable="selection">
<iterate operator="and">
<instanceof
value="org.eclipse.cdt.debug.internal.core.model.CRegisterGroup">
</instanceof>
</iterate>
<count value="1">
</count>
</with>
</activeWhen>
</handler>
<handler
class="org.eclipse.cdt.debug.internal.ui.commands.RestoreRegisterGroupsCommandHandler"
commandId="org.eclipse.cdt.debug.ui.command.restoreRegisterGroups">
<activeWhen>
<with variable="selection">
<iterate operator="and">
<or>
<instanceof
value="org.eclipse.cdt.debug.internal.core.model.CRegisterGroup">
</instanceof>
<instanceof
value="org.eclipse.cdt.debug.internal.core.model.CRegister">
</instanceof>
</or>
</iterate>
<count value="+">
</count>
</with>
</activeWhen>
</handler>
<handler
class="org.eclipse.cdt.debug.internal.ui.commands.RemoveRegisterGroupsCommandHandler"
commandId="org.eclipse.cdt.debug.ui.command.removeRegisterGroups">
<activeWhen>
<with variable="selection">
<iterate operator="and">
<instanceof
value="org.eclipse.cdt.debug.internal.core.model.CRegisterGroup">
</instanceof>
</iterate>
<count value="+">
</count>
</with>
</activeWhen>
</handler>
<handler <handler
class="org.eclipse.cdt.debug.internal.ui.commands.ReverseToggleCommandHandler" class="org.eclipse.cdt.debug.internal.ui.commands.ReverseToggleCommandHandler"
commandId="org.eclipse.cdt.debug.ui.command.reverseToggle"> commandId="org.eclipse.cdt.debug.ui.command.reverseToggle">
@ -2279,6 +2325,48 @@
<extension <extension
point="org.eclipse.ui.menus"> point="org.eclipse.ui.menus">
<!-- Register Grouping contributions to the registers view popup -->
<menuContribution
locationURI="popup:org.eclipse.debug.ui.RegisterView?after=additions">
<command
commandId="org.eclipse.cdt.debug.ui.command.restoreRegisterGroups"
label="%RestoreRegisterGroups.label"
style="push">
<visibleWhen checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.debug.ui.RegisterView?after=additions">
<command
commandId="org.eclipse.cdt.debug.ui.command.addRegisterGroup"
label="%AddRegisterGroup.label"
style="push">
<visibleWhen checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.debug.ui.RegisterView?after=additions">
<command
commandId="org.eclipse.cdt.debug.ui.command.removeRegisterGroups"
label="%RemoveRegisterGroups.label"
style="push">
<visibleWhen checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.debug.ui.RegisterView?after=additions">
<command
commandId="org.eclipse.cdt.debug.ui.command.editRegisterGroup"
label="%EditRegisterGroup.label"
style="push">
<visibleWhen checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
<!-- Reverse debugging contributions to Debug view --> <!-- Reverse debugging contributions to Debug view -->
<menuContribution <menuContribution
locationURI="toolbar:org.eclipse.debug.ui.DebugView?after=additions"> locationURI="toolbar:org.eclipse.debug.ui.DebugView?after=additions">

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2007 QNX Software Systems and others. * Copyright (c) 2004, 2014 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Alvaro Sanchez-Leon (Ericsson) - preserve selection changes (needed by Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
@ -187,6 +188,7 @@ public abstract class AbstractViewActionDelegate extends ActionDelegate implemen
*/ */
@Override @Override
public void selectionChanged( IAction action, ISelection selection ) { public void selectionChanged( IAction action, ISelection selection ) {
setSelection( selection );
update(); update();
} }

View file

@ -11,6 +11,7 @@
# Marc Khouzam (Ericsson) - Added dynamic printf support (400628) # Marc Khouzam (Ericsson) - Added dynamic printf support (400628)
# Simon Marchi (Ericsson) - Modified error messages in CastToArrayActionDelegate (437182) # Simon Marchi (Ericsson) - Modified error messages in CastToArrayActionDelegate (437182)
# Marc Dumais (Ericsson) - Bug 437692 # Marc Dumais (Ericsson) - Bug 437692
# Alvaro Sanchez-Leon (Ericsson) - Allow user to edit the register groups (Bug 235747)
############################################################################### ###############################################################################
LoadSymbolsActionDelegate.Unable_to_load_symbols_of_shared_library_1=Unable to load symbols of shared library. LoadSymbolsActionDelegate.Unable_to_load_symbols_of_shared_library_1=Unable to load symbols of shared library.
@ -119,9 +120,10 @@ ToggleDetailPaneAction.4=Place the Detail Pane on the Right of the Main Tree Vie
ToggleDetailPaneAction.5=Place the Detail Pane on the Right of the Main Tree View ToggleDetailPaneAction.5=Place the Detail Pane on the Right of the Main Tree View
ToggleDetailPaneAction.6=Hide the Detail Pane so that only the Main Tree View is Visible ToggleDetailPaneAction.6=Hide the Detail Pane so that only the Main Tree View is Visible
ToggleDetailPaneAction.7=Hide the Detail Pane so that only the Main Tree View is Visible ToggleDetailPaneAction.7=Hide the Detail Pane so that only the Main Tree View is Visible
AddRegisterGroupActionDelegate.0=Error RegisterGroupActionDelegate.0=Error
AddRegisterGroupActionDelegate.1=Error(s) occurred adding register group. AddRegisterGroupActionDelegate.1=Error(s) occurred adding register group.
EditRegisterGroupActionDelegate.0=Unable to edit register group. EditRegisterGroupActionDelegate.0=Unable to edit register group.
RemoveRegisterGroupsActionDelegate.0=Unable to remove register group(s).
AddEventBreakpointActionDelegate.0=Error adding Event Breakpoint AddEventBreakpointActionDelegate.0=Error adding Event Breakpoint
AddEventBreakpointActionDelegate.2=Action is not supported by installed debuggers AddEventBreakpointActionDelegate.2=Action is not supported by installed debuggers
ToggleCBreakpointsTargetFactory.CBreakpointDescription=Standard C/C++ breakpoint type. ToggleCBreakpointsTargetFactory.CBreakpointDescription=Standard C/C++ breakpoint type.

View file

@ -1,91 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
/**
* A delegate for the "Add register group" action.
*/
public class AddRegisterGroupActionDelegate extends AbstractViewActionDelegate {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogTitle()
*/
@Override
protected String getErrorDialogTitle() {
return ActionMessages.getString( "AddRegisterGroupActionDelegate.0" ); //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#getErrorDialogMessage()
*/
@Override
protected String getErrorDialogMessage() {
return ActionMessages.getString( "AddRegisterGroupActionDelegate.1" ); //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doAction()
*/
@Override
protected void doAction() throws DebugException {
RegisterGroupDialog dialog = new RegisterGroupDialog( getView().getSite().getShell(), getDebugTarget().getRegisterDescriptors() );
if ( dialog.open() == Window.OK ) {
getDebugTarget().addRegisterGroup( dialog.getName(), dialog.getDescriptors() );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#update()
*/
@Override
protected void update() {
IAction action = getAction();
if ( action != null ) {
ICDebugTarget target = getDebugTarget();
action.setEnabled( ( target != null ) ? target.isSuspended() : false );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#doHandleDebugEvent(org.eclipse.debug.core.DebugEvent)
*/
@Override
protected void doHandleDebugEvent( DebugEvent event ) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#init(org.eclipse.jface.action.IAction)
*/
@Override
public void init( IAction action ) {
super.init( action );
Object element = DebugUITools.getDebugContext();
setSelection( (element != null) ? new StructuredSelection( element ) : new StructuredSelection() );
update();
}
private ICDebugTarget getDebugTarget() {
Object element = getSelection().getFirstElement();
if ( element instanceof IDebugElement ) {
return (ICDebugTarget)((IDebugElement)element).getDebugTarget().getAdapter( ICDebugTarget.class );
}
return null;
}
}

View file

@ -1,82 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup;
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionDelegate;
public class EditRegisterGroupActionDelegate extends ActionDelegate implements IObjectActionDelegate {
private IPersistableRegisterGroup fSelection;
/* (non-Javadoc)
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged( IAction action, ISelection selection ) {
if ( selection instanceof IStructuredSelection ) {
IStructuredSelection ss = (IStructuredSelection)selection;
if ( !ss.isEmpty() ) {
Object s = ss.getFirstElement();
if ( s instanceof IPersistableRegisterGroup ) {
fSelection = (IPersistableRegisterGroup)s;
}
}
}
}
private IPersistableRegisterGroup getRegisterGroup() {
return fSelection;
}
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run( IAction action ) {
IPersistableRegisterGroup group = getRegisterGroup();
IRegisterDescriptor[] all;
try {
all = ((CDebugTarget)group.getDebugTarget()).getRegisterDescriptors();
RegisterGroupDialog dialog = new RegisterGroupDialog( Display.getCurrent().getActiveShell(), group.getName(), all, group.getRegisterDescriptors() );
if ( dialog.open() == Window.OK ) {
IDebugTarget target = group.getDebugTarget();
if ( target instanceof ICDebugTarget ) {
((ICDebugTarget)target).modifyRegisterGroup( group, dialog.getDescriptors() );
}
}
}
catch( DebugException e ) {
CDebugUIPlugin.errorDialog( ActionMessages.getString( "EditRegisterGroupActionDelegate.0" ), e.getStatus() ); //$NON-NLS-1$
}
}
}

View file

@ -1,87 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IRegisterGroup;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionDelegate;
/**
* The "Remove Register Group" action.
*/
public class RemoveRegisterGroupActionDelegate extends ActionDelegate implements IObjectActionDelegate {
private IRegisterGroup[] fRegisterGroups;
/**
* Constructor for RemoveRegisterGroupActionDelegate.
*/
public RemoveRegisterGroupActionDelegate() {
super();
setRegisterGroups( new IRegisterGroup[0] );
}
/* (non-Javadoc)
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged( IAction action, ISelection selection ) {
ArrayList list = new ArrayList();
if ( selection instanceof IStructuredSelection ) {
IStructuredSelection ss = (IStructuredSelection)selection;
Iterator it = ss.iterator();
while( it.hasNext() ) {
Object o = it.next();
if ( o instanceof IRegisterGroup ) {
list.add( o );
}
}
}
setRegisterGroups( (IRegisterGroup[])list.toArray( new IRegisterGroup[list.size()] ) );
}
protected IRegisterGroup[] getRegisterGroups() {
return fRegisterGroups;
}
protected void setRegisterGroups( IRegisterGroup[] registerGroups ) {
fRegisterGroups = registerGroups;
}
/* (non-Javadoc)
* @see org.eclipse.ui.actions.ActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run( IAction action ) {
IRegisterGroup[] groups = getRegisterGroups();
if ( groups.length > 0 ) {
IDebugTarget target = groups[0].getDebugTarget();
if ( target instanceof ICDebugTarget ) {
((ICDebugTarget)target).removeRegisterGroups( groups );
}
}
}
}

View file

@ -1,70 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.StructuredSelection;
public class RestoreDefaultRegisterGroupsActionDelegate extends AbstractViewActionDelegate {
@Override
protected String getErrorDialogTitle() {
return ActionMessages.getString( "RestoreDefaultRegisterGroupsActionDelegate.0" ); //$NON-NLS-1$
}
@Override
protected String getErrorDialogMessage() {
return ActionMessages.getString( "RestoreDefaultRegisterGroupsActionDelegate.1" ); //$NON-NLS-1$
}
@Override
protected void doAction() throws DebugException {
getDebugTarget().restoreDefaultRegisterGroups();
}
@Override
protected void update() {
IAction action = getAction();
if ( action != null ) {
ICDebugTarget target = getDebugTarget();
action.setEnabled( ( target != null ) ? target.isSuspended() : false );
}
}
@Override
protected void doHandleDebugEvent( DebugEvent event ) {
}
private ICDebugTarget getDebugTarget() {
Object element = getSelection().getFirstElement();
if ( element instanceof IDebugElement ) {
return (ICDebugTarget)((IDebugElement)element).getDebugTarget().getAdapter( ICDebugTarget.class );
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractViewActionDelegate#init(org.eclipse.jface.action.IAction)
*/
@Override
public void init( IAction action ) {
super.init( action );
Object element = DebugUITools.getDebugContext();
setSelection( (element != null) ? new StructuredSelection( element ) : new StructuredSelection() );
update();
}
}

View file

@ -0,0 +1,169 @@
/*******************************************************************************
* Copyright (c) 2004, 2014 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Alvaro Sanchez-Leon (Ericsson) - Support Register Groups (Bug 235747)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.commands;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup;
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.debug.internal.ui.actions.RegisterGroupDialog;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IRegisterGroup;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
public abstract class AbstractRegisterGroupCommandHandler extends AbstractHandler {
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.IRegisterGroupActionsTarget#addRegisterGroup(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.IStructuredSelection)
*/
public void addRegisterGroup(IStructuredSelection selection) {
ICDebugTarget t = getDebugTarget(selection);
if (t != null) {
// Using Debug model
try {
IRegisterDescriptor[] registers = t.getRegisterDescriptors();
RegisterGroupDialog dialog = new RegisterGroupDialog(Display.getCurrent().getActiveShell(), registers);
if (dialog.open() == Window.OK) {
t.addRegisterGroup(dialog.getName(), dialog.getDescriptors());
}
} catch (DebugException e) {
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.IRegisterGroupActionsTarget#canAddRegisterGroup(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.IStructuredSelection)
*/
public boolean canAddRegisterGroup(IStructuredSelection selection) {
ICDebugTarget target = getDebugTarget(selection);
return (target != null) ? target.isSuspended() : false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.IRegisterGroupActionsTarget#editRegisterGroup(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.IStructuredSelection)
*/
public void editRegisterGroup(IStructuredSelection selection) {
IPersistableRegisterGroup group = getRegisterGroup(selection);
if (group == null) {
return;
}
IRegisterDescriptor[] all;
try {
all = ((CDebugTarget) group.getDebugTarget()).getRegisterDescriptors();
RegisterGroupDialog dialog = new RegisterGroupDialog(Display.getCurrent().getActiveShell(),
group.getName(), all, group.getRegisterDescriptors());
if (dialog.open() == Window.OK) {
IDebugTarget target = group.getDebugTarget();
if (target instanceof ICDebugTarget) {
((ICDebugTarget) target).modifyRegisterGroup(group, dialog.getDescriptors());
}
}
} catch (DebugException e) {
CDebugUIPlugin.errorDialog(ActionMessages.getString("EditRegisterGroupActionDelegate.0"), e.getStatus()); //$NON-NLS-1$
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.IRegisterGroupActionsTarget#canEditRegisterGroup(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.IStructuredSelection)
*/
public boolean canEditRegisterGroup(IStructuredSelection selection) {
IPersistableRegisterGroup group = getRegisterGroup(selection);
return (group != null);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.IRegisterGroupActionsTarget#removeRegisterGroups(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.IStructuredSelection)
*/
public void removeRegisterGroups(IStructuredSelection selection) {
IRegisterGroup[] groups = getRegisterGroups(selection);
if (groups.length > 0) {
IDebugTarget target = groups[0].getDebugTarget();
if (target instanceof ICDebugTarget) {
((ICDebugTarget) target).removeRegisterGroups(groups);
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.IRegisterGroupActionsTarget#canRemoveRegisterGroups(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.IStructuredSelection)
*/
public boolean canRemoveRegisterGroups(IStructuredSelection selection) {
IRegisterGroup[] groups = getRegisterGroups(selection);
if (groups.length > 0) {
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.IRegisterGroupActionsTarget#restoreDefaultGroups(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.IStructuredSelection)
*/
public void restoreDefaultGroups(IStructuredSelection selection) {
getDebugTarget(selection).restoreDefaultRegisterGroups();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.ui.actions.IRegisterGroupActionsTarget#canRestoreDefaultGroups(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.IStructuredSelection)
*/
public boolean canRestoreDefaultGroups(IStructuredSelection selection) {
ICDebugTarget target = getDebugTarget(selection);
return (target != null) ? target.isSuspended() : false;
}
private ICDebugTarget getDebugTarget(IStructuredSelection selection) {
Object element = selection.getFirstElement();
if (element instanceof IDebugElement) {
return (ICDebugTarget) ((IDebugElement) element).getDebugTarget().getAdapter(ICDebugTarget.class);
}
return null;
}
private IPersistableRegisterGroup getRegisterGroup(IStructuredSelection ss) {
IPersistableRegisterGroup selectedGroup = null;
if (!ss.isEmpty()) {
Object s = ss.getFirstElement();
if (s instanceof IPersistableRegisterGroup) {
selectedGroup = (IPersistableRegisterGroup) s;
}
}
return selectedGroup;
}
private IRegisterGroup[] getRegisterGroups(IStructuredSelection ss) {
ArrayList<IRegisterGroup> list = new ArrayList<IRegisterGroup>();
for (Iterator<?> iterator = ss.iterator(); iterator.hasNext();) {
Object selection = iterator.next();
if (selection instanceof IRegisterGroup) {
list.add((IRegisterGroup) selection);
}
}
return list.toArray(new IRegisterGroup[list.size()]);
}
}

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.commands;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command handler to trigger an AddRegisterGroup operation
*/
public class AddRegisterGroupCommandHandler extends AbstractRegisterGroupCommandHandler {
public void setEnabled(Object evaluationContext) {
boolean state = false;
if (evaluationContext instanceof IEvaluationContext) {
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
if (s instanceof IStructuredSelection) {
state = canAddRegisterGroup((IStructuredSelection)s);
}
}
setBaseEnabled(state);
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
addRegisterGroup((IStructuredSelection)selection);
}
return null;
}
}

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.commands;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command handler to trigger an AddRegisterGroup operation
*/
public class EditRegisterGroupCommandHandler extends AbstractRegisterGroupCommandHandler {
public void setEnabled(Object evaluationContext) {
boolean state = false;
if (evaluationContext instanceof IEvaluationContext) {
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
if (s instanceof IStructuredSelection) {
state = canEditRegisterGroup((IStructuredSelection)s);
}
}
setBaseEnabled(state);
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
editRegisterGroup((IStructuredSelection)selection);
}
return null;
}
}

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.commands;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command handler to trigger a RemoveRegisterGroups operation
*/
public class RemoveRegisterGroupsCommandHandler extends AbstractRegisterGroupCommandHandler {
public void setEnabled(Object evaluationContext) {
boolean state = false;
if (evaluationContext instanceof IEvaluationContext) {
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
if (s instanceof IStructuredSelection) {
state = canRemoveRegisterGroups((IStructuredSelection)s);
}
}
setBaseEnabled(state);
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
removeRegisterGroups((IStructuredSelection)selection);
}
return null;
}
}

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.commands;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command handler to trigger an AddRegisterGroup operation
*/
public class RestoreRegisterGroupsCommandHandler extends AbstractRegisterGroupCommandHandler {
public void setEnabled(Object evaluationContext) {
boolean state = false;
if (evaluationContext instanceof IEvaluationContext) {
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
if (s instanceof IStructuredSelection) {
state = canRestoreDefaultGroups((IStructuredSelection)s);
}
}
setBaseEnabled(state);
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
restoreDefaultGroups((IStructuredSelection)selection);
}
return null;
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Ericsson and others. * Copyright (c) 2012, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Marc Khouzam (Ericsson) - initial API and implementation * Marc Khouzam (Ericsson) - initial API and implementation
* Grzegorz Kuligowski - Cannot cast to type that contain commas (bug 393474) * Grzegorz Kuligowski - Cannot cast to type that contain commas (bug 393474)
* Marc Khouzam (Ericsson) - Support for glob-expressions for local variables (bug 394408) * Marc Khouzam (Ericsson) - Support for glob-expressions for local variables (bug 394408)
* Alvaro Sanchez-Leon (Ericsson AB) - Allow user to edit register groups (Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service; package org.eclipse.cdt.dsf.gdb.service;
@ -37,9 +38,9 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions;
import org.eclipse.cdt.dsf.debug.service.IExpressions2; import org.eclipse.cdt.dsf.debug.service.IExpressions2;
import org.eclipse.cdt.dsf.debug.service.IExpressions3; import org.eclipse.cdt.dsf.debug.service.IExpressions3;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues; import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
import org.eclipse.cdt.dsf.debug.service.IRegisters;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext; import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext; import org.eclipse.cdt.dsf.debug.service.IRegisters2;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack; 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.IFrameDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext;
@ -781,41 +782,38 @@ public class GDBPatternMatchingExpressions extends AbstractDsfService implements
* @param rm RequestMonitor that will contain the unsorted matches. * @param rm RequestMonitor that will contain the unsorted matches.
*/ */
protected void matchRegisters(final IExpressionGroupDMContext globDmc, final DataRequestMonitor<List<IExpressionDMContext>> rm) { protected void matchRegisters(final IExpressionGroupDMContext globDmc, final DataRequestMonitor<List<IExpressionDMContext>> rm) {
final IRegisters registerService = getServicesTracker().getService(IRegisters.class); final IRegisters2 registerService = getServicesTracker().getService(IRegisters2.class);
if (registerService == null) { if (registerService == null) {
rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Register service unavailable", null)); //$NON-NLS-1$ rm.done(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Register service unavailable", null)); //$NON-NLS-1$
return; return;
} }
registerService.getRegisterGroups(globDmc, new ImmediateDataRequestMonitor<IRegisterGroupDMContext[]>(rm) { final IContainerDMContext contDmc = DMContexts.getAncestorOfType(globDmc, IContainerDMContext.class);
@Override
protected void handleSuccess() {
registerService.getRegisters(
new CompositeDMContext(new IDMContext[] { getData()[0], globDmc } ),
new ImmediateDataRequestMonitor<IRegisterDMContext[]>(rm) {
@Override
protected void handleSuccess() {
assert getData() instanceof MIRegisterDMC[];
ArrayList<IExpressionDMContext> matches = new ArrayList<IExpressionDMContext>();
String fullExpr = globDmc.getExpression().trim(); registerService.getRegisters(
if (fullExpr.startsWith(GLOB_EXPRESSION_PREFIX)) { new CompositeDMContext(new IDMContext[] { contDmc, globDmc } ),
// Strip the leading '=' and any extra spaces new ImmediateDataRequestMonitor<IRegisterDMContext[]>(rm) {
fullExpr = fullExpr.substring(1).trim(); @Override
} protected void handleSuccess() {
assert getData() instanceof MIRegisterDMC[];
ArrayList<IExpressionDMContext> matches = new ArrayList<IExpressionDMContext>();
for (MIRegisterDMC register : (MIRegisterDMC[])getData()) { String fullExpr = globDmc.getExpression().trim();
String potentialMatch = REGISTER_PREFIX + register.getName(); if (fullExpr.startsWith(GLOB_EXPRESSION_PREFIX)) {
if (globMatches(fullExpr, potentialMatch)) { // Strip the leading '=' and any extra spaces
matches.add(createExpression(globDmc, potentialMatch)); fullExpr = fullExpr.substring(1).trim();
} }
}
rm.done(matches); for (MIRegisterDMC register : (MIRegisterDMC[])getData()) {
String potentialMatch = REGISTER_PREFIX + register.getName();
if (globMatches(fullExpr, potentialMatch)) {
matches.add(createExpression(globDmc, potentialMatch));
} }
}); }
}
}); rm.done(matches);
}
});
} }
/** /**

View file

@ -17,6 +17,7 @@
* William Riley (Renesas) - Support for GDB 7.3 disassembly service (Bug 357270) * William Riley (Renesas) - Support for GDB 7.3 disassembly service (Bug 357270)
* Marc Khouzam (Ericsson) - Support for GDB 7.4 processes service (Bug 389945) * Marc Khouzam (Ericsson) - Support for GDB 7.4 processes service (Bug 389945)
* Marc Khouzam (Ericsson) - Support dynamic printf in bp service 7.5 (Bug 400628) * Marc Khouzam (Ericsson) - Support dynamic printf in bp service 7.5 (Bug 400628)
* Alvaro Sanchez-Leon (Ericsson) - Allow user to edit the register groups (Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service; package org.eclipse.cdt.dsf.gdb.service;
@ -48,7 +49,6 @@ import org.eclipse.cdt.dsf.mi.service.MIBreakpointsSynchronizer;
import org.eclipse.cdt.dsf.mi.service.MIDisassembly; import org.eclipse.cdt.dsf.mi.service.MIDisassembly;
import org.eclipse.cdt.dsf.mi.service.MIExpressions; import org.eclipse.cdt.dsf.mi.service.MIExpressions;
import org.eclipse.cdt.dsf.mi.service.MIModules; import org.eclipse.cdt.dsf.mi.service.MIModules;
import org.eclipse.cdt.dsf.mi.service.MIRegisters;
import org.eclipse.cdt.dsf.mi.service.MIStack; import org.eclipse.cdt.dsf.mi.service.MIStack;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
@ -231,7 +231,7 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
@Override @Override
protected IRegisters createRegistersService(DsfSession session) { protected IRegisters createRegistersService(DsfSession session) {
return new MIRegisters(session); return new GDBRegisters(session);
} }
@Override @Override

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012, 2013 Ericsson and others. * Copyright (c) 2012, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation * Marc Khouzam (Ericsson) - initial API and implementation
* Alvaro Sanchez-Leon (Ericsson) - Bug 235747
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service; package org.eclipse.cdt.dsf.gdb.service;
@ -25,6 +26,9 @@ class Messages extends NLS {
public static String UniqueMatch; public static String UniqueMatch;
public static String UniqueMatches; public static String UniqueMatches;
public static String ErrorNotSupported; public static String ErrorNotSupported;
public static String RegisterGroup_name_reserved;
public static String RegisterGroup_name_used;
public static String RegisterGroup_invalid_number_of_registers;
static { static {
// initialize resource bundle // initialize resource bundle

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2012 Ericsson and others. # Copyright (c) 2012, 2014 Ericsson and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
# #
# Contributors: # Contributors:
# Marc Khouzam (Ericsson) - initial API and implementation # Marc Khouzam (Ericsson) - initial API and implementation
# Alvaro Sanchez-Leon (Ericsson) - Support Register Groups (Bug 235747)
############################################################################### ###############################################################################
Tracing_not_supported_error=Tracing not supported Tracing_not_supported_error=Tracing not supported
@ -17,3 +18,6 @@ NoMatches=No matches
UniqueMatch={0} unique match UniqueMatch={0} unique match
UniqueMatches={0} unique matches UniqueMatches={0} unique matches
ErrorNotSupported=Operation not supported with this GDB version ErrorNotSupported=Operation not supported with this GDB version
RegisterGroup_name_reserved=The group name "{0}" is reserved
RegisterGroup_name_used=The group name "{0}" is already in use
RegisterGroup_invalid_number_of_registers=A minimum of one register is needed for a Register Group

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems and others. * Copyright (c) 2006, 2014 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,6 +11,7 @@
* Roland Grunberg (RedHat) - Refresh all registers once one is changed (Bug 400840) * Roland Grunberg (RedHat) - Refresh all registers once one is changed (Bug 400840)
* Alvaro Sanchez-Leon (Ericsson) - Make Registers View specific to a frame (Bug 323552) * Alvaro Sanchez-Leon (Ericsson) - Make Registers View specific to a frame (Bug 323552)
* Alvaro Sanchez-Leon (Ericsson) - Register view does not refresh register names per process (Bug 418176) * Alvaro Sanchez-Leon (Ericsson) - Register view does not refresh register names per process (Bug 418176)
* Alvaro Sanchez-Leon (Ericsson) - Allow user to edit the register groups (Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.mi.service; package org.eclipse.cdt.dsf.mi.service;
@ -66,7 +67,18 @@ import org.osgi.framework.BundleContext;
*/ */
public class MIRegisters extends AbstractDsfService implements IRegisters, ICachingService { public class MIRegisters extends AbstractDsfService implements IRegisters, ICachingService {
private static final String BLANK_STRING = ""; //$NON-NLS-1$ /**
* @since 4.6
*/
protected static final String BLANK_STRING = ""; //$NON-NLS-1$
/**
* @since 4.6
*/
protected static final String ROOT_GROUP_NAME = Messages.MIRegisters_General_Registers;
/**
* @since 4.6
*/
protected static final String ROOT_GROUP_DESCRIPTION = Messages.MIRegisters_General_Registers_description;
/* /*
* Support class used to construct Register Group DMCs. * Support class used to construct Register Group DMCs.
*/ */
@ -83,6 +95,12 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
public int getGroupNo() { return fGroupNo; } public int getGroupNo() { return fGroupNo; }
public String getName() { return fGroupName; } public String getName() { return fGroupName; }
/**
* @since 4.6
*/
public void setName(String groupName) {
fGroupName = groupName;
}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
@ -93,7 +111,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
@Override @Override
public int hashCode() { return super.baseHashCode() ^ fGroupNo; } public int hashCode() { return super.baseHashCode() ^ fGroupNo; }
@Override @Override
public String toString() { return baseToString() + ".group[" + fGroupNo + "]"; } //$NON-NLS-1$ //$NON-NLS-2$ public String toString() { return baseToString() + ".group[" + fGroupNo + "," + fGroupName + "]"; } //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} }
/* /*
@ -125,20 +143,20 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
} }
/** /**
* This Register context is associated to two parent contexts. A stack frame context (IFrameDMContext), and a register group * This Register context is associated to two parent contexts. A stack frame context (IFrameDMContext), and a
* context (MIRegisterGroupDMC). When the scenario requires to build a register contexts from the selection of a thread, then the top * register group context (MIRegisterGroupDMC). When the scenario requires to build a register contexts from the
* frame shall be resolved and be provided in this constructor. * selection of a thread, then the top frame shall be resolved and be provided in this constructor.
* *
* The frame context is necessary to resolve the register's data e.g. value * The frame context is necessary to resolve the register's data e.g. value
* *
* @since 4.3 * @since 4.3
*/ */
public MIRegisterDMC(MIRegisters service, MIRegisterGroupDMC group, IFrameDMContext frameDmc, int regNo, String regName) { public MIRegisterDMC(MIRegisters service, MIRegisterGroupDMC group, IFrameDMContext frameDmc, int regNo,
super(service.getSession().getId(), String regName) {
new IDMContext[] { frameDmc, group }); super(service.getSession().getId(), new IDMContext[] { frameDmc, group });
fRegNo = regNo; fRegNo = regNo;
fRegName = regName; fRegName = regName;
} }
public int getRegNo() { return fRegNo; } public int getRegNo() { return fRegNo; }
public String getName() { return fRegName; } public String getName() { return fRegName; }
@ -162,7 +180,10 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
private final IRegisterDMContext fRegisterDmc; private final IRegisterDMContext fRegisterDmc;
RegisterChangedDMEvent(IRegisterDMContext registerDMC) { /**
* @since 4.6
*/
public RegisterChangedDMEvent(IRegisterDMContext registerDMC) {
fRegisterDmc = registerDMC; fRegisterDmc = registerDMC;
} }
@ -172,14 +193,33 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
} }
} }
/**
* Indicates a change in the list of Register groups e.g. after addition and removal
* @since 4.6
*/
public static class GroupsChangedDMEvent implements IRegisters.IGroupsChangedDMEvent {
private final IContainerDMContext fGroupContainerDmc;
public GroupsChangedDMEvent(IContainerDMContext containerDMC) {
fGroupContainerDmc = containerDMC;
}
@Override
public IContainerDMContext getDMContext() {
return fGroupContainerDmc;
}
}
/* /*
* Internal control variables. * Internal control variables.
*/ */
private CommandFactory fCommandFactory; private CommandFactory fCommandFactory;
//One Group per container process //One Group per container process
private final Map<IContainerDMContext, MIRegisterGroupDMC> fContainerToGroupMap = new HashMap<IContainerDMContext, MIRegisterGroupDMC>(); private final Map<IContainerDMContext, MIRegisterGroupDMC> fContainerToGroupMap = new HashMap<IContainerDMContext, MIRegisterGroupDMC>();
private CommandCache fRegisterNameCache; // Cache for holding the Register Names in the single Group private CommandCache fRegisterNameCache; // Cache for holding the Register Names in the single Group
private CommandCache fRegisterValueCache; // Cache for holding the Register Values private CommandCache fRegisterValueCache; // Cache for holding the Register Values
@ -267,13 +307,13 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
public void getRegisterGroupData(IRegisterGroupDMContext regGroupDmc, DataRequestMonitor<IRegisterGroupDMData> rm) { public void getRegisterGroupData(IRegisterGroupDMContext regGroupDmc, DataRequestMonitor<IRegisterGroupDMData> rm) {
/** /**
* For the GDB GDBMI implementation there is only on group. The GPR and FPU registers are grouped into * For the GDB GDBMI implementation there is only on group. The GPR and FPU registers are grouped into
* one set. We are going to hard wire this set as the "General Registers". * one set. We are going to hard wire this set as the value of ROOT_GROUP_NAME.
*/ */
class RegisterGroupData implements IRegisterGroupDMData { class RegisterGroupData implements IRegisterGroupDMData {
@Override @Override
public String getName() { return "General Registers"; } //$NON-NLS-1$ public String getName() { return ROOT_GROUP_NAME; }
@Override @Override
public String getDescription() { return "General Purpose and FPU Register Group"; } //$NON-NLS-1$ public String getDescription() { return ROOT_GROUP_DESCRIPTION; }
} }
rm.setData( new RegisterGroupData() ) ; rm.setData( new RegisterGroupData() ) ;
@ -387,7 +427,10 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
}); });
} }
static class RegisterData implements IRegisterDMData { /**
* @since 4.6
*/
protected static class RegisterData implements IRegisterDMData {
final private String fRegName; final private String fRegName;
final private String fRegDesc; final private String fRegDesc;
@ -487,14 +530,18 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
fRegisterValueCache.reset(); fRegisterValueCache.reset();
} }
private void generateRegisterChangedEvent(final IRegisterDMContext dmc ) { /**
* @since 4.6
*/
protected void generateRegisterChangedEvent(IRegisterDMContext dmc ) {
getSession().dispatchEvent(new RegisterChangedDMEvent(dmc), getProperties()); getSession().dispatchEvent(new RegisterChangedDMEvent(dmc), getProperties());
// Temporary fix for Bug 400840 // Fix for Bug 400840
// When one register is modified, it could affect other registers. // When one register is modified, it could affect other registers.
// To properly reflect that, we send a change for all registers. // To properly reflect that, we send a change for all registers.
// We cheat since we know there is currently only one group. Once we handle // We cheat by pretending the group has changed, since we know there is
// more groups, this may not work properly. // only one group.
// This method can be extended by group managers to propagate the event as needed
final IRegisterGroupDMContext groupDmc = DMContexts.getAncestorOfType(dmc, IRegisterGroupDMContext.class); final IRegisterGroupDMContext groupDmc = DMContexts.getAncestorOfType(dmc, IRegisterGroupDMContext.class);
if (groupDmc != null) { if (groupDmc != null) {
IRegistersChangedDMEvent event = new IRegistersChangedDMEvent() { IRegistersChangedDMEvent event = new IRegistersChangedDMEvent() {
@ -505,7 +552,6 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
}; };
getSession().dispatchEvent(event, getProperties()); getSession().dispatchEvent(event, getProperties());
} }
} }
/* /*
@ -524,15 +570,16 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
} }
//Bug 418176 //Bug 418176
//Only one group per Process (container) is supported for the time being //Only one group per Process (container) is supported in the implementation of this class
MIRegisterGroupDMC registerGroup = fContainerToGroupMap.get(contDmc); MIRegisterGroupDMC registerGroup = fContainerToGroupMap.get(contDmc);
if (registerGroup == null) { if (registerGroup == null) {
registerGroup = new MIRegisterGroupDMC( this , contDmc, 0 , "General Registers" ) ; //$NON-NLS-1$ registerGroup = new MIRegisterGroupDMC(this, contDmc, 0, ROOT_GROUP_NAME);
fContainerToGroupMap.put(contDmc, registerGroup); fContainerToGroupMap.put(contDmc, registerGroup);
} }
MIRegisterGroupDMC[] groupDMCs = new MIRegisterGroupDMC[] { registerGroup }; MIRegisterGroupDMC[] groupDMCs = new MIRegisterGroupDMC[] { registerGroup };
rm.setData(groupDMCs) ; rm.setData(groupDMCs) ;
rm.done() ; rm.done() ;
} }
@ -642,48 +689,35 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach
* @see org.eclipse.cdt.dsf.debug.service.IRegisters#writeRegister(org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext, java.lang.String, java.lang.String, org.eclipse.cdt.dsf.concurrent.RequestMonitor) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#writeRegister(org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext, java.lang.String, java.lang.String, org.eclipse.cdt.dsf.concurrent.RequestMonitor)
*/ */
@Override @Override
public void writeRegister(IRegisterDMContext regCtx, final String regValue, final String formatId, final RequestMonitor rm) { public void writeRegister(IRegisterDMContext regCtx, final String regValue, final String formatId,
MIRegisterGroupDMC grpDmc = DMContexts.getAncestorOfType(regCtx, MIRegisterGroupDMC.class); final RequestMonitor rm) {
if ( grpDmc == null ) {
rm.setStatus( new Status( IStatus.ERROR , GdbPlugin.PLUGIN_ID , INVALID_HANDLE , "RegisterGroup context not found" , null ) ) ; //$NON-NLS-1$
rm.done();
return;
}
final MIRegisterDMC regDmc = (MIRegisterDMC)regCtx; assert(regCtx instanceof MIRegisterDMC);
// There is only one group and its number must be 0. final MIRegisterDMC regDmc = (MIRegisterDMC) regCtx;
if ( grpDmc.getGroupNo() == 0 ) {
final IExpressions exprService = getServicesTracker().getService(IExpressions.class);
String regName = regDmc.getName();
final IExpressionDMContext exprCtxt = exprService.createExpression(regCtx, "$" + regName); //$NON-NLS-1$
final FormattedValueDMContext valueDmc = exprService.getFormattedValueContext(exprCtxt, formatId); final IExpressions exprService = getServicesTracker().getService(IExpressions.class);
exprService.getFormattedExpressionValue( String regName = regDmc.getName();
valueDmc, final IExpressionDMContext exprCtxt = exprService.createExpression(regCtx, "$" + regName); //$NON-NLS-1$
new DataRequestMonitor<FormattedValueDMData>(getExecutor(), rm) {
@Override final FormattedValueDMContext valueDmc = exprService.getFormattedValueContext(exprCtxt, formatId);
protected void handleSuccess() { exprService.getFormattedExpressionValue(valueDmc, new DataRequestMonitor<FormattedValueDMData>(getExecutor(), rm) {
if(! regValue.equals(getData().getFormattedValue()) || ! valueDmc.getFormatID().equals(formatId)){ @Override
exprService.writeExpression(exprCtxt, regValue, formatId, new DataRequestMonitor<MIInfo>(getExecutor(), rm) { protected void handleSuccess() {
@Override if (!regValue.equals(getData().getFormattedValue()) || !valueDmc.getFormatID().equals(formatId)) {
protected void handleSuccess() { exprService.writeExpression(exprCtxt, regValue, formatId, new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
generateRegisterChangedEvent(regDmc); @Override
rm.done(); protected void handleSuccess() {
} generateRegisterChangedEvent(regDmc);
}); rm.done();
}//if }
else { });
rm.done(); }// if
} else {
}//handleSuccess rm.done();
} }
); }// handleSuccess
} });
else { }
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Invalid group = " + grpDmc, null)); //$NON-NLS-1$
rm.done();
}
}
/* /*
* (non-Javadoc) * (non-Javadoc)

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Ericsson and others. * Copyright (c) 2010, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Ericsson - initial API and implementation * Ericsson - initial API and implementation
* Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
* Alvaro Sanchez-Leon (Ericsson) - Support Register Groups (Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.mi.service; package org.eclipse.cdt.dsf.mi.service;
@ -23,6 +24,8 @@ class Messages extends NLS {
public static String Breakpoint_installation_failed; public static String Breakpoint_installation_failed;
public static String MIExpressions_NotAvailableBecauseChildOfDynamicVarobj; public static String MIExpressions_NotAvailableBecauseChildOfDynamicVarobj;
public static String MIExpressions_ReturnValueAlias; public static String MIExpressions_ReturnValueAlias;
public static String MIRegisters_General_Registers;
public static String MIRegisters_General_Registers_description;
static { static {
// initialize resource bundle // initialize resource bundle

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2010 Ericsson and others. # Copyright (c) 2010, 2014 Ericsson and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
# Contributors: # Contributors:
# Ericsson - initial API and implementation # Ericsson - initial API and implementation
# Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) # Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121)
# Alvaro Sanchez-Leon (Ericsson) - Support Register Groups (Bug 235747)
############################################################################### ###############################################################################
Breakpoint_attribute_detailed_problem=Breakpoint installation failed: {0} Breakpoint_attribute_detailed_problem=Breakpoint installation failed: {0}
@ -16,3 +17,7 @@ Breakpoint_installation_failed=installation failed
MIExpressions_NotAvailableBecauseChildOfDynamicVarobj=N/A (child of pretty-printed object) MIExpressions_NotAvailableBecauseChildOfDynamicVarobj=N/A (child of pretty-printed object)
MIExpressions_ReturnValueAlias=%s returned MIExpressions_ReturnValueAlias=%s returned
MIRegisters_General_Registers=General Registers
MIRegisters_General_Registers_description=General Purpose and FPU Register Group

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2013 Ericsson and others. * Copyright (c) 2007, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,9 +9,11 @@
* Ericsson - Initial Implementation * Ericsson - Initial Implementation
* Marc Khouzam (Ericsson) - Add support to receive multiple events * Marc Khouzam (Ericsson) - Add support to receive multiple events
* Alvaro Sanchez-Leon (Ericsson) - Add filter out and wait for a given type of event * Alvaro Sanchez-Leon (Ericsson) - Add filter out and wait for a given type of event
* Alvaro Sanchez-Leon (Ericsson) - Allow user to edit the register groups (Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.framework; package org.eclipse.cdt.tests.dsf.gdb.framework;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -96,29 +98,34 @@ public class ServiceEventWaitor<V> {
} }
/** /**
* Will wait and discard events that are not either of the specified type or a subtype * Wait for events of V type for the specified amount of time
* It will stop and return the first one found or exit after the specified timeout
*
* @param type - The parent type of an acceptable event
* @param timeout the maximum time to wait in milliseconds to wait for a specified event
*/ */
@SuppressWarnings("unchecked") public synchronized List<V> waitForEvents(int period) {
public synchronized <T extends V> T waitForEvent(Class<T> type, int timeout) throws Exception {
long startMs = System.currentTimeMillis(); long startMs = System.currentTimeMillis();
//The Specified Event received or Timeout exception will exit the loop List<V> events = new ArrayList<V>();
//Timeout exception will exit the loop and return the resulting list of events
while (true) { while (true) {
int timeRemaining = (int) (timeout - (System.currentTimeMillis() - startMs)); int timeRemaining = (int) (period - (System.currentTimeMillis() - startMs));
if (timeRemaining > 0) { if (timeRemaining > 0) {
V sevent = waitForEvent(timeRemaining); V sevent;
if (type.isAssignableFrom(sevent.getClass())) { try {
return (T) sevent; sevent = waitForEvent(timeRemaining);
if (sevent != null) {
events.add(sevent);
}
} catch (Exception e) {
break;
} }
} else { } else {
throw new Exception("Timed out waiting for ServiceEvent: " + type.getName()); break;
} }
} }
return events;
} }
/* /*
* Block until 'timeout' or the expected event occurs. The expected event is * Block until 'timeout' or the expected event occurs. The expected event is
* specified at construction time. * specified at construction time.

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Ericsson and others. * Copyright (c) 2012, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Marc Khouzam (Ericsson) - Initial Implementation * Marc Khouzam (Ericsson) - Initial Implementation
* Marc Khouzam (Ericsson) - Tests for Pattern Matching for variables (Bug 394408) * Marc Khouzam (Ericsson) - Tests for Pattern Matching for variables (Bug 394408)
* Alvaro Sanchez-Leon (Ericsson AB) - Allow user to edit register groups (Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.gdb.tests; package org.eclipse.cdt.tests.dsf.gdb.tests;
@ -24,9 +25,7 @@ import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Query; import org.eclipse.cdt.dsf.concurrent.Query;
import org.eclipse.cdt.dsf.datamodel.CompositeDMContext;
import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IExpressions; import org.eclipse.cdt.dsf.debug.service.IExpressions;
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
@ -36,9 +35,8 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtensio
import org.eclipse.cdt.dsf.debug.service.IFormattedValues; import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext; import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData; import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
import org.eclipse.cdt.dsf.debug.service.IRegisters;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext; import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext; import org.eclipse.cdt.dsf.debug.service.IRegisters2;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType; import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
@ -67,7 +65,7 @@ public class GDBPatternMatchingExpressionsTest extends BaseTestCase {
private DsfServicesTracker fServicesTracker; private DsfServicesTracker fServicesTracker;
protected IMIExpressions fExpService; protected IMIExpressions fExpService;
protected IRegisters fRegService; protected IRegisters2 fRegService;
@Override @Override
protected void setLaunchAttributes() { protected void setLaunchAttributes() {
@ -88,7 +86,7 @@ public class GDBPatternMatchingExpressionsTest extends BaseTestCase {
fExpService = fServicesTracker.getService(IMIExpressions.class); fExpService = fServicesTracker.getService(IMIExpressions.class);
fRegService = fServicesTracker.getService(IRegisters.class); fRegService = fServicesTracker.getService(IRegisters2.class);
} }
}; };
fSession.getExecutor().submit(runnable).get(); fSession.getExecutor().submit(runnable).get();
@ -173,33 +171,27 @@ public class GDBPatternMatchingExpressionsTest extends BaseTestCase {
Query<String> query = new Query<String>() { Query<String> query = new Query<String>() {
@Override @Override
protected void execute(final DataRequestMonitor<String> rm) { protected void execute(final DataRequestMonitor<String> rm) {
fRegService.getRegisterGroups(threadDmc, new ImmediateDataRequestMonitor<IRegisterGroupDMContext[]>(rm) { fRegService.getRegisters(threadDmc,
@Override new ImmediateDataRequestMonitor<IRegisterDMContext[]>(rm) {
protected void handleSuccess() { @Override
fRegService.getRegisters( protected void handleSuccess() {
new CompositeDMContext(new IDMContext[] { getData()[0], threadDmc } ), assert getData() instanceof MIRegisterDMC[];
new ImmediateDataRequestMonitor<IRegisterDMContext[]>(rm) { for (MIRegisterDMC register : (MIRegisterDMC[])getData()) {
@Override if (register.getName().equals(regName)) {
protected void handleSuccess() { final FormattedValueDMContext valueDmc = fRegService.getFormattedValueContext(register, IFormattedValues.HEX_FORMAT);
assert getData() instanceof MIRegisterDMC[]; fRegService.getFormattedExpressionValue(valueDmc, new ImmediateDataRequestMonitor<FormattedValueDMData>(rm) {
for (MIRegisterDMC register : (MIRegisterDMC[])getData()) { @Override
if (register.getName().equals(regName)) { protected void handleSuccess() {
final FormattedValueDMContext valueDmc = fRegService.getFormattedValueContext(register, IFormattedValues.HEX_FORMAT); rm.done(getData().getFormattedValue());
fRegService.getFormattedExpressionValue(valueDmc, new ImmediateDataRequestMonitor<FormattedValueDMData>(rm) { };
@Override });
protected void handleSuccess() { return;
rm.done(getData().getFormattedValue());
};
});
return;
}
}
// If we get here, we didn't find the register!
assertTrue("Invalid register: " + regName, false);
} }
}); }
} // If we get here, we didn't find the register!
}); assertTrue("Invalid register: " + regName, false);
}
});
} }
}; };

View file

@ -341,6 +341,70 @@
</with> </with>
</activeWhen> </activeWhen>
</handler> </handler>
<handler
class="org.eclipse.cdt.dsf.debug.internal.ui.actions.DsfAddRegisterGroupCommand"
commandId="org.eclipse.cdt.debug.ui.command.addRegisterGroup">
<activeWhen>
<with variable="selection">
<iterate operator="and">
<or>
<instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterVMNode$RegisterVMC">
</instanceof>
<instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterGroupVMNode$RegisterGroupVMC">
</instanceof>
</or>
</iterate>
<count value="+">
</count>
</with>
</activeWhen>
</handler>
<handler
class="org.eclipse.cdt.dsf.debug.internal.ui.actions.DsfEditRegisterGroupCommand"
commandId="org.eclipse.cdt.debug.ui.command.editRegisterGroup">
<activeWhen>
<with variable="selection">
<iterate operator="and">
<instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterGroupVMNode$RegisterGroupVMC">
</instanceof>
</iterate>
<count value="1">
</count>
</with>
</activeWhen>
</handler>
<handler
class="org.eclipse.cdt.dsf.debug.internal.ui.actions.DsfRemoveRegisterGroupsCommand"
commandId="org.eclipse.cdt.debug.ui.command.removeRegisterGroups">
<activeWhen>
<with variable="selection">
<iterate operator="and">
<instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterGroupVMNode$RegisterGroupVMC">
</instanceof>
</iterate>
<count value="+">
</count>
</with>
</activeWhen>
</handler>
<handler
class="org.eclipse.cdt.dsf.debug.internal.ui.actions.DsfRestoreRegisterGroupsCommand"
commandId="org.eclipse.cdt.debug.ui.command.restoreRegisterGroups">
<activeWhen>
<with variable="selection">
<iterate operator="and">
<or>
<instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterVMNode$RegisterVMC">
</instanceof>
<instanceof value="org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterGroupVMNode$RegisterGroupVMC">
</instanceof>
</or>
</iterate>
<count value="+">
</count>
</with>
</activeWhen>
</handler>
</extension> </extension>
<extension point="org.eclipse.core.expressions.definitions"> <extension point="org.eclipse.core.expressions.definitions">
<definition id="org.eclipse.cdt.dsf.debug.ui.testIsUpdateModesActionSetActive"> <definition id="org.eclipse.cdt.dsf.debug.ui.testIsUpdateModesActionSetActive">

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 Wind River Systems, Inc. and others. * Copyright (c) 2009, 2014 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* Wind River Systems - initial API and implementation * Wind River Systems - initial API and implementation
* Patrick Chuong (Texas Instruments) - Bug 315446: Invalid event breakpoint type (group) name * Patrick Chuong (Texas Instruments) - Bug 315446: Invalid event breakpoint type (group) name
* Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection (bug 244865) * Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection (bug 244865)
* Alvaro Sanchez-Leon (Ericsson AB) - Support Register Groups (Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui; package org.eclipse.cdt.dsf.debug.internal.ui;
@ -18,6 +19,14 @@ public class Messages extends NLS {
public static String ToggleBreakpointsTargetFactory_description; public static String ToggleBreakpointsTargetFactory_description;
public static String ToggleBreakpointsTargetFactory_name; public static String ToggleBreakpointsTargetFactory_name;
public static String DsfUIStepIntoEditorSelection; public static String DsfUIStepIntoEditorSelection;
public static String RegisterGroupInfo;
public static String Information;
public static String DefaultRegistersGroupName;
public static String ProposeGroupNameRoot;
public static String RegisterGroupConfirmRestoreTitle;
public static String RegisterGroupConfirmRestoreMessage;
public static String RegisterGroupRestore;
public static String RegisterGroupRestoreCancel;
static { static {
// initialize resource bundle // initialize resource bundle

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2009, 2013 Wind River Systems and others. # Copyright (c) 2009, 2014 Wind River Systems and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -9,9 +9,19 @@
# Wind River Systems - initial API and implementation # Wind River Systems - initial API and implementation
# Ericsson - added Tracepoint support # Ericsson - added Tracepoint support
# Ericsson - added Step into selection support # Ericsson - added Step into selection support
# Ericsson - Support Register Groups
############################################################################### ###############################################################################
ToggleBreakpointsTargetFactory_description=Standard C/C++ breakpoint type. ToggleBreakpointsTargetFactory_description=Standard C/C++ breakpoint type.
ToggleBreakpointsTargetFactory_name=C/C++ Breakpoints ToggleBreakpointsTargetFactory_name=C/C++ Breakpoints
DsfUIStepIntoEditorSelection=Step Into DsfUIStepIntoEditorSelection=Step Into
Information=Information
RegisterGroupInfo=Register Group
DefaultRegistersGroupName=New Group
ProposeGroupNameRoot=Group_
RegisterGroupConfirmRestoreTitle=Register Groups - Confirm Restore
RegisterGroupConfirmRestoreMessage=Are you sure you want to restore to the default register group(s) ?
RegisterGroupRestore=OK
RegisterGroupRestoreCancel=Cancel

View file

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.actions;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command performing adding a register group.
* @since 2.4
*/
public class DsfAddRegisterGroupCommand extends AbstractDsfRegisterGroupActions {
@Override
public void setEnabled(Object evaluationContext) {
boolean state = false;
if (evaluationContext instanceof IEvaluationContext) {
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
Object p = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_PART_NAME);
if (s instanceof IStructuredSelection && p instanceof IWorkbenchPart) {
state = canAddRegisterGroup((IWorkbenchPart)p, (IStructuredSelection)s);
}
}
setBaseEnabled(state);
}
@Override
public Object execute(ExecutionEvent event) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if (selection instanceof IStructuredSelection) {
addRegisterGroup(part, (IStructuredSelection)selection);
}
return null;
}
}

View file

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.actions;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command performing adding a register group.
* @since 2.4
*/
public class DsfEditRegisterGroupCommand extends AbstractDsfRegisterGroupActions {
@Override
public void setEnabled(Object evaluationContext) {
boolean state = false;
if (evaluationContext instanceof IEvaluationContext) {
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
Object p = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_PART_NAME);
if (s instanceof IStructuredSelection && p instanceof IWorkbenchPart) {
state = canEditRegisterGroup((IWorkbenchPart)p, (IStructuredSelection)s);
}
}
setBaseEnabled(state);
}
@Override
public Object execute(ExecutionEvent event) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if (selection instanceof IStructuredSelection) {
editRegisterGroup(part, (IStructuredSelection)selection);
}
return null;
}
}

View file

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.actions;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command performing adding a register group.
* @since 2.4
*/
public class DsfRemoveRegisterGroupsCommand extends AbstractDsfRegisterGroupActions {
@Override
public void setEnabled(Object evaluationContext) {
boolean state = false;
if (evaluationContext instanceof IEvaluationContext) {
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
Object p = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_PART_NAME);
if (s instanceof IStructuredSelection && p instanceof IWorkbenchPart) {
state = canRemoveRegisterGroups((IWorkbenchPart)p, (IStructuredSelection)s);
}
}
setBaseEnabled(state);
}
@Override
public Object execute(ExecutionEvent event) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if (selection instanceof IStructuredSelection) {
removeRegisterGroups(part, (IStructuredSelection)selection);
}
return null;
}
}

View file

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.actions;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Command performing adding a register group.
* @since 2.4
*/
public class DsfRestoreRegisterGroupsCommand extends AbstractDsfRegisterGroupActions {
@Override
public void setEnabled(Object evaluationContext) {
boolean state = false;
if (evaluationContext instanceof IEvaluationContext) {
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
Object p = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_PART_NAME);
if (s instanceof IStructuredSelection && p instanceof IWorkbenchPart) {
state = canRestoreDefaultGroups((IWorkbenchPart)p, (IStructuredSelection)s);
}
}
setBaseEnabled(state);
}
@Override
public Object execute(ExecutionEvent event) {
ISelection selection = HandlerUtil.getCurrentSelection(event);
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if (selection instanceof IStructuredSelection) {
restoreDefaultGroups(part, (IStructuredSelection)selection);
}
return null;
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems and others. * Copyright (c) 2006, 2014 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Wind River Systems - initial API and implementation * Wind River Systems - initial API and implementation
* Alvaro Sanchez-Leon (Ericsson) - Allow user to edit the register groups (Bug 235747)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.internal.ui; package org.eclipse.cdt.dsf.internal.ui;
@ -22,6 +23,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
@ -169,4 +172,18 @@ public class DsfUIPlugin extends AbstractUIPlugin {
return new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, code, message, exception); return new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, code, message, exception);
} }
/**
* Returns the active workbench shell or <code>null</code> if none
*
* @return the active workbench shell or <code>null</code> if none
*/
public static Shell getActiveWorkbenchShell() {
IWorkbenchWindow window = getDefault().getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
return window.getShell();
}
return null;
}
} }

View file

@ -0,0 +1,90 @@
/*******************************************************************************
* Copyright (c) 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alvaro Sanchez-Leon (Ericsson) - First API (Bug 235747)
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.service;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
/**
* Service extension of IRegisters to manage user defined Register Groups
* @since 2.6
*/
public interface IRegisters2 extends IRegisters {
/**
* Returns a boolean indicating if it is allowed to add a new register group with the given selected context
*
* @param rm - monitor encapsulating the response
*/
public void canAddRegisterGroup(IDMContext ctx, DataRequestMonitor<Boolean> rm);
/**
* Add a Register group referencing the given registers
*
* @param ctx - A context containing a parent group context e.g. IContainerDMContext
* @param name - register group name
* @param registers - registers part of this new group
* @param rm - request monitor
*/
public void addRegisterGroup(IDMContext ctx, String name, IRegisterDMContext[] registers, RequestMonitor rm);
/**
* Returns a boolean indicating if it is allowed to edit the given group
*
* @param rm - monitor encapsulating the response
*/
public void canEditRegisterGroup(IRegisterGroupDMContext group,
DataRequestMonitor<Boolean> rm);
/**
* Edit the given register group and update its name and associated registers
*
* @param group - group to be edited
* @param groupName - new group name or null if name is not to be changed
* @param registers - new list of registers for this group or null if the list of registers is not be changed
* @param rm - request monitor
*/
public void editRegisterGroup(IRegisterGroupDMContext group, String groupName,
IRegisterDMContext[] registers, RequestMonitor rm);
/**
* Returns a boolean indicating if it is allowed to remove the given registers groups
* @param groups - list of register group contexts to be removed
* @param rm
*/
public void canRemoveRegisterGroups(IRegisterGroupDMContext[] groups,
DataRequestMonitor<Boolean> rm);
/**
* Remove the given register groups
*
* @param groups - groups that shall be removed
* @param rm - request monitor
*/
public void removeRegisterGroups(IRegisterGroupDMContext[] groups, RequestMonitor rm);
/**
* Returns a boolean indicating if it is allowed to restore to the default groups
* @param ctx
* @param rm
*/
public void canRestoreDefaultGroups(IDMContext ctx, DataRequestMonitor<Boolean> rm);
/**
* Remove all the user defined register groups and restore the default ones to their
* original state.
*
* @param rm - request monitor
*/
public void restoreDefaultGroups(IDMContext selectionContext, RequestMonitor rm);
}