Debugger: How can I get "Mutex Owned" or "Mutex Free" information in the crash dump?

I don't know what I'm not doing, but I just can't get my own debugger to save the "Mutex Owned" or "Mutex Free" information for the application being debugged.

CDB works fine if I call it like this:

  cdb -pn test.exe -c ".dump /f /ma /u test.dmp;.detach;q"

      

When I open the crash dump file in WinDbg and type the following commands, I see Mutex Free or Mutex Owned states:

 0:001> !handle 0 f Mutant
Handle 7f4
  Type             Mutant
  Attributes       0
  GrantedAccess    0x1f0001:
         Delete,ReadControl,WriteDac,WriteOwner,Synch
         QueryState
  HandleCount      2
  PointerCount     4
  Name             \BaseNamedObjects\PAUL_HANG_MUTEX
  Object Specific Information
 Mutex is Owned  <--- THIS HERE IS WHAT I WANT TO SEE 

      

Below is my function - I had to comment out some of the MiniDumpWith options as it won't write the crash dump file at all unless I comment them out.

Does anyone know why CDB can save information when I use / ma, but my own code cannot?

void WriteCrashDump( EXCEPTION_DEBUG_INFO *pExceptionInfo )
{
  CONTEXT c;

  memset( &c, 0, sizeof( c ) );

  GetThreadContext( hThread, &c );

  EXCEPTION_POINTERS ep;

  memset( &ep, 0, sizeof( ep ) );

  ep.ContextRecord   = &c;
  ep.ExceptionRecord = &pExceptionInfo->ExceptionRecord;

    MINIDUMP_EXCEPTION_INFORMATION minidump_exception;

  memset( &minidump_exception, 0, sizeof( minidump_exception ) );

    minidump_exception .ThreadId          = dwThreadId;
    minidump_exception.ExceptionPointers = &ep;
    minidump_exception.ClientPointers    = true;

  char txDumpPath[ MAX_PATH + 1 ];

  sprintf( txDumpPath, "%s.dmp", txProcess );

    HANDLE hFile = CreateFile( txDumpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );

    if( hFile )
  {
    BOOL  fSuccess;


    SetLastError( 0L );

    int nDumpOptions =

    MiniDumpNormal
|    MiniDumpWithDataSegs                  
|    MiniDumpWithFullMemory                
|    MiniDumpWithHandleData                
|    MiniDumpFilterMemory                  
|    MiniDumpScanMemory                    
|    MiniDumpWithUnloadedModules           
|    MiniDumpWithIndirectlyReferencedMemory
|    MiniDumpFilterModulePaths             
|    MiniDumpWithProcessThreadData         
|    MiniDumpWithPrivateReadWriteMemory    
|    MiniDumpWithoutOptionalData           
//|    MiniDumpWithFullMemoryInfo            
//|    MiniDumpWithThreadInfo                
//|    MiniDumpWithCodeSegs                  
//|    MiniDumpWithoutManagedState          
    ;

    fSuccess = MiniDumpWriteDump( hProcess,
                                  dwProcessId,
                                  hFile,
                                  (MINIDUMP_TYPE) nDumpOptions,
                                  &minidump_exception,
                                  NULL,
                                  NULL );

    DWORD dwErr = GetLastError();

    if( ! fSuccess )
            printf( "MiniDumpWriteDump -FAILED (LastError:%u)\n", dwErr );

        CloseHandle( hFile );
    }
}

      

+3


source to share


1 answer


Whether it contains information about the mutex even with the MiniDumpWithHandleData flag, it is also possible that it does not work because some of the flags might not be compatible with the version of DebugHlp.dll you are calling. See enumeration MINIDUMP_TYPE



+2


source







All Articles