mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 489516 - Traditional mem., choose visibility of the cross ref
information This facility is dependent of the issues below. Bug 489512 - Show local variables in the traditional memory render Bug 489513 - Show registers in the traditional memory render Allow the user to choose visibility of the available cross reference information e.g. Variables, Registers In addition to the preferences at a instance level, a global preference is introduced to disable the resolution of additional information altogether. Change-Id: I9f8b9b612ff288b369ba6fca3402c0c911aa5f48
This commit is contained in:
parent
c73978c03a
commit
3822ee7b43
7 changed files with 165 additions and 23 deletions
|
@ -39,6 +39,7 @@ import org.eclipse.debug.core.model.MemoryByte;
|
||||||
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
|
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
|
||||||
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
|
import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
|
||||||
import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite;
|
import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
@ -2338,9 +2339,23 @@ public class Rendering extends Composite implements IDebugEventSetListener
|
||||||
*
|
*
|
||||||
* @param addTypeHeaders
|
* @param addTypeHeaders
|
||||||
* Indicates if the string shall include a data type name before each list of items of the same
|
* Indicates if the string shall include a data type name before each list of items of the same
|
||||||
* type e.g. Variables, Regitsters, etc.
|
* type e.g. Variables, Registers, etc.
|
||||||
*/
|
*/
|
||||||
String buildAddressInfoString(BigInteger address, String separator, boolean addTypeHeaders) {
|
String buildAddressInfoString(BigInteger address, String separator, boolean addTypeHeaders) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns Dynamic context menu actions to this render, No actions by default
|
||||||
|
* @since 1.4
|
||||||
|
*/
|
||||||
|
Action[] getDynamicActions() {
|
||||||
|
return new Action[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger the resolution of additional address information - No action by default
|
||||||
|
*/
|
||||||
|
void resolveAddressInfoForCurrentSelection() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ import org.eclipse.debug.ui.DebugUITools;
|
||||||
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||||
import org.eclipse.debug.ui.contexts.IDebugContextService;
|
import org.eclipse.debug.ui.contexts.IDebugContextService;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.StructuredSelection;
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
@ -58,6 +60,10 @@ public class RenderingAddressInfo extends Rendering
|
||||||
*/
|
*/
|
||||||
private volatile IMemoryBlockAddressInfoItem[] fAddressInfoItems;
|
private volatile IMemoryBlockAddressInfoItem[] fAddressInfoItems;
|
||||||
|
|
||||||
|
|
||||||
|
private final AddressInfoTypeMap fAddressInfoTypeStatusMap = new AddressInfoTypeMap();
|
||||||
|
|
||||||
|
|
||||||
public RenderingAddressInfo(Composite parent, TraditionalRendering renderingParent) {
|
public RenderingAddressInfo(Composite parent, TraditionalRendering renderingParent) {
|
||||||
super(parent, renderingParent);
|
super(parent, renderingParent);
|
||||||
|
|
||||||
|
@ -71,10 +77,62 @@ public class RenderingAddressInfo extends Rendering
|
||||||
resolveAddressInfoForCurrentSelection(contextService);
|
resolveAddressInfoForCurrentSelection(contextService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps a map from information type to its state and to a corresponding Action instance
|
||||||
|
* needed to update the actual state from UI interactions
|
||||||
|
*/
|
||||||
|
class AddressInfoTypeMap extends HashMap<String, Boolean> {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final Map<String, Action> fTypeToActionMap = new HashMap<>();
|
||||||
|
|
||||||
|
public Action getAction(final String infoType) {
|
||||||
|
if (!containsKey(infoType)) {
|
||||||
|
if (fTypeToActionMap.containsKey(infoType)) {
|
||||||
|
// The key status has been removed, clean the action map
|
||||||
|
fTypeToActionMap.remove(infoType);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Action action = fTypeToActionMap.get(infoType);
|
||||||
|
if (action != null) {
|
||||||
|
return action;
|
||||||
|
} else {
|
||||||
|
action = new Action(infoType, IAction.AS_CHECK_BOX) {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
put(infoType, Boolean.valueOf(isChecked()));
|
||||||
|
redrawPanes();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
action.setChecked(get(infoType));
|
||||||
|
fTypeToActionMap.put(infoType, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
fTypeToActionMap.clear();
|
||||||
|
super.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void resolveAddressInfoForCurrentSelection() {
|
||||||
|
IWorkbenchPartSite site = fParent.getMemoryRenderingContainer().getMemoryRenderingSite().getSite();
|
||||||
|
IDebugContextService contextService = DebugUITools.getDebugContextManager()
|
||||||
|
.getContextService(site.getWorkbenchWindow());
|
||||||
|
resolveAddressInfoForCurrentSelection(contextService);
|
||||||
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
|
||||||
fSelectedContext = null;
|
fSelectedContext = null;
|
||||||
fMapStartAddrToInfoItems.clear();
|
fMapStartAddrToInfoItems.clear();
|
||||||
|
fAddressInfoTypeStatusMap.clear();
|
||||||
fAddressInfoItems = null;
|
fAddressInfoItems = null;
|
||||||
|
|
||||||
IWorkbenchPartSite site = fParent.getMemoryRenderingContainer().getMemoryRenderingSite().getSite();
|
IWorkbenchPartSite site = fParent.getMemoryRenderingContainer().getMemoryRenderingSite().getSite();
|
||||||
|
@ -158,8 +216,8 @@ public class RenderingAddressInfo extends Rendering
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDebugContextChanged(final Object context) {
|
private void handleDebugContextChanged(final Object context) {
|
||||||
if (isDisposed() || context == null) {
|
if (isDisposed() || context == null || !fParent.isShowCrossRefInfoGlobalPref()) {
|
||||||
// Invalid context or Data pane is not visible
|
// Invalid context or user has chosen not to see additional address information
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,21 +243,33 @@ public class RenderingAddressInfo extends Rendering
|
||||||
// If the context is still valid
|
// If the context is still valid
|
||||||
if (getContext().equals(fSelectedContext)) {
|
if (getContext().equals(fSelectedContext)) {
|
||||||
final IMemoryBlockAddressInfoItem[] addressInfoItems = getAllAddressInfoItems();
|
final IMemoryBlockAddressInfoItem[] addressInfoItems = getAllAddressInfoItems();
|
||||||
if (!display.isDisposed()) {
|
|
||||||
display.asyncExec(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// The selection has changed, so our Address information may no longer be valid
|
|
||||||
fAddressInfoItems = addressInfoItems;
|
|
||||||
fMapStartAddrToInfoItems.clear();
|
|
||||||
|
|
||||||
if (fBinaryPane.isVisible()) {
|
|
||||||
redrawPanes();
|
if (fParent.isShowCrossRefInfoGlobalPref()) {
|
||||||
|
final String[] types = getAddressInfoItemTypes();
|
||||||
|
|
||||||
|
if (!display.isDisposed()) {
|
||||||
|
display.asyncExec(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (String type : types) {
|
||||||
|
if (!fAddressInfoTypeStatusMap.containsKey(type)) {
|
||||||
|
fAddressInfoTypeStatusMap.put(type, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The selection has changed, so our Address information may no longer be valid
|
||||||
|
fAddressInfoItems = addressInfoItems;
|
||||||
|
fMapStartAddrToInfoItems.clear();
|
||||||
|
|
||||||
|
if (fBinaryPane.isVisible()) {
|
||||||
|
redrawPanes();
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshUpdateListener(addrInfo);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
refreshUpdateListener(addrInfo);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,16 +326,13 @@ public class RenderingAddressInfo extends Rendering
|
||||||
@Override
|
@Override
|
||||||
public void handleAddressInfoUpdate(EventType type, Object update) {
|
public void handleAddressInfoUpdate(EventType type, Object update) {
|
||||||
fAddressInfoItems = null;
|
fAddressInfoItems = null;
|
||||||
IWorkbenchPartSite site = fParent.getMemoryRenderingContainer().getMemoryRenderingSite().getSite();
|
resolveAddressInfoForCurrentSelection();
|
||||||
IDebugContextService contextService = DebugUITools.getDebugContextManager()
|
|
||||||
.getContextService(site.getWorkbenchWindow());
|
|
||||||
resolveAddressInfoForCurrentSelection(contextService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Map<BigInteger, List<IMemoryBlockAddressInfoItem>> getVisibleValueToAddressInfoItems() {
|
Map<BigInteger, List<IMemoryBlockAddressInfoItem>> getVisibleValueToAddressInfoItems() {
|
||||||
IMemoryBlockAddressInfoItem[] items = fAddressInfoItems;
|
IMemoryBlockAddressInfoItem[] items = fAddressInfoItems;
|
||||||
if (items == null) {
|
if (items == null || !fParent.isShowCrossRefInfoGlobalPref()) {
|
||||||
fMapStartAddrToInfoItems.clear();
|
fMapStartAddrToInfoItems.clear();
|
||||||
return fMapStartAddrToInfoItems;
|
return fMapStartAddrToInfoItems;
|
||||||
}
|
}
|
||||||
|
@ -302,6 +369,13 @@ public class RenderingAddressInfo extends Rendering
|
||||||
BigInteger endAddress = getViewportEndAddressSingleHeight();
|
BigInteger endAddress = getViewportEndAddressSingleHeight();
|
||||||
|
|
||||||
for (IMemoryBlockAddressInfoItem item : items) {
|
for (IMemoryBlockAddressInfoItem item : items) {
|
||||||
|
// Skip information types not wanted by the user
|
||||||
|
String itemType = item.getInfoType();
|
||||||
|
if (!fAddressInfoTypeStatusMap.containsKey(itemType)
|
||||||
|
|| fAddressInfoTypeStatusMap.get(itemType).equals(Boolean.FALSE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
List<IMemoryBlockAddressInfoItem> containers = allValuesMap.get(item.getAddress());
|
List<IMemoryBlockAddressInfoItem> containers = allValuesMap.get(item.getAddress());
|
||||||
if (containers == null) {
|
if (containers == null) {
|
||||||
containers = new ArrayList<>();
|
containers = new ArrayList<>();
|
||||||
|
@ -392,4 +466,18 @@ public class RenderingAddressInfo extends Rendering
|
||||||
return (fBinaryPane.fPaneVisible && fMapStartAddrToInfoItems.size() > 0);
|
return (fBinaryPane.fPaneVisible && fMapStartAddrToInfoItems.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Action[] getDynamicActions() {
|
||||||
|
List<Action> actionList = new ArrayList<Action>(fAddressInfoTypeStatusMap.size());
|
||||||
|
if (getPaneVisible(Rendering.PANE_BINARY)) {
|
||||||
|
for (final String infoType : fAddressInfoTypeStatusMap.keySet()) {
|
||||||
|
Action action = fAddressInfoTypeStatusMap.getAction(infoType);
|
||||||
|
if (action != null) {
|
||||||
|
actionList.add(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return actionList.toArray(new Action[actionList.size()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -645,6 +645,9 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
||||||
panes[i].setBackground(getColorBackground());
|
panes[i].setBackground(getColorBackground());
|
||||||
|
|
||||||
setRenderingPadding(TraditionalRenderingPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR));
|
setRenderingPadding(TraditionalRenderingPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR));
|
||||||
|
if (store.getBoolean(TraditionalRenderingPreferenceConstants.MEM_CROSS_REFERENCE_INFO)) {
|
||||||
|
fRendering.resolveAddressInfoForCurrentSelection();
|
||||||
|
}
|
||||||
|
|
||||||
fRendering.redrawPanes();
|
fRendering.redrawPanes();
|
||||||
}
|
}
|
||||||
|
@ -777,6 +780,14 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
||||||
return colorTextAlternate;
|
return colorTextAlternate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.4
|
||||||
|
*/
|
||||||
|
public boolean isShowCrossRefInfoGlobalPref() {
|
||||||
|
IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore();
|
||||||
|
return store.getBoolean(TraditionalRenderingPreferenceConstants.MEM_CROSS_REFERENCE_INFO);
|
||||||
|
}
|
||||||
|
|
||||||
public void createMenus()
|
public void createMenus()
|
||||||
{
|
{
|
||||||
// add the menu to each of the rendering panes
|
// add the menu to each of the rendering panes
|
||||||
|
@ -1251,6 +1262,21 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
|
||||||
sub.add(displayTextPaneAction);
|
sub.add(displayTextPaneAction);
|
||||||
manager.add(sub);
|
manager.add(sub);
|
||||||
|
|
||||||
|
// if there is cross reference info types available
|
||||||
|
// add Actions to allow the user to toggle the visibility for each of them
|
||||||
|
if (isShowCrossRefInfoGlobalPref()) {
|
||||||
|
Action[] dynamicActions = fRendering.getDynamicActions();
|
||||||
|
if (dynamicActions != null) {
|
||||||
|
sub = new MenuManager(TraditionalRenderingMessages
|
||||||
|
.getString("TraditionalRenderingPreferencePage_ShowCrossRefInfo_Label")); //$NON-NLS-1$
|
||||||
|
for (Action action : dynamicActions) {
|
||||||
|
sub.add(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.add(sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub = new MenuManager(TraditionalRenderingMessages
|
sub = new MenuManager(TraditionalRenderingMessages
|
||||||
.getString("TraditionalRendering.ENDIAN")); //$NON-NLS-1$
|
.getString("TraditionalRendering.ENDIAN")); //$NON-NLS-1$
|
||||||
sub.add(displayEndianBigAction);
|
sub.add(displayEndianBigAction);
|
||||||
|
|
|
@ -62,4 +62,8 @@ public class TraditionalRenderingPreferenceConstants {
|
||||||
*/
|
*/
|
||||||
public static final String MEM_MEMORY_SPACE_ID_PREFIX = MEM_COLOR_BACKGROUND + "MemorySpace-";
|
public static final String MEM_MEMORY_SPACE_ID_PREFIX = MEM_COLOR_BACKGROUND + "MemorySpace-";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.4
|
||||||
|
*/
|
||||||
|
public static final String MEM_CROSS_REFERENCE_INFO = "memCrossReferenceInfo";
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,8 @@ public class TraditionalRenderingPreferenceInitializer extends AbstractPreferenc
|
||||||
TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY);
|
TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY);
|
||||||
|
|
||||||
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT, "1");
|
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT, "1");
|
||||||
|
|
||||||
|
store.setDefault(TraditionalRenderingPreferenceConstants.MEM_CROSS_REFERENCE_INFO, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,11 @@ public class TraditionalRenderingPreferencePage
|
||||||
|
|
||||||
addField(new ScaleFieldEditor(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT,
|
addField(new ScaleFieldEditor(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT,
|
||||||
TraditionalRenderingMessages.getString("TraditionalRenderingPreferencePage_HistoryTrailLevels"), getFieldEditorParent(), 1, 10, 1, 1)); //$NON-NLS-1$
|
TraditionalRenderingMessages.getString("TraditionalRenderingPreferencePage_HistoryTrailLevels"), getFieldEditorParent(), 1, 10, 1, 1)); //$NON-NLS-1$
|
||||||
|
|
||||||
|
addField(new BooleanFieldEditor(TraditionalRenderingPreferenceConstants.MEM_CROSS_REFERENCE_INFO,
|
||||||
|
TraditionalRenderingMessages
|
||||||
|
.getString("TraditionalRenderingPreferencePage_ShowCrossRefInfo"), //$NON-NLS-1$
|
||||||
|
getFieldEditorParent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -84,6 +84,8 @@ TraditionalRenderingPreferencePage_TextColor=&Text Color:
|
||||||
TraditionalRenderingPreferencePage_UseGlobalBackgroundColor=Use Global B&ackground Color
|
TraditionalRenderingPreferencePage_UseGlobalBackgroundColor=Use Global B&ackground Color
|
||||||
TraditionalRenderingPreferencePage_UseGlobalSelectionColor=Use Global Se&lection Color
|
TraditionalRenderingPreferencePage_UseGlobalSelectionColor=Use Global Se&lection Color
|
||||||
TraditionalRenderingPreferencePage_UseGlobalTextColor=Use Global Te&xt Color
|
TraditionalRenderingPreferencePage_UseGlobalTextColor=Use Global Te&xt Color
|
||||||
|
TraditionalRenderingPreferencePage_ShowCrossRefInfo=Show cross reference information
|
||||||
|
TraditionalRenderingPreferencePage_ShowCrossRefInfo_Label=Cross Reference Information
|
||||||
ColorAndEffectFieldEditor.bold=Bold
|
ColorAndEffectFieldEditor.bold=Bold
|
||||||
ColorAndEffectFieldEditor.italic=Italic
|
ColorAndEffectFieldEditor.italic=Italic
|
||||||
ColorAndEffectFieldEditor.box=Box
|
ColorAndEffectFieldEditor.box=Box
|
||||||
|
|
Loading…
Add table
Reference in a new issue