当前位置: 首页>>代码示例>>C#>>正文


C# SourceLocation.Encode方法代码示例

本文整理汇总了C#中SourceLocation.Encode方法的典型用法代码示例。如果您正苦于以下问题:C# SourceLocation.Encode方法的具体用法?C# SourceLocation.Encode怎么用?C# SourceLocation.Encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SourceLocation的用法示例。


在下文中一共展示了SourceLocation.Encode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindSymbols

        public static DkmInstructionSymbol[] FindSymbols(DkmResolvedDocument resolvedDocument, DkmTextSpan textSpan, string text, out DkmSourcePosition[] symbolLocation) {
            var sourceFileId = DkmSourceFileId.Create(resolvedDocument.DocumentName, null, null, null);
            var resultSpan = new DkmTextSpan(textSpan.StartLine, textSpan.StartLine, 0, 0);
            symbolLocation = new[] { DkmSourcePosition.Create(sourceFileId, resultSpan) };

            var location = new SourceLocation(resolvedDocument.DocumentName, textSpan.StartLine);
            var encodedLocation = location.Encode();
            return new[] { DkmCustomInstructionSymbol.Create(resolvedDocument.Module, Guids.PythonRuntimeTypeGuid, encodedLocation, 0, encodedLocation) };
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:9,代码来源:ModuleManager.cs

示例2: FilterNextFrame

        public DkmStackWalkFrame[] FilterNextFrame(DkmStackContext stackContext, DkmStackWalkFrame nativeFrame) {
            var nativeModuleInstance = nativeFrame.ModuleInstance;
            if (nativeModuleInstance == _pyrtInfo.DLLs.DebuggerHelper) {
                return DebuggerOptions.ShowNativePythonFrames ? new[] { nativeFrame } : new DkmStackWalkFrame[0];
            }

            var result = new List<DkmStackWalkFrame>();
            var stackWalkData = stackContext.GetDataItem<StackWalkContextData>();
            if (stackWalkData == null) {
                stackWalkData = new StackWalkContextData();
                stackContext.SetDataItem(DkmDataCreationDisposition.CreateNew, stackWalkData);
            }
            bool? wasLastFrameNative = stackWalkData.IsLastFrameNative;

            if (nativeModuleInstance != _pyrtInfo.DLLs.Python && nativeModuleInstance != _pyrtInfo.DLLs.CTypes) {
                stackWalkData.IsLastFrameNative = true;
                if (wasLastFrameNative == false) {
                    result.Add(DkmStackWalkFrame.Create(nativeFrame.Thread, null, nativeFrame.FrameBase, nativeFrame.FrameSize,
                        DkmStackWalkFrameFlags.NonuserCode, "[Native to Python Transition]", null, null));
                } else {
                    stackWalkData.IsLastFrameNative = true;
                }
                result.Add(nativeFrame);
                return result.ToArray();
            } else {
                stackWalkData.IsLastFrameNative = false;
                if (wasLastFrameNative == true) {
                    result.Add(DkmStackWalkFrame.Create(nativeFrame.Thread, null, nativeFrame.FrameBase, nativeFrame.FrameSize,
                        DkmStackWalkFrameFlags.NonuserCode, "[Python to Native Transition]", null, null));
                }
            }

            var pythonFrame = PyFrameObject.TryCreate(nativeFrame);
            if (pythonFrame == null) {
                if (DebuggerOptions.ShowNativePythonFrames) {
                    result.Add(nativeFrame);
                }
                return result.ToArray();
            }

            PyCodeObject code = pythonFrame.f_code.Read();
            var loc = new SourceLocation(
                code.co_filename.Read().ToStringOrNull(),
                pythonFrame.f_lineno.Read(),
                code.co_name.Read().ToStringOrNull(),
                nativeFrame.InstructionAddress as DkmNativeInstructionAddress);

            var pythonRuntime = _process.GetPythonRuntimeInstance();
            var pythonModuleInstances = pythonRuntime.GetModuleInstances().OfType<DkmCustomModuleInstance>();
            var pyModuleInstance = pythonModuleInstances.Where(m => m.FullName == loc.FileName).FirstOrDefault();
            if (pyModuleInstance == null) {
                pyModuleInstance = pythonModuleInstances.Single(m => m.Module.Id.Mvid == Guids.UnknownPythonModuleGuid);
            }

            var encodedLocation = loc.Encode();
            var instrAddr = DkmCustomInstructionAddress.Create(pythonRuntime, pyModuleInstance, encodedLocation, 0, encodedLocation, null);
            var frame = DkmStackWalkFrame.Create(
                nativeFrame.Thread,
                instrAddr,
                nativeFrame.FrameBase,
                nativeFrame.FrameSize,
                DkmStackWalkFrameFlags.None,
                null,
                nativeFrame.Registers,
                nativeFrame.Annotations);
            result.Add(frame);

            if (DebuggerOptions.ShowNativePythonFrames) {
                result.Add(nativeFrame);
            }
            return result.ToArray();
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:72,代码来源:CallStackFilter.cs


注:本文中的SourceLocation.Encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。