Exemplo n.º 1
0
        internal void UpdateSyntaxNode(SyntaxNode node, EmitContext context)
        {
            var nodeLocation = node.GetLocation().GetLineSpan().EndLinePosition;

            MethodDebugMarker currentMarker = _currentSpan ?? new MethodDebugMarker()
            {
                startInstruction = -1
            };

            int currentAddress = (int)context.Module.CurrentAddress;

            if (currentMarker.startInstruction == -1)
            {
                currentMarker.startInstruction = currentAddress;
                currentMarker.startLine        = nodeLocation.Line;
                currentMarker.startChar        = nodeLocation.Character;

                _currentSpan = currentMarker;
            }
            else if (currentMarker.startLine != nodeLocation.Line ||
                     currentMarker.startChar != nodeLocation.Character)
            {
                if (_currentDebugInfo.debugMarkers == null)
                {
                    _currentDebugInfo.debugMarkers = new List <MethodDebugMarker>();
                }

                _currentDebugInfo.debugMarkers.Add(currentMarker);
                _currentSpan = null;
            }
        }
Exemplo n.º 2
0
        public void GetPositionFromProgramCounter(int programCounter, out string sourceFilePath, out string methodName, out int line, out int character)
        {
            sourceFilePath = null;
            methodName     = null;
            line           = 0;
            character      = 0;

            if (_methodDebugInfos == null)
            {
                return;
            }

            foreach (MethodDebugInfo debugInfo in _methodDebugInfos)
            {
                if (programCounter >= debugInfo.methodStartAddress && programCounter < debugInfo.methodEndAddress)
                {
                    sourceFilePath = debugInfo.containingFilePath;
                    methodName     = debugInfo.methodName;

                    if (debugInfo.debugMarkers == null || debugInfo.debugMarkers.Count == 0)
                    {
                        return;
                    }

                    if (programCounter >= debugInfo.debugMarkers.Last().startInstruction)
                    {
                        line      = debugInfo.debugMarkers.Last().startLine;
                        character = debugInfo.debugMarkers.Last().startChar;
                        return;
                    }

                    for (int i = 0; i < debugInfo.debugMarkers.Count - 1; ++i)
                    {
                        MethodDebugMarker currentMarker = debugInfo.debugMarkers[i];
                        MethodDebugMarker nextMarker    = debugInfo.debugMarkers[i + 1];

                        if (programCounter >= currentMarker.startInstruction &&
                            programCounter < nextMarker.startInstruction)
                        {
                            line      = currentMarker.startLine;
                            character = currentMarker.startChar;
                            return;
                        }
                    }

                    line      = debugInfo.debugMarkers.Last().startLine;
                    character = debugInfo.debugMarkers.Last().startChar;
                }
            }
        }