static void IndexDumps() { Console.WriteLine("Setting up a lazy xml files reader that yields packages..."); var packages = DumpReader.GetPackages(); Console.Write("Indexing documents into Elasticsearch..."); var waitHandle = new CountdownEvent(1); var bulkAll = Client.BulkAll(packages, b => b .Index(CurrentIndexName) .BackOffRetries(2) .BackOffTime("30s") .RefreshOnCompleted(true) .MaxDegreeOfParallelism(4) .Size(1000) ); bulkAll.Subscribe(new BulkAllObserver( onNext: b => Console.Write("."), onError: e => throw e, onCompleted: () => waitHandle.Signal() )); waitHandle.Wait(TimeSpan.FromMinutes(30)); Console.WriteLine("Done."); }
public DumpDataReader(string file) { if (!File.Exists(file)) throw new FileNotFoundException(file); if (Path.GetExtension(file).ToLower() == ".cab") file = ExtractCab(file); m_fileName = file; m_dumpReader = new DumpReader(file); }
public DumpDataReader(string file) { if (!File.Exists(file)) { throw new FileNotFoundException(file); } if (Path.GetExtension(file).ToLower() == ".cab") { file = ExtractCab(file); } _fileName = file; _dumpReader = new DumpReader(file); }
public static ICorDebugProcess GetDebuggerHandleFromProcessDump(string processDumpFile, long clrInstanceId = 0) { LibraryProvider libraryProvider = new LibraryProvider(); using (DumpReader reader = new DumpReader(processDumpFile)) { if ((IntPtr.Size == 8) && (reader.ProcessorArchitecture == ProcessorArchitecture.PROCESSOR_ARCHITECTURE_INTEL)) { throw new InvalidOperationException("Opening a 32 bit dump in a 64 bit process."); } if ((IntPtr.Size == 4) && (reader.ProcessorArchitecture == ProcessorArchitecture.PROCESSOR_ARCHITECTURE_AMD64)) { throw new InvalidOperationException("Opening a 64 bit dump in a 32 bit process."); } using (DumpDataTarget target = new DumpDataTarget(reader)) { foreach (DumpModule module in reader.EnumerateModules()) { if ((clrInstanceId == 0) || (clrInstanceId == (long)module.BaseAddress)) { Version version; ClrDebuggingProcessFlags flags; ICorDebugProcess process; int errorCode = new CLRDebugging().TryOpenVirtualProcess( module.BaseAddress, target, libraryProvider, new Version(4, 0, 0x7fff, 0x7fff), out version, out flags, out process); if (errorCode < 0) { if (((errorCode != -2146231228) && (errorCode != -2146231226)) && (errorCode != -2146231225)) { Marshal.ThrowExceptionForHR(errorCode); } } else { return(process); } } } } } throw new InvalidOperationException("No V4.0 .NET Runtime found in dump file."); }
/// <summary> /// Constructor a Dump Target around an existing DumpReader. /// </summary> /// <param name="reader"></param> public DumpDataTarget(DumpReader reader) { m_reader = reader; string s = ".\\"; try { // For our trivial implementation, try looking in the CLR directory DumpModule dm = m_reader.LookupModule("clr.dll"); s = dm.FullName; if (s.LastIndexOf('\\') != -1) { s = s.Substring(0, s.LastIndexOf('\\')); } } catch (DumpMissingDataException) { } m_metaDataLocator = new CorDebugMetaDataLocator(s); }
private void ViewDump_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialog()) { ofd.Title = T._("Dump auswählen"); ofd.AddLegacyFilter("*.fpldmp|*.fpldmp"); if (ofd.ShowDialog(this) == DialogResult.Ok) { try { var reader = new DumpReader(ofd.FileName); var events = reader.Events; using (var isf = new InspectForm(events)) isf.ShowModal(); } catch { MessageBox.Show(T._("Fehler beim Öffnen der Datei.")); } } } }
public static void OpendumpCmd(string arguments) { const string pathArg = "path"; ArgParser ap = new ArgParser(arguments, pathArg + ":1"); if (ap.Count > 1) { throw new MDbgShellException("Wrong # of arguments."); } if (!ap.Exists(0) && !ap.OptionPassed(pathArg)) { throw new MDbgShellException("Specify a dump file to open"); } string path; if (ap.Exists(0)) path = ap.AsString(0); else path = ap.GetOption(pathArg).AsString; DumpReader dump = new DumpReader(path); MDbgProcess process = Debugger.Processes.CreateProcess(); // An exception partway through attaching can leave the debugger in an odd in-between state. // We need to attempt to detach. bool success = false; try { process.AttachToDump(dump, null); success = true; } finally { // Fault handler (emulate with finally & success bool since C# doesn't support fault blocks) // Detach on failure so we're not left with a partially attached process if (!success) process.Detach(); } WriteOutput("DBI path: " + ((LibraryProvider)process.LibraryProvider).LastLoadedDbi); // If there's an exception of interest stored in the dump, use it. // Otherwise, fall back on going to the first thread with managed code. if (dump.IsExceptionStream()) { uint TID = dump.ExceptionStreamThreadId(); WriteOutput("OS TID from last exception in dump was 0n" + TID); MDbgThread thread = process.Threads.GetThreadFromThreadId((int)TID); if (null == thread) { WriteOutput("Could not find a managed thread corresponding to native TID!\n" + "This should indicate that the last event was a native event on an unmanaged thread.\n" ); } else { process.Threads.Active = thread; WriteOutput("Active thread set to " + process.Threads.Active.Id); } } else { WriteOutput("No exception in dump, current thread will be chosen randomly."); // Set the currently active thread to the first thread we find with managed code on it. bool foundThread = false; for (int i = 0; i < process.Threads.Count && !foundThread; i++) { foreach (MDbgFrame frame in process.Threads[i].Frames) { if (frame != null && frame.IsManaged) { process.Threads.Active = process.Threads[i]; foundThread = true; } } } if (!foundThread) { WriteOutput("Warning: couldn't find thread with managed frame at base in dump"); } } // This can fail silently if we can't walk the first frame of the stack. process.AsyncStop(); process.Threads.Active.InvalidateStackWalker(); WriteOutput("Dump loaded successfully."); }
/// <summary> /// Attaches the process to a dump using the specified DumpDataTarget /// </summary> /// <param name="dumpReader">A reader for the dump</param> /// <param name="clrInstanceId">The moduleBaseAddress of the CLR to debug or null /// to debug the first CLR encountered</param> public void AttachToDump(DumpReader dumpReader, long? clrInstanceId, ICorDebugDataTarget dataTarget) { Debug.Assert(!IsAlive); if (IsAlive) throw new InvalidOperationException("cannot call Attach on active process"); // set up the stopGo controller NoninvasiveStopGoController stopGo = new NoninvasiveStopGoController(); stopGo.Init(this); m_stopGo = stopGo; NativeProcessCreated(); foreach (DumpModule module in dumpReader.EnumerateModules()) { // use the selected runtime if there was one, otherwise just attach to the first // runtime we find if (clrInstanceId.HasValue && (clrInstanceId.Value != (long)module.BaseAddress)) continue; CLRDebugging clrDebugging = new CLRDebugging(); Version actualVersion; ClrDebuggingProcessFlags flags; CorProcess proc; int hr = clrDebugging.TryOpenVirtualProcess(module.BaseAddress, dataTarget, LibraryProvider, new Version(4, 0, short.MaxValue, short.MaxValue), out actualVersion, out flags, out proc); if (hr < 0) { if ((hr == (int)HResult.CORDBG_E_NOT_CLR) || (hr == (int)HResult.CORDBG_E_UNSUPPORTED_DEBUGGING_MODEL) || (hr == (int)HResult.CORDBG_E_UNSUPPORTED_FORWARD_COMPAT)) { // these errors are all potentially benign, just ignore this module. } else { Marshal.ThrowExceptionForHR(hr); // the rest are bad } } else { // We must have succeeded Debug.Assert(proc != null); BindToExistingClrInTarget(proc); m_dumpReader = dumpReader; return; // SUCCESS - done } } // If we've got here, it means there were no supported CLRs in the dump Debug.Assert(m_corProcess == null); // Should not yet be bound throw new MDbgException("Failed to open the dump - no supported CLRs found in the module list"); }
/// <summary> /// Attaches the process to a dump /// </summary> /// <param name="dumpReader">A reader for the dump</param> /// <param name="clrInstanceId">The moduleBaseAddress of the CLR to debug or null /// to debug the first CLR encountered</param> public void AttachToDump(DumpReader dumpReader, long? clrInstanceId) { // bind to a runtime in the dump DumpDataTarget dataTarget = new DumpDataTarget(dumpReader); AttachToDump(dumpReader, clrInstanceId, dataTarget); }