mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
[275238] Added extra Details format which gives more details and supports pretty-printing
This commit is contained in:
parent
67a203c382
commit
bf9c3f543a
3 changed files with 61 additions and 16 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String[]> 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<ExprMetaGetValueInfo>(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<MIDataEvaluateExpressionInfo>(exprDmc),
|
||||
new DataRequestMonitor<MIDataEvaluateExpressionInfo>(getExecutor(), rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
rm.setData(new FormattedValueDMData(getData().getValue()));
|
||||
rm.done();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fExpressionCache.execute(
|
||||
new ExprMetaGetValue(dmc),
|
||||
new DataRequestMonitor<ExprMetaGetValueInfo>(getExecutor(), rm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
rm.setData(new FormattedValueDMData(getData().getValue()));
|
||||
rm.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,14 @@ abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover i
|
|||
*/
|
||||
abstract protected String getModelId();
|
||||
|
||||
private static class GetExpressionValueQuery extends Query<FormattedValueDMData> {
|
||||
/**
|
||||
* Returns the type of format that should be used for the hover.
|
||||
*/
|
||||
protected String getHoverFormat() {
|
||||
return IFormattedValues.NATURAL_FORMAT;
|
||||
}
|
||||
|
||||
private class GetExpressionValueQuery extends Query<FormattedValueDMData> {
|
||||
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<FormattedValueDMData>(session.getExecutor(), rm) {
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue