public bool ManagedCallback(ManagedCallbackFunction func, CommandResult result) { ManagedCallbackData data = new ManagedCallbackData (func, result); return (bool) SendCommand (delegate { Report.Debug (DebugFlags.SSE, "{0} starting managed callback: {1}", this, func); AcquireThreadLock (); if (is_managed_frame ()) { // // We found a managed frame; now let's first check whether we can do // all the work without starting an operation. // OperationManagedCallback omc = new OperationManagedCallback (this, data); if (omc.Run ()) return false; // // Ok, we're done -> return to the user. // ReleaseThreadLock (); return true; } // // Stop all threads and check whether one of them is in managed land. // Report.Debug (DebugFlags.SSE, "{0} managed callback needs global thread lock", this); bool ok = false; process.AcquireGlobalThreadLock (this); foreach (SingleSteppingEngine engine in process.ThreadServants) { try { if (engine.is_managed_frame ()) { ok = true; break; } } catch (Exception ex) { Console.WriteLine ("F**K: {0} {1}", engine, ex); } } if (!ok) { // // None of the threads is currently in managed land; request a managed // callback. // request_managed_callback (data); } Report.Debug (DebugFlags.SSE, "{0} managed callback releasing global thread lock", this); process.ReleaseGlobalThreadLock (this); ReleaseThreadLock (); Report.Debug (DebugFlags.SSE, "{0} managed callback done: {1} {2}", this, data.Running, data.Completed); return false; }); }
internal bool OnManagedCallback(Queue<ManagedCallbackData> callbacks) { Report.Debug (DebugFlags.SSE, "{0} on managed callback", this); OperationManagedCallback omc = new OperationManagedCallback (this, callbacks); if (omc.Run ()) { Report.Debug (DebugFlags.SSE, "{0} started managed callback operation", this); return true; } Report.Debug (DebugFlags.SSE, "{0} completed managed callback", this); return false; }