internal static MSAst.Expression RemoveDebugInfo(int prevStart, MSAst.Expression res) { MSAst.BlockExpression block = res as MSAst.BlockExpression; if (block != null && block.Expressions.Count > 0) { MSAst.DebugInfoExpression dbgInfo = block.Expressions[0] as MSAst.DebugInfoExpression; // body on the same line as an if, don't generate a 2nd sequence point if (dbgInfo != null && dbgInfo.StartLine == prevStart) { // we remove the debug info based upon how it's generated in DebugStatement.AddDebugInfo which is // the helper method which adds the debug info. if (block.Type == typeof(void)) { Debug.Assert(block.Expressions.Count == 3); Debug.Assert(block.Expressions[2] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear); res = block.Expressions[1]; } else { Debug.Assert(block.Expressions.Count == 4); Debug.Assert(block.Expressions[3] is MSAst.DebugInfoExpression && ((MSAst.DebugInfoExpression)block.Expressions[2]).IsClear); Debug.Assert(block.Expressions[1] is MSAst.BinaryExpression && ((MSAst.BinaryExpression)block.Expressions[2]).NodeType == MSAst.ExpressionType.Assign); res = ((MSAst.BinaryExpression)block.Expressions[1]).Right; } } } return(res); }
internal static ClearDebugInfo ClearDebugInfo(DebugInfoExpression expression) { return new ClearDebugInfo() { Document = SymbolDocumentInfo.Serialize(expression.Document), }.Apply(n => n.Type = TypeRef.Serialize(expression.Type)); }
internal override void MarkSequencePoint(LambdaExpression method, MethodBase methodBase, ILGenerator ilg, DebugInfoExpression sequencePoint) { MethodBuilder builder = methodBase as MethodBuilder; if (builder != null) { ilg.MarkSequencePoint(this.GetSymbolWriter(builder, sequencePoint.Document), sequencePoint.StartLine, sequencePoint.StartColumn, sequencePoint.EndLine, sequencePoint.EndColumn); } }
protected internal override Expression VisitDebugInfo(DebugInfoExpression node) { Out($"<DebugInfo({node.Document.FileName}: {node.StartLine}, {node.StartColumn}, {node.EndLine}, {node.EndColumn})>"); return(node); }
public DebugInfoExpressionProxy(DebugInfoExpression node) { _node = node; }
internal static DebugInfo DebugInfo(DebugInfoExpression expression) { return expression.IsClear ? ClearDebugInfo(expression) : new DebugInfo() { Document = SymbolDocumentInfo.Serialize(expression.Document), StartLine = expression.StartLine, StartColumn = expression.StartColumn, EndLine = expression.EndLine, EndColumn = expression.EndColumn, }.Apply(n => n.Type = TypeRef.Serialize(expression.Type)); }
protected override MSAst.Expression VisitDebugInfo(MSAst.DebugInfoExpression node) { if (!node.IsClear) { MSAst.Expression transformedExpression; // Verify that DebugInfoExpression has valid SymbolDocumentInfo if (node.Document == null) { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, ErrorStrings.DebugInfoWithoutSymbolDocumentInfo, _locationCookie)); } DebugSourceFile sourceFile = _debugContext.GetDebugSourceFile( String.IsNullOrEmpty(node.Document.FileName) ? "<compile>" : node.Document.FileName); // Update the location cookie int locationCookie = _locationCookie++; if (!_transformToGenerator) { MSAst.Expression tracebackCall = null; if (locationCookie == 0) { tracebackCall = Ast.Empty(); } else { tracebackCall = Ast.Call( typeof(RuntimeOps).GetMethod(nameof(RuntimeOps.OnTraceEvent)), _thread, AstUtils.Constant(locationCookie), Ast.Convert(Ast.Constant(null), typeof(Exception)) ); } transformedExpression = Ast.Block( Ast.Assign( _debugMarker, AstUtils.Constant(locationCookie) ), Ast.IfThen( Ast.GreaterThan( Ast.Property(_sourceFilesToVariablesMap[sourceFile], "Mode"), Ast.Constant((int)DebugMode.ExceptionsOnly) ), Ast.IfThen( Ast.OrElse( Ast.Equal( Ast.Property(_sourceFilesToVariablesMap[sourceFile], "Mode"), Ast.Constant((int)DebugMode.FullyEnabled) ), Ast.ArrayIndex( _traceLocations, AstUtils.Constant(locationCookie) ) ), Ast.Block( _pushFrame ?? Ast.Empty(), tracebackCall ) ) ) ); } else { Debug.Assert(_generatorLabelTarget != null); transformedExpression = Ast.Block( AstUtils.YieldReturn( _generatorLabelTarget, _debugYieldValue, locationCookie ) ); // Update the variable scope map if (_currentLocals.Count > 0) { BlockExpression curentBlock = _currentLocals.Peek(); if (!_variableScopeMapCache.TryGetValue(curentBlock, out IList <VariableInfo> scopedVaribles)) { scopedVaribles = new List <VariableInfo>(); BlockExpression[] blocks = _currentLocals.ToArray(); for (int i = blocks.Length - 1; i >= 0; i--) { foreach (var variable in blocks[i].Variables) { scopedVaribles.Add(_localsToVarInfos[variable]); } } _variableScopeMapCache.Add(curentBlock, scopedVaribles); } _variableScopeMap.Add(locationCookie, scopedVaribles); } DebugSourceSpan span = new DebugSourceSpan( sourceFile, node.StartLine, node.StartColumn, node.EndLine, node.EndColumn); // Update the location-span map _markerLocationMap.Add(locationCookie, span); } return(transformedExpression); } return(Ast.Empty()); }
/// <summary> /// Marks a sequence point. /// </summary> /// <param name="method">The lambda being generated.</param> /// <param name="ilOffset">IL offset where to mark the sequence point.</param> /// <param name="sequencePoint">Debug informaton corresponding to the sequence point.</param> public abstract void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint);
protected override Expression VisitDebugInfo(DebugInfoExpression node) { throw new NotSupportedException(); }
public virtual bool IsEvaluatableDebugInfo (DebugInfoExpression node) { ArgumentUtility.CheckNotNull ("node", node); return true; }
protected internal virtual new Expression VisitDebugInfo(DebugInfoExpression node) { return(default(Expression)); }
protected virtual Expression VisitDebugInfo(DebugInfoExpression node) { throw new NotImplementedException(); }
public override void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint) { Debug.Assert(false); }
/// <summary> /// Visits the <see cref="DebugInfoExpression"/>. /// </summary> /// <param name="node">The expression to visit.</param> /// <returns>The modified expression, if it or any subexpression was modified; /// otherwise, returns the original expression.</returns> protected internal virtual Expression VisitDebugInfo(DebugInfoExpression node) { return(node); }
protected internal override Expression VisitDebugInfo(DebugInfoExpression node) { Visit(node.Expression); return(node); }
// Summary: // Marks a sequence point in Microsoft intermediate language (MSIL) code. // // Parameters: // method: // The lambda expression that is generated. // // ilOffset: // The offset within MSIL code at which to mark the sequence point. // // sequencePoint: // Debug information that corresponds to the sequence point. public override void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint) { Contract.Requires(method != null); Contract.Requires(sequencePoint != null); }
public DebugInfoExpressionProxy(DebugInfoExpression node) { ArgumentNullException.ThrowIfNull(node); _node = node; }
public DebugInfoExpressionProxy(DebugInfoExpression node) { ContractUtils.RequiresNotNull(node, nameof(node)); _node = node; }
public override void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint) { throw Error.PdbGeneratorNeedsExpressionCompiler(); }
}//end static method internal XElement DebugInfoExpressionToXElement(DebugInfoExpression e) { object value; string xName = "DebugInfoExpression"; object[] XElementValues = new object[9]; value = ((DebugInfoExpression)e).Type; XElementValues[0] = GenerateXmlFromProperty(typeof(System.Type), "Type", value ?? string.Empty); value = ((DebugInfoExpression)e).NodeType; XElementValues[1] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.ExpressionType), "NodeType", value ?? string.Empty); value = ((DebugInfoExpression)e).StartLine; XElementValues[2] = GenerateXmlFromProperty(typeof(System.Int32), "StartLine", value ?? string.Empty); value = ((DebugInfoExpression)e).StartColumn; XElementValues[3] = GenerateXmlFromProperty(typeof(System.Int32), "StartColumn", value ?? string.Empty); value = ((DebugInfoExpression)e).EndLine; XElementValues[4] = GenerateXmlFromProperty(typeof(System.Int32), "EndLine", value ?? string.Empty); value = ((DebugInfoExpression)e).EndColumn; XElementValues[5] = GenerateXmlFromProperty(typeof(System.Int32), "EndColumn", value ?? string.Empty); value = ((DebugInfoExpression)e).Document; XElementValues[6] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.SymbolDocumentInfo), "Document", value ?? string.Empty); value = ((DebugInfoExpression)e).IsClear; XElementValues[7] = GenerateXmlFromProperty(typeof(System.Boolean), "IsClear", value ?? string.Empty); value = ((DebugInfoExpression)e).CanReduce; XElementValues[8] = GenerateXmlFromProperty(typeof(System.Boolean), "CanReduce", value ?? string.Empty); return new XElement(xName, XElementValues); }//end static method
internal virtual void MarkSequencePoint(LambdaExpression method, MethodBase methodBase, ILGenerator ilg, DebugInfoExpression sequencePoint) { MarkSequencePoint(method, ilg.ILOffset, sequencePoint); }
public override void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression node) { RubyMethodDebugInfo.GetOrCreate(method.Name).AddMapping(ilOffset, node.StartLine); }
private Variable VisitDebugInfo(DebugInfoExpression node) { // nothing to do throw new NotSupportedException("Expression of type " + node.NodeType + " is not supported"); }