goldshtn / msos

Command-line environment a-la WinDbg for executing SOS commands without having SOS available.
Other
96 stars 21 forks source link

Generate minimal .NET dumps that can be analyzed effectively #35

Closed goldshtn closed 9 years ago

goldshtn commented 9 years ago

Currently, there's nothing that we can do with a .NET dump unless it has the full process memory. But it's possible (and some attempts were made in the past, e.g. ClrDump) to include only specific memory regions in the dump. We can use CLRMD to determine which regions must be included -- heap, loader heaps, JIT data, etc. -- and then generate a dump that is potentially much smaller. This can be a utility that takes a list of flags (want all heap objects, want all modules, want native heap, etc.) and generates the minimal dump that can satisfy all requirements.

Check what CLRMD needs to successfully display minimal exception information in a .NET dump. Does a default WER minidump work? Looks like Procdump's default configuration is enough (without -ma).

goldshtn commented 9 years ago

Basic exception triage seems to be possible with what WER DumpType=1 or Procdump's default configuration generates: getting the list of threads, loaded modules, !clrstack, and !pe (small bug notwithstanding). But to get good symbols in that case the modules themselves (.exe/.dll) need to be provided to the debugger on the symbol path.

Other commands will fail spuriously, mostly because the heap is not available -- so need to add some mode that disables these commands when working with a small dump. This was done in https://github.com/goldshtn/msos/issues/36.

goldshtn commented 9 years ago

Now working on a a slightly different approach. MiniDumpWriteDump takes a callback that tells it which memory regions to include in the dump. Before letting it do its thing, attach CLRMD to the live target, run some commands that touch all the required memory regions (e.g. enumerate objects, threads, types, etc.), and use a custom IDataReader that logs all memory accesses against the live target. Aggregate these accesses to figure out which regions we need to include (additionally, include everything reported by ClrRuntime.EnumerateMemoryRegions).

goldshtn commented 9 years ago

Support for generating smaller dump files with the .dump command added in ec152a1c5aae3b56adb516ea8237015dfed73eb8. Now need to work on opening these dump files -- currently, MinimalWithFullCLRHeap is considered a mini dump with no heap. Need to parse the dump comment we embed and check the real type ourselves.

goldshtn commented 9 years ago

Closing in 630f0e20c099f17497fb6dfb38309144401e9dbe with full support for opening these "mini" dump files.