I wish to debug application hang via collected crash dump from customer site as I cannot install visual studio and debugger on customer site machine. Full memory dump would be my first choice as debugging hang via full memory dump is informative and effective way. Nonetheless, as my application getting more complex from time to time, the RAM usage of the exe increase to almost 15GB (mostly heap memory image buffer), which take a huge toll on my collected crash dump. Thus, I am exploring a way to minimize the crash dump file while maintaining only specific useful heap memory region via MiniDumpWriteDump API options in DbgHelp library. However, I stuck when I try a way to append specific memory region via memory callback.

I had tried to refer to http://www.nynaeve.net/?p=126 to implement memory callback and https://www.debuginfo.com/articles/effminidumps.html#minidumptypes to choose my desired minidump types flag to minimize the dump size. So my current strategy would be minimize the size via flags below instead of using full memory dump flag

...
MINIDUMP_TYPE dwFlags = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory 
| MiniDumpScanMemory                                           
| MiniDumpWithHandleData                                        
| MiniDumpWithUnloadedModules                                   
| MiniDumpWithProcessThreadData
| MiniDumpWithFullMemoryInfo                                
| MiniDumpWithThreadInfo                                
| MiniDumpWithCodeSegs                                  
| MiniDumpWithDataSegs
);

MINIDUMP_CALLBACK_INFORMATION mci;
mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE)MyMiniDumpCallback;
mci.CallbackParam   = pErrorLog;

BOOL rv = MiniDumpWriteDump(processHandle, dwProcessID, hFile, dwFlags, NULL, NULL, &mci); 
...

then using memory callback to append heap memory region

BOOL CALLBACK MyMiniDumpCallback(
    PVOID                            pParam, 
    const PMINIDUMP_CALLBACK_INPUT   pInput, 
    PMINIDUMP_CALLBACK_OUTPUT        pOutput 
) 
{
...
case MemoryCallback: 
{
     if(vctMemoryBlock.size() > 0)
     {
       pOutput->MemoryBase = vctMemoryBlock.back().uBase;
       pOutput->MemorySize = vctMemoryBlock.back().uSize;

      // logger function here... 

       vctMemoryBlock.pop_back();

       bRet = TRUE;
     }
     else
     {
       bRet = FALSE; 
     }

     //bRet = TRUE;
}
break; 

...
}

However, when I generate the crash dump and open it using visual studio 2015 then debug with native symbol, it stated heap memory not present and I can't get the detail of heap memory variable at that specific memory region.

I am not sure what I had done wrong, whether is the way I collect my heap memory address, or the way I implement crash dump generation above that causing issue.

Hopefully there is some master here which can guide me through...

Findings:

Custom dump with memory appended are larger than the one without memory appended dump size comparison

Full Memory Dump showing heap variable... Full Memory Dump Show Heap Variable

Custom Dump with memory appended unable to show heap variable Custom dump unable to show heap variable

0

There are 0 answers