|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
4 | 4 | #include "createdump.h" |
| 5 | +#include <clrconfignocache.h> |
5 | 6 |
|
6 | 7 | // This is for the PAL_VirtualUnwindOutOfProc read memory adapter. |
7 | 8 | CrashInfo* g_crashInfo; |
@@ -328,24 +329,34 @@ CrashInfo::EnumerateMemoryRegionsWithDAC(MINIDUMP_TYPE minidumpType) |
328 | 329 | { |
329 | 330 | TRACE("EnumerateMemoryRegionsWithDAC: Memory enumeration STARTED (%d %d)\n", m_enumMemoryPagesAdded, m_dataTargetPagesAdded); |
330 | 331 |
|
331 | | - // Since on both Linux and MacOS all the RW regions will be added for heap |
332 | | - // dumps by createdump, the only thing differentiating a MiniDumpNormal and |
333 | | - // a MiniDumpWithPrivateReadWriteMemory is that the later uses the EnumMemory |
334 | | - // APIs. This is kind of expensive on larger applications (4 minutes, or even |
335 | | - // more), and this should already be in RW pages. Change the dump type to the |
336 | | - // faster normal one. This one already ensures necessary DAC globals, etc. |
337 | | - // without the costly assembly, module, class, type runtime data structures |
338 | | - // enumeration. |
| 332 | + // Since on MacOS all the RW regions will be added for heap dumps by createdump, the |
| 333 | + // only thing differentiating a MiniDumpNormal and a MiniDumpWithPrivateReadWriteMemory |
| 334 | + // is that the later uses the EnumMemoryRegions APIs. This is kind of expensive on larger |
| 335 | + // applications (4 minutes, or even more), and this should already be in RW pages. Change |
| 336 | + // the dump type to the faster normal one. This one already ensures necessary DAC globals, |
| 337 | + // etc. without the costly assembly, module, class, type runtime data structures enumeration. |
| 338 | + CLRDataEnumMemoryFlags flags = CLRDATA_ENUM_MEM_DEFAULT; |
339 | 339 | if (minidumpType & MiniDumpWithPrivateReadWriteMemory) |
340 | 340 | { |
341 | | - char* fastHeapDumps = getenv("COMPlus_DbgEnableFastHeapDumps"); |
342 | | - if (fastHeapDumps != nullptr && strcmp(fastHeapDumps, "1") == 0) |
| 341 | + // This is the old fast heap env var for backwards compatibility for VS4Mac. |
| 342 | + CLRConfigNoCache fastHeapDumps = CLRConfigNoCache::Get("DbgEnableFastHeapDumps", /*noprefix*/ false, &getenv); |
| 343 | + DWORD val = 0; |
| 344 | + if (fastHeapDumps.IsSet() && fastHeapDumps.TryAsInteger(10, val) && val == 1) |
343 | 345 | { |
344 | 346 | minidumpType = MiniDumpNormal; |
345 | 347 | } |
| 348 | + // This the new variable that also skips the expensive (in both time and memory usage) |
| 349 | + // enumeration of the low level data structures and adds all the loader allocator heaps |
| 350 | + // instead. The above original env var didn't generate a complete enough heap dump on |
| 351 | + // Linux and this new one does. |
| 352 | + fastHeapDumps = CLRConfigNoCache::Get("EnableFastHeapDumps", /*noprefix*/ false, &getenv); |
| 353 | + if (fastHeapDumps.IsSet() && fastHeapDumps.TryAsInteger(10, val) && val == 1) |
| 354 | + { |
| 355 | + flags = CLRDATA_ENUM_MEM_HEAP2; |
| 356 | + } |
346 | 357 | } |
347 | 358 | // Calls CrashInfo::EnumMemoryRegion for each memory region found by the DAC |
348 | | - HRESULT hr = m_pClrDataEnumRegions->EnumMemoryRegions(this, minidumpType, CLRDATA_ENUM_MEM_DEFAULT); |
| 359 | + HRESULT hr = m_pClrDataEnumRegions->EnumMemoryRegions(this, minidumpType, flags); |
349 | 360 | if (FAILED(hr)) |
350 | 361 | { |
351 | 362 | printf_error("EnumMemoryRegions FAILED %s (%08x)\n", GetHResultString(hr), hr); |
|
0 commit comments