1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-07 08:15:48 +02:00

Expose raw varobj fields in MIVariableObject.

Presently, the field from MI are parsed in MIVar, then copied to
MIVariableManager.MIVariableObject, and then to ExprMetaGetVarInfo.
As result, although MI allows additional fields, a custom IDE cannot
access them, even though all of the above classes are in dsf.gdb
package.

This package firstly eliminates some code duplication, and then make
raw MITuple be propagated along the chain.

Change-Id: I57436fef65aaaf4805422df34466d10f2a205920
This commit is contained in:
Vladimir Prus 2015-02-05 20:44:05 +03:00
parent c7f6b0f2b8
commit 1502c78cd6
3 changed files with 79 additions and 19 deletions

View file

@ -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());
}

View file

@ -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 <code>true</code>, 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; }

View file

@ -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() {