Exemplo n.º 1
0
        public unsafe void QueueForDecRef(PyObject obj)
        {
            byte[] buf = new byte[sizeof(ObjectToRelease)];
            fixed(byte *p = buf)
            {
                var otr = (ObjectToRelease *)p;

                otr->pyObject = obj.Address;
                otr->next     = _objectsToRelease.Read();
            }

            ulong otrPtr = _process.AllocateVirtualMemory(0, sizeof(ObjectToRelease), NativeMethods.MEM_COMMIT | NativeMethods.MEM_RESERVE, NativeMethods.PAGE_READWRITE);

            _process.WriteMemory(otrPtr, buf);
            _objectsToRelease.Write(otrPtr);
        }
Exemplo n.º 2
0
        public void Step(DkmStepper stepper, DkmStepArbitrationReason reason)
        {
            var thread  = stepper.Thread;
            var process = thread.Process;

            if (stepper.StepKind == DkmStepKind.StepIntoSpecific)
            {
                throw new NotSupportedException();
            }
            else if (_stepper != null)
            {
                _stepper.CancelStepper(process.GetPythonRuntimeInstance());
                _stepper = null;
            }

            // Check if this was a step out (or step over/in that fell through) from native to Python.
            // If so, we consider the step done, since we can report the correct callstack at this point.
            if (reason == DkmStepArbitrationReason.TransitionModule)
            {
                var beginState = stepper.GetDataItem <StepBeginState>();
                if (beginState != null)
                {
                    thread.GetCurrentFrameInfo(out global::System.UInt64 retAddr, out global::System.UInt64 frameBase, out global::System.UInt64 vframe);
                    if (frameBase >= beginState.FrameBase)
                    {
                        stepper.OnStepComplete(thread, false);
                        return;
                    }
                }
            }

            if (stepper.StepKind == DkmStepKind.Into)
            {
                new LocalComponent.BeginStepInNotification
                {
                    ThreadId = thread.UniqueId
                }.SendHigher(process);
            }

            _stepper = stepper;
            _stepKind.Write((int)stepper.StepKind + 1);
            _stepThreadId.Write((uint)thread.SystemPart.Id);
            _steppingStackDepth.Write(0);
        }