//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public CLangDebuggeeProperty (CLangDebugger debugger, CLangDebuggeeStackFrame stackFrame, MiVariable gdbVariable) : base (debugger.Engine, stackFrame, gdbVariable.Expression, string.Empty) { m_debugger = debugger; m_gdbVariable = gdbVariable; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public CLangDebuggeeProperty CreatePropertyFromVariable (CLangDebuggeeStackFrame stackFrame, MiVariable variable) { LoggingUtils.PrintFunction (); try { if (stackFrame == null) { throw new ArgumentNullException ("stackFrame"); } if (variable == null) { throw new ArgumentNullException ("variable"); } /*CLangDebuggeeProperty [] childProperties = GetChildProperties (stackFrame, parentProperty); parentProperty.AddChildren (childProperties);*/ return new CLangDebuggeeProperty (m_debugger, stackFrame, variable);; } catch (Exception e) { LoggingUtils.HandleException (e); return null; } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public CLangDebuggeeProperty (CLangDebugger debugger, CLangDebuggeeStackFrame stackFrame, string expression, string value) : base (debugger.Engine, stackFrame, expression, value) { m_debugger = debugger; m_gdbVariable = null; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void AddChild(MiVariable variable) { LoggingUtils.PrintFunction(); if (variable == null) { throw new ArgumentNullException("variable"); } m_children [variable.Name] = variable; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void AddChild (MiVariable variable) { LoggingUtils.PrintFunction (); if (variable == null) { throw new ArgumentNullException ("variable"); } m_children [variable.Name] = variable; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public CLangDebuggeeProperty (CLangDebuggeeProperty parent, MiVariable gdbVariable) : this (parent.m_debugger, parent.m_stackFrame as CLangDebuggeeStackFrame, gdbVariable) { m_parent = parent; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void DeleteGdbVariable (MiVariable gdbVariable) { LoggingUtils.PrintFunction (); string command = string.Format ("-var-delete \"{0}\"", gdbVariable.Name); MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand (command); MiResultRecord.RequireOk (resultRecord, command); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void UpdateVariable (MiVariable variable) { LoggingUtils.PrintFunction (); string command = string.Format ("-var-update --all-values \"{0}\"", variable.Name); MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand (command); MiResultRecord.RequireOk (resultRecord, command); if (resultRecord.HasField ("changelist")) { variable.Populate (resultRecord ["changelist"]); } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private MiVariable [] GetChildVariables (MiVariable parentVariable, int depth) { LoggingUtils.PrintFunction (); List<MiVariable> childVariables = new List<MiVariable> (); if ((depth > 0) && (parentVariable.HasChildren)) { string command = string.Format ("-var-list-children --all-values \"{0}\"", parentVariable.Name); MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand (command); MiResultRecord.RequireOk (resultRecord, command); if (resultRecord.HasField ("children")) { List<MiResultValue> childrenList = resultRecord ["children"] [0] ["child"]; for (int i = 0; i < childrenList.Count; ++i) { MiResultValueTuple childTuple = childrenList [i] as MiResultValueTuple; string variableName = childTuple ["name"] [0].GetString (); MiVariable childVariable = null; bool isPseudoChild = false; if (childTuple.HasField ("exp")) { string variableExpression = childTuple ["exp"] [0].GetString (); if (!string.IsNullOrEmpty (variableExpression)) { childVariable = new MiVariable (variableName, variableExpression); childVariable.Populate (childTuple.Values); isPseudoChild = childVariable.IsPseudoChild; } } if (childVariable == null) { childVariable = new MiVariable (variableName, childTuple.Values); } if (isPseudoChild) { depth += 1; // need an additional level of children. MiVariable [] evaluatedChildren = GetChildVariables (childVariable, depth - 1); foreach (MiVariable child in evaluatedChildren) { childVariable.AddChild (child); } } childVariables.Add (childVariable); } } } return childVariables.ToArray (); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void CreateChildVariables (MiVariable parentVariable, int depth) { LoggingUtils.PrintFunction (); if ((depth > 0) && (parentVariable.HasChildren)) { MiVariable [] evaluatedChildren = GetChildVariables (parentVariable, depth); foreach (MiVariable child in evaluatedChildren) { CreateChildVariables (child, depth - 1); parentVariable.AddChild (child); } } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void AddChild(MiVariable variable) { m_children [variable.Name] = variable ?? throw new ArgumentNullException(nameof(variable));; }