/// <summary> /// Parses an expression in text form for later evaluation. /// </summary> /// <param name="pszCode">The expression to be parsed.</param> /// <param name="dwFlags">A combination of flags from the PARSEFLAGS enumeration that controls parsing.</param> /// <param name="nRadix">The radix to be used in parsing any numerical information in pszCode.</param> /// <param name="ppExpr">Returns the IDebugExpression2 object that represents the parsed expression, which is ready for binding and evaluation.</param> /// <param name="pbstrError">Returns the error message if the expression contains an error.</param> /// <param name="pichError">Returns the character index of the error in pszCode if the expression contains an error.</param> /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns> /// <remarks> /// When this method is called, a debug engine (DE) should parse the expression and validate it for correctness. /// The pbstrError and pichError parameters may be filled in if the expression is invalid. /// /// Note that the expression is not evaluated, only parsed. A later call to the IDebugExpression2.EvaluateSync /// or IDebugExpression2.EvaluateAsync methods evaluates the parsed expression. /// </remarks> public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { if (pszCode == null) throw new ArgumentNullException("pszCode"); if (pszCode.Length == 0) throw new ArgumentException(); // dwFlags=0 in the Immediate window if (dwFlags != enum_PARSEFLAGS.PARSE_EXPRESSION && dwFlags != 0) throw new NotImplementedException(); try { var expressionInput = new ANTLRStringStream(pszCode); var expressionUnicodeInput = new JavaUnicodeStream(expressionInput); var expressionLexer = new Java2Lexer(expressionUnicodeInput); var expressionTokens = new CommonTokenStream(expressionLexer); var expressionParser = new Java2Parser(expressionTokens); IAstRuleReturnScope<CommonTree> result = expressionParser.standaloneExpression(); ppExpr = new JavaDebugExpression(this, result.Tree, pszCode); pbstrError = null; pichError = 0; return VSConstants.S_OK; } catch (RecognitionException e) { ppExpr = null; pbstrError = e.Message; pichError = (uint)Math.Max(0, e.Index); return VSConstants.E_FAIL; } }
public int GetExpression(out IDebugExpression2 ppExpr) { if (_exception != null) { throw _exception; } ppExpr = _expression; return VSConstants.S_OK; }
public DebugExpressionEvaluationCompleteEvent(enum_EVENTATTRIBUTES attributes, IDebugExpression2 expression, IDebugProperty2 property) : base(attributes) { Contract.Requires<ArgumentNullException>(expression != null, "expression"); Contract.Requires<ArgumentNullException>(property != null, "property"); _expression = expression; _property = property; }
public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = ""; pichError = 0; ppExpr = null; string lookup = pszCode; LocalVariable result = ThreadContext.GetVisibleVariableByName(lookup); if (result != null) { ppExpr = new AD7Expression(new MonoProperty(ThreadContext, result)); return VSConstants.S_OK; } pbstrError = "Unsupported Expression"; pichError = (uint)pbstrError.Length; return VSConstants.S_FALSE; }
int IDebugExpressionContext2.ParseText( string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = null; ppExpr = null; pichError = 0; try { AD7DebugExpression expr = new AD7DebugExpression(_stackFrame, pszCode); bool success = DebuggerManager.Instance.Debugger.TryParseExpression(pszCode, out pbstrError); if (success) ppExpr = (IDebugExpression2)expr; } catch (Exception e) { pbstrError = e.Message; return VSConstants.E_FAIL; } return VSConstants.S_OK; }
public int GetExpression(out IDebugExpression2 expr) { expr = new AD7Expression(_engine, _var); return(Constants.S_OK); }
/// <summary> /// Parses an expression in text form for later evaluation. /// </summary> public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { DLog.Debug(DContext.VSDebuggerComCall, "DebugStackFrame.ParseText"); ppExpr = null; pbstrError = null; pichError = 0; // Try to match a local variable var locals = GetValues(); var localVariable = locals.FirstOrDefault(x => x.Name == pszCode); if (localVariable != null) { ppExpr = new DebugExpression(new DebugValueProperty(localVariable, null)); return VSConstants.S_OK; } return VSConstants.E_FAIL; }
public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { ppExpr = null; pbstrError = ""; pichError = 0; return VSConstants.E_NOTIMPL; }
public int GetExpression(out IDebugExpression2 expr) { expr = new AD7Expression(_engine, _var); return Constants.S_OK; }
public int GetExpression(out IDebugExpression2 ppExpr) { ppExpr = _expression; return VSConstants.S_OK; }
public static int OnEvaluationComplete(this IDebugEngineHandler handler, IDebugExpression2 expr, IDebugProperty2 result, IGgpDebugProgram program, IDebugThread2 thread) => handler.SendEvent(new DebugExpressionEvaluationCompleteEvent(expr, result), program, thread);
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = ""; pichError = 0; if (_parameters != null) { foreach (NodeEvaluationResult currVariable in _parameters) { if (String.CompareOrdinal(currVariable.Name, pszCode) == 0) { ppExpr = new AD7Expression(this, currVariable.Name); return VSConstants.S_OK; } } } if (_locals != null) { foreach (NodeEvaluationResult currVariable in _locals) { if (String.CompareOrdinal(currVariable.Name, pszCode) == 0) { ppExpr = new AD7Expression(this, currVariable.Name); return VSConstants.S_OK; } } } string errorMsg; if (!_stackFrame.TryParseText(pszCode, out errorMsg)) { pbstrError = "Error: " + errorMsg; pichError = (uint) pbstrError.Length; } ppExpr = new AD7Expression(this, pszCode); return VSConstants.S_OK; }
int IDebugExpressionEvaluationCompleteEvent2.GetExpression (out IDebugExpression2 ppExpr) { LoggingUtils.PrintFunction (); ppExpr = m_debugExpression; return Constants.S_OK; }
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = ""; pichError = 0; ppExpr = null; try { var localOrArg = m_parameters.Concat(m_locals).FirstOrDefault(v => String.CompareOrdinal(v.m_name, pszCode) == 0); if (localOrArg != null) { ppExpr = new AD7Property(localOrArg); return Constants.S_OK; } var result = m_engine.DebuggedProcess.Evaluate(m_threadContext, pszCode, out pbstrError); if (result != null) { ppExpr = new AD7Property(result); return Constants.S_OK; } pichError = (uint)pbstrError.Length; return Constants.S_FALSE; } catch (Exception e) { return EngineUtils.UnexpectedException(e); } }
public int GetExpression(out IDebugExpression2 ppExpr) { ppExpr = _expression; return(VisualStudioExtensionConstants.S_OK); }
// Parses a text-based expression for evaluation. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = ""; pichError = 0; ppExpr = null; try { // Check if the expression belongs to the parameters foreach (var currVariable in _parameters) { if (String.CompareOrdinal(currVariable.Name, pszCode) == 0) { ppExpr = new XamarinExpression(_engine, _thread, currVariable); return(VisualStudioExtensionConstants.S_OK); } } // Check if the expression belongs to the locals foreach (var currVariable in _locals) { if (String.CompareOrdinal(currVariable.Name, pszCode) == 0) { ppExpr = new XamarinExpression(_engine, _thread, currVariable); return(VisualStudioExtensionConstants.S_OK); } } if (_thisObject != null) { // Are we looking for "this"? if (String.CompareOrdinal("this", pszCode) == 0) { ppExpr = new XamarinExpression(_engine, _thread, _thisObject); return(VisualStudioExtensionConstants.S_OK); } // Lastly, check if it's a member of this var parsedExpression = ParseThisInternals(_thisObject, pszCode); if (parsedExpression != null) { ppExpr = parsedExpression; return(VisualStudioExtensionConstants.S_OK); } } pbstrError = "Invalid Expression"; pichError = (uint)pbstrError.Length; return(VisualStudioExtensionConstants.S_FALSE); } catch (ComponentException e) { return(e.HResult); } catch (Exception e) { NLogService.Logger.Error(e); return(VisualStudioExtensionConstants.S_FALSE); } }
public ExpressionEvalCompleteEvent(IDebugExpression2 pExpr, IDebugProperty2 pProp) { _expr = pExpr; _prop = pProp; }
// Token: 0x060001F8 RID: 504 RVA: 0x00006E30 File Offset: 0x00005030 int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { EvaluationOptions defaultOptions = StackFrame.DefaultOptions; defaultOptions.AllowMethodEvaluation = false; defaultOptions.AllowTargetInvoke = false; defaultOptions.AllowToStringCalls = false; defaultOptions.EvaluationTimeout = 1000; defaultOptions.MemberEvaluationTimeout = 1000; if (nRadix == 16U) { defaultOptions.IntegerDisplayFormat = IntegerDisplayFormat.Hexadecimal; } else { defaultOptions.IntegerDisplayFormat = IntegerDisplayFormat.Decimal; } ValidationResult validationResult = this.Frame.Frame.ValidateExpression(pszCode, defaultOptions); if (!validationResult.IsValid) { pbstrError = validationResult.Message; pichError = 0U; ppExpr = null; return(1); } pbstrError = null; pichError = 0U; ppExpr = new StackFrame.Expression(this.Frame, pszCode); return(0); }
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = ""; pichError = 0; ppExpr = null; if (IsDebuggingNPL()) { VariableInformation varInfo = VariableInformation.Create(m_engine.DebuggedProcess, pszCode); if (varInfo != null) { ppExpr = new AD7Expression(varInfo); return(Constants.S_OK); } else { return(Constants.S_FALSE); } } try { if (m_parameters != null) { foreach (VariableInformation currVariable in m_parameters) { if (String.CompareOrdinal(currVariable.m_name, pszCode) == 0) { ppExpr = new AD7Expression(currVariable); return(Constants.S_OK); } } } if (m_locals != null) { foreach (VariableInformation currVariable in m_locals) { if (String.CompareOrdinal(currVariable.m_name, pszCode) == 0) { ppExpr = new AD7Expression(currVariable); return(Constants.S_OK); } } } pbstrError = "Invalid Expression"; pichError = (uint)pbstrError.Length; return(Constants.S_FALSE); } catch (ComponentException e) { return(e.HResult); } catch (Exception e) { return(EngineUtils.UnexpectedException(e)); } }
int IDebugExpressionEvaluationCompleteEvent2.GetExpression(out IDebugExpression2 ppExpr) { ppExpr = Expression; return(VSConstants.S_OK); }
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { // pbstrError = ""; // pichError = 0; // ppExpr = null; // return VSConstants.E_NOTIMPL; pbstrError = ""; pichError = 0; ppExpr = null; // Parse here, if needed: verify if it is a valid expression, and store the parsed results into VariableInfo, or create another object. // if not: send a GDB command to evaluate the expression pszCode. It should return the result or an error message. // This object is indirectly sent to IDebugExpression2.EvaluateAsync // if pszCode is a variable, it must be found in Locals. // VariableInfo vi = new VariableInfo(pszCode,"",""); ppExpr = new AD7Expression(pszCode, this, m_engine.eDispatcher); return VSConstants.S_OK; }
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { //System.Windows.Forms.AD7Util.MessageBox("pszCode: " + pszCode); pbstrError = ""; pichError = 0; ppExpr = null; try { if (mParams != null) { foreach (DebugLocalInfo currVariable in mParams) { if (String.CompareOrdinal(currVariable.Name, pszCode) == 0) { ppExpr = new AD7Expression(currVariable, mProcess, this); return(VSConstants.S_OK); } } } if (mLocals != null) { foreach (DebugLocalInfo currVariable in mLocals) { if (String.CompareOrdinal(currVariable.Name, pszCode) == 0) { ppExpr = new AD7Expression(currVariable, mProcess, this); return(VSConstants.S_OK); } } } pbstrError = "Invalid Expression"; pichError = (uint)pbstrError.Length; return(VSConstants.S_FALSE); } catch (Exception e) { return(EngineUtils.UnexpectedException(e)); } }
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = ""; pichError = 0; ppExpr = null; if(IsDebuggingNPL()) { VariableInformation varInfo = VariableInformation.Create(m_engine.DebuggedProcess, pszCode); if (varInfo!=null) { ppExpr = new AD7Expression(varInfo); return Constants.S_OK; } else { return Constants.S_FALSE; } } try { if (m_parameters != null) { foreach (VariableInformation currVariable in m_parameters) { if (String.CompareOrdinal(currVariable.m_name, pszCode) == 0) { ppExpr = new AD7Expression(currVariable); return Constants.S_OK; } } } if (m_locals != null) { foreach (VariableInformation currVariable in m_locals) { if (String.CompareOrdinal(currVariable.m_name, pszCode) == 0) { ppExpr = new AD7Expression(currVariable); return Constants.S_OK; } } } pbstrError = "Invalid Expression"; pichError = (uint)pbstrError.Length; return Constants.S_FALSE; } catch (ComponentException e) { return e.HResult; } catch (Exception e) { return EngineUtils.UnexpectedException(e); } }
public ExpressionEvaluationComplete (IDebugExpression2 expression, IDebugProperty2 property) { m_debugExpression = expression; m_debugProperty = property; }
public DebugExpressionEvaluationCompleteEvent(enum_EVENTATTRIBUTES attributes, IDebugExpression2 expression, IDebugProperty2 property) : base(attributes) { Contract.Requires <ArgumentNullException>(expression != null, "expression"); Contract.Requires <ArgumentNullException>(property != null, "property"); _expression = expression; _property = property; }
/// <summary> /// Parses an expression in text form for later evaluation. /// </summary> public int ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { DLog.Debug(DContext.VSDebuggerComCall, "DebugStackFrame.ParseText"); ppExpr = null; pbstrError = null; pichError = 0; // special registers group? if (pszCode.StartsWith("$reg", StringComparison.InvariantCultureIgnoreCase)) { ppExpr = new DebugExpression(new DebugRegisterGroupProperty(this, false)); return VSConstants.S_OK; } // Try to match a local variable try { var locals = GetValues(); var localVariable = locals == null ? null : locals.FirstOrDefault(x => x.Name == pszCode); if (localVariable != null) { ppExpr = new DebugExpression(new DebugStackFrameValueProperty(localVariable, null, this)); return VSConstants.S_OK; } } catch { } // try to match any of the registers. var match = castRegisterExpression.Match(pszCode); if (match.Success) { var castExpr = match.Groups[1].Value.Trim(); var registerType = match.Groups[2].Value; int index = int.Parse(match.Groups[3].Value); ppExpr = new DebugRegisterExpression(this, pszCode, registerType, index, castExpr); return VSConstants.S_OK; } // try to match opcode help (in disassembly) var opHelp = Opcodes.Lookup(pszCode); if (opHelp != null) { ppExpr = new DebugExpression(new DebugConstProperty(pszCode, opHelp.Syntax + "\r\n\r\n" + opHelp.Arguments + "\r\n\r\n" + opHelp.Description, "(opcode)", null)); return VSConstants.S_OK; } return VSConstants.E_FAIL; }
public int GetExpression(out IDebugExpression2 expr) { expr = new MonoExpression(engine, thread, expression, value); return(VSConstants.S_OK); }
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = String.Empty; pichError = 0; IEnumerable<NodeEvaluationResult> evaluationResults = _stackFrame.Locals.Union(_stackFrame.Parameters); foreach (NodeEvaluationResult currVariable in evaluationResults) { if (String.CompareOrdinal(currVariable.Expression, pszCode) == 0) { ppExpr = new UncalculatedAD7Expression(this, currVariable.Expression); return VSConstants.S_OK; } } string errorMsg; if (!_stackFrame.TryParseText(pszCode, out errorMsg)) { pbstrError = "Error: " + errorMsg; pichError = (uint)pbstrError.Length; } ppExpr = new UncalculatedAD7Expression(this, pszCode); return VSConstants.S_OK; }
public int GetExpression(out IDebugExpression2 ppExpr) { ppExpr = _evaluatedExpression; return(S_OK); }
int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = ""; pichError = 0; ppExpr = new AD7Expression(this, pszCode); return VSConstants.S_OK; }
public AD7ExpressionEvaluationCompleteEvent(IDebugExpression2 expression, IDebugProperty2 property) { this._expression = expression; this._property = property; }
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { //System.Windows.Forms.MessageBox.Show("pszCode: " + pszCode); pbstrError = ""; pichError = 0; ppExpr = null; try { if (mParams != null) { foreach (DebugLocalInfo currVariable in mParams) { if (String.CompareOrdinal(currVariable.Name, pszCode) == 0) { ppExpr = new AD7Expression(currVariable, mProcess, this); return VSConstants.S_OK; } } } if (mLocals != null) { foreach (DebugLocalInfo currVariable in mLocals) { if (String.CompareOrdinal(currVariable.Name, pszCode) == 0) { ppExpr = new AD7Expression(currVariable, mProcess, this); return VSConstants.S_OK; } } } pbstrError = "Invalid Expression"; pichError = (uint)pbstrError.Length; return VSConstants.S_FALSE; } catch (Exception e) { return EngineUtils.UnexpectedException(e); } }
public int GetExpression(out IDebugExpression2 ppExpr) { ppExpr = _expression; return(VSConstants.S_OK); }
public AD7ExpressionEvaluationCompleteEvent(IDebugExpression2 expression, IDebugProperty2 property) { _expression = expression; _property = property; }
public void ExpressionEvalCompleted( AD7ProgramNode node, IDebugExpression2 pExpr, IDebugProperty2 pProp) { Debug.WriteLine("Event ExpressionEvaluationCompleted"); Guid iid = new Guid(ExpressionEvalCompleteEvent.IID); _callback.Event( _engine, null, node, node, new ExpressionEvalCompleteEvent( pExpr, pProp ), ref iid, ExpressionEvalCompleteEvent.Attributes); }
public ExpressionEvalCompleteEvent( IDebugExpression2 pExpr, IDebugProperty2 pProp ) { _expr = pExpr; _prop = pProp; }
int IDebugExpressionEvaluationCompleteEvent2.GetExpression(out IDebugExpression2 ppExpr) { ppExpr = _expr; return VSConstants.S_OK; }
// Parses a text-based expression for evaluation. // The engine sample only supports locals and parameters so the only task here is to check the names in those collections. int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = null; pichError = 0; ppExpr = null; try { // we have no "parser" as such, so we accept anything that isn't blank and let the Evaluate method figure out the errors ppExpr = new AD7Expression(Engine.DebuggedProcess.Natvis.GetVariable(pszCode, this)); return Constants.S_OK; } catch (MIException e) { return e.HResult; } catch (Exception e) { return EngineUtils.UnexpectedException(e); } }
int IDebugExpressionContext2.ParseText(string pszCode, enum_PARSEFLAGS dwFlags, uint nRadix, out IDebugExpression2 ppExpr, out string pbstrError, out uint pichError) { pbstrError = ""; pichError = 0; ppExpr = new AD7Expression(this, pszCode); return(VSConstants.S_OK); }