/// <summary> /// Initializes the test class with the specified dump file. /// </summary> /// <param name="dumpFile">The dump file.</param> /// <param name="symbolPath">The symbol path.</param> /// <param name="addSymbolServer">if set to <c>true</c> symbol server will be added to the symbol path.</param> protected static void InitializeDump(string dumpFile, string symbolPath, bool addSymbolServer = true) { NormalizeDebugPaths(ref dumpFile, ref symbolPath, addSymbolServer); client = DebugClient.OpenDumpFile(dumpFile, symbolPath); Context.Initalize(client); }
public DbgEngDataReader(string dumpFile) { if (!File.Exists(dumpFile)) { throw new FileNotFoundException(dumpFile); } DisplayName = dumpFile; IntPtr pClient = CreateIDebugClient(); CreateClient(pClient); HResult hr = _client.OpenDumpFile(dumpFile); if (hr != 0) { const int STATUS_MAPPED_FILE_SIZE_ZERO = unchecked ((int)0xC000011E); if (hr == HResult.E_INVALIDARG || hr == (STATUS_MAPPED_FILE_SIZE_ZERO | 0x10000000)) { throw new InvalidDataException($"'{dumpFile}' is not a crash dump."); } throw new ClrDiagnosticsException($"Could not load crash dump, HRESULT: {hr}", hr).AddData("DumpFile", dumpFile); } // This actually "attaches" to the crash dump. HResult result = _control.WaitForEvent(0xffffffff); _systemObjects.Init(); DebugOnly.Assert(result); }
/// <summary> /// Initializes debugger for processing the specified dump. /// </summary> /// <param name="dumpPath">Path to the dump.</param> /// <param name="symbolPaths">Array of paths where debugger will look for symbols.</param> public static void OpenDump(string dumpPath, params string[] symbolPaths) { try { IDebugClient debugClient = DebugClient.OpenDumpFile(dumpPath, string.Join(";", symbolPaths)); InitializeDbgEng(debugClient); } catch { IDebuggerEngine engine = new ElfCoreDumpDebuggingEngine(dumpPath); Context.InitializeDebugger(engine); } }
public DbgEngDumpInitialization(string dumpPath, string defaultModuleName, string symbolPath = DefaultDumpPath, bool addSymbolServer = true, bool useDia = true, bool useDwarf = false) : base(dumpPath, defaultModuleName, FixSymbolPath(symbolPath, addSymbolServer)) { IDebugClient client = DebugClient.OpenDumpFile(DumpPath, SymbolPath); DbgEngDll.InitializeContext(client); if (!useDia && !useDwarf) { Context.InitializeDebugger(Context.Debugger); } else if (useDwarf) { Context.InitializeDebugger(Context.Debugger, new DwarfSymbolProvider.DwarfSymbolProvider()); } }
public DbgEngDumpInitialization(string dumpPath, string defaultModuleName, string symbolPath = DefaultDumpPath, bool addSymbolServer = true, bool useDia = true, bool useDwarf = false, bool useILCodeGen = false) : base(dumpPath, defaultModuleName, FixSymbolPath(symbolPath, addSymbolServer), useILCodeGen) { // Clear all processes being debugged with DbgEng.dll... (Context.Debugger as DbgEngDll)?.Client?.EndSession(DebugEnd.ActiveTerminate); IDebugClient client = DebugClient.OpenDumpFile(DumpPath, SymbolPath); DbgEngDll.InitializeContext(client); if (!useDia && !useDwarf) { Context.InitializeDebugger(Context.Debugger); } else if (useDwarf) { Context.InitializeDebugger(Context.Debugger, new DwarfSymbolProvider.DwarfSymbolProvider()); } }
public DbgEngDataReader(string dumpFile) { if (!File.Exists(dumpFile)) throw new FileNotFoundException(dumpFile); IntPtr pClient = CreateIDebugClient(); CreateClient(pClient); int hr = _client.OpenDumpFile(dumpFile); if (hr != 0) { var kind = (uint)hr == 0x80004005 ? ClrDiagnosticsExceptionKind.CorruptedFileOrUnknownFormat : ClrDiagnosticsExceptionKind.DebuggerError; throw new ClrDiagnosticsException($"Could not load crash dump, HRESULT: 0x{hr:x8}", kind, hr).AddData("DumpFile", dumpFile); } // This actually "attaches" to the crash dump. bool result = _control.WaitForEvent(0xffffffff); DebugOnly.Assert(result); }
static void Main(string[] args) { Options options = null; Parser.Default.ParseArguments <Options>(args) .WithParsed(o => options = o); if (options == null) { return; } Context.Initalize(DebugClient.OpenDumpFile(options.DumpPath, options.SymbolPath)); Console.WriteLine("Threads: {0}", Thread.All.Length); Console.WriteLine("Current thread: {0}", Thread.Current.Id); var frames = Thread.Current.StackTrace.Frames; Console.WriteLine("Call stack:"); foreach (var frame in frames) { try { Console.WriteLine(" {0,3:x} {1}+0x{2:x} ({3}:{4})", frame.FrameNumber, frame.FunctionName, frame.FunctionDisplacement, frame.SourceFileName, frame.SourceFileLine); } catch (Exception) { Console.WriteLine(" {0,3:x} {1}+0x{2:x}", frame.FrameNumber, frame.FunctionName, frame.FunctionDisplacement); } } // In order to use console output and error in scripts, we must set it to debug client DebugOutput captureFlags = DebugOutput.Normal | DebugOutput.Error | DebugOutput.Warning | DebugOutput.Verbose | DebugOutput.Prompt | DebugOutput.PromptRegisters | DebugOutput.ExtensionWarning | DebugOutput.Debuggee | DebugOutput.DebuggeePrompt | DebugOutput.Symbols | DebugOutput.Status; var callbacks = DebuggerOutputToTextWriter.Create(Console.Out, captureFlags); using (OutputCallbacksSwitcher switcher = OutputCallbacksSwitcher.Create(callbacks)) { Executor.Execute(@"..\..\..\..\samples\script.csx"); } }
public DbgEngDataReader(string dumpFile) { if (!File.Exists(dumpFile)) { throw new FileNotFoundException(dumpFile); } IntPtr pClient = CreateIDebugClient(); CreateClient(pClient); HResult hr = _client.OpenDumpFile(dumpFile); if (hr != 0) { const int STATUS_MAPPED_FILE_SIZE_ZERO = unchecked ((int)0xC000011E); if (hr == HResult.E_INVALIDARG || hr == HRESULT_FROM_NT(STATUS_MAPPED_FILE_SIZE_ZERO)) { throw new InvalidDataException($"'{dumpFile}' is not a crash dump."); } var kind = hr == HResult.E_FAIL ? ClrDiagnosticsExceptionKind.CorruptedFileOrUnknownFormat : ClrDiagnosticsExceptionKind.DebuggerError; throw new ClrDiagnosticsException($"Could not load crash dump, HRESULT: {hr}", kind, hr).AddData("DumpFile", dumpFile);
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)); }
/// <summary> /// Initializes the test class with the specified dump file. /// </summary> /// <param name="dumpFile">The dump file.</param> /// <param name="symbolPath">The symbol path.</param> protected static void Initialize(string dumpFile, string symbolPath) { client = DebugClient.OpenDumpFile(dumpFile, symbolPath); Context.Initalize(client); }