public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "Proto", ref available); argumentCount = Helper.Read(inspectionSession, thread, frame, "Proto", "numparams", ref available, ref success, ref failure); isVarargs = Helper.Read(inspectionSession, thread, frame, "Proto", "is_vararg", ref available, ref success, ref failure); maxStackSize_opt = Helper.ReadOptional(inspectionSession, thread, frame, "Proto", "maxstacksize", "not used", ref optional); upvalueSize = Helper.Read(inspectionSession, thread, frame, "Proto", "sizeupvalues", ref available, ref success, ref failure); constantSize = Helper.Read(inspectionSession, thread, frame, "Proto", "sizek", ref available, ref success, ref failure); codeSize = Helper.Read(inspectionSession, thread, frame, "Proto", "sizecode", ref available, ref success, ref failure); lineInfoSize = Helper.Read(inspectionSession, thread, frame, "Proto", "sizelineinfo", ref available, ref success, ref failure); absLineInfoSize_5_4 = Helper.ReadOptional(inspectionSession, thread, frame, "Proto", "sizeabslineinfo", "used in 5.4", ref optional); localFunctionSize = Helper.Read(inspectionSession, thread, frame, "Proto", "sizep", ref available, ref success, ref failure); localVariableSize = Helper.Read(inspectionSession, thread, frame, "Proto", "sizelocvars", ref available, ref success, ref failure); definitionStartLine_opt = Helper.ReadOptional(inspectionSession, thread, frame, "Proto", "linedefined", "used to detect main function", ref optional); definitionEndLine_opt = Helper.ReadOptional(inspectionSession, thread, frame, "Proto", "lastlinedefined", "not used", ref optional); constantDataAddress = Helper.Read(inspectionSession, thread, frame, "Proto", "k", ref available, ref success, ref failure); codeDataAddress = Helper.Read(inspectionSession, thread, frame, "Proto", "code", ref available, ref success, ref failure); localFunctionDataAddress = Helper.Read(inspectionSession, thread, frame, "Proto", "p", ref available, ref success, ref failure); lineInfoDataAddress = Helper.Read(inspectionSession, thread, frame, "Proto", "lineinfo", ref available, ref success, ref failure); absLineInfoDataAddress_5_4 = Helper.ReadOptional(inspectionSession, thread, frame, "Proto", "abslineinfo", "used in 5.4", ref optional); localVariableDataAddress = Helper.Read(inspectionSession, thread, frame, "Proto", "locvars", ref available, ref success, ref failure); upvalueDataAddress = Helper.Read(inspectionSession, thread, frame, "Proto", "upvalues", ref available, ref success, ref failure); sourceAddress = Helper.Read(inspectionSession, thread, frame, "Proto", "source", ref available, ref success, ref failure); gclistAddress = Helper.Read(inspectionSession, thread, frame, "Proto", "gclist", ref available, ref success, ref failure); if (Log.instance != null) { Log.instance.Debug($"LuaFunctionData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; success = 0; failure = 0; optional = 0; structSize = Helper.GetSize(inspectionSession, thread, frame, "Node", ref available); valueDataAddress = Helper.Read(inspectionSession, thread, frame, "Node", "i_val", ref available, ref success, ref failure); keyDataTypeAddress_5_4 = Helper.ReadOptional(inspectionSession, thread, frame, "Node", "u.key_tt", "used in Lua 5.4", ref optional); keyDataValueAddress_5_4 = Helper.ReadOptional(inspectionSession, thread, frame, "Node", "u.key_val", "used in Lua 5.4", ref optional); if (!keyDataTypeAddress_5_4.HasValue || !keyDataValueAddress_5_4.HasValue) { keyDataAddress_5_123 = Helper.Read(inspectionSession, thread, frame, "Node", "i_key", ref available, ref success, ref failure); } else { keyDataAddress_5_123 = null; } if (Log.instance != null) { Log.instance.Debug($"LuaNodeData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
internal static DkmEvaluationResult ExecuteRawExpression(string expression, DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame input, DkmRuntimeInstance runtimeInstance, DkmEvaluationFlags flags) { var compilerId = new DkmCompilerId(DkmVendorId.Microsoft, DkmLanguageId.Cpp); var language = DkmLanguage.Create("C++", compilerId); var languageExpression = DkmLanguageExpression.Create(language, DkmEvaluationFlags.None, expression, null); var inspectionContext = DkmInspectionContext.Create(inspectionSession, runtimeInstance, thread, 200, flags, DkmFuncEvalFlags.None, 10, language, null, null, DkmCompiledVisualizationDataPriority.None, null, workerConnection); var workList = DkmWorkList.Create(null); try { DkmEvaluationResult result = null; inspectionContext.EvaluateExpression(workList, languageExpression, input, res => { if (res.ErrorCode == 0) { result = res.ResultObject; } }); workList.Execute(); return(result); } catch (OperationCanceledException) { return(null); } }
internal DkmInspectionContext(DkmInspectionSession inspectionSession, DkmEvaluationFlags evaluationFlags, uint radix, DkmRuntimeInstance runtimeInstance) { this.InspectionSession = inspectionSession; this.EvaluationFlags = evaluationFlags; this.Radix = radix; this.RuntimeInstance = runtimeInstance ?? DkmClrRuntimeInstance.DefaultRuntime; }
public static ulong?Read(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame, string type, string[] memberOptions, ref bool available, ref int success, ref int failure) { Debug.Assert(memberOptions.Length > 0); long?result = null; foreach (var option in memberOptions) { result = EvaluationHelpers.TryEvaluateNumberExpression($"(int)&(({type}*)0)->{option}", inspectionSession, thread, frame, DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects); if (result != null) { break; } } if (!result.HasValue) { available = false; failure++; if (Log.instance != null) { Log.instance.Debug($"Failed to get offsetof '{memberOptions[0]}' in '{type}'"); } return(null); } success++; return((ulong)result.Value); }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; success = 0; failure = 0; optional = 0; structSize = Helper.GetSize(inspectionSession, thread, frame, "CallInfo", ref available); funcAddress = Helper.Read(inspectionSession, thread, frame, "CallInfo", "func", ref available, ref success, ref failure); previousAddress_5_23 = Helper.ReadOptional(inspectionSession, thread, frame, "CallInfo", "previous", "used in 5.2/5.3", ref optional); // Try to guess if we have Lua 5.4 using new field if (!Helper.ReadOptional(inspectionSession, thread, frame, "CallInfo", "u.l.trap", "used to detect 5.4", ref optional).HasValue) { stackBaseAddress_5_123 = Helper.Read(inspectionSession, thread, frame, "CallInfo", new[] { "u.l.base", "base" }, ref available, ref success, ref failure); } else { stackBaseAddress_5_123 = null; } savedInstructionPointerAddress = Helper.Read(inspectionSession, thread, frame, "CallInfo", new[] { "u.l.savedpc", "savedpc" }, ref available, ref success, ref failure); tailCallCount_5_1 = Helper.ReadOptional(inspectionSession, thread, frame, "CallInfo", "tailcalls", "used in 5.1", ref optional); callStatus_5_23 = Helper.ReadOptional(inspectionSession, thread, frame, "CallInfo", "callstatus", "used in 5.2/5.3", ref optional, out callStatus_size); if (Log.instance != null) { Log.instance.Debug($"LuaFunctionCallInfoData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static string GetTypeName( this System.Type type, DkmClrCustomTypeInfo typeInfo = null, bool escapeKeywordIdentifiers = false, DkmInspectionContext inspectionContext = null ) { var formatter = new CSharpFormatter(); var clrType = new DkmClrType((TypeImpl)type); if (inspectionContext == null) { var inspectionSession = new DkmInspectionSession( ImmutableArray.Create <IDkmClrFormatter>(formatter), ImmutableArray.Create <IDkmClrResultProvider>(new CSharpResultProvider()) ); inspectionContext = new DkmInspectionContext( inspectionSession, DkmEvaluationFlags.None, radix: 10, runtimeInstance: null ); } return(escapeKeywordIdentifiers ? ((IDkmClrFullNameProvider)formatter).GetClrTypeName( inspectionContext, clrType, typeInfo ) : inspectionContext.GetTypeName(clrType, typeInfo, Formatter.NoFormatSpecifiers)); }
internal ResultProviderTestBase(DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext) { _inspectionSession = inspectionSession; DefaultInspectionContext = defaultInspectionContext; // We never want to swallow Exceptions (generate a non-fatal Watson) when running tests. ExpressionEvaluatorFatalError.IsFailFastEnabled = true; }
internal static DkmInspectionContext CreateDkmInspectionContext( DkmInspectionSession inspectionSession, DkmEvaluationFlags flags, uint radix, DkmRuntimeInstance runtimeInstance = null) { return(new DkmInspectionContext(inspectionSession, flags, radix, runtimeInstance)); }
internal static ulong?TryEvaluateAddressExpression(string expression, DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame input, DkmEvaluationFlags flags) { if (ExecuteExpression(expression, inspectionSession, thread, input, flags, true, out ulong address) != null) { return(address); } return(null); }
internal static DkmInspectionSession CreateInspectionSession(DkmProcess process, DkmThread thread, SupportBreakpointHitMessage data, out DkmStackWalkFrame frame) { const int CV_ALLREG_VFRAME = 0x00007536; var vFrameRegister = DkmUnwoundRegister.Create(CV_ALLREG_VFRAME, new ReadOnlyCollection <byte>(BitConverter.GetBytes(data.vframe))); var registers = thread.GetCurrentRegisters(new[] { vFrameRegister }); var instructionAddress = process.CreateNativeInstructionAddress(registers.GetInstructionPointer()); frame = DkmStackWalkFrame.Create(thread, instructionAddress, data.frameBase, 0, DkmStackWalkFrameFlags.None, null, registers, null); return(DkmInspectionSession.Create(process, null)); }
public static InspectionSession GetInstance(DkmInspectionSession dkmObject) { InspectionSession session = dkmObject.GetDataItem<InspectionSession>(); if (session == null) { session = new InspectionSession(); dkmObject.SetDataItem(DkmDataCreationDisposition.CreateNew, session); } return session; }
public static InspectionSession GetInstance(DkmInspectionSession dkmObject) { InspectionSession session = dkmObject.GetDataItem <InspectionSession>(); if (session == null) { session = new InspectionSession(); dkmObject.SetDataItem(DkmDataCreationDisposition.CreateNew, session); } return(session); }
internal static string ExecuteExpression(string expression, DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame input, DkmEvaluationFlags flags, bool allowZero, out ulong address) { if (Log.instance != null) { Log.instance.Verbose($"ExecuteExpression begin evaluation of '{expression}'"); } var compilerId = new DkmCompilerId(DkmVendorId.Microsoft, DkmLanguageId.Cpp); var language = DkmLanguage.Create("C++", compilerId); var languageExpression = DkmLanguageExpression.Create(language, DkmEvaluationFlags.None, expression, null); var inspectionContext = DkmInspectionContext.Create(inspectionSession, input.RuntimeInstance, thread, 200, flags, DkmFuncEvalFlags.None, 10, language, null, null, DkmCompiledVisualizationDataPriority.None, null, workerConnection); var workList = DkmWorkList.Create(null); try { string resultText = null; ulong resultAddress = 0; inspectionContext.EvaluateExpression(workList, languageExpression, input, res => { if (res.ErrorCode == 0) { var result = res.ResultObject as DkmSuccessEvaluationResult; if (result != null && result.TagValue == DkmEvaluationResult.Tag.SuccessResult && (allowZero || result.Address.Value != 0)) { resultText = result.Value; resultAddress = result.Address.Value; } res.ResultObject.Close(); } }); workList.Execute(); if (Log.instance != null) { Log.instance.Verbose($"ExecuteExpression completed"); } address = resultAddress; return(resultText); } catch (OperationCanceledException) { address = 0; return(null); } }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "TString", ref available); offsetToContent_5_4 = Helper.ReadOptional(inspectionSession, thread, frame, "TString", "contents", "used in 5.4", ref optional); if (Log.instance != null) { Log.instance.Debug($"LuaStringData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "Udata", ref available); metaTableDataAddress = Helper.Read(inspectionSession, thread, frame, "Udata", new[] { "uv.metatable", "metatable" }, ref available, ref success, ref failure); if (Log.instance != null) { Log.instance.Debug($"LuaUserDataData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static string GetTypeName(this System.Type type, DkmClrCustomTypeInfo typeInfo, bool escapeKeywordIdentifiers = false, DkmInspectionContext inspectionContext = null) { var formatter = new CSharpFormatter(); var clrType = new DkmClrType((TypeImpl)type); if (inspectionContext == null) { var inspectionSession = new DkmInspectionSession(ImmutableArray.Create<IDkmClrFormatter>(formatter), ImmutableArray.Create<IDkmClrResultProvider>(new CSharpResultProvider())); inspectionContext = new DkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10, runtimeInstance: null); } return escapeKeywordIdentifiers ? ((IDkmClrFullNameProvider)formatter).GetClrTypeName(inspectionContext, clrType, typeInfo) : inspectionContext.GetTypeName(clrType, typeInfo, Formatter.NoFormatSpecifiers); }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "CClosure", ref available); functionAddress = Helper.Read(inspectionSession, thread, frame, "CClosure", "f", ref available, ref success, ref failure); if (Log.instance != null) { Log.instance.Debug($"LuaExternalClosureData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
internal CSharpResultProviderTestBase( DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext = null ) : base( inspectionSession, defaultInspectionContext ?? CreateDkmInspectionContext( inspectionSession, DkmEvaluationFlags.None, radix: 10 ) ) { }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "LocVar", ref available); nameAddress = Helper.Read(inspectionSession, thread, frame, "LocVar", "varname", ref available, ref success, ref failure); lifetimeStartInstruction = Helper.Read(inspectionSession, thread, frame, "LocVar", "startpc", ref available, ref success, ref failure); lifetimeEndInstruction = Helper.Read(inspectionSession, thread, frame, "LocVar", "endpc", ref available, ref success, ref failure); if (Log.instance != null) { Log.instance.Debug($"LuaLocalVariableData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "TValue", ref available); valueAddress = Helper.Read(inspectionSession, thread, frame, "TValue", new[] { "u.i.v__", "value_", "value" }, ref available, ref success, ref failure); typeAddress = Helper.Read(inspectionSession, thread, frame, "TValue", new[] { "u.i.tt__", "tt_", "tt" }, ref available, ref success, ref failure); doubleAddress = Helper.ReadOptional(inspectionSession, thread, frame, "TValue", "u.d__", "used in NAN trick", ref optional); if (Log.instance != null) { Log.instance.Debug($"LuaValueData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; success = 0; failure = 0; optional = 0; structSize = Helper.GetSize(inspectionSession, thread, frame, "Upvaldesc", ref available); nameAddress = Helper.Read(inspectionSession, thread, frame, "Upvaldesc", "name", ref available, ref success, ref failure); if (Log.instance != null) { Log.instance.Debug($"LuaUpvalueDescriptionData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static DkmInspectionContext Create( DkmInspectionSession InspectionSession, DkmRuntimeInstance RuntimeInstance, DkmThread Thread, uint Timeout, DkmEvaluationFlags EvaluationFlags, DkmFuncEvalFlags FuncEvalFlags, uint Radix, DkmLanguage Language, DkmRawReturnValue ReturnValue, DkmCompiledVisualizationData AdditionalVisualizationData, DkmCompiledVisualizationDataPriority AdditionalVisualizationDataPriority, ReadOnlyCollection<DkmRawReturnValueContainer> ReturnValues) { return new DkmInspectionContext(InspectionSession, EvaluationFlags, Radix, RuntimeInstance); }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "lua_State", ref available); globalStateAddress_opt = Helper.ReadOptional(inspectionSession, thread, frame, "lua_State", "l_G", "used in Locals Window", ref optional); callInfoAddress = Helper.Read(inspectionSession, thread, frame, "lua_State", "ci", ref available, ref success, ref failure); savedProgramCounterAddress_5_1_opt = Helper.ReadOptional(inspectionSession, thread, frame, "lua_State", "savedpc", "used in 5.1 (*)", ref optional); baseCallInfoAddress_5_1 = Helper.ReadOptional(inspectionSession, thread, frame, "lua_State", "base_ci", "used in 5.1", ref optional); if (Log.instance != null) { Log.instance.Debug($"LuaStateData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
internal static long?TryEvaluateNumberExpression(string expression, DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame input, DkmEvaluationFlags flags) { string result = ExecuteExpression(expression, inspectionSession, thread, input, flags, true, out _); if (result == null) { return(null); } if (long.TryParse(result, out long value)) { return(value); } return(null); }
public CppExpressionEvaluator(DkmThread thread, ulong frameBase, ulong vframe) { _process = thread.Process; var inspectionSession = DkmInspectionSession.Create(_process, null); _cppInspectionContext = DkmInspectionContext.Create(inspectionSession, _process.GetNativeRuntimeInstance(), thread, Timeout, DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects, DkmFuncEvalFlags.None, 10, CppLanguage, null); const int CV_ALLREG_VFRAME = 0x00007536; var vframeReg = DkmUnwoundRegister.Create(CV_ALLREG_VFRAME, new ReadOnlyCollection <byte>(BitConverter.GetBytes(vframe))); var regs = thread.GetCurrentRegisters(new[] { vframeReg }); var iaddr = _process.CreateNativeInstructionAddress(regs.GetInstructionPointer()); _nativeFrame = DkmStackWalkFrame.Create(thread, iaddr, frameBase, 0, DkmStackWalkFrameFlags.None, null, regs, null); }
public static ulong?ReadOptional(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame, string type, string member, string message, ref int optional) { long?result = EvaluationHelpers.TryEvaluateNumberExpression($"(int)&(({type}*)0)->{member}", inspectionSession, thread, frame, DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects); if (!result.HasValue) { if (Log.instance != null) { Log.instance.Debug($"Failed to get offsetof '{member}' in '{type}' (optional, {message})"); } return(null); } optional++; return((ulong)result.Value); }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "LClosure", ref available); isC_5_1 = Helper.ReadOptional(inspectionSession, thread, frame, "LClosure", "isC", "used in 5.1", ref optional); upvalueSize_opt = Helper.ReadOptional(inspectionSession, thread, frame, "LClosure", "nupvalues", "used if avaiable", ref optional); envTableDataAddress_5_1 = Helper.ReadOptional(inspectionSession, thread, frame, "LClosure", "env", "used in 5.1", ref optional); functionAddress = Helper.Read(inspectionSession, thread, frame, "LClosure", "p", ref available, ref success, ref failure); firstUpvaluePointerAddress = Helper.Read(inspectionSession, thread, frame, "LClosure", "upvals", ref available, ref success, ref failure); if (Log.instance != null) { Log.instance.Debug($"LuaClosureData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static long GetSize(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame, string type, ref bool available) { long?result = EvaluationHelpers.TryEvaluateNumberExpression($"sizeof({type})", inspectionSession, thread, frame, DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects).GetValueOrDefault(0); if (!result.HasValue) { available = false; if (Log.instance != null) { Log.instance.Debug($"Failed to get sizeof '{type}'"); } return(0); } return(result.Value); }
public static unsafe PyFrameObject TryCreate(DkmStackWalkFrame frame) { var process = frame.Process; if (frame.InstructionAddress == null) { return(null); } if (frame.RuntimeInstance.Id.RuntimeType != Guids.PythonRuntimeTypeGuid && !IsInEvalFrame(frame)) { return(null); } var cppLanguage = DkmLanguage.Create("C++", new DkmCompilerId(Guids.MicrosoftVendorGuid, Guids.CppLanguageGuid)); var inspectionSession = DkmInspectionSession.Create(process, null); var inspectionContext = DkmInspectionContext.Create(inspectionSession, process.GetNativeRuntimeInstance(), frame.Thread, 0, DkmEvaluationFlags.TreatAsExpression | DkmEvaluationFlags.NoSideEffects, DkmFuncEvalFlags.None, 10, cppLanguage, null); CppExpressionEvaluator cppEval; try { cppEval = new CppExpressionEvaluator(inspectionContext, frame); } catch (ArgumentException) { Debug.Fail("Failed to create C++ expression evaluator while obtaining PyFrameObject from a native frame."); return(null); } ulong framePtr; try { framePtr = cppEval.EvaluateUInt64("f"); } catch (CppEvaluationException) { Debug.Fail("Failed to evaluate the 'f' parameter to PyEval_EvalFrameEx while obtaining PyFrameObject from a native frame."); return(null); } return(new PyFrameObject(frame.Process, framePtr)); }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "Table", ref available); flags = Helper.Read(inspectionSession, thread, frame, "Table", "flags", ref available, ref success, ref failure); nodeArraySizeLog2 = Helper.Read(inspectionSession, thread, frame, "Table", "lsizenode", ref available, ref success, ref failure); arraySize = Helper.Read(inspectionSession, thread, frame, "Table", new[] { "sizearray", "alimit" }, ref available, ref success, ref failure); arrayDataAddress = Helper.Read(inspectionSession, thread, frame, "Table", "array", ref available, ref success, ref failure); nodeDataAddress = Helper.Read(inspectionSession, thread, frame, "Table", "node", ref available, ref success, ref failure); lastFreeNodeDataAddress = Helper.Read(inspectionSession, thread, frame, "Table", "lastfree", ref available, ref success, ref failure); metaTableDataAddress = Helper.Read(inspectionSession, thread, frame, "Table", "metatable", ref available, ref success, ref failure); gclistAddress = Helper.Read(inspectionSession, thread, frame, "Table", "gclist", ref available, ref success, ref failure); if (Log.instance != null) { Log.instance.Debug($"LuaTableData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static void LoadSchema(DkmInspectionSession inspectionSession, DkmThread thread, DkmStackWalkFrame frame) { available = true; structSize = Helper.GetSize(inspectionSession, thread, frame, "lua_Debug", ref available); eventType = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "event", ref available, ref success, ref failure); nameAddress = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "name", ref available, ref success, ref failure); nameWhatAddress = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "namewhat", ref available, ref success, ref failure); whatAddress = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "what", ref available, ref success, ref failure); sourceAddress = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "source", ref available, ref success, ref failure); currentLine = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "currentline", ref available, ref success, ref failure); upvalueSize = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "nups", ref available, ref success, ref failure); definitionStartLine = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "linedefined", ref available, ref success, ref failure); definitionEndLine = Helper.Read(inspectionSession, thread, frame, "lua_Debug", "lastlinedefined", ref available, ref success, ref failure); if (Log.instance != null) { Log.instance.Debug($"LuaDebugData schema {(available ? "available" : "not available")} with {success} successes and {failure} failures and {optional} optional"); } }
public static DkmSourcePosition GetSourcePosition(DkmInstructionSymbol instruction, DkmSourcePositionFlags flags, DkmInspectionSession inspectionSession, out bool startOfLine) { var insSym = instruction as DkmCustomInstructionSymbol; var loc = new SourceLocation(insSym.AdditionalData); startOfLine = true; return(DkmSourcePosition.Create(DkmSourceFileId.Create(loc.FileName, null, null, null), new DkmTextSpan(loc.LineNumber, loc.LineNumber, 0, 0))); }
public void OnBeginStepOut(DkmThread thread) { // When we're stepping out while in Python code, there are two possibilities. Either the stack looks like this: // // PythonFrame1 // PythonFrame2 // // or else it looks like this: // // PythonFrame // [Native to Python transition] // NativeFrame // // In both cases, we use native breakpoints on the return address to catch the end of step-out operation. // For Python-to-native step-out, this is the only option. For Python-to-Python, it would seem that TraceFunc // can detect it via PyTrace_RETURN, but it doesn't actually know whether the return is to Python or to // native at the point where it's reported - and, in any case, we need to let PyEval_EvalFrameEx to return // before reporting the completion of that step-out (otherwise we will show the returning frame in call stack). // Find the destination for step-out by walking the call stack and finding either the first native frame // outside of Python and helper DLLs, or the second Python frame. var inspectionSession = DkmInspectionSession.Create(_process, null); var frameFormatOptions = new DkmFrameFormatOptions(DkmVariableInfoFlags.None, DkmFrameNameFormatOptions.None, DkmEvaluationFlags.None, 10000, 10); var stackContext = DkmStackContext.Create(inspectionSession, thread, DkmCallStackFilterOptions.None, frameFormatOptions, null, null); DkmStackFrame frame = null; for (int pyFrameCount = 0; pyFrameCount != 2;) { DkmStackFrame[] frames = null; var workList = DkmWorkList.Create(null); stackContext.GetNextFrames(workList, 1, (result) => { frames = result.Frames; }); workList.Execute(); if (frames == null || frames.Length != 1) { return; } frame = frames[0]; var frameModuleInstance = frame.ModuleInstance; if (frameModuleInstance is DkmNativeModuleInstance && frameModuleInstance != _pyrtInfo.DLLs.Python && frameModuleInstance != _pyrtInfo.DLLs.DebuggerHelper && frameModuleInstance != _pyrtInfo.DLLs.CTypes) { break; } else if (frame.RuntimeInstance != null && frame.RuntimeInstance.Id.RuntimeType == Guids.PythonRuntimeTypeGuid) { ++pyFrameCount; } } var nativeAddr = frame.InstructionAddress as DkmNativeInstructionAddress; if (nativeAddr == null) { var customAddr = frame.InstructionAddress as DkmCustomInstructionAddress; if (customAddr == null) { return; } var loc = new SourceLocation(customAddr.AdditionalData, thread.Process); nativeAddr = loc.NativeAddress; if (nativeAddr == null) { return; } } var bp = DkmRuntimeInstructionBreakpoint.Create(Guids.PythonStepTargetSourceGuid, thread, nativeAddr, false, null); bp.Enable(); _stepOutTargetBreakpoints.Add(bp); }
internal CSharpResultProviderTestBase(DkmInspectionSession inspectionSession, DkmInspectionContext defaultInspectionContext = null) : base(inspectionSession, defaultInspectionContext ?? CreateDkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10)) { }
public static DkmSourcePosition GetSourcePosition(DkmInstructionSymbol instruction, DkmSourcePositionFlags flags, DkmInspectionSession inspectionSession, out bool startOfLine) { var insSym = instruction as DkmCustomInstructionSymbol; var loc = new SourceLocation(insSym.AdditionalData); startOfLine = true; return DkmSourcePosition.Create(DkmSourceFileId.Create(loc.FileName, null, null, null), new DkmTextSpan(loc.LineNumber, loc.LineNumber, 0, 0)); }