diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java index a8cb20028c4..07246086dfb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2014 Monta Vista and others. + * Copyright (c) 2008, 2015 Monta Vista 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 @@ -17,6 +17,7 @@ * Anders Dahlberg (Ericsson) - Need additional API to extend support for memory spaces (Bug 431627) * Alvaro Sanchez-Leon (Ericsson) - Need additional API to extend support for memory spaces (Bug 431627) * Martin Schreiber - Bug 435606 - write unsigned variables (UINT32 and UINT64) in the binary format + * Vladimir Prus (Mentor Graphics) - add MIVariableObject.getRawFields *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service; @@ -75,6 +76,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIDataEvaluateExpressionInf import org.eclipse.cdt.dsf.mi.service.command.output.MIDisplayHint; import org.eclipse.cdt.dsf.mi.service.command.output.MIDisplayHint.GdbDisplayHint; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; +import org.eclipse.cdt.dsf.mi.service.command.output.MITuple; import org.eclipse.cdt.dsf.mi.service.command.output.MIVar; import org.eclipse.cdt.dsf.mi.service.command.output.MIVarAssignInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIVarChange; @@ -340,6 +342,12 @@ public class MIVariableManager implements ICommandControl { // This id is the one used to search for this object in our hash-map private final VariableObjectId internalId; + + /** The raw MI value for this variable object + * @since 4.6 + */ + private MITuple raw; + // This is the name of the variable object, as given by GDB (e.g., var1 or var1.public.x) private String gdbName = null; // The current format of this variable object, within GDB @@ -418,6 +426,15 @@ public class MIVariableManager implements ICommandControl { resetValues(); } + /** Return the raw fields reported via MI. + * + * This method can be used to obtain information from debugger that + * is too special for a particular debugger or architecture to + * be represented as fields or methods in this class. + * @since 4.7 + */ + public MITuple getRawFields() { return raw; } + public VariableObjectId getInternalId() { return internalId; } public String getGdbName() { return gdbName; } public String getCurrentFormat() { return format; } @@ -2048,6 +2065,9 @@ public class MIVariableManager implements ICommandControl { boolean newHasMore = miVar.hasMore() || (miVar.isDynamic() && (miVar.getNumChild() == 0)); + assert miVar.getRawFields() != null; + raw = miVar.getRawFields(); + setGdbName(miVar.getVarName()); setDisplayHint(miVar.getDisplayHint()); setExpressionData( @@ -2928,12 +2948,8 @@ public class MIVariableManager implements ICommandControl { drm.setData( new ExprMetaGetVarInfo( exprCtx.getRelativeExpression(), - varObj.isSafeToAskForAllChildren(), - getData().getChildrenCount(), - varObj.getType(), - varObj.getGDBType(), - !varObj.isComplex(), - varObj.getDisplayHint().isCollectionHint())); + varObj, + getData().getChildrenCount())); drm.done(); processCommandDone(token, drm.getData()); } @@ -2942,15 +2958,7 @@ public class MIVariableManager implements ICommandControl { drm.setData( new ExprMetaGetVarInfo( exprCtx.getRelativeExpression(), - varObj.isSafeToAskForAllChildren(), - // We only provide the hint here. It will be used for hasChildren() - // To obtain the correct number of children, the user should use - // IExpressions#getSubExpressionCount() - varObj.getNumChildrenHint(), - varObj.getType(), - varObj.getGDBType(), - !varObj.isComplex(), - varObj.getDisplayHint().isCollectionHint())); + varObj)); drm.done(); processCommandDone(token, drm.getData()); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java index 5785f7a2eff..7eabadbe454 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Ericsson and others. + * Copyright (c) 2007, 2015 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 @@ -8,12 +8,15 @@ * Contributors: * Ericsson - initial API and implementation * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) + * Vladimir Prus (Mentor Graphics) - Added getRawFields method. *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.output; import org.eclipse.cdt.dsf.debug.service.command.ICommand; import org.eclipse.cdt.dsf.debug.service.command.ICommandResult; import org.eclipse.cdt.dsf.gdb.GDBTypeParser.GDBType; +import org.eclipse.cdt.dsf.mi.service.MIVariableManager; +import org.eclipse.cdt.dsf.mi.service.MIVariableManager.MIVariableObject; import org.eclipse.cdt.dsf.mi.service.command.commands.ExprMetaGetChildCount; public class ExprMetaGetVarInfo implements ICommandResult { @@ -26,6 +29,7 @@ public class ExprMetaGetVarInfo implements ICommandResult { /** If true, the variable is a collection, i.e. it may have children. */ private final boolean isCollectionHint; private final boolean isSafeToAskForAllChildren; + private MIVariableObject varObj; public ExprMetaGetVarInfo(String e, int n, String t, boolean edit) { this (e, n, t, null, edit); @@ -51,6 +55,37 @@ public class ExprMetaGetVarInfo implements ICommandResult { gdbType = gt; this.isCollectionHint = isCollectionHint; } + + /** + * @since 4.7 + */ + public ExprMetaGetVarInfo(String e, MIVariableObject varObj, int n) + { + this(e, + varObj.isSafeToAskForAllChildren(), + n, + varObj.getType(), + varObj.getGDBType(), + !varObj.isComplex(), + varObj.getDisplayHint().isCollectionHint()); + this.varObj = varObj; + } + + /** + * @since 4.7 + */ + public ExprMetaGetVarInfo(String e, MIVariableManager.MIVariableObject varObj) + { + // We only provide the hint here. It will be used for hasChildren() + // To obtain the correct number of children, the user should use + // IExpressions#getSubExpressionCount() + this(e, varObj, varObj.getNumChildrenHint()); + } + + /** Return raw MI fields for this variable. + * @since 4.7 + */ + public MITuple getRawFields() { return varObj.getRawFields(); } public String getExpr() { return expression; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIVar.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIVar.java index 48ccfc3bd46..c99a2c0537e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIVar.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIVar.java @@ -9,6 +9,7 @@ * QNX Software Systems - Initial API and implementation * Wind River Systems - Modified for new DSF Reference Implementation * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) + * Vladimir Prus (Mentor Graphics) - Add getRawFields method. *******************************************************************************/ package org.eclipse.cdt.dsf.mi.service.command.output; @@ -26,6 +27,8 @@ namic="1"},child={name="var6.[0].[3]",exp="[3]",numchild="0",type="std::basic_st */ public class MIVar { + MITuple raw; + String name = ""; //$NON-NLS-1$ String type = ""; //$NON-NLS-1$ String value = ""; //$NON-NLS-1$ @@ -35,6 +38,15 @@ public class MIVar { private boolean hasMore = false; private MIDisplayHint displayHint = MIDisplayHint.NONE; + /** + * Construct from the raw MI tuple. This is the preferred constructor, since calling all others + * will require caller to reimplement all or parts of parsing. + */ + public MIVar(MITuple tuple) { + this.raw = tuple; + parse(tuple); + } + public MIVar(String n, int num, String t) { this(n, false, num, false, t, MIDisplayHint.NONE); } @@ -78,8 +90,13 @@ public class MIVar { this.displayHint = displayHint; } - public MIVar(MITuple tuple) { - parse(tuple); + /** Return raw fields from MI. + * @since 4.7 + */ + public MITuple getRawFields() + { + assert raw != null; + return raw; } public String getVarName() {