Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 5
0
 public DebugInfoExpressionProxy(DebugInfoExpression node)
 {
     _node = node;
 }
Esempio n. 6
0
 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());
        }
Esempio n. 8
0
 /// <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;
    }
Esempio n. 11
0
 protected internal virtual new Expression VisitDebugInfo(DebugInfoExpression node)
 {
     return(default(Expression));
 }
Esempio n. 12
0
 protected virtual Expression VisitDebugInfo(DebugInfoExpression node)
 {
     throw new NotImplementedException();
 }
Esempio n. 13
0
 public override void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint) {
     Debug.Assert(false);
 }
Esempio n. 14
0
 /// <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);
 }
Esempio n. 15
0
 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);
 }
Esempio n. 17
0
 public DebugInfoExpressionProxy(DebugInfoExpression node)
 {
     ArgumentNullException.ThrowIfNull(node);
     _node = node;
 }
 public DebugInfoExpressionProxy(DebugInfoExpression node) {
     _node = node;
 }
Esempio n. 19
0
 public DebugInfoExpressionProxy(DebugInfoExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }
Esempio n. 20
0
 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
Esempio n. 22
0
 internal virtual void MarkSequencePoint(LambdaExpression method, MethodBase methodBase, ILGenerator ilg, DebugInfoExpression sequencePoint) {
     MarkSequencePoint(method, ilg.ILOffset, sequencePoint);
 }
 public DebugInfoExpressionProxy(DebugInfoExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }
Esempio n. 24
0
 public override void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression node) {
     RubyMethodDebugInfo.GetOrCreate(method.Name).AddMapping(ilOffset, node.StartLine);
 }
Esempio n. 25
0
 private Variable VisitDebugInfo(DebugInfoExpression node)
 {
     // nothing to do
     throw new NotSupportedException("Expression of type " + node.NodeType + " is not supported");
 }