public DebuggerThread(IDebugClient client, Symbols symbols) { _symbols = symbols; _control5 = (IDebugControl5)client; _advanced2 = (IDebugAdvanced2)client; _systemObjects = (IDebugSystemObjects)client; }
public Debugger(IDebugClient client) { _client = (IDebugClient6)client; _control5 = (IDebugControl5)client; _advanced2 = (IDebugAdvanced2)client; //_client.SetOutputCallbacksWide(new NullDebugOutput()); }
public static LastEventInformation GetLastEventInformation(this DataTarget target) { var control = (IDebugControl)target.DebuggerInterface; DEBUG_EVENT eventType; uint procId, threadId; StringBuilder description = new StringBuilder(2048); uint unused; uint descriptionSize; if (0 != control.GetLastEventInformation( out eventType, out procId, out threadId, IntPtr.Zero, 0, out unused, description, description.Capacity, out descriptionSize)) { return(null); } var osThreadIds = target.GetOSThreadIds(); var eventInformation = new LastEventInformation { OSThreadId = (int)osThreadIds[threadId], EventType = eventType, EventDescription = description.ToString() }; IDebugAdvanced2 debugAdvanced = (IDebugAdvanced2)target.DebuggerInterface; int outSize; byte[] buffer = new byte[Marshal.SizeOf(typeof(EXCEPTION_RECORD64))]; int hr = debugAdvanced.Request(DEBUG_REQUEST.TARGET_EXCEPTION_RECORD, null, 0, buffer, buffer.Length, out outSize); if (hr == 0) { GCHandle gch = GCHandle.Alloc(buffer, GCHandleType.Pinned); try { eventInformation.ExceptionRecord = (EXCEPTION_RECORD64)Marshal.PtrToStructure(gch.AddrOfPinnedObject(), typeof(EXCEPTION_RECORD64)); } finally { gch.Free(); } } return(eventInformation); }
public void Fill(IDebugAdvanced2 debugAdvanced) { int size = Marshal.SizeOf(typeof(DEBUG_THREAD_BASIC_INFORMATION)); byte[] buffer = new byte[size]; if (HR.Failed(debugAdvanced.GetSystemObjectInformation( DEBUG_SYSOBJINFO.THREAD_BASIC_INFORMATION, 0, EngineThreadId, buffer, buffer.Length, out size))) { return; } var gch = GCHandle.Alloc(buffer, GCHandleType.Pinned); try { var threadBasicInformation = (DEBUG_THREAD_BASIC_INFORMATION) Marshal.PtrToStructure(gch.AddrOfPinnedObject(), typeof(DEBUG_THREAD_BASIC_INFORMATION)); if ((threadBasicInformation.Valid & DEBUG_TBINFO.AFFINITY) != 0) { Affinity = threadBasicInformation.Affinity; } if ((threadBasicInformation.Valid & DEBUG_TBINFO.PRIORITY_CLASS) != 0) { PriorityClass = threadBasicInformation.PriorityClass; } if ((threadBasicInformation.Valid & DEBUG_TBINFO.PRIORITY) != 0) { Priority = threadBasicInformation.Priority; } if ((threadBasicInformation.Valid & DEBUG_TBINFO.TIMES) != 0) { CreateTime = threadBasicInformation.CreateTime; KernelTime = threadBasicInformation.KernelTime; UserTime = threadBasicInformation.UserTime; } } finally { gch.Free(); } }
public static LastEventInformation GetLastEventInformation(this DataTarget target) { var control = (IDebugControl)target.DebuggerInterface; DEBUG_EVENT eventType; uint procId, threadId; StringBuilder description = new StringBuilder(2048); uint unused; uint descriptionSize; if (HR.Failed(control.GetLastEventInformation( out eventType, out procId, out threadId, IntPtr.Zero, 0, out unused, description, description.Capacity, out descriptionSize))) { return(null); } var osThreadIds = target.GetOSThreadIds(); var eventInformation = new LastEventInformation { OSThreadId = (int)osThreadIds[threadId], EventType = eventType, EventDescription = description.ToString() }; IDebugAdvanced2 debugAdvanced = (IDebugAdvanced2)target.DebuggerInterface; int outSize; byte[] buffer = new byte[Marshal.SizeOf(typeof(EXCEPTION_RECORD64))]; int hr = debugAdvanced.Request(DEBUG_REQUEST.TARGET_EXCEPTION_RECORD, null, 0, buffer, buffer.Length, out outSize); if (HR.Succeeded(hr)) { GCHandle gch = GCHandle.Alloc(buffer, GCHandleType.Pinned); try { eventInformation.ExceptionRecord = (EXCEPTION_RECORD64)Marshal.PtrToStructure(gch.AddrOfPinnedObject(), typeof(EXCEPTION_RECORD64)); } finally { gch.Free(); } } buffer = new byte[Marshal.SizeOf(typeof(uint))]; hr = debugAdvanced.Request(DEBUG_REQUEST.TARGET_EXCEPTION_THREAD, null, 0, buffer, buffer.Length, out outSize); if (HR.Succeeded(hr)) { // If there is a stored exception event with a thread id, use that instead // of what GetLastEventInformation returns, because it might be different. eventInformation.OSThreadId = (int)BitConverter.ToUInt32(buffer, 0); } buffer = new byte[Marshal.SizeOf(typeof(CONTEXT))]; hr = debugAdvanced.Request(DEBUG_REQUEST.TARGET_EXCEPTION_CONTEXT, null, 0, buffer, buffer.Length, out outSize); if (HR.Succeeded(hr)) { var gch = GCHandle.Alloc(buffer, GCHandleType.Pinned); try { eventInformation.ExceptionContext = (CONTEXT)Marshal.PtrToStructure( gch.AddrOfPinnedObject(), typeof(CONTEXT)); } finally { gch.Free(); } } return(eventInformation); }