Exemplo n.º 1
0
        private void CreateClient(IntPtr ptr)
        {
            _systemObjects = new DebugSystemObjects(_library, ptr);
            _client = new DebugClient(_library, ptr, _systemObjects);
            _control = new DebugControl(_library, ptr, _systemObjects);
            _spaces = new DebugDataSpaces(_library, ptr, _systemObjects);
            _advanced = new DebugAdvanced(_library, ptr, _systemObjects);
            _symbols = new DebugSymbols(_library, ptr, _systemObjects);

            _client.SuppressRelease();
            _control.SuppressRelease();
            _spaces.SuppressRelease();
            _advanced.SuppressRelease();
            _symbols.SuppressRelease();
            _systemObjects.SuppressRelease();

            Interlocked.Increment(ref s_totalInstanceCount);
        }
Exemplo n.º 2
0
        public DataTarget LoadFullDumpWithDbgEng(GCMode gc = GCMode.Workstation)
        {
            Guid guid = DebugClient.IID_IDebugClient;
            int  hr   = DebugCreate(guid, out IntPtr pDebugClient);

            if (hr != 0)
            {
                throw new Exception($"Failed to create DebugClient, hr={hr:x}.");
            }

            RefCountedFreeLibrary library = new RefCountedFreeLibrary(IntPtr.Zero);

            Marshal.AddRef(pDebugClient);
            Marshal.AddRef(pDebugClient);
            DebugSystemObjects sys     = new DebugSystemObjects(library, pDebugClient);
            DebugClient        client  = new DebugClient(library, pDebugClient, sys);
            DebugControl       control = new DebugControl(library, pDebugClient, sys);

            string dumpPath = BuildDumpName(gc, true);

            hr = client.OpenDumpFile(dumpPath);
            if (hr != 0)
            {
                throw new Exception($"Failed to OpenDumpFile, hr={hr:x}.");
            }

            hr = control.WaitForEvent(10000);

            if (hr != 0)
            {
                throw new Exception($"Failed to attach to dump file, hr={hr:x}.");
            }

            Marshal.Release(pDebugClient);
            return(DataTarget.CreateFromDbgEng(pDebugClient));
        }