diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java index 2364d781e64..7f4d1caf1ac 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbDebugTextHover.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems and others. + * Copyright (c) 2009, 2010 Wind River 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 @@ -7,11 +7,13 @@ * * Contributors: * Wind River Systems - initial API and implementation + * Ericsson - Updated hover to use the new Details format *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui; import org.eclipse.cdt.dsf.debug.ui.AbstractDsfDebugTextHover; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate; +import org.eclipse.cdt.dsf.mi.service.MIExpressions; /** * Debug editor text hover for GDB. @@ -25,4 +27,8 @@ public class GdbDebugTextHover extends AbstractDsfDebugTextHover { return GdbLaunchDelegate.GDB_DEBUG_MODEL_ID; } + @Override + protected String getHoverFormat() { + return MIExpressions.DETAILS_FORMAT; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java index 6d4800dd156..36a56ce0e15 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java @@ -65,6 +65,23 @@ import org.osgi.framework.BundleContext; */ public class MIExpressions extends AbstractDsfService implements IExpressions, ICachingService { + /** + * A format that gives more details about an expression and supports pretty-printing + * provided by the backend. + * + * @since 3.0 + */ + public static final String DETAILS_FORMAT = "Details"; + + /* The order given here is the order that will be used by DSF in the Details Pane */ + private static final String[] FORMATS_SUPPORTED = new String[] { + DETAILS_FORMAT, + IFormattedValues.NATURAL_FORMAT, + IFormattedValues.DECIMAL_FORMAT, + IFormattedValues.HEX_FORMAT, + IFormattedValues.BINARY_FORMAT, + IFormattedValues.OCTAL_FORMAT }; + /** * This class represents the two expressions that characterize an Expression Context. */ @@ -566,9 +583,7 @@ public class MIExpressions extends AbstractDsfService implements IExpressions, I public void getAvailableFormats(IFormattedDataDMContext dmc, final DataRequestMonitor rm) { - rm.setData(new String[] { IFormattedValues.BINARY_FORMAT, - IFormattedValues.NATURAL_FORMAT, IFormattedValues.HEX_FORMAT, - IFormattedValues.OCTAL_FORMAT, IFormattedValues.DECIMAL_FORMAT }); + rm.setData(FORMATS_SUPPORTED); rm.done(); } @@ -680,19 +695,36 @@ public class MIExpressions extends AbstractDsfService implements IExpressions, I // Note that we look for MIExpressionDMC and not IExpressionDMC, because getting // looking for IExpressionDMC could yield InvalidContextExpressionDMC which is still // not what we need to have. - if (DMContexts.getAncestorOfType(dmc, MIExpressionDMC.class) == null ) { + MIExpressionDMC exprDmc = DMContexts.getAncestorOfType(dmc, MIExpressionDMC.class); + if (exprDmc == null ) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$ rm.done(); } else { - fExpressionCache.execute( - new ExprMetaGetValue(dmc), - new DataRequestMonitor(getExecutor(), rm) { - @Override - protected void handleSuccess() { - rm.setData(new FormattedValueDMData(getData().getValue())); - rm.done(); - } - }); + if (DETAILS_FORMAT.equals(dmc.getFormatID())) { + // This format is obtained through a different GDB command. + // It yields more details than the variableObject output. + // Starting with GDB 7.0, this format automatically supports pretty-printing, as long as + // GDB has been configured to support it. + fExpressionCache.execute( + new MIDataEvaluateExpression(exprDmc), + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleSuccess() { + rm.setData(new FormattedValueDMData(getData().getValue())); + rm.done(); + } + }); + } else { + fExpressionCache.execute( + new ExprMetaGetValue(dmc), + new DataRequestMonitor(getExecutor(), rm) { + @Override + protected void handleSuccess() { + rm.setData(new FormattedValueDMData(getData().getValue())); + rm.done(); + } + }); + } } } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java index 1d74b8d3eaa..81a0aec31c7 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java @@ -49,7 +49,14 @@ abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover i */ abstract protected String getModelId(); - private static class GetExpressionValueQuery extends Query { + /** + * Returns the type of format that should be used for the hover. + */ + protected String getHoverFormat() { + return IFormattedValues.NATURAL_FORMAT; + } + + private class GetExpressionValueQuery extends Query { private final IFrameDMContext frame; private final String expression; private DsfServicesTracker dsfServicesTracker; @@ -65,7 +72,7 @@ abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover i DsfSession session = DsfSession.getSession(frame.getSessionId()); IExpressions expressions = dsfServicesTracker.getService(IExpressions.class); IExpressionDMContext expressionDMC = expressions.createExpression(frame, expression); - FormattedValueDMContext formattedValueContext = expressions.getFormattedValueContext(expressionDMC, IFormattedValues.NATURAL_FORMAT); + FormattedValueDMContext formattedValueContext = expressions.getFormattedValueContext(expressionDMC, getHoverFormat()); expressions.getFormattedExpressionValue(formattedValueContext, new DataRequestMonitor(session.getExecutor(), rm) { @Override