private void WriteCrashDumps(GCMode gc) { if (_fullDumpPath[(int)gc] != null) { return; } string executable = Executable; DebuggerStartInfo info = new DebuggerStartInfo(); if (gc == GCMode.Server) { info.SetEnvironmentVariable("COMPlus_BuildFlavor", "svr"); } using (Debugger dbg = info.LaunchProcess(executable, Helpers.TestWorkingDirectory)) { dbg.SecondChanceExceptionEvent += delegate(Debugger d, EXCEPTION_RECORD64 ex) { if (ex.ExceptionCode == (uint)ExceptionTypes.Clr) { WriteDumps(dbg, executable, gc); } }; DEBUG_STATUS status; do { status = dbg.ProcessEvents(0xffffffff); } while (status != DEBUG_STATUS.NO_DEBUGGEE); Assert.IsNotNull(_miniDumpPath[(int)gc]); Assert.IsNotNull(_fullDumpPath[(int)gc]); } }
public DataTarget LoadFullDumpWithDbgEng(GCMode gc = GCMode.Workstation) { Guid guid = new Guid("27fe5639-8407-4f47-8364-ee118fb08ac8"); int hr = DebugCreate(guid, out IntPtr pDebugClient); if (hr != 0) { throw new Exception($"Failed to create DebugClient, hr={hr:x}."); } IDebugClient client = (IDebugClient)Marshal.GetTypedObjectForIUnknown(pDebugClient, typeof(IDebugClient)); IDebugControl control = (IDebugControl)client; string dumpPath = BuildDumpName(gc, true); hr = client.OpenDumpFile(dumpPath); if (hr != 0) { throw new Exception($"Failed to OpenDumpFile, hr={hr:x}."); } hr = control.WaitForEvent(DEBUG_WAIT.DEFAULT, 10000); if (hr != 0) { throw new Exception($"Failed to attach to dump file, hr={hr:x}."); } Marshal.Release(pDebugClient); return(DataTarget.CreateFromDbgEng(pDebugClient)); }
private static string GetFullDumpName(string executable, GCMode gc) { string basePath = Path.Combine(Path.GetDirectoryName(executable), Path.GetFileNameWithoutExtension(executable)); basePath += gc == GCMode.Workstation ? "_wks" : "_svr"; basePath += "_full.dmp"; return(basePath); }
private string BuildDumpName(GCMode gcmode, bool full) { string filename = Path.Combine(Path.GetDirectoryName(Executable), Path.GetFileNameWithoutExtension(Executable)); string gc = gcmode == GCMode.Server ? "svr" : "wks"; string dumpType = full ? "" : "_mini"; filename = $"{filename}_{gc}{dumpType}.dmp"; return(filename); }
public DataTarget LoadMiniDump(GCMode gc = GCMode.Workstation) { string path = GetMiniDumpName(Executable, gc); if (File.Exists(path)) return DataTarget.LoadCrashDump(path); WriteCrashDumps(gc); return DataTarget.LoadCrashDump(_miniDumpPath[(int)gc]); }
public DataTarget LoadMiniDump(GCMode gc = GCMode.Workstation) { string path = GetMiniDumpName(Executable, gc); if (File.Exists(path)) { return(DataTarget.LoadCrashDump(path)); } WriteCrashDumps(gc); return(DataTarget.LoadCrashDump(_miniDumpPath[(int)gc])); }
private void WriteDumps(Debugger dbg, string exe, GCMode gc) { string dump = GetMiniDumpName(exe, gc); dbg.WriteDumpFile(dump, DEBUG_DUMP.SMALL); _miniDumpPath[(int)gc] = dump; dump = GetFullDumpName(exe, gc); dbg.WriteDumpFile(dump, DEBUG_DUMP.DEFAULT); _fullDumpPath[(int)gc] = dump; dbg.TerminateProcess(); }
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)); }
public DataTarget LoadFullDump(GCMode gc = GCMode.Workstation) { string path = BuildDumpName(gc, full: true); return(DataTarget.LoadCrashDump(path)); }
private static string GetFullDumpName(string executable, GCMode gc) { string basePath = Path.Combine(Path.GetDirectoryName(executable), Path.GetFileNameWithoutExtension(executable)); basePath += gc == GCMode.Workstation ? "_wks" : "_svr"; basePath += "_full.dmp"; return basePath; }
private void WriteCrashDumps(GCMode gc) { if (_fullDumpPath[(int)gc] != null) return; string executable = Executable; DebuggerStartInfo info = new DebuggerStartInfo(); if (gc == GCMode.Server) info.SetEnvironmentVariable("COMPlus_BuildFlavor", "svr"); using (Debugger dbg = info.LaunchProcess(executable, Helpers.TestWorkingDirectory)) { dbg.SecondChanceExceptionEvent += delegate (Debugger d, EXCEPTION_RECORD64 ex) { if (ex.ExceptionCode == (uint)ExceptionTypes.Clr) WriteDumps(dbg, executable, gc); }; DEBUG_STATUS status; do { status = dbg.ProcessEvents(0xffffffff); } while (status != DEBUG_STATUS.NO_DEBUGGEE); Assert.IsNotNull(_miniDumpPath[(int)gc]); Assert.IsNotNull(_fullDumpPath[(int)gc]); } }
public DataTarget LoadFullDump(GCMode gc = GCMode.Workstation) => LoadDump(BuildDumpName(gc, true));
public DataTarget LoadMinidump(GCMode gc = GCMode.Workstation) => LoadDump(BuildDumpName(gc, false));
public DataTarget LoadMiniDump(GCMode gc = GCMode.Workstation) { string path = BuildDumpName(gc, false); return(DataTarget.LoadCrashDump(path)); }