// Raw direct call to Player public static void doShowVariable(DebugCLI cli) { cli.waitTilHalted(); try { // an integer followed by a variable name Session session = cli.Session; int id = cli.nextIntToken(); String name = (cli.hasMoreTokens())?cli.nextToken():null; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(name); sb.Append(" = "); //$NON-NLS-1$ Value v = ((PlayerSession)session).getValue(id, name); ExpressionCache.appendVariableValue(sb, v); cli.output(sb.ToString()); } catch (NullReferenceException) { cli.err(LocalizationManager.getLocalizedTextString("key26")); //$NON-NLS-1$ } }
/* returns a string consisting of formatted member names and values */ public virtual Object lookupMembers(Object o) { Variable var = null; Value val = null; Variable[] mems = null; try { var = resolveToVariable(o); if (var != null) { val = var.getValue(); } else { val = resolveToValue(o); } mems = val.getMembers(Session); } catch (NullReferenceException) { throw new NoSuchVariableException(o); } catch (PlayerDebugException) { throw new NoSuchVariableException(o); // not quite right... } System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (var != null) { ExpressionCache.appendVariable(sb, var); } else { ExpressionCache.appendVariableValue(sb, val); } bool attrs = m_cache.propertyEnabled(DebugCLI.DISPLAY_ATTRIBUTES); if (attrs && var != null) { ExpressionCache.appendVariableAttributes(sb, var); } // [mmorearty] experimenting with hierarchical display of members String[] classHierarchy = val.getClassHierarchy(false); if (classHierarchy != null && Session.getPreference(SessionManager.PREF_HIERARCHICAL_VARIABLES) != 0) { for (int c = 0; c < classHierarchy.Length; ++c) { String classname = classHierarchy[c]; sb.Append(m_newline + "(Members of " + classname + ")"); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < mems.Length; ++i) { if (classname.Equals(mems[i].getDefiningClass())) { sb.Append(m_newline + " "); //$NON-NLS-1$ ExpressionCache.appendVariable(sb, mems[i]); if (attrs) { ExpressionCache.appendVariableAttributes(sb, mems[i]); } } } } } else { for (int i = 0; i < mems.Length; i++) { sb.Append(m_newline + " "); //$NON-NLS-1$ ExpressionCache.appendVariable(sb, mems[i]); if (attrs) { ExpressionCache.appendVariableAttributes(sb, mems[i]); } } } return(sb.ToString()); }