bool IDkmRuntimeStepper.OwnsCurrentExecutionLocation(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, DkmStepArbitrationReason reason) { var processData = DebugHelpers.GetOrCreateDataItem <LuaRemoteProcessData>(runtimeInstance.Process); // Can't handle steps without an address if (stepper.StartingAddress == null) { return(false); } // Stepping can be performed if we are inside the debug helper or inside luaV_execute var instructionAddress = stepper.StartingAddress.CPUInstructionPart.InstructionPointer; if (processData.locations == null) { return(false); } if (instructionAddress >= processData.locations.helperStartAddress && instructionAddress < processData.locations.helperEndAddress) { return(true); } if (instructionAddress >= processData.locations.executionStartAddress && instructionAddress < processData.locations.executionEndAddress) { return(true); } return(false); }
public void BeforeEnableNewStepper(DkmRuntimeInstance runtimeInstance, DkmStepper stepper) { stepper.Thread.GetCurrentFrameInfo(out global::System.UInt64 retAddr, out global::System.UInt64 frameBase, out global::System.UInt64 vframe); stepper.SetDataItem(DkmDataCreationDisposition.CreateAlways, new StepBeginState { FrameBase = frameBase }); }
internal DkmInspectionContext(IDkmClrFormatter formatter, DkmEvaluationFlags evaluationFlags, uint radix, DkmRuntimeInstance runtimeInstance = null) { _formatter = formatter; this.EvaluationFlags = evaluationFlags; this.Radix = radix; this.RuntimeInstance = runtimeInstance ?? DkmClrRuntimeInstance.DefaultRuntime; }
internal DkmInspectionContext CreateDkmInspectionContext( DkmEvaluationFlags flags = DkmEvaluationFlags.None, uint radix = 10, DkmRuntimeInstance runtimeInstance = null) { return(CreateDkmInspectionContext(_formatter, flags, radix, runtimeInstance)); }
bool IDkmRuntimeStepper.OwnsCurrentExecutionLocation(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, DkmStepArbitrationReason reason) { var processData = DebugHelpers.GetOrCreateDataItem <NullcRemoteProcessDataItem>(runtimeInstance.Process); // Can't handle steps without an address if (stepper.StartingAddress == null) { return(false); } var instructionAddress = stepper.StartingAddress.CPUInstructionPart.InstructionPointer; if (DebugHelpers.useNativeInterfaces) { if (processData.nativeModuleInstance != null) { if (instructionAddress >= processData.nativeModuleInstance.BaseAddress && instructionAddress < processData.nativeModuleInstance.BaseAddress + processData.nativeModuleInstance.Size) { return(processData.bytecode.ConvertNativeAddressToInstruction(instructionAddress) != 0); } } } else { if (processData.moduleInstance != null) { if (instructionAddress >= processData.moduleInstance.BaseAddress && instructionAddress < processData.moduleInstance.BaseAddress + processData.moduleInstance.Size) { return(processData.bytecode.ConvertNativeAddressToInstruction(instructionAddress) != 0); } } } return(false); }
internal DkmInspectionContext(DkmInspectionSession inspectionSession, DkmEvaluationFlags evaluationFlags, uint radix, DkmRuntimeInstance runtimeInstance) { this.InspectionSession = inspectionSession; this.EvaluationFlags = evaluationFlags; this.Radix = radix; this.RuntimeInstance = runtimeInstance ?? DkmClrRuntimeInstance.DefaultRuntime; }
unsafe void IDkmRuntimeInstanceLoadNotification.OnRuntimeInstanceLoad(DkmRuntimeInstance runtimeInstance, DkmEventDescriptor eventDescriptor) { if (runtimeInstance.Id.RuntimeType != Guids.PythonRuntimeTypeGuid) { Debug.Fail("OnRuntimeInstanceLoad notification for a non-Python runtime."); throw new NotSupportedException(); } var process = runtimeInstance.Process; process.SetDataItem(DkmDataCreationDisposition.CreateNew, new ModuleManager(process)); process.SetDataItem(DkmDataCreationDisposition.CreateNew, new CallStackFilter(process)); process.SetDataItem(DkmDataCreationDisposition.CreateNew, new ExpressionEvaluator(process)); process.SetDataItem(DkmDataCreationDisposition.CreateNew, new PyObjectAllocator(process)); if (process.LivePart != null) { process.SetDataItem(DkmDataCreationDisposition.CreateNew, new TraceManagerLocalHelper(process, TraceManagerLocalHelper.Kind.StepIn)); } // If both local and remote components are actually in the same process, they share the same DebuggerOptions, so no need to propagate it. if (process.Connection.Flags.HasFlag(DkmTransportConnectionFlags.MarshallingRequired)) { process.SetDataItem(DkmDataCreationDisposition.CreateNew, new DebuggerOptionsPropagator(process)); } }
internal static DkmInspectionContext CreateDkmInspectionContext( DkmInspectionSession inspectionSession, DkmEvaluationFlags flags, uint radix, DkmRuntimeInstance runtimeInstance = null) { return(new DkmInspectionContext(inspectionSession, flags, radix, runtimeInstance)); }
internal static DkmInspectionContext CreateDkmInspectionContext( IDkmClrFormatter formatter, DkmEvaluationFlags flags, uint radix, DkmRuntimeInstance runtimeInstance = null) { return(new DkmInspectionContext(formatter, flags, radix, runtimeInstance)); }
void IDkmRuntimeStepper.OnNewControllingRuntimeInstance(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, DkmStepArbitrationReason reason, DkmRuntimeInstance controllingRuntimeInstance) { var process = runtimeInstance.Process; var processData = DebugHelpers.GetOrCreateDataItem <LuaRemoteProcessData>(runtimeInstance.Process); ClearStepperData(process, processData); }
void IDkmRuntimeStepper.StopStep(DkmRuntimeInstance runtimeInstance, DkmStepper stepper) { var process = runtimeInstance.Process; var processData = DebugHelpers.GetOrCreateDataItem <LuaRemoteProcessData>(runtimeInstance.Process); ClearStepperData(process, processData); }
void IDkmRuntimeStepper.TakeStepControl(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, bool leaveGuardsInPlace, DkmStepArbitrationReason reason, DkmRuntimeInstance callingRuntimeInstance) { var process = runtimeInstance.Process; var processData = DebugHelpers.GetOrCreateDataItem <LuaRemoteProcessData>(runtimeInstance.Process); ClearStepperData(process, processData); }
public void BeforeEnableNewStepper(DkmRuntimeInstance runtimeInstance, DkmStepper stepper) { ulong retAddr, frameBase, vframe; stepper.Thread.GetCurrentFrameInfo(out retAddr, out frameBase, out vframe); stepper.SetDataItem(DkmDataCreationDisposition.CreateAlways, new StepBeginState { FrameBase = frameBase }); }
internal DkmInspectionContext( DkmInspectionSession inspectionSession, DkmEvaluationFlags evaluationFlags, uint radix, DkmRuntimeInstance runtimeInstance ) { this.InspectionSession = inspectionSession; this.EvaluationFlags = evaluationFlags; this.Radix = radix; this.RuntimeInstance = runtimeInstance ?? DkmClrRuntimeInstance.DefaultRuntime; }
void IDkmRuntimeStepper.TakeStepControl(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, bool leaveGuardsInPlace, DkmStepArbitrationReason reason, DkmRuntimeInstance callingRuntimeInstance) { var traceManager = runtimeInstance.Process.GetDataItem <TraceManager>(); if (traceManager == null) { Debug.Fail("TakeStepControl called before TraceMananger is initialized."); throw new InvalidOperationException(); } traceManager.CancelStep(stepper); }
void IDkmRuntimeStepper.StopStep(DkmRuntimeInstance runtimeInstance, DkmStepper stepper) { var traceManager = runtimeInstance.Process.GetDataItem <TraceManager>(); if (traceManager == null) { Debug.Fail("StopStep called before TraceMananger is initialized."); throw new InvalidOperationException(); } traceManager.CancelStep(stepper); }
void IDkmRuntimeStepper.BeforeEnableNewStepper(DkmRuntimeInstance runtimeInstance, DkmStepper stepper) { var traceManager = runtimeInstance.Process.GetDataItem <TraceManager>(); if (traceManager == null) { Debug.Fail("OnNewControllingRuntimeInstance called before TraceMananger is initialized."); throw new InvalidOperationException(); } traceManager.BeforeEnableNewStepper(runtimeInstance, stepper); }
unsafe void IDkmRuntimeInstanceLoadNotification.OnRuntimeInstanceLoad(DkmRuntimeInstance runtimeInstance, DkmEventDescriptor eventDescriptor) { if (runtimeInstance.Id.RuntimeType != Guids.PythonRuntimeTypeGuid) { Debug.Fail("OnRuntimeInstanceLoad notification for a non-Python runtime."); throw new NotSupportedException(); } var process = runtimeInstance.Process; process.SetDataItem(DkmDataCreationDisposition.CreateNew, new TraceManagerLocalHelper(process, TraceManagerLocalHelper.Kind.StepOut)); }
internal static ulong FindFunctionAddress(DkmRuntimeInstance runtimeInstance, string name) { foreach (var module in runtimeInstance.GetModuleInstances()) { var address = (module as DkmNativeModuleInstance)?.FindExportName(name, IgnoreDataExports: true); if (address != null) { return(address.CPUInstructionPart.InstructionPointer); } } return(0); }
private DkmIntermediateEvaluationResult( DkmInspectionContext inspectionContext, DkmStackWalkFrame stackFrame, string name, string fullName, string expression, DkmLanguage intermediateLanguage, DkmRuntimeInstance targetRuntime, DkmDataItem dataItem) : base(inspectionContext, stackFrame, name, fullName, DkmEvaluationResultFlags.None, null, dataItem) { this.Expression = expression; this.IntermediateLanguage = intermediateLanguage; this.TargetRuntime = targetRuntime; }
private DkmIntermediateEvaluationResult( DkmInspectionContext inspectionContext, DkmStackWalkFrame stackFrame, string name, string fullName, string expression, DkmLanguage intermediateLanguage, DkmRuntimeInstance targetRuntime, DkmDataItem dataItem) : base(inspectionContext, stackFrame, name, fullName, DkmEvaluationResultFlags.None, null, dataItem) { this.Expression = expression; this.IntermediateLanguage = intermediateLanguage; this.TargetRuntime = targetRuntime; }
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 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 DkmIntermediateEvaluationResult Create( DkmInspectionContext InspectionContext, DkmStackWalkFrame StackFrame, string Name, string FullName, string Expression, DkmLanguage IntermediateLanguage, DkmRuntimeInstance TargetRuntime, DkmDataItem DataItem) { return new DkmIntermediateEvaluationResult( InspectionContext, StackFrame, Name, FullName, Expression, IntermediateLanguage, TargetRuntime, DataItem); }
public static DkmIntermediateEvaluationResult Create( DkmInspectionContext InspectionContext, DkmStackWalkFrame StackFrame, string Name, string FullName, string Expression, DkmLanguage IntermediateLanguage, DkmRuntimeInstance TargetRuntime, DkmDataItem DataItem) { return(new DkmIntermediateEvaluationResult( InspectionContext, StackFrame, Name, FullName, Expression, IntermediateLanguage, TargetRuntime, DataItem)); }
bool IDkmRuntimeStepper.OwnsCurrentExecutionLocation(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, DkmStepArbitrationReason reason) { if (!DebuggerOptions.UsePythonStepping) { return(false); } var process = runtimeInstance.Process; var pyrtInfo = process.GetPythonRuntimeInfo(); if (pyrtInfo.DLLs.Python == null) { return(false); } var thread = stepper.Thread; var ip = thread.GetCurrentRegisters(new DkmUnwoundRegister[0]).GetInstructionPointer(); return(pyrtInfo.DLLs.Python.ContainsAddress(ip) || (pyrtInfo.DLLs.DebuggerHelper != null && pyrtInfo.DLLs.DebuggerHelper.ContainsAddress(ip)) || (pyrtInfo.DLLs.CTypes != null && pyrtInfo.DLLs.CTypes.ContainsAddress(ip))); }
public static void VscxOnRuntimeInstanceLoad(this DkmRuntimeInstance runtime) { if (runtime.TagValue != DkmRuntimeInstance.Tag.NativeRuntimeInstance) { return; } DkmNativeRuntimeInstance nativeRuntime = (DkmNativeRuntimeInstance)runtime; bool isChrome = false; bool isTestProcess = false; // Check if the process is a chrome executable, and if so, attach a CallstackFilter to the DkmProcess. if (ChromeUtility.IsChromeProcess(nativeRuntime.Process.Path)) { isChrome = true; } #if DEBUG string fileName = Path.GetFileName(nativeRuntime.Process.Path); if (fileName.Equals("vistest.exe", StringComparison.CurrentCultureIgnoreCase)) { isTestProcess = true; } #endif if (isTestProcess || isChrome) { DkmProcess process = nativeRuntime.Process; DebugProcessOptions options = DebugProcessOptions.Create(process.DebugLaunchSettings.OptionsString); ProcessDebugOptionsDataItem optionsDataItem = new ProcessDebugOptionsDataItem(options); process.SetDataItem(DkmDataCreationDisposition.CreateAlways, optionsDataItem); if (isTestProcess || ShouldEnableChildDebugging(nativeRuntime.Process, options)) { process.SetDataItem(DkmDataCreationDisposition.CreateAlways, new RuntimeBreakpointHandler()); process.SetDataItem(DkmDataCreationDisposition.CreateAlways, new AutoAttachToChildHandler()); } } }
void IDkmRuntimeStepper.Step(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, DkmStepArbitrationReason reason) { var process = runtimeInstance.Process; var processData = DebugHelpers.GetOrCreateDataItem <LuaRemoteProcessData>(runtimeInstance.Process); if (stepper.StepKind == DkmStepKind.StepIntoSpecific) { throw new NotSupportedException(); } if (processData.activeStepper != null) { processData.activeStepper.CancelStepper(processData.runtimeInstance); processData.activeStepper = null; } if (stepper.StepKind == DkmStepKind.Over) { DebugHelpers.TryWriteIntVariable(process, processData.locations.helperStepOverAddress, 1); } else if (stepper.StepKind == DkmStepKind.Into) { DebugHelpers.TryWriteIntVariable(process, processData.locations.helperStepOverAddress, 1); DebugHelpers.TryWriteIntVariable(process, processData.locations.helperStepIntoAddress, 1); } else if (stepper.StepKind == DkmStepKind.Out) { DebugHelpers.TryWriteIntVariable(process, processData.locations.helperStepOutAddress, 1); } processData.activeStepper = stepper; processData.hadActiveStepper = true; UpdateHooks(process, processData); }
void IDkmRuntimeStepper.BeforeEnableNewStepper(DkmRuntimeInstance runtimeInstance, DkmStepper stepper) { // Don't have anything to do here right now }
void IDkmRuntimeStepper.AfterSteppingArbitration(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, DkmStepArbitrationReason reason, DkmRuntimeInstance newControllingRuntimeInstance) { }
internal DkmInspectionContext(IDkmClrFormatter formatter, DkmEvaluationFlags evaluationFlags, uint radix, DkmRuntimeInstance runtimeInstance = null) { _formatter = formatter; this.EvaluationFlags = evaluationFlags; this.Radix = radix; this.RuntimeInstance = runtimeInstance ?? DkmClrRuntimeInstance.DefaultRuntime; }
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); DkmInspectionContext inspectionContext; LuaWorkerConnectionWrapper workerConnectionWrapper = inspectionSession.Process.GetDataItem <LuaWorkerConnectionWrapper>(); if (workerConnectionWrapper != null) { inspectionContext = workerConnectionWrapper.CreateInspectionSession(inspectionSession, runtimeInstance, thread, flags, language); } else { inspectionContext = DkmInspectionContext.Create(inspectionSession, runtimeInstance, thread, 200, flags, DkmFuncEvalFlags.None, 10, language, null); } 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); } }
void IDkmRuntimeStepper.AfterSteppingArbitration(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, DkmStepArbitrationReason reason, DkmRuntimeInstance newControllingRuntimeInstance) { // Don't have anything to do here right now }
bool IDkmRuntimeStepper.StepControlRequested(DkmRuntimeInstance runtimeInstance, DkmStepper stepper, DkmStepArbitrationReason reason, DkmRuntimeInstance callingRuntimeInstance) { return(true); }
void IDkmRuntimeStepper.NotifyStepComplete(DkmRuntimeInstance runtimeInstance, DkmStepper stepper) { }