本文整理汇总了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) };
}
示例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();
}